/**
  * Looks if the specified table exists and if not create it with the key-
  * field (uid). Then it syncs the DB-fields with the fields found in the form 
  * with help of template parser
  */
 protected function createTable()
 {
     $fields = $this->getFormFields();
     if ($this->settings['excludeFields']) {
         $excludes = t3lib_div::trimExplode(',', $this->settings['excludeFields']);
         foreach ($excludes as $exclude) {
             unset($fields[$exclude]);
         }
     }
     if (Tx_Formhandler_Globals::$settings['debug']) {
         $this->db->debugOutput = 1;
     }
     $res = $this->db->sql_query("SHOW TABLES LIKE '" . $this->table . "'");
     if (!$this->db->sql_num_rows($res)) {
         $query = "CREATE TABLE `" . $this->table . "` (\n\t\t\t\t`" . $this->key . "` INT( 11 ) UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY\n\t\t\t)";
         $this->db->sql_query($query);
         Tx_Formhandler_StaticFuncs::debugMessage('sql_request', array($query));
         $dbFields = array($this->key);
     } else {
         $dbFields = array_keys($this->db->admin_get_fields($this->table));
     }
     $createFields = array_diff($fields, $dbFields);
     if (count($createFields)) {
         $sql = 'ALTER TABLE ' . $this->table . ' ADD `';
         $sql .= implode('` ' . $this->newFieldsSqlAttribs . ', ADD `', $createFields);
         $sql .= '` ' . $this->newFieldsSqlAttribs . '';
         $this->db->sql_query($sql);
         Tx_Formhandler_StaticFuncs::debugMessage('sql_request', array($sql));
         if ($this->db->sql_error()) {
             Tx_Formhandler_StaticFuncs::debugMessage('error', array($this->db->sql_error()), 3);
         }
     }
 }
 /**
  * Relative filemounts are transformed to relate to our fileadmin/ storage
  * and their path is modified to be a valid resource location
  */
 protected function migrateRelativeFilemounts()
 {
     $relativeFilemounts = $this->db->exec_SELECTgetRows('*', 'sys_filemounts', 'base = 1' . \TYPO3\CMS\Backend\Utility\BackendUtility::deleteClause('sys_filemounts'));
     foreach ($relativeFilemounts as $filemount) {
         $this->db->exec_UPDATEquery('sys_filemounts', 'uid=' . intval($filemount['uid']), array('base' => $this->storage->getUid(), 'path' => '/' . ltrim($filemount['path'], '/')));
         $this->sqlQueries[] = $GLOBALS['TYPO3_DB']->debug_lastBuiltQuery;
     }
 }
Ejemplo n.º 3
0
 /**
  * Check if there are still resources left for the process with the given id
  * Used to determine timeouts and to ensure a proper cleanup if there's a timeout
  *
  * @param  string  identification string for the process
  * @return boolean determines if the process is still active / has resources
  */
 function CLI_checkIfProcessIsActive($pid)
 {
     $ret = false;
     $this->db->sql_query('BEGIN');
     $res = $this->db->exec_SELECTquery('process_id,active,ttl', 'tx_crawler_process', 'process_id = \'' . $pid . '\'  AND deleted=0', '', 'ttl', '0,1');
     if ($row = $this->db->sql_fetch_assoc($res)) {
         $ret = intVal($row['active']) == 1;
     }
     $this->db->sql_query('COMMIT');
     return $ret;
 }
Ejemplo n.º 4
0
 /**
  * @param int                                            $startPage
  * @param array                                          $basePages
  * @param Tx_GoogleServices_Controller_SitemapController $obj
  *
  * @return array|Tx_GoogleServices_Domain_Model_Node
  */
 public function getRecords($startPage, $basePages, Tx_GoogleServices_Controller_SitemapController $obj)
 {
     $nodes = array();
     foreach ($basePages as $uid) {
         if ($this->currentLanguageUid) {
             $fields = $this->cObject->enableFields('pages_language_overlay');
             $overlay = $this->database->exec_SELECTgetSingleRow('uid', 'pages_language_overlay', ' pid = ' . intval($uid) . ' AND sys_language_uid = ' . $this->currentLanguageUid . $fields);
             if (!is_array($overlay)) {
                 continue;
             }
         }
         // Build URL
         $url = $obj->getUriBuilder()->setTargetPageUid($uid)->build();
         // can't generate a valid url
         if (!strlen($url)) {
             continue;
         }
         // Get Record
         $record = \TYPO3\CMS\Backend\Utility\BackendUtility::getRecord('pages', $uid);
         // exclude Doctypes
         if (in_array($record['doktype'], array(4))) {
             continue;
         }
         // Build Node
         $node = new Tx_GoogleServices_Domain_Model_Node();
         $node->setLoc($url);
         $node->setPriority($this->getPriority($startPage, $record));
         $node->setChangefreq(Tx_GoogleServices_Service_SitemapDataService::mapTimeout2Period($record['cache_timeout']));
         $node->setLastmod($this->getModifiedDate($record));
         #$geo = new Tx_GoogleServices_Domain_Model_Node_Geo();
         #$geo->setFormat('kml');
         #$node->setGeo($geo);
         $nodes[] = $node;
     }
     return $nodes;
 }
 /**
  * Clear the TYPO3 page cache for the given record.
  * If the record lies on a page, then we clear the cache of this page.
  * If the record has no PID column, we clear the cache of the current page as best-effort.
  *
  * Much of this functionality is taken from t3lib_tcemain::clear_cache() which unfortunately only works with logged-in BE user.
  *
  * @param $tableName Table name of the record
  * @param $uid UID of the record
  * @return void
  */
 protected function clearPageCache($tableName, $uid)
 {
     $extbaseSettings = Tx_Extbase_Dispatcher::getExtbaseFrameworkConfiguration();
     if (isset($extbaseSettings['persistence']['enableAutomaticCacheClearing']) && $extbaseSettings['persistence']['enableAutomaticCacheClearing'] === '1') {
     } else {
         // if disabled, return
         return;
     }
     $pageIdsToClear = array();
     $storagePage = NULL;
     $columns = $this->databaseHandle->admin_get_fields($tableName);
     if (array_key_exists('pid', $columns)) {
         $result = $this->databaseHandle->exec_SELECTquery('pid', $tableName, 'uid=' . intval($uid));
         if ($row = $this->databaseHandle->sql_fetch_assoc($result)) {
             $storagePage = $row['pid'];
             $pageIdsToClear[] = $storagePage;
         }
     } elseif (isset($GLOBALS['TSFE'])) {
         // No PID column - we can do a best-effort to clear the cache of the current page if in FE
         $storagePage = $GLOBALS['TSFE']->id;
         $pageIdsToClear[] = $storagePage;
     }
     if ($storagePage === NULL) {
         return;
     }
     if (!isset($this->pageTSConfigCache[$storagePage])) {
         $this->pageTSConfigCache[$storagePage] = t3lib_BEfunc::getPagesTSconfig($storagePage);
     }
     if (isset($this->pageTSConfigCache[$storagePage]['TCEMAIN.']['clearCacheCmd'])) {
         $clearCacheCommands = t3lib_div::trimExplode(',', strtolower($this->pageTSConfigCache[$storagePage]['TCEMAIN.']['clearCacheCmd']), 1);
         $clearCacheCommands = array_unique($clearCacheCommands);
         foreach ($clearCacheCommands as $clearCacheCommand) {
             if (t3lib_div::testInt($clearCacheCommand)) {
                 $pageIdsToClear[] = $clearCacheCommand;
             }
         }
     }
     // TODO check if we can hand this over to the Dispatcher to clear the page only once, this will save around 10% time while inserting and updating
     Tx_Extbase_Utility_Cache::clearPageCache($pageIdsToClear);
 }
Ejemplo n.º 6
0
 /**
  * Return the memory for the sql query.
  *
  * @return void
  */
 public function free()
 {
     $this->db->sql_free_result($this->resource);
 }
 /**
  * Directly execute a query on the db and return the result.
  *
  * @param string $query The query.
  * @param mixed $result If set to false, no result is returned. If set to true, an array with the rows is returned. If set to a string, an associated array is returned, where the $row[$result] is used as the key.
  * @return array The assoc return array.
  * @internal
  */
 public function _sql($query, $result = true)
 {
     $resource = $this->db->sql_query($query);
     if ($resource === null) {
         // mysqli 6.2
         return;
     }
     if ($result === false) {
         if ($resource !== null) {
             $this->db->sql_free_result($resource);
         }
         return;
     }
     if ($resource === null) {
         return array();
     }
     $output = array();
     if ($result === true) {
         while (($row = $this->db->sql_fetch_assoc($resource)) !== false) {
             $output[] = $row;
         }
     } else {
         $result = (string) $result;
         while (($row = $this->db->sql_fetch_assoc($resource)) !== false) {
             $output[$row[$result]] = $row;
         }
     }
     $this->db->sql_free_result($resource);
     return $output;
 }