/** * Deletes a row in the storage * * @param string $tableName The database table name * @param array $where An array of where array('fieldname' => value). * @param bool $isRelation TRUE if we are currently manipulating a relation table, FALSE by default * @return bool */ public function removeRow($tableName, array $where, $isRelation = FALSE) { $deleteSuccessful = $this->databaseHandle->exec_DELETEquery($tableName, $this->resolveWhereStatement($where, $tableName)); $this->checkSqlErrors(); if (!$isRelation && isset($where['uid'])) { $this->clearPageCache($tableName, $where['uid']); } return $deleteSuccessful; }
/** * Indexes a specific post. * @param array $conf The calling plugin's configuration vars. Not actually used. * @param $post_array * @internal param int $post_id The UID of the post to be indexed. * @return void */ function ind_post($conf, $post_array) { // Delete old records in the index table regarding this post. $this->databaseHandle->exec_DELETEquery('tx_mmforum_wordmatch', "post_id='" . $post_array['uid'] . "'"); // If post is deleted, do not index again... if ($post_array['deleted'] == 0) { // Get post content $content = $this->get_posttext($post_array['uid']); // Retrieve all words in the post content as array $wordArray = $this->wordArray($conf, $content); // Load topic information $topic_array = $this->topic_information($post_array['topic_id']); $res = $this->databaseHandle->exec_SELECTquery('f.grouprights_read as f_read, c.grouprights_read as c_read', 'tx_mmforum_forums f, tx_mmforum_forums c', 'f.uid="' . $topic_array['forum_id'] . '" AND c.uid = f.parentID'); $arr = $this->databaseHandle->sql_fetch_assoc($res); $f_groups = GeneralUtility::intExplode(',', $arr['f_read']); $c_groups = GeneralUtility::intExplode(',', $arr['c_read']); #$groups = array_merge($f_groups,$c_groups); $rFGroups = array(); foreach ($f_groups as $group) { if ($group > 0) { $rFGroups[] = $group; } } $sFGroups = implode(',', $rFGroups); $rCGroups = array(); foreach ($c_groups as $group) { if ($group > 0) { $rCGroups[] = $group; } } $sCGroups = implode(',', $rCGroups); // Compose data for word matches $matchparams['post_id'] = $post_array['uid']; $matchparams['topic_id'] = $post_array['topic_id']; $matchparams['forum_id'] = $topic_array['forum_id']; $matchparams['solved'] = $topic_array['solved']; $matchparams['topic_title'] = $topic_array['topic_title']; $matchparams['topic_views'] = $topic_array['topic_views']; $matchparams['topic_replies'] = $topic_array['topic_replies']; $matchparams['post_crdate'] = $post_array['crdate']; $matchparams['post_cruser'] = $post_array['cruser_id']; $matchparams['reqUserGroups_f'] = $sFGroups; $matchparams['reqUserGroups_c'] = $sCGroups; // Insert words and word matches into data base. Very time consuming. foreach ($wordArray as $value) { $word_id = $this->wordAdd($value); // Insert word into database and get UID $this->wortMatchAdd($word_id, $matchparams, true); // Write word match into database } } $this->write_post_ind_date($post_array['uid']); // Update post indexing date }
/** * if an image was removed from the select box, this method deletes the relating * image record from the DB */ private function deleteRecords() { $fileNames = explode(',', $this->collection['images']); // remove imagerecords which are not used anymore foreach ($this->images as $filename => $image) { if (array_search($filename, $fileNames) === false) { $this->db->exec_DELETEquery('tx_gorillary_images', "image='{$filename}' AND collection='" . $this->collection['uid'] . "'"); //unset ($this->images[$filename]); } } }
/** * getUser * * @param array $user * @param \Hybrid_User_Profile $socialUser * @param \Portrino\PxHybridAuth\Service\SocialLoginAuthenticationService $pObj * * @throws \Exception */ public function getUser(&$user, $socialUser, $pObj) { $this->extConf = unserialize($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf']['px_hybrid_auth']); $this->database = $this->getDatabaseConnection(); if (!isset($this->extConf['auto_fe_user_creation.']['storagePid'])) { throw new \Exception('[px_hybrid_auth]: No storagePid for new fe_user records given! Please configure it in the extension configuration', 1445939601); } if (!$user) { $autoCreatedUser = $this->createFrontendUserRecordFromSocialUser($socialUser, intval($this->extConf['auto_fe_user_creation.']['storagePid'])); if ($autoCreatedUser) { $identity = $this->addIdentityToFrontendUser($autoCreatedUser, $pObj->getServiceProvider(), $socialUser->identifier); if ($identity) { // overwrite the user with call by reference $user = $autoCreatedUser; } else { // delete the auto created user $this->database->exec_DELETEquery('fe_users', 'uid=' . intval($autoCreatedUser['uid'])); } } } }
/** * Db delete object * * @param int $uid Uid * @param Tx_Commerce_Dao_BasicDaoObject $object Object * * @return void */ protected function dbDelete($uid, Tx_Commerce_Dao_BasicDaoObject &$object) { $dbWhere = 'uid = ' . (int) $uid; // execute query $this->database->exec_DELETEquery($this->dbTable, $dbWhere); // any errors $error = $this->database->sql_error(); if (!empty($error)) { $this->addError(array($error, $this->database->DELETEquery($this->dbTable, $dbWhere))); } // remove object itself $object->destroy(); }
/** * * Deletes a single posts. * This method deletes a single post and all associated objects (alerts, ratings, * search index entries etc.). * * @author Martin Helmich <*****@*****.**> * @version 2009-12-20 * @param int $postId The UID of the post that is to be deleted. * @param boolean $noUpdate Set to TRUE, in order to suspend updating of * internal counters. * @return void */ function delete_post($postId, $noUpdate = false) { $arr = $this->databaseHandle->sql_fetch_assoc($this->databaseHandle->exec_SELECTquery('*', 'tx_mmforum_posts', 'uid=' . intval($postId))); $uA = array('deleted' => 1, 'tstamp' => $GLOBALS['EXEC_TIME']); $this->databaseHandle->exec_UPDATEquery('tx_mmforum_posts', $uA, 'uid=' . intval($postId)); $this->databaseHandle->exec_UPDATEquery('tx_mmforum_posts_text', $uA, 'post_id=' . intval($postId)); $this->databaseHandle->exec_UPDATEquery('tx_mmforum_post_alert', $uA, 'post_id=' . intval($postId)); $this->databaseHandle->exec_UPDATEquery('tx_mmforum_attachments', $uA, 'post_id=' . intval($postId)); $this->databaseHandle->exec_DELETEquery('tx_mmforum_wordmatch', 'post_id=' . intval($postId) . ''); if (ExtensionManagementUtility::isLoaded('ratings')) { $this->databaseHandle->exec_DELETEquery('tx_ratings_data', $uA, 'reference="tx_mmforum_posts_' . intval($postId) . '"'); } if (!$noUpdate) { $this->updateTopicPostCount($arr['topic_id']); $this->updateForumPostCount($arr['forum_id']); $this->updateUserPostCount($arr['poster_id']); } else { $this->updateQueue_addTopic($arr['topic_id']); $this->updateQueue_addForum($arr['forum_id']); $this->updateQueue_addUser($arr['poster_id']); } }
/** * Insert into database * Does not check permissions but expects them to be verified on beforehand * * @param string $table Record table name * @param string $id "NEW...." uid string * @param array $fieldArray Array of field=>value pairs to insert. FIELDS MUST MATCH the database FIELDS. No check is done. "pid" must point to the destination of the record! * @param bool $newVersion Set to TRUE if new version is created. * @param int $suggestedUid Suggested UID value for the inserted record. See the array $this->suggestedInsertUids; Admin-only feature * @param bool $dontSetNewIdIndex If TRUE, the ->substNEWwithIDs array is not updated. Only useful in very rare circumstances! * @return int|NULL Returns ID on success. */ public function insertDB($table, $id, $fieldArray, $newVersion = false, $suggestedUid = 0, $dontSetNewIdIndex = false) { if (is_array($fieldArray) && is_array($GLOBALS['TCA'][$table]) && isset($fieldArray['pid'])) { // Do NOT insert the UID field, ever! unset($fieldArray['uid']); if (!empty($fieldArray)) { // Check for "suggestedUid". // This feature is used by the import functionality to force a new record to have a certain UID value. // This is only recommended for use when the destination server is a passive mirror of another server. // As a security measure this feature is available only for Admin Users (for now) $suggestedUid = (int) $suggestedUid; if ($this->BE_USER->isAdmin() && $suggestedUid && $this->suggestedInsertUids[$table . ':' . $suggestedUid]) { // When the value of ->suggestedInsertUids[...] is "DELETE" it will try to remove the previous record if ($this->suggestedInsertUids[$table . ':' . $suggestedUid] === 'DELETE') { // DELETE: $this->databaseConnection->exec_DELETEquery($table, 'uid=' . (int) $suggestedUid); } $fieldArray['uid'] = $suggestedUid; } $fieldArray = $this->insertUpdateDB_preprocessBasedOnFieldType($table, $fieldArray); // Execute the INSERT query: $this->databaseConnection->exec_INSERTquery($table, $fieldArray); // If succees, do...: if (!$this->databaseConnection->sql_error()) { // Set mapping for NEW... -> real uid: // the NEW_id now holds the 'NEW....' -id $NEW_id = $id; $id = $this->databaseConnection->sql_insert_id(); if (!$dontSetNewIdIndex) { $this->substNEWwithIDs[$NEW_id] = $id; $this->substNEWwithIDs_table[$NEW_id] = $table; } $newRow = array(); // Checking the record is properly saved and writing to log if ($this->enableLogging && $this->checkStoredRecords) { $newRow = $this->checkStoredRecord($table, $id, $fieldArray, 1); } // Update reference index: $this->updateRefIndex($table, $id); if ($newVersion) { if ($this->enableLogging) { $propArr = $this->getRecordPropertiesFromRow($table, $newRow); $this->log($table, $id, 1, 0, 0, 'New version created of table \'%s\', uid \'%s\'. UID of new version is \'%s\'', 10, array($table, $fieldArray['t3ver_oid'], $id), $propArr['event_pid'], $NEW_id); } } else { if ($this->enableLogging) { $propArr = $this->getRecordPropertiesFromRow($table, $newRow); $page_propArr = $this->getRecordProperties('pages', $propArr['pid']); $this->log($table, $id, 1, 0, 0, 'Record \'%s\' (%s) was inserted on page \'%s\' (%s)', 10, array($propArr['header'], $table . ':' . $id, $page_propArr['header'], $newRow['pid']), $newRow['pid'], $NEW_id); } // Clear cache for relevant pages: $this->registerRecordIdForPageCacheClearing($table, $id); } return $id; } elseif ($this->enableLogging) { $this->log($table, $id, 1, 0, 2, 'SQL error: \'%s\' (%s)', 12, array($this->databaseConnection->sql_error(), $table . ':' . $id)); } } } return null; }
/** * Removes old nonces * * @return void */ public function cleanupNonces() { $where = sprintf('crdate<%d', time() - self::NONCE_STORAGE_TIME); $this->databaseConnection->exec_DELETEquery(self::NONCE_TABLE_NAME, $where); }
/** * Empties the URL cache for one page. * * @param int $pageId * @return void */ public function clearUrlCacheForPage($pageId) { $this->databaseConnection->sql_query('DELETE FROM tx_realurl_uniqalias_cache_map WHERE url_cache_id IN (SELECT cache_id FROM tx_realurl_urlcache WHERE page_id=' . (int) $pageId . ')'); $this->databaseConnection->exec_DELETEquery('tx_realurl_urlcache', 'page_id=' . (int) $pageId); }
/** * Delete processes marked as deleted * * @return void */ public function CLI_deleteProcessesMarkedDeleted() { $this->db->exec_DELETEquery('tx_crawler_process', 'deleted = 1'); }
/** * Displays a list of a user's email subscriptions. * Performs also actions like editing or deleting subscriptions. * @param \tx_mmforum_base $forumObj * @return string */ static function edit(\tx_mmforum_base $forumObj) { $content = ''; $feUserId = intval($GLOBALS['TSFE']->fe_user->user['uid']); // can be // "topic" - only topic subscriptions // "forum" - only forum subscriptions // "all" - both of them (default) $displayMode = 'all'; if ($forumObj->conf['havealook.']['displayOnlyTopics']) { $displayMode = 'topic'; } if (isset($forumObj->piVars['displayMode'])) { $displayMode = $forumObj->piVars['displayMode']; } if ($feUserId) { // Delete a single subscription (through the link at every subscription) if ($forumObj->piVars['deltid']) { $deleleTopicId = intval($forumObj->piVars['deltid']); if ($forumObj->piVars['delmode'] == 'topic') { $this->databaseHandle->exec_DELETEquery('tx_mmforum_topicmail', 'user_id = ' . $feUserId . ' AND topic_id = ' . $deleleTopicId . $forumObj->getStoragePIDQuery()); } else { $this->databaseHandle->exec_DELETEquery('tx_mmforum_forummail', 'user_id = ' . $feUserId . ' AND forum_id = ' . $deleleTopicId . $forumObj->getStoragePIDQuery()); } unset($forumObj->piVars['deltid']); } // Delete several subscriptions (through the checkboxes) if ($forumObj->piVars['havealook_action'] == 'delete') { foreach ((array) $forumObj->piVars['fav_delete']['topic'] as $deleleTopicId) { $this->databaseHandle->exec_DELETEquery('tx_mmforum_topicmail', 'user_id = ' . $feUserId . ' AND topic_id = ' . intval($deleleTopicId) . $forumObj->getStoragePIDQuery()); } foreach ((array) $forumObj->piVars['fav_delete']['forum'] as $deleleTopicId) { $this->databaseHandle->exec_DELETEquery('tx_mmforum_forummail', 'user_id = ' . $feUserId . ' AND forum_id = ' . intval($deleleTopicId) . $forumObj->getStoragePIDQuery()); } unset($forumObj->piVars['havealook_action']); } // Determination of sorting mode $orderBy = $forumObj->piVars['order'] ? $forumObj->piVars['order'] : 'added'; // rendering the settings $templateFile = $forumObj->cObj->fileResource($forumObj->conf['template.']['havealook']); $template = $forumObj->cObj->getSubpart($templateFile, '###HAVEALOOK_SETTINGS###'); $marker = array('###ACTION###' => $forumObj->escapeURL($forumObj->pi_linkTP_keepPIvars_url()), '###ORDER_LPDATE###' => $orderBy == 'lpdate' ? 'selected="selected"' : '', '###ORDER_CAT###' => $orderBy == 'cat' ? 'selected="selected"' : '', '###ORDER_ADDED###' => $orderBy == 'added' ? 'selected="selected"' : '', '###ORDER_ALPHAB###' => $orderBy == 'alphab' ? 'selected="selected"' : '', '###LABEL_ORDERBY###' => $forumObj->pi_getLL('favorites.orderBy'), '###LABEL_ORDER_LPDATE###' => $forumObj->pi_getLL('favorites.orderBy.lpdate'), '###LABEL_ORDER_CAT###' => $forumObj->pi_getLL('favorites.orderBy.cat'), '###LABEL_ORDER_ADDED###' => $forumObj->pi_getLL('favorites.orderBy.added'), '###LABEL_ORDER_ALPHAB###' => $forumObj->pi_getLL('favorites.orderBy.alphab')); // Include hook to modify the output of the settings if (is_array($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['mm_forum']['havealook']['listsettings'])) { foreach ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['mm_forum']['havealook']['listsettings'] as $_classRef) { $_procObj =& GeneralUtility::getUserObj($_classRef); $marker = $_procObj->havealook_listsettings($marker, $forumObj); } } $content = $forumObj->cObj->substituteMarkerArray($template, $marker); // rendering the head part $template = $forumObj->cObj->getSubpart($templateFile, '###HAVEALOOK_BEGIN###'); $marker = array('###ACTION###' => $forumObj->escapeURL($forumObj->pi_linkTP_keepPIvars_url()), '###LABEL_HAVEALOOK###' => $forumObj->pi_getLL('havealook.title'), '###LABEL_OPTIONS###' => $forumObj->pi_getLL('favorites.options'), '###LABEL_TOPICNAME###' => $forumObj->pi_getLL('topic.title'), '###LABEL_CONFIRMMULTIPLE###' => $forumObj->pi_getLL('havealook.confirmMultiple')); $content .= $forumObj->cObj->substituteMarkerArray($template, $marker); switch ($orderBy) { case 'lpdate': $order = 'item_lastpost_uid DESC'; break; case 'cat': $order = 'cat_order ASC, forum_order ASC, item_lastpost_uid DESC'; break; case 'added': $order = 'mail_uid DESC'; break; case 'alphab': default: $order = 'item_title ASC'; break; } $sqlTopic = 'SELECT' . ' t.topic_title AS item_title,' . ' t.uid AS item_uid,' . ' t.topic_last_post_id AS item_lastpost_uid,' . ' t.solved AS item_solved,' . ' t.topic_is AS item_prefix,' . ' m.uid AS mail_uid,' . ' f.forum_name AS forum_title,' . ' f.uid AS forum_uid,' . ' f.forum_last_post_id AS forum_lastpost_id,' . ' f.sorting AS forum_order,' . ' c.forum_name AS cat_title,' . ' c.uid AS cat_uid,' . ' c.sorting AS cat_order,' . ' "topic" AS notify_mode ' . 'FROM' . ' tx_mmforum_topicmail m' . ' LEFT JOIN tx_mmforum_topics t ON m.topic_id = t.uid ' . ' LEFT JOIN tx_mmforum_forums f ON t.forum_id = f.uid ' . ' LEFT JOIN tx_mmforum_forums c ON f.parentID = c.uid ' . 'WHERE' . ' m.user_id = ' . $feUserId . ' AND ' . ' m.deleted = 0 AND' . ' t.deleted = 0 AND' . ' f.deleted = 0 AND' . ' c.deleted = 0 ' . $forumObj->getMayRead_forum_query('f') . $forumObj->getMayRead_forum_query('c'); $sqlForum = 'SELECT' . ' f.forum_name AS item_title,' . ' f.uid AS item_uid,' . ' f.forum_last_post_id AS item_lastpost_uid,' . ' 0 AS item_solved,' . ' "" AS item_prefix,' . ' m.uid AS mail_uid,' . ' f.forum_name AS forum_title,' . ' f.uid AS forum_uid,' . ' f.forum_last_post_id AS forum_lastpost_uid,' . ' f.sorting AS forum_order,' . ' c.forum_name AS cat_title,' . ' c.uid AS cat_uid,' . ' c.sorting AS cat_order,' . ' "forum" AS notify_mode ' . 'FROM' . ' tx_mmforum_forummail m' . ' LEFT JOIN tx_mmforum_forums f ON m.forum_id = f.uid ' . ' LEFT JOIN tx_mmforum_forums c ON (f.parentID = c.uid OR (f.parentID = 0 AND f.uid = c.uid)) ' . 'WHERE' . ' m.user_id = ' . $feUserId . ' AND ' . ' m.deleted = 0 AND ' . ' f.deleted = 0 AND ' . ' c.deleted = 0 ' . $forumObj->getMayRead_forum_query('f') . $forumObj->getMayRead_forum_query('c'); if ($displayMode == 'topic') { $sql = $sqlTopic; } else { if ($displayMode == 'forum') { $sql = $sqlForum; } else { $sql = '(' . $sqlTopic . ') UNION (' . $sqlForum . ')'; } } $sql .= 'ORDER BY ' . $order; $res = $this->databaseHandle->sql_query($sql); if ($this->databaseHandle->sql_num_rows($res) == 0) { $template = $forumObj->cObj->getSubpart($templateFile, '###LIST_HAVEALOOK_EMPTY###'); $content .= $forumObj->cObj->substituteMarker($template, '###LLL_HAVEALOOK_EMPTY###', $forumObj->pi_getLL('havealook.empty')); } else { $template = $forumObj->cObj->getSubpart($templateFile, '###LIST_HAVEALOOK###'); // go through every found subscription while ($row = $this->databaseHandle->sql_fetch_assoc($res)) { if ($row['notify_mode'] == 'topic') { $linkParams[$forumObj->prefixId] = array('action' => 'list_post', 'tid' => $row['item_uid']); $marker['###TOPICICON###'] = $forumObj->getTopicIcon($row['item_uid']); } else { $linkParams[$forumObj->prefixId] = array('action' => 'list_prefix', 'fid' => $row['item_uid']); $marker['###TOPICICON###'] = $forumObj->getForumIcon($row['item_uid']); } $imgInfo = array('src' => $forumObj->conf['path_img'] . $forumObj->conf['images.']['solved'], 'alt' => $forumObj->pi_getLL('topic.isSolved')); $marker['###SOLVED###'] = $row['item_solved'] == 1 ? $forumObj->buildImageTag($imgInfo) : ''; $marker['###PREFIX###'] = $row['item_prefix'] ? $forumObj->cObj->wrap($row['item_prefix'], $forumObj->conf['list_topics.']['prefix_wrap']) : ''; $marker['###NAME###'] = $forumObj->pi_linkToPage($forumObj->escape($row['item_title']), $forumObj->conf['pid_forum'], '', $linkParams); $marker['###FORUMNAME###'] = $forumObj->escape($row['forum_title']); $marker['###CATEGORY###'] = $forumObj->escape($row['cat_title']); $marker['###TOPICNAME###'] = $marker['###PREFIX###'] . $marker['###NAME###'] . $marker['###SOLVED###']; $marker['###TOPICSUB###'] = $marker['###CATEGORY###'] . ' / ' . $marker['###FORUMNAME###'] . ($row['notify_mode'] == 'topic' ? ' / ' . $forumObj->escape($row['item_title']) : ''); $marker['###TOPIC_CHECKBOX###'] = '<input type="checkbox" name="tx_mmforum_pi1[fav_delete][' . $row['notify_mode'] . '][]" value="' . $row['item_uid'] . '" />'; $linkParams[$forumObj->prefixId] = array('action' => 'havealook', 'deltid' => $row['item_uid'], 'delmode' => $row['notify_mode']); $marker['###DELETELINK###'] = $marker['###TOPICDELLINK###'] = $forumObj->pi_linkTP($forumObj->pi_getLL('havealook.delete'), $linkParams); // Include hook to modify the output of each item if (is_array($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['mm_forum']['havealook']['listitem'])) { foreach ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['mm_forum']['havealook']['listitem'] as $_classRef) { $_procObj =& GeneralUtility::getUserObj($_classRef); $marker = $_procObj->havealook_listitem($marker, $row, $forumObj); } } $content .= $forumObj->cObj->substituteMarkerArrayCached($template, $marker); } } $template = $forumObj->cObj->getSubpart($templateFile, '###HAVEALOOK_END###'); $marker = array('###LABEL_MARKEDTOPICS###' => $forumObj->pi_getLL('havealook.markedTopics'), '###LABEL_DELETE###' => $forumObj->pi_getLL('havealook.delete'), '###LABEL_GO###' => $forumObj->pi_getLL('havealook.go')); } else { $templateFile = $forumObj->cObj->fileResource($forumObj->conf['template.']['login_error']); $template = $forumObj->cObj->getSubpart($templateFile, '###LOGINERROR###'); $marker = array('###LOGINERROR_MESSAGE###' => $forumObj->pi_getLL('subscr.noLogin')); } // Include hook to modify the output of the whole thing if (is_array($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['mm_forum']['havealook']['edit'])) { foreach ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['mm_forum']['havealook']['edit'] as $_classRef) { $_procObj =& GeneralUtility::getUserObj($_classRef); $marker = $_procObj->havealook_edit($marker, $forumObj); } } $content .= $forumObj->cObj->substituteMarkerArray($template, $marker); return $content; }
/** * Remove a process from processlist * * @param string $processId Unique process Id. * * @return void */ private function removeProcessFromProcesslist($processId) { $this->db->exec_DELETEquery('tx_crawler_process', 'process_id = ' . $this->db->fullQuoteStr($processId, 'tx_crawler_process')); }
/** * Removes entries with parameters that should be ignored. */ protected function removeUrlDataEntriesWithIgnoredParameters() { $this->databaseConnection->exec_DELETEquery('tx_realurl_urlcache', 'original_url RLIKE \'(^|&)(utm_[a-z]+|pk_campaign|pk_kwd)=\''); }
/** * Removes a cache variable. * * @author Martin Helmich <*****@*****.**> * @version 2008-06-22 * @param string $key The key of the cache variable. * @return boolean TRUE on success, otherwise FALSE */ function removeCacheValue($key) { $res = $this->databaseHandle->exec_DELETEquery('tx_mmforum_cache', 'cache_key=' . $this->databaseHandle->fullQuoteStr($key, 'tx_mmforum_cache')); return $res ? true : false; }
public function purge($simulate) { $this->output->info('Purge deleted'); $this->purgeDeleted('sys_file_reference', $simulate); $this->db->exec_DELETEquery('sys_file_reference', 'tablenames = \'\' OR fieldname = \'\''); $delete = new PreparedStatement('DELETE FROM sys_file_reference WHERE uid = ?', 'sys_file_reference'); $this->output->info('Purge references pointing to deleted records'); $res = $this->db->exec_SELECTquery('*', 'sys_file_reference', ''); $pageTools = new PageRepository(); $pageTools->init(FALSE); while ($row = $this->db->sql_fetch_assoc($res)) { $cnt = $this->db->exec_SELECTcountRows('uid', $row['tablenames'], 'uid = ' . $row['uid_foreign'] . $pageTools->enableFields($row['tablenames'])); if (!$cnt) { if ($simulate) { $this->output->info('Would delete reference ' . $row['uid']); } else { $delete->execute(array($row['uid'])); $this->output->info('Deleted reference ' . $row['uid']); } } } $delete->free(); $this->output->info('Purge sys_file records with no references'); $delete = new PreparedStatement('DELETE FROM sys_file WHERE uid = ?', 'sys_file'); $res = $this->db->exec_SELECTquery('uid', 'sys_file', 'uid NOT IN (select uid_local from sys_file_reference group by uid_local)'); while ($row = $this->db->sql_fetch_assoc($res)) { if ($simulate) { $this->output->info('Would delete file record %s', array($row['uid'])); } else { $delete->execute(array($row['uid'])); $this->output->info('Deleted file record <b>%s</b>', array($row['uid'])); } } $this->output->info('Purge actual files with no record'); $prefixRegex = '/^' . preg_quote(PATH_site, '/') . '(fileadmin|uploads)/'; $files = new \RegexIterator(new RecursiveIteratorIterator(new RecursiveDirectoryIterator(PATH_site, RecursiveDirectoryIterator::SKIP_DOTS | RecursiveDirectoryIterator::UNIX_PATHS), RecursiveIteratorIterator::LEAVES_ONLY | RecursiveIteratorIterator::CHILD_FIRST), $prefixRegex); $exists = new PreparedStatement('SELECT uid FROM sys_file WHERE identifier = ?', 'sys_file'); $fileSize = 0; foreach ($files as $file) { $filename = (string) $file; if (!is_file($filename)) { continue; } $fileId = preg_replace($prefixRegex, '', $filename); $exists->execute(array($fileId)); $result = $exists->fetchAll(); if (empty($result[0]['uid'])) { $fileSize += filesize($filename); if ($simulate) { $this->output->info('<i>Would delete file %s</i>', array($filename)); } else { unlink($filename); $this->output->info('Delete file %s', array($filename)); } } } $size = GeneralUtility::formatSize($fileSize); if ($simulate) { $this->output->info('Would delete %s of files', array($size)); $this->output->info('Would truncate table sys_file_processedfile'); } else { $this->output->info('Deleted %s of files', array($size)); $this->db->exec_TRUNCATEquery('sys_file_processedfile'); $this->output->info('Truncated table sys_file_processedfile'); } }
/** * Deletes all search index entries regarding a certain forum. * This function deletes all entries of a certain forum from the * search index table. * * @author Martin Helmich <*****@*****.**> * @version 2007-05-25 * @param int $fid The id of the forum whose index is to be deleted. * @return void */ function delete_forumIndex($fid) { $this->databaseHandle->exec_DELETEquery('tx_mmforum_wordmatch', 'forum_id=' . $fid); $this->databaseHandle->exec_DELETEquery('tx_mmforum_searchresults', '1'); $this->databaseHandle->exec_UPDATEquery('tx_mmforum_topics', 'forum_id=' . $fid, array('tx_mmforumsearch_index_write' => 0)); }
/** * Garbage collector, removing old expired sessions. * * @return void * @internal * @todo Define visibility */ public function gc() { $this->db->exec_DELETEquery($this->session_table, 'ses_tstamp < ' . (int) ($GLOBALS['EXEC_TIME'] - $this->gc_time) . ' AND ses_name = ' . $this->db->fullQuoteStr($this->name, $this->session_table)); }
/** * Running the functionality of the CLI (crawling URLs from queue) * * @param int $countInARun * @param int $sleepTime * @param int $sleepAfterFinish * @return string Status message */ public function CLI_run($countInARun, $sleepTime, $sleepAfterFinish) { $result = 0; $counter = 0; // First, run hooks: $this->CLI_runHooks(); // Clean up the queue if (intval($this->extensionSettings['purgeQueueDays']) > 0) { $purgeDate = $this->getCurrentTime() - 24 * 60 * 60 * intval($this->extensionSettings['purgeQueueDays']); $del = $this->db->exec_DELETEquery('tx_crawler_queue', 'exec_time!=0 AND exec_time<' . $purgeDate); } // Select entries: //TODO Shouldn't this reside within the transaction? $rows = $this->db->exec_SELECTgetRows('qid,scheduled', 'tx_crawler_queue', 'exec_time=0 AND process_scheduled= 0 AND scheduled<=' . $this->getCurrentTime(), '', 'scheduled, qid', intval($countInARun)); if (count($rows) > 0) { $quidList = array(); foreach ($rows as $r) { $quidList[] = $r['qid']; } $processId = $this->CLI_buildProcessId(); //reserve queue entrys for process $this->db->sql_query('BEGIN'); //TODO make sure we're not taking assigned queue-entires $this->db->exec_UPDATEquery('tx_crawler_queue', 'qid IN (' . implode(',', $quidList) . ')', array('process_scheduled' => intval($this->getCurrentTime()), 'process_id' => $processId)); //save the number of assigned queue entrys to determine who many have been processed later $numberOfAffectedRows = $this->db->sql_affected_rows(); $this->db->exec_UPDATEquery('tx_crawler_process', "process_id = '" . $processId . "'", array('assigned_items_count' => intval($numberOfAffectedRows))); if ($numberOfAffectedRows == count($quidList)) { $this->db->sql_query('COMMIT'); } else { $this->db->sql_query('ROLLBACK'); $this->CLI_debug("Nothing processed due to multi-process collision (" . $this->CLI_buildProcessId() . ")"); return $result | self::CLI_STATUS_ABORTED; } foreach ($rows as $r) { $result |= $this->readUrl($r['qid']); $counter++; usleep(intval($sleepTime)); // Just to relax the system // if during the start and the current read url the cli has been disable we need to return from the function // mark the process NOT as ended. if ($this->getDisabled()) { return $result | self::CLI_STATUS_ABORTED; } if (!$this->CLI_checkIfProcessIsActive($this->CLI_buildProcessId())) { $this->CLI_debug("conflict / timeout (" . $this->CLI_buildProcessId() . ")"); //TODO might need an additional returncode $result |= self::CLI_STATUS_ABORTED; break; //possible timeout } } sleep(intval($sleepAfterFinish)); $msg = 'Rows: ' . $counter; $this->CLI_debug($msg . " (" . $this->CLI_buildProcessId() . ")"); } else { $this->CLI_debug("Nothing within queue which needs to be processed (" . $this->CLI_buildProcessId() . ")"); } if ($counter > 0) { $result |= self::CLI_STATUS_PROCESSED; } return $result; }