require_once dirname(__FILE__) . '/../includes/suxPhoto.php'; set_time_limit(900); // Set the timeout to 15 minutes. // ---------------------------------------------------------------------------- // Set debug mode, if true nothing actually gets deleted // ---------------------------------------------------------------------------- $debug = true; // ---------------------------------------------------------------------------- // Purge orphaned link tables // ---------------------------------------------------------------------------- if ($debug) { echo "> Debug mode = true, nothing will be deleted. <br />\n"; } $db = suxDB::get(); // Scan for missing links, push them in $not_found array $link = new suxLink(); $link_tables = $link->getLinkTables(); $not_found = array(); foreach ($link_tables as $val) { $parts = explode('__', $val); if (count($parts) != 3) { die('Unexpected result, ejecting early to avoid catastrophe...'); } $st = $db->query("SELECT * FROM {$val} "); $tmp = $st->fetchAll(PDO::FETCH_ASSOC); foreach ($tmp as $val2) { $tmp2 = "{$parts[1]}_id"; $tmp3 = "{$parts[2]}_id"; // Table 1 $query = 'SELECT id FROM ' . $parts[1] . " WHERE id = {$val2[$tmp2]} "; $st = $db->query($query);
/** * @param int $id feed id */ function deleteFeed($id) { if (!filter_var($id, FILTER_VALIDATE_INT) || $id < 1) { return false; } $tid = suxDB::requestTransaction(); $this->inTransaction = true; $st = $this->db->prepare("DELETE FROM {$this->db_feeds} WHERE id = ? "); $st->execute(array($id)); $st = $this->db->prepare("SELECT id FROM {$this->db_items} WHERE rss_feeds_id = ? "); $st->execute(array($id)); $result = $st->fetchAll(PDO::FETCH_ASSOC); // Used with link deletion $st = $this->db->prepare("DELETE FROM {$this->db_items} WHERE rss_feeds_id = ? "); $st->execute(array($id)); // Delete links, too $link = new suxLink(); $links = $link->getLinkTables('rss_feeds'); foreach ($links as $table) { $link->deleteLink($table, 'rss_feeds', $id); } $links = $link->getLinkTables('rss_items'); foreach ($links as $table) { foreach ($result as $key => $val) { $link->deleteLink($table, 'rss_items', $val['id']); } } suxDB::commitTransaction($tid); $this->inTransaction = false; }
/** * Delete tag * * @param int $id tag id */ function delete($id) { if (!filter_var($id, FILTER_VALIDATE_INT) || $id < 1) { return false; } $tid = suxDB::requestTransaction(); $this->inTransaction = true; $st = $this->db->prepare("DELETE FROM {$this->db_table} WHERE id = ? "); $st->execute(array($id)); // Delete links, too $link = new suxLink(); $links = $link->getLinkTables('tags'); foreach ($links as $table) { $link->deleteLink($table, 'tags', $id); } suxDB::commitTransaction($tid); $this->inTransaction = false; }
<?php // Ajax // Echo the content of a bayesian document if (isset($_POST['id']) && filter_var($_POST['id'], FILTER_VALIDATE_INT)) { require_once dirname(__FILE__) . '/../../config.php'; require_once dirname(__FILE__) . '/../../initialize.php'; $nb = new suxNaiveBayesian(); $doc = $nb->getDocument($_POST['id']); if ($doc) { $text = suxFunct::gtext('bayes'); $tmp = null; $link = new suxLink(); foreach ($link->getLinkTables('bayes_documents') as $table) { $links = $link->getLinks($table, 'bayes_documents', $_POST['id']); if ($links && count($links)) { $table = str_replace('link__', '', $table); $table = str_replace('bayes_documents', '', $table); $table = str_replace('__', '', $table); $tmp .= "[ {$text['to']} {$table}_id -> "; foreach ($links as $val) { $tmp .= " {$val},"; } $tmp = rtrim($tmp, ', '); $tmp .= ' ]'; } } echo '<em>bayes_document_id: ', $_POST['id'], '</em><br />'; if ($tmp) { echo "<em><strong>{$text['is_linked']}</strong></em> "; echo $tmp;
// Get image names from template config $tpl = new suxTemplate($module); $tpl->configLoad('my.conf', $module); $image = $tpl->getConfigVars('imgUnsubscribed'); $db = suxDB::get(); $query = "SELECT COUNT(*) FROM {$link} WHERE {$col}_id = ? AND users_id = ? "; $st = $db->prepare($query); $st->execute(array($id, $_SESSION['users_id'])); if ($st->fetchColumn() > 0) { // Delete $query = "DELETE FROM {$link} WHERE {$col}_id = ? AND users_id = ? "; $st = $db->prepare($query); $st->execute(array($id, $_SESSION['users_id'])); } else { // Insert $suxLink = new suxLink(); $suxLink->saveLink($link, 'users', $_SESSION['users_id'], $col, $id); $image = $tpl->getConfigVars('imgSubscribed'); } // Log $log = new suxLog(); $log->write($_SESSION['users_id'], "sux0r::feeds::toggle() bookmarks_id: {$id}", 1); // Private // --------------------------------------------------------------------------- // Clear template caches // --------------------------------------------------------------------------- $tpl->clearCache(null, "{$_SESSION['nickname']}"); // clear all caches with "nickname" as the first cache_id group // --------------------------------------------------------------------------- // Return image string to Ajax request // ---------------------------------------------------------------------------
failure('Invalid module'); } if (!isset($_POST['id']) || !filter_var($_POST['id'], FILTER_VALIDATE_INT) || $_POST['id'] < 1) { failure('Invalid id'); } if (!isset($_POST['cat_id']) || !filter_var($_POST['cat_id'], FILTER_VALIDATE_INT) || $_POST['cat_id'] < 1) { failure('Invalid cat_id'); } $link = $_POST['link']; $module = $_POST['module']; $id = $_POST['id']; $cat_id = $_POST['cat_id']; // --------------------------------------------------------------------------- // Secondary error checking // --------------------------------------------------------------------------- $suxLink = new suxLink(); $nb = new suxUserNaiveBayesian(); $user = new suxUser(); $log = new suxLog(); if (!$nb->isCategoryTrainer($cat_id, $_SESSION['users_id'])) { failure('User is not authorized to train category.'); } // Something is wrong, abort // --------------------------------------------------------------------------- // Create $body based on $link type // --------------------------------------------------------------------------- $body = getBody($link, $id); if ($body === false) { failure('No $body, nothing to train.'); } // Something is wrong, abort.
/** * Delete thread * * @param int $thread_id thread id */ function deleteThread($thread_id) { if (!filter_var($thread_id, FILTER_VALIDATE_INT) || $thread_id < 1) { return false; } // Begin transaction $tid = suxDB::requestTransaction(); $this->inTransaction = true; $st = $this->db->prepare("SELECT id FROM {$this->db_table} WHERE thread_id = ? "); $st->execute(array($thread_id)); $result = $st->fetchAll(PDO::FETCH_ASSOC); foreach ($result as $key => $val) { $st = $this->db->prepare("DELETE FROM {$this->db_table} WHERE id = ? "); $st->execute(array($val['id'])); $st = $this->db->prepare("DELETE FROM {$this->db_table_hist} WHERE messages_id = ? "); $st->execute(array($val['id'])); } // Delete links, too $link = new suxLink(); $links = $link->getLinkTables('messages'); foreach ($result as $key => $val) { foreach ($links as $table) { $link->deleteLink($table, 'messages', $val['id']); } } // Commit suxDB::commitTransaction($tid); $this->inTransaction = false; }