Source for file install.class.inc.php

Documentation is available at install.class.inc.php

  1. <?php
  2. require_once(dirname(__FILE__).'/../../manager/includes/core.class.inc.php');
  3.  
  4. class Install extends Core {
  5.  
  6.     public $installFailed$mysqlErrors$prefix;
  7.     public $mode$fileManagerPath$imgPath$imgUrl;
  8.     public $errContinue = false;
  9.     public $autoTemplateLogic;
  10.     public $table_options;
  11.  
  12.     /**
  13.      * Exits with error message
  14.      * 
  15.      * @param string $msg Default: unspecified error
  16.      * @param string $query Default: Empty string
  17.      * @param boolean $is_error Default: true
  18.      * @param string $nr Default: Empty string
  19.      * @param string $file Default: Empty string
  20.      * @param string $source Default: Empty string
  21.      * @param string $text Default: Empty string
  22.      * @param string $line Default: Empty string
  23.      * @return void 
  24.      */
  25.     function messageQuit($msg'unspecified error'$query''$is_errortrue$nr''$file''$source''$text''$line''{
  26.         if ($this->errContinue{
  27.             exit("\n\n$msg\n\n$query");
  28.         }
  29.     }
  30.  
  31.     /**
  32.     * Parser function to set up tables and data from *.sql setup files
  33.     * transferred from sqlParser class
  34.     */
  35.     function process($filename{
  36.  
  37.     // check to make sure file exists
  38.     if (file_exists($filename)) {
  39.         $this->mysqlErrors[array("error" => "File '$filename' not found");
  40.         $this->installFailed = true ;
  41.         return false;
  42.     }
  43.  
  44.     $fh fopen($filename'r');
  45.     $idata '';
  46.  
  47.     while (!feof($fh)) {
  48.         $idata .= fread($fh1024);
  49.     }
  50.  
  51.     fclose($fh);
  52.     $idata str_replace("\r"''$idata);
  53.  
  54.     // check if in upgrade mode
  55.     if ($this->mode=="upd"{
  56.         // remove non-upgradeable parts
  57.         $s strpos($idata,"non-upgrade-able[[");
  58.         $e strpos($idata,"]]non-upgrade-able")+17;
  59.         if($s && $e$idata str_replace(substr($idata,$s,$e-$s)," Removed non upgradeable items",$idata);
  60.     }
  61.  
  62.     // replace {} tags
  63.     $idata str_replace('{PREFIX}'$this->prefix$idata);
  64.     $idata str_replace('{ADMIN}'$this->adminname$idata);
  65.     $idata str_replace('{ADMINEMAIL}'$this->adminemail$idata);
  66.     $idata str_replace('{ADMINPASS}'$this->adminpass$idata);
  67.     $idata str_replace('{IMAGEPATH}'$this->imagePath$idata);
  68.     $idata str_replace('{IMAGEURL}'$this->imageUrl$idata);
  69.     $idata str_replace('{FILEMANAGERPATH}'$this->fileManagerPath$idata);
  70.     $idata str_replace('{MANAGERLANGUAGE}'$this->managerlanguage$idata);
  71.     $idata str_replace('{AUTOTEMPLATELOGIC}'$this->autoTemplateLogic$idata);
  72.     $idata str_replace('{GLOBAL_TABLE_OPTIONS}'$this->table_options$idata);
  73.  
  74.     $sql_array explode("\n\n"$idata);
  75.  
  76.     $num 0;
  77.  
  78. // Don't exit on failed query
  79.     $this->errContinue = true;
  80.  
  81.     foreach($sql_array as $sql_entry{
  82.         $sql_do trim($sql_entry"\r\n; ");
  83.  
  84.         if (preg_match('/^\#/'$sql_do)) continue;
  85.  
  86.         $num $num 1;
  87.  
  88.         if ($sql_do{
  89.             $this->db->query($sql_do);
  90.         }
  91.  
  92.         if ($this->db->getLastError()) {
  93.             // Ignore duplicate and drop errors - Raymond
  94.             if ($this->ignoreDuplicateErrors){
  95.                 $errno $this->db->getLastError(true);
  96.                 if ($errno == 1060 || $errno == 1061 || $errno == 1091continue;
  97.             }
  98.  
  99.             $this->mysqlErrors[array("error" => $this->db->getLastError()"sql" => $sql_do);
  100.             $this->installFailed = true;
  101.         }
  102.     }
  103.  
  104.     $this->errContinue = false;
  105.     }
  106.  
  107.     /**
  108.     * Select or create category for installation TPL file
  109.     * transferred from instprocessor.php
  110.     */
  111. function getCreateDbCategory($category{
  112.     $table_prefix $this->prefix;
  113.     $category_id 0;
  114.  
  115.     if(!empty($category)) {
  116.         $category $this->db->escape($category);
  117.         $rs $this->db->select('id'"`{$table_prefix}categories`""category='$category");
  118.         
  119.         $row $this->db->getValue($rs);
  120.  
  121.         if (empty($row)) {
  122.             $category_id $row[0];
  123.         else {
  124.             $category_id $this->db->insert(array("`category`"=>"$category")"`{$table_prefix}categories`");
  125.         }
  126.     }
  127.     return $category_id;
  128. }
  129.  
  130. }

Documentation generated on Fri, 21 Jun 2013 12:37:07 +0100 by phpDocumentor 1.4.4