Exemplo n.º 1
0
 /**
  * Prepares the SQL query string.
  *
  * @return
  * @param object $QueryData - the object of one of the DB_Select, DB_Table_Create,
  * DB_Insert, DB_Update, DB_Delete classes.
  */
 function PrepareSQL($QueryData)
 {
     $this->querytype = $QueryData->getQueryType();
     switch ($this->querytype) {
         case DBQUERY_TYPE_CREATE:
             $this->QueryString = $this->PrepareCreateQuery($QueryData);
             break;
         case DBQUERY_TYPE_SELECT:
             $this->QueryString = $this->PrepareSelectQuery($QueryData);
             break;
         case DBQUERY_TYPE_INSERT:
             $table_list = array($QueryData->getInsertTable());
             clearQueriesCache($table_list);
             $this->QueryString = $this->PrepareInsertQuery($QueryData);
             break;
         case DBQUERY_TYPE_REPLACE:
             $table_list = array($QueryData->getReplaceTable());
             clearQueriesCache($table_list);
             $this->QueryString = $this->PrepareReplaceQuery($QueryData);
             break;
         case DBQUERY_TYPE_MULTIPLE_INSERT:
             $table_list = array($QueryData->getInsertTable());
             clearQueriesCache($table_list);
             $this->QueryString = $this->PrepareMultipleInsertQuery($QueryData);
             break;
         case DBQUERY_TYPE_MULTIPLE_REPLACE:
             $table_list = array($QueryData->getReplaceTable());
             clearQueriesCache($table_list);
             $this->QueryString = $this->PrepareMultipleReplaceQuery($QueryData);
             break;
         case DBQUERY_TYPE_INSERT_SELECT:
             $table_list = array($QueryData->getInsertTable());
             clearQueriesCache($table_list);
             $this->QueryString = $this->PrepareInsertSelectQuery($QueryData);
             break;
         case DBQUERY_TYPE_UPDATE:
             $table_list = array($QueryData->getUpdateTable());
             clearQueriesCache($table_list);
             $this->QueryString = $this->PrepareUpdateQuery($QueryData);
             break;
         case DBQUERY_TYPE_DELETE:
             $table_list = array($QueryData->getDeleteTable());
             clearQueriesCache($table_list);
             $this->QueryString = $this->PrepareDeleteQuery($QueryData);
             break;
         case DBQUERY_TYPE_TABLE_DELETE:
             $table_list = array($QueryData->getDeleteTables());
             clearQueriesCache($table_list);
             $this->QueryString = $this->PrepareTableDeleteQuery($QueryData);
             break;
         case 'DEBUG':
             $this->QueryString = $QueryData->Query;
             break;
         case DBQUERY_TYPE_LOCK_TABLES:
             $this->QueryString = $this->PrepareLockTablesQuery($QueryData);
             break;
         case DBQUERY_TYPE_UNLOCK_TABLES:
             $this->QueryString = $this->PrepareUnlockTablesQuery($QueryData);
             break;
         default:
             $this->QueryString = '';
             break;
     }
 }
Exemplo n.º 2
0
 function addCatTreeLog(&$before, &$after, $query)
 {
     global $application;
     $_type = getMsg('TL', 'TL_CATTREE_TITLE');
     $_body = '';
     if (!empty($before)) {
         $tmp = '';
         foreach ($before as $k => $v) {
             $tmp .= str_replace(array('{ID}', '{LEFT}', '{RIGHT}', '{LEVEL}', '{BGCOLOR}'), array($v['catid'], $v['catleft'], $v['catright'], $v['catlevel'], $k % 2 ? '#BBBBBB' : 'white'), getMsg('TL', 'TL_CATTREE_BODY_TABLE_TR'));
         }
         $_body .= str_replace(array('{TREE_NAME}', '{LIST}'), array(getMsg('TL', 'TL_CATTREE_TREE_BEFORE'), $tmp), getMsg('TL', 'TL_CATTREE_BODY_TABLE'));
         $_status_before = getMsg('TL', 'TL_CATTREE_ERROR');
         $_sbcolor = 'red';
     } else {
         $_status_before = getMsg('TL', 'TL_CATTREE_OK');
         $_sbcolor = 'green';
     }
     if (!empty($after)) {
         $tmp = '';
         foreach ($after as $k => $v) {
             $tmp .= str_replace(array('{ID}', '{LEFT}', '{RIGHT}', '{LEVEL}', '{BGCOLOR}'), array($v['catid'], $v['catleft'], $v['catright'], $v['catlevel'], $k % 2 ? '#BBBBBB' : 'white'), getMsg('TL', 'TL_CATTREE_BODY_TABLE_TR'));
         }
         $_body .= str_replace(array('{TREE_NAME}', '{LIST}'), array(getMsg('TL', 'TL_CATTREE_TREE_AFTER'), $tmp), getMsg('TL', 'TL_CATTREE_BODY_TABLE'));
         $_status_after = getMsg('TL', 'TL_CATTREE_ERROR');
         $_sacolor = 'red';
     } else {
         $_status_after = getMsg('TL', 'TL_CATTREE_OK');
         $_sacolor = 'green';
     }
     $_header = str_replace(array('{REQUEST_URL}', '{STATUS_BEFORE_COLOR}', '{STATUS_BEFORE}', '{QUERY}', '{STATUS_AFTER_COLOR}', '{STATUS_AFTER}'), array(getCurrentURL(), $_sbcolor, $_status_before, $query, $_sacolor, $_status_after), getMsg('TL', 'TL_CATTREE'));
     if ($_body == null or empty($_body)) {
         $_body = null;
     } else {
         $_body = gzdeflate($_body, 3);
     }
     $prefix = $application->getAppIni('DB_TABLE_PREFIX');
     $t = $this->getTables();
     $t = $t['timeline']['columns'];
     $_query = 'INSERT INTO ' . $prefix . 'timeline (' . $t['datetime'] . ', ' . $t['type'] . ', ' . $t['header'] . ', ' . $t['body'] . ') VALUES (\'' . date('Y-m-d H:i:s', time()) . '\', \'' . addslashes($_type) . '\', \'' . addslashes($_header) . '\', \'' . addslashes($_body) . '\')';
     clearQueriesCache(array($prefix . 'timeline'));
     $application->db->DB_Query($_query, 'db_link', false);
 }