Exemple #1
0
 function dbError($sql, $msg, $dberror)
 {
     global $_Error_FatalHandler;
     if (method_exists($_Error_FatalHandler, 'dbError')) {
         $_Error_FatalHandler->dbError($sql, $msg, $dberror);
     } else {
         Fatal::error('Database Error: ' . $msg . ' in query: ' . $sql . ' DBMS says: ' . $dberror);
     }
 }
 function executeSqlFile($filename, $tablePrfx = DB_TABLENAME_PREFIX, $Quiet = false)
 {
     $fp = false;
     if (!file_exists($filename)) {
         $filename = absolutePath($filename);
     }
     if (file_exists($filename)) {
         $fp = fopen($filename, "r");
     }
     # show error if file could not be opened
     if ($fp == false) {
         if ($Quiet) {
             return false;
         }
         Fatal::error("Error reading file: " . H($filename));
     } else {
         $dir = dirname($filename);
         $sql_charset = DB_CHARSET;
         if (file_exists($dir . "/sqlcharset.php")) {
             include $dir . "/sqlcharset.php";
         }
         $this->UseLinkCharset($sql_charset);
         $sqlStmt = "";
         while (!feof($fp)) {
             $char = fgetc($fp);
             $sqlStmt .= $char;
             if ($char == ";") {
                 //replace table prefix, we're doing it here as the install script may
                 //want to override the required prefix (eg. during upgrade / conversion
                 //process)
                 $sql = str_replace("%prfx%", $tablePrfx, $sqlStmt);
                 $sql = $this->PreprocessSQL($sql);
                 //replace ENGINE with TYPE for old MySQL versions
                 $MySQLn = explode('.', implode('', explode('-', $this->server_info)));
                 if ($MySQLn[0] < '5') {
                     $sql = str_replace("ENGINE=", "TYPE=", $sql);
                     $sql = str_replace("engine=", "type=", $sql);
                 } else {
                     $sql = str_replace("TYPE=", "ENGINE=", $sql);
                     $sql = str_replace("type=", "engine=", $sql);
                 }
                 $this->exec($sql);
                 $sqlStmt = "";
             }
         }
         fclose($fp);
     }
     return true;
 }
 function executeSqlFile($filename, $tablePrfx = DB_TABLENAME_PREFIX)
 {
     $fp = fopen($filename, "r");
     # show error if file could not be opened
     if ($fp == false) {
         Fatal::error("Error reading file: " . H($filename));
     } else {
         $sqlStmt = "";
         while (!feof($fp)) {
             $char = fgetc($fp);
             if ($char == ";") {
                 //replace table prefix, we're doing it here as the install script may
                 //want to override the required prefix (eg. during upgrade / conversion
                 //process)
                 $sql = str_replace("%prfx%", $tablePrfx, $sqlStmt);
                 $root_path = "http://" . $_SERVER['HTTP_HOST'] . dirname(dirname($_SERVER['SCRIPT_NAME']));
                 if (substr($root_path, -1) == '/') {
                     $root_path = substr($root_path, 0, -1);
                 }
                 $sql = str_replace('%domain%', $root_path . "/cron/lookup.php", $sql);
                 $this->exec($sql);
                 $sqlStmt = "";
             } else {
                 $sqlStmt .= $char;
             }
         }
         fclose($fp);
     }
 }
 function freshInstallLocale()
 {
     if ($this->_isdefaultlocale) {
         return true;
     }
     if ($this->_version == '') {
         $this->_version = $this->getCurrentDatabaseVersion($this->tablePrfx);
     }
     $meta = Settings::getLocaleMeta($this->_locale);
     $this->_localeDescr = $meta[$this->_locale];
     if (!isset($this->_localeDescr)) {
         Fatal::error("desired local " . $this->_locale . " absent");
         return;
     }
     $localeDir = OBIB_LOCALE_ROOT . '/' . $this->_locale . '/sql/' . $this->_version;
     if (!is_dir($localeDir)) {
         $localeDir = OBIB_LOCALE_ROOT . '/default/sql/' . $this->_version;
     }
     if (!is_dir($localeDir)) {
         Fatal::error("DB sql for desired local " . $this->_locale . " absent");
         return;
     }
     $lang_sqls[] = 'lang.sql';
     $lang_files['lang.sql'] = 1;
     $lang_dir = $localeDir . '/append';
     $sqlfiles = $this->getSqlFilesInDir($lang_dir, $this->tablePrfx);
     $this->append_SqlRelations($lang_dir, $sqlfiles);
     $lang_sqls = $this->filter_files($sqlfiles, $lang_files);
     echo '<h3>' . "install sql update relations on lang_sqls at " . $lang_dir . '</h3>';
     echo '<table> <tr>';
     foreach ($lang_sqls as $item) {
         echo '<tr><td>' . H($item) . '</td></tr>';
     }
     echo '</table>';
     $this->executeSqlFiles($lang_dir, $lang_sqls, $this->tablePrfx, true);
     $array = $this->_readLocaleInfo();
     if ($array == false) {
         Fatal::error("fail _readLocaleInfo: " . $this->_locale);
         return false;
     }
     $this->localekey = $array["code"];
     $sqlfiles = $this->remove_files($sqlfiles, $lang_sqls);
     if (!empty($sqlfiles)) {
         echo '<h3>' . "install sqls " . '</h3>';
         echo '<table> <tr>';
         foreach ($sqlfiles as $item) {
             echo '<tr><td>' . H($item) . '</td></tr>';
         }
         echo '</table>';
         $this->executeSqlFiles($localeDir . '/append', $sqlfiles, $this->tablePrfx);
     }
     $this->GenerateLocaleInterface();
     return true;
 }
 function update($set)
 {
     $localizator = new LocaleQuery($set->getLocale(), $set->getCharset(), $set->getVersion());
     $locok = $localizator->PrepareLocaleSeance();
     if (!$locok) {
         Fatal::error("fail PrepareLocale: " . $set->getLocale() . " version:" . $set->getVersion());
         //!!! this hook does not inspire confidence
         return true;
     }
     $sql = $this->mkSQL("update settings set " . "library_name=%Q, library_image_url=%Q, " . "use_image_flg=%Q, library_hours=%Q, " . "library_aders=%Q, library_phone=%Q, library_url=%Q, " . "opac_url=%Q, session_timeout=%N, " . "items_per_page=%N, purge_history_after_months=%N, " . "block_checkouts_when_fines_due=%Q, " . "hold_max_days=%N, " . "locale=%Q, charset=%Q, html_lang_attr=%Q, " . "font_normal=%Q, font_size=%Q, inactive_member_after_days=%Q", $set->getLibraryName(), $set->getLibraryImageUrl(), $set->isUseImageSet() ? "Y" : "N", $set->getLibraryHours(), $set->getLibraryAders(), $set->getLibraryPhone(), $set->getLibraryUrl(), $set->getOpacUrl(), $set->getSessionTimeout(), $set->getItemsPerPage(), $set->getPurgeHistoryAfterMonths(), $set->isBlockCheckoutsWhenFinesDue() ? "Y" : "N", $set->getHoldMaxDays(), $set->getLocale(), $set->getCharset(), $set->getHtmlLangAttr(), $set->getFontNormal(), $set->getFontSize(), $set->getInactiveMemberAfterDays());
     return $this->_query($sql, "Error updating library settings information");
 }
Exemple #6
0
 function executeSqlFile($filename, $tablePrfx = DB_TABLENAME_PREFIX)
 {
     $fp = fopen($filename, "r");
     # show error if file could not be opened
     if ($fp == false) {
         Fatal::error("Error reading file: " . H($filename));
     } else {
         $sqlStmt = "";
         while (!feof($fp)) {
             $char = fgetc($fp);
             if ($char == ";") {
                 //replace table prefix, we're doing it here as the install script may
                 //want to override the required prefix (eg. during upgrade / conversion
                 //process)
                 $sql = str_replace("%prfx%", $tablePrfx, $sqlStmt);
                 $this->exec($sql);
                 $sqlStmt = "";
             } else {
                 $sqlStmt .= $char;
             }
         }
         fclose($fp);
     }
 }
Exemple #7
0
 function executeSqlFile($filename, $tablePrfx = DB_TABLENAME_PREFIX)
 {
     $fp = fopen($filename, "r");
     # show error if file could not be opened
     if ($fp == false) {
         Fatal::error("Error reading file: " . H($filename));
     } else {
         $sqlStmt = "";
         while (!feof($fp)) {
             $char = fgetc($fp);
             if ($char == ";") {
                 //replace table prefix, we're doing it here as the install script may
                 //want to override the required prefix (eg. during upgrade / conversion
                 //process)
                 $sql = str_replace("%prfx%", $tablePrfx, $sqlStmt);
                 //replace ENGINE with TYPE for old MySQL versions
                 $MySQLn = explode('.', implode('', explode('-', mysql_get_server_info())));
                 if ($MySQLn[0] < '5') {
                     $sql = str_replace("ENGINE=", "TYPE=", $sql);
                     $sql = str_replace("engine=", "type=", $sql);
                 } else {
                     $sql = str_replace("TYPE=", "ENGINE=", $sql);
                     $sql = str_replace("type=", "engine=", $sql);
                 }
                 $this->exec($sql);
                 $sqlStmt = "";
             } else {
                 $sqlStmt .= $char;
             }
         }
         fclose($fp);
     }
 }