コード例 #1
0
ファイル: suxRSS.php プロジェクト: hashimmm/sux0r
 /**
  * @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;
 }
コード例 #2
0
ファイル: purge_orphans.php プロジェクト: hashimmm/sux0r
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);
        if ($st->fetchColumn() <= 0) {
コード例 #3
0
ファイル: ajax.getDoc.php プロジェクト: hashimmm/sux0r
<?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 -&gt; ";
                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;
コード例 #4
0
ファイル: suxTags.php プロジェクト: hashimmm/sux0r
 /**
  * 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;
 }
コード例 #5
0
 /**
  * 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;
 }