예제 #1
0
    /**
     * Automatically prune shadow topics
     * Based on fuunction auto_prune()
     * @param int $forum_id Forum ID of forum that should be pruned
     * @param string $prune_mode Prune mode
     * @param int $prune_flags Prune flags
     * @param int $prune_days Prune date in days
     * @param int $prune_freq Prune frequency
     * @return null
     */
    protected function auto_prune_shadow_topics($forum_id, $prune_mode, $prune_flags, $prune_days, $prune_freq)
    {
        $sql = 'SELECT forum_name
			FROM ' . FORUMS_TABLE . "\n\t\t\tWHERE forum_id = {$forum_id}";
        $result = $this->db->sql_query($sql, 3600);
        $row = $this->db->sql_fetchrow($result);
        $this->db->sql_freeresult($result);
        if ($row) {
            $prune_date = time() - $prune_days * 86400;
            $next_prune = time() + $prune_freq * 86400;
            prune($forum_id, $prune_mode, $prune_date, $prune_flags, true);
            $sql = 'UPDATE ' . FORUMS_TABLE . "\n\t\t\t\tSET prune_shadow_next = {$next_prune}\n\t\t\t\tWHERE forum_id = {$forum_id}";
            $this->db->sql_query($sql);
            $user_id = empty($this->user->data) ? ANONYMOUS : $this->user->data['user_id'];
            $user_ip = empty($this->user->ip) ? '' : $this->user->ip;
            $this->log->add('admin', $user_id, $user_ip, 'LOG_PRUNE_SHADOW', false, array($row['forum_name']));
        }
        return;
    }
예제 #2
0
파일: prune.php 프로젝트: cbsistem/nexos
function auto_prune($forum_id = 0)
{
    global $db, $lang;
    $result = $db->sql_query("SELECT * FROM " . PRUNE_TABLE . " WHERE forum_id = {$forum_id}");
    if ($row = $db->sql_fetchrow($result)) {
        if ($row['prune_freq'] && $row['prune_days']) {
            $prune_date = time() - $row['prune_days'] * 86400;
            $next_prune = time() + $row['prune_freq'] * 86400;
            prune($forum_id, $prune_date);
            sync('forum', $forum_id);
            $db->sql_query("UPDATE " . FORUMS_TABLE . " SET prune_next = {$next_prune} WHERE forum_id = {$forum_id}");
        }
    }
    return;
}
function delete_item($old, $new = '', $topic_dest = '')
{
    global $db;
    // no changes
    if ($old == $new) {
        return;
    }
    // old type and id
    $old_type = substr($old, 0, 1);
    $old_id = intval(substr($old, 1));
    // new type and id
    $new_type = substr($new, 0, 1);
    $new_id = intval(substr($new, 1));
    if ($new_id == 0 || !in_array($new_type, array(POST_FORUM_URL, POST_CAT_URL))) {
        $new_type = POST_CAT_URL;
        $new_id = 0;
    }
    // topic dest
    $dst_type = substr($topic_dest, 0, 1);
    $dst_id = intval(substr($topic_dest, 1));
    if ($dst_id == 0 || $dst_type != POST_FORUM_URL) {
        $topic_dest = '';
    }
    // re-attach all the content to the new id
    if (!empty($new)) {
        $sql = "UPDATE " . FORUMS_TABLE . "\n\t\t\t\t\tSET main_type = '{$new_type}', parent_id = {$new_id}\n\t\t\t\t\tWHERE main_type = '{$old_type}' AND parent_id = {$old_id}";
        $db->sql_query($sql);
    }
    // topics move
    if (!empty($topic_dest) && $dst_type == POST_FORUM_URL) {
        if ($dst_type == POST_FORUM_URL && $old_type == POST_FORUM_URL) {
            // topics
            $sql = "UPDATE " . TOPICS_TABLE . " SET forum_id = {$dst_id} WHERE forum_id = {$old_id}";
            $db->sql_query($sql);
            // posts
            $sql = "UPDATE " . POSTS_TABLE . " SET forum_id = {$dst_id} WHERE forum_id = {$old_id}";
            $db->sql_query($sql);
            if (!class_exists('class_mcp')) {
                include IP_ROOT_PATH . 'includes/class_mcp.' . PHP_EXT;
            }
            if (empty($class_mcp)) {
                $class_mcp = new class_mcp();
            }
            $class_mcp->sync('forum', $dst_id);
        }
    }
    // all what is attached to a forum
    if ($old_type == POST_FORUM_URL) {
        // read current moderators for the old forum
        $sql = "SELECT ug.user_id FROM " . AUTH_ACCESS_TABLE . " a, " . USER_GROUP_TABLE . " ug\n\t\t\t\t\tWHERE a.forum_id = {$old_id}\n\t\t\t\t\t\tAND a.auth_mod = 1\n\t\t\t\t\t\tAND ug.group_id = a.group_id";
        $result = $db->sql_query($sql);
        $user_ids = array();
        while ($row = $db->sql_fetchrow($result)) {
            $user_ids[] = $row['user_id'];
        }
        $db->sql_freeresult($result);
        // remove moderator status for those ones
        if (!empty($user_ids)) {
            $old_moderators = implode(', ', $user_ids);
            // check which ones remain moderators
            $sql = "SELECT ug.user_id FROM " . AUTH_ACCESS_TABLE . " a, " . USER_GROUP_TABLE . " ug\n\t\t\t\t\t\tWHERE a.forum_id <> {$old_id}\n\t\t\t\t\t\t\tAND a.auth_mod = 1\n\t\t\t\t\t\t\tAND ug.group_id = a.group_id\n\t\t\t\t\t\t\tAND ug.user_id IN ({$old_moderators})";
            $result = $db->sql_query($sql);
            $user_ids = array();
            while ($row = $db->sql_fetchrow($result)) {
                $user_ids[] = $row['user_id'];
            }
            $new_moderators = empty($user_ids) ? '' : implode(', ', $user_ids);
            // update users status
            $sql = "UPDATE " . USERS_TABLE . "\n\t\t\t\t\t\tSET user_level = " . USER . "\n\t\t\t\t\t\tWHERE user_id IN ({$old_moderators})\n\t\t\t\t\t\t\tAND user_level NOT IN (" . JUNIOR_ADMIN . ", " . ADMIN . ")";
            $db->sql_query($sql);
            if (!empty($new_moderators)) {
                $sql = "UPDATE " . USERS_TABLE . "\n\t\t\t\t\t\t\tSET user_level = " . MOD . "\n\t\t\t\t\t\t\tWHERE user_id IN ({$new_moderators})\n\t\t\t\t\t\t\t\tAND user_level NOT IN (" . JUNIOR_ADMIN . ", " . ADMIN . ")";
                $db->sql_query($sql);
            }
        }
        // remove auth for the old forum
        $sql = "DELETE FROM " . AUTH_ACCESS_TABLE . " WHERE forum_id = {$old_id}";
        $db->sql_query($sql);
        // prune table
        $sql = "DELETE FROM " . PRUNE_TABLE . " WHERE forum_id = {$old_id}";
        $db->sql_query($sql);
        // polls
        $sql = "SELECT t.topic_id FROM " . TOPICS_TABLE . " t\n\t\t\t\t\tWHERE t.forum_id = {$old_id}";
        $result = $db->sql_query($sql);
        $topic_ids = array();
        while ($row = $db->sql_fetchrow($result)) {
            $topic_ids[] = $row['topic_id'];
        }
        if (!empty($topic_ids)) {
            if (!class_exists('class_mcp')) {
                include IP_ROOT_PATH . 'includes/class_mcp.' . PHP_EXT;
            }
            if (empty($class_mcp)) {
                $class_mcp = new class_mcp();
            }
            $class_mcp->topic_poll_delete($topic_ids);
        }
        // topics
        prune($old_id, 0, true);
        // Delete everything from forum
    }
    // delete the old one
    $sql = "DELETE FROM " . FORUMS_TABLE . " WHERE forum_id = {$old_id}";
    $db->sql_query($sql);
}
예제 #4
0
        $prune_ids = array();
        $p_result['topics'] = 0;
        $p_result['posts'] = 0;
        $log_data = '';
        do {
            if ($_CLASS['auth']->acl_get('f_list', $row['forum_id'])) {
                if ($prune_all) {
                    $p_result = prune($row['forum_id'], 'posted', time(), $prune_flags, false);
                } else {
                    if ($prune_posted) {
                        $return = prune($row['forum_id'], 'posted', $prunedate_posted, $prune_flags, false);
                        $p_result['topics'] += $return['topics'];
                        $p_result['posts'] += $return['posts'];
                    }
                    if ($prune_viewed) {
                        $return = prune($row['forum_id'], 'viewed', $prunedate_viewed, $prune_flags, false);
                        $p_result['topics'] += $return['topics'];
                        $p_result['posts'] += $return['posts'];
                    }
                }
                $prune_ids[] = $row['forum_id'];
                $row_class = $row_class == 'row1' ? 'row2' : 'row1';
                ?>
	<tr>
		<td class="<?php 
                echo $row_class;
                ?>
" align="center"><?php 
                echo $row['forum_name'];
                ?>
</td>
예제 #5
0
 if (isset($_POST['prune_comply'])) {
     confirm_referrer(PANTHER_ADMIN_DIR . '/maintenance.php');
     $prune_days = intval($_POST['prune_days']);
     $prune_date = $prune_days ? time() - $prune_days * 86400 : -1;
     @set_time_limit(0);
     if ($prune_from == 'all') {
         $ps = $db->select('forums', 'id');
         $num_forums = $ps->rowCount();
         for ($i = 0; $i < $num_forums; ++$i) {
             $fid = $ps->fetchColumn();
             prune($fid, $prune_sticky, $prune_date);
             update_forum($fid);
         }
     } else {
         $prune_from = intval($prune_from);
         prune($prune_from, $prune_sticky, $prune_date);
         update_forum($prune_from);
     }
     // Locate any "orphaned redirect topics" and delete them
     $ps = $db->run('SELECT t1.id FROM ' . $db->prefix . 'topics AS t1 LEFT JOIN ' . $db->prefix . 'topics AS t2 ON t1.moved_to=t2.id WHERE t2.id IS NULL AND t1.moved_to IS NOT NULL');
     $num_orphans = $ps->rowCount();
     if ($num_orphans) {
         for ($i = 0; $i < $num_orphans; ++$i) {
             $orphans[] = $ps->fetchColumn();
             $markers[] = '?';
         }
         $db->run('DELETE FROM ' . $db->prefix . 'topics WHERE id IN(' . implode(',', $markers) . ')', $orphans);
     }
     redirect(panther_link($panther_url['admin_maintenance']), $lang_admin_maintenance['Posts pruned redirect']);
 }
 $prune_days = panther_trim($_POST['req_prune_days']);
    message_die(GENERAL_ERROR, 'Could not obtain list of forums for pruning', '', __LINE__, __FILE__, $sql);
}
$forum_rows = array();
while ($row = $db->sql_fetchrow($result)) {
    $forum_rows[] = $row;
}
//
// Check for submit to be equal to Prune. If so then proceed with the pruning.
//
if (isset($HTTP_POST_VARS['doprune'])) {
    $prunedays = isset($HTTP_POST_VARS['prunedays']) ? intval($HTTP_POST_VARS['prunedays']) : 0;
    // Convert days to seconds for timestamp functions...
    $prunedate = time() - $prunedays * 86400;
    $template->set_filenames(array('body' => 'forum_prune_result_body.tpl'));
    for ($i = 0; $i < count($forum_rows); $i++) {
        $p_result = prune($forum_rows[$i]['forum_id'], $prunedate);
        sync('forum', $forum_rows[$i]['forum_id']);
        $row_color = !($i % 2) ? $theme['td_color1'] : $theme['td_color2'];
        $row_class = !($i % 2) ? $theme['td_class1'] : $theme['td_class2'];
        $template->assign_block_vars('prune_results', array('ROW_COLOR' => '#' . $row_color, 'ROW_CLASS' => $row_class, 'FORUM_NAME' => $forum_rows[$i]['forum_name'], 'FORUM_TOPICS' => $p_result['topics'], 'FORUM_POSTS' => $p_result['posts']));
    }
    $template->assign_vars(array('L_FORUM_PRUNE' => $lang['Forum_Prune'], 'L_FORUM' => $lang['Forum'], 'L_TOPICS_PRUNED' => $lang['Topics_pruned'], 'L_POSTS_PRUNED' => $lang['Posts_pruned'], 'L_PRUNE_RESULT' => $lang['Prune_success']));
} else {
    //
    // If they haven't selected a forum for pruning yet then
    // display a select box to use for pruning.
    //
    if (empty($HTTP_POST_VARS[POST_FORUM_URL])) {
        //
        // Output a selection table if no forum id has been specified.
        //
예제 #7
0
/**
 * The actual renderingfunction for handling all the stuff
 */
function renderEngine($timelinesrc, $args = null, $parser = null)
{
    global $wgTitle, $wgUploadDirectory, $wgUploadPath, $wgGraphVizSettings, $info;
    // some html-output for retracing what we did
    $info = "<h1>Graphviz Information</h1>";
    $info .= "<h2>Called render</h2>";
    /* Prepare Directories
     */
    $dest = $wgUploadDirectory . "/graphviz/";
    if (stristr(PHP_OS, 'WIN') && !stristr(PHP_OS, 'Darwin')) {
        $dest = str_replace("/", '\\', $dest);
        // switch the slashes for windows
        $isWindows = true;
    } else {
        $isWindows = false;
    }
    if (!is_dir($dest)) {
        mkdir($dest, 0777);
    }
    // create directory if it isn't there
    /* Start pruning  (if enabled) - use directory generated before
     * prune before creating a new image so that it won't be pruned right after creation
     */
    if ($wgGraphVizSettings->pruneEnabled) {
        prune($dest, $wgGraphVizSettings->pruneStrategy, $wgGraphVizSettings->pruneValue, $wgGraphVizSettings->pruneAmount);
        // prune the collection first
    }
    /* Check renderer - renderer should be set at least in renderMscgen or renderGraphviz but for security we check agaion and set some additional params
     */
    if (isset($args['renderer'])) {
        $renderer = $args['renderer'];
    } else {
        $renderer = 'dot';
    }
    switch ($renderer) {
        case 'circo':
        case 'dot':
        case 'fdp':
        case 'sfdp':
        case 'neato':
        case 'twopi':
            $mapDashTOption = ' -Tcmapx ';
            $inputOption = '';
            break;
        case 'mscgen':
            if ($wgGraphVizSettings->mscgenPath != null) {
                // check if path to mscgen is set - if not use agaion graphviz with dot
                $inputOption = '-i ';
                $mapDashTOption = ' -T ismap ';
                $wgGraphVizSettings->execPath = $wgGraphVizSettings->mscgenPath;
                // not that nice but functional: overwrite execPath with the path to mscgen
            } else {
                $renderer = 'dot';
                $mapDashTOption = ' -Tcmapx ';
                $inputOption = '';
            }
            break;
        default:
            $renderer = 'dot';
            $mapDashTOption = ' -Tcmapx ';
            $inputOption = '';
    }
    /* create the command for graphviz or mscgen
     */
    $cmd = $renderer;
    $cmd = $wgGraphVizSettings->execPath . $cmd;
    // example: /user/bin/dot
    if ($isWindows) {
        $cmd = $cmd . '.exe';
        // executables in windows
    }
    $info .= "<pre>Dir={$dest}</pre>";
    $info .= "<pre>execPath=" . $wgGraphVizSettings->execPath . "</pre>";
    $info .= "<pre>named=" . $wgGraphVizSettings->named . "</pre>";
    /* create actual storagename
     */
    $wgGraphVizSettings->named = strtolower($wgGraphVizSettings->named);
    // avoid problems with upper/lowercase
    /* get title name from parser. If parser not set, use $wgTitle instead
     */
    if ($parser != null) {
        $title = $parser->getTitle()->getFulltext();
    } else {
        $title = $wgTitle->getFulltext();
    }
    $storagename = str_replace("%", '_perc_', urlencode($title)) . '---';
    // clean up pagename (special chars etc)
    if ($wgGraphVizSettings->named == 'md5') {
        $storagename = md5($storagename . $timelinesrc);
        // produce md5-hash out of the storagename !can be duplicate!
    } elseif ($wgGraphVizSettings->named == 'sha1') {
        $storagename = sha1($storagename . $timelinesrc);
        // produce sha1-hash
    } else {
        // named == 'named'
        $storagename .= str_replace("%", '_perc_', urlencode(trim(str_replace(array("\n", "\\"), array('', '/'), substr($timelinesrc, 0, strpos($timelinesrc, '{'))))));
    }
    $info .= "<pre>storagename=" . $storagename . "</pre>";
    /* check if some outputtype is specified in the wikipage - else use the default value
     */
    if (isset($args['format'])) {
        $outputType = $args['format'];
    } else {
        $outputType = $wgGraphVizSettings->outputType;
    }
    /* inputcheck of supported image types
     */
    if ($renderer != 'mscgen') {
        // see supported types by graphviz itself (here only those that seem to be kind of useful) - http://www.graphviz.org/doc/info/output.html
        switch ($outputType) {
            case 'bmp':
            case 'gif':
            case 'jpg':
            case 'jpeg':
            case 'png':
            case 'svg':
                // for svg you need extra MediaWiki configuration
            // for svg you need extra MediaWiki configuration
            case 'svgz':
                // same as for svg
                // case 'tif':
                // case 'tiff':
                break;
            default:
                $outputType = 'png';
        }
    } else {
        // mscgen does only support png, svg and eps
        switch ($outputType) {
            case 'png':
            case 'svg':
                break;
            default:
                $outputType = 'png';
        }
    }
    $info .= "<pre>outputType=" . $outputType . "</pre>";
    /* prepare the actual files
     */
    $src = $dest . $storagename;
    // the raw input code - needed for the renderers - e.g. /graphviz/imagename (will be deleted later on)
    $imgn = $src . '.' . $outputType;
    // the whole image name -  e.g. /graphviz/imagename.png
    $mapn = $src . '.map';
    // the whole map name   - e.g. /graphviz/imagename.map
    $info .= '<pre>Src=' . $src . '</pre>';
    $info .= '<pre>imgn=' . $imgn . '</pre>';
    $info .= '<pre>mapn=' . $mapn . '</pre>';
    /* The actual commands for the rendering
     * check first if we have to overwrite the file (if we don't use hashes) or if it already exists
     */
    if ($wgGraphVizSettings->named == 'named' || !(file_exists($imgn) || file_exists($src . ".err"))) {
        $timelinesrc = rewriteWikiUrls($timelinesrc);
        // if we use wiki-links we transform them to real urls
        // write the given dot-commands into a textfile
        $handle = fopen($src, "w");
        if (!$handle) {
            return 'Error writing graphviz file to disk.';
        }
        $ret2 = fwrite($handle, $timelinesrc);
        $ret3 = fclose($handle);
        $info .= '<pre>Opened and closed $src, handle=' . $handle . ', timeelinesrc=' . $timelinesrc . ', ret2=' . $ret2 . ', ret3=' . $ret3 . '</pre>';
        // prepare the whole commands for image and map
        $cmdline = wfEscapeShellArg($cmd) . ' -T ' . $outputType . '   -o ' . wfEscapeShellArg($imgn) . ' ' . $inputOption . wfEscapeShellArg($src);
        $cmdlinemap = wfEscapeShellArg($cmd) . $mapDashTOption . '-o ' . wfEscapeShellArg($mapn) . ' ' . $inputOption . wfEscapeShellArg($src);
        // run the commands
        if ($isWindows) {
            $WshShell = new COM("WScript.Shell");
            $ret = $WshShell->Exec($cmdline);
            $retmap = $WshShell->Exec($cmdlinemap);
        } else {
            $ret = shell_exec($cmdline);
            $retmap = shell_exec($cmdlinemap);
        }
        $info .= '<pre>Ran cmd line (image). ret=$ret cmdline=' . $cmdline . '</pre>';
        $info .= '<pre>Ran cmd line (map). ret=$ret cmdlinemap=' . $cmdlinemap . '</pre>';
        // Error messages for image-creation
        if ($wgGraphVizSettings->install && $ret == "") {
            echo '<div id="toc"><tt>Timeline error: Executable not found.' . "\n" . 'Command line was: ' . $cmdline . '</tt></div>';
            $info .= '<div id="toc"><tt>Timeline error: Executable not found.' . "\n" . 'Command line was: ' . $cmdline . '</tt></div>';
            exit;
        }
        // Error messages for map-creation
        if ($wgGraphVizSettings->install && $retmap == "") {
            echo '<div id="toc"><tt>Timeline error: Executable not found.' . "\n" . 'Command line was: ' . $cmdlinemap . '</tt></div>';
            $info .= '<div id="toc"><tt>Timeline error: Executable not found.' . "\n" . 'Command line was: ' . $cmdlinemap . '</tt></div>';
            exit;
        }
        // let some other programs do their stuff
        if ($isWindows) {
            while ($ret->Status == 0 || $retmap->Status == 0) {
                usleep(100);
            }
        }
        unlink($src);
        // delete the src right away
    }
    /* put the produced into the website
     */
    @($err = file_get_contents($src . ".err"));
    // not really used
    if ($err != "") {
        $info .= '<div id="toc"><tt>' . $err . '</tt></div>';
        // print error message
    } else {
        if (false == ($map = file_get_contents($mapn))) {
            if ($wgGraphVizSettings->install) {
                echo '<div id="toc"><tt>File: ' . $mapn . ' is missing or empty.</tt></div>';
                $info .= '<div id="toc"><tt>File: ' . $mapn . ' is missing or empty.</tt></div>';
            }
        }
        // clean up map-name
        $map = preg_replace('#<ma(.*)>#', ' ', $map);
        $map = str_replace('</map>', '', $map);
        if ($renderer == 'mscgen') {
            $mapbefore = $map;
            $map = preg_replace('/(\\w+)\\s([_:%#/\\w]+)\\s(\\d+,\\d+)\\s(\\d+,\\d+)/', '<area shape="$1" href="$2" title="$2" alt="$2" coords="$3,$4" />', $map);
        }
        /* Procduce html
         */
        if ($wgGraphVizSettings->imageFormatting) {
            $txt = imageAtrributes($args, $storagename, $map, $outputType, $wgUploadPath);
            // if we want borders/position/...
        } else {
            $txt = '<map name="' . $storagename . '">' . $map . '</map>' . '<img src="' . $wgUploadPath . '/graphviz/' . $storagename . '.' . $outputType . '"' . ' usemap="#' . $storagename . '" />';
        }
    }
    /* give it back to your wiki
     */
    if ($wgGraphVizSettings->info) {
        $txt .= $info;
    }
    // do we want the information snipptes?
    return $txt;
}
예제 #8
0
    if (!$xoopsSecurity->check()) {
        redirectMsg('prune.php', __('Session token expired!', 'bxpress'), 0);
        die;
    }
    $db = XoopsDatabaseFactory::getDatabaseConnection();
    $sql = "SELECT id_topic FROM " . $db->prefix('bxpress_topics') . " WHERE ";
    $sql .= $forums == 0 ? '' : "id_forum='{$forums}' ";
    //Determinamos de que foro se va a limpiar temas
    $sql .= $forums ? " AND date<" . (time() - $days * 86400) : " date<" . (time() - $days * 86400);
    //Determinamos los temas con los dias de antigüedad especificados
    $sql .= $option == 2 ? " AND replies=0" : '';
    //Determinamos los temas a eliminar
    $sql .= $fixed ? " AND sticky=1 " : ' AND sticky=0';
    //Temas fijos
    $result = $db->queryF($sql);
    $num = $db->getRowsNum($result);
    while ($rows = $db->fetchArray($result)) {
        $topic = new BBTopic();
        $topic->assignVars($rows);
        $topic->delete();
    }
    redirectMsg('prune.php', sprintf(__('Prune done! %u topics deleted', 'bxpress'), $num), 0);
}
$action = rmc_server_var($_POST, 'action', '');
switch ($action) {
    case 'deltopics':
        deleteTopics();
        break;
    default:
        prune();
}
예제 #9
0
파일: common.php 프로젝트: EQ4/DRR
function db_all($what) {
  $res = [];
  while($item = prune($what)) {
    $res[] = $item;
  }
  return $res;
}
예제 #10
0
파일: admin.php 프로젝트: EQ4/DRR
?>
</tbody>
</table>
<?php if (!is_read_only()) { 
  echo '<a href="modify.php">Add Station</a>';
}
$now = time();

echo '<p>Now: ' . $now . '</p>';

echo '<table>';
$res = $db->query('select * from reminders');
$isFirst = true;

while($row = prune($res)) {
  if($isFirst) {
    echo '<thead><tr>';
    echo '<th>' . implode('</th><th>', array_keys($row)) . '</th>';
    echo '</thead><tbody>';
    $isFirst = False;
  }


  if (is_read_only()) {
    $row['email'] = '<em>(hidden)</em>';
  }

  $intval = intval($row['end_time']);
  $row['end_time'] = "$intval<br><small>(" . ($now - $intval) . ')</small>';
  echo '<tr><td>' . implode('</td><td>', array_values($row)) . '</td>';
예제 #11
0
     }
     $prune_sticky = intval($_POST['prune_sticky']);
     $prune_days = intval($_POST['prune_days']);
     $prune_date = $prune_days ? time() - $prune_days * 86400 : -1;
     @set_time_limit(0);
     if ($prune_from == 'all') {
         $result = $db->query('SELECT id FROM ' . $db->prefix . 'forums') or error('Unable to fetch forum list', __FILE__, __LINE__, $db->error());
         $num_forums = $db->num_rows($result);
         for ($i = 0; $i < $num_forums; ++$i) {
             $fid = $db->result($result, $i);
             prune($fid, $prune_sticky, $prune_date);
             update_forum($fid);
         }
     } else {
         foreach ($prune_from as $fid) {
             prune($fid, $prune_sticky, $prune_date);
             update_forum($fid);
         }
     }
     // Locate any "orphaned redirect topics" and delete them
     $result = $db->query('SELECT t1.id FROM ' . $db->prefix . 'topics AS t1 LEFT JOIN ' . $db->prefix . 'topics AS t2 ON t1.moved_to=t2.id WHERE t2.id IS NULL AND t1.moved_to IS NOT NULL') or error('Unable to fetch redirect topics', __FILE__, __LINE__, $db->error());
     $num_orphans = $db->num_rows($result);
     if ($num_orphans) {
         for ($i = 0; $i < $num_orphans; ++$i) {
             $orphans[] = $db->result($result, $i);
         }
         $db->query('DELETE FROM ' . $db->prefix . 'topics WHERE id IN(' . implode(',', $orphans) . ')') or error('Unable to delete redirect topics', __FILE__, __LINE__, $db->error());
     }
     redirect('admin_prune.php', 'Posts pruned. Redirecting &hellip;');
 }
 $prune_days = $_POST['req_prune_days'];
예제 #12
0
function auto_prune($forum_id = 0)
{
    global $db, $lang, $class_mcp;
    $sql = "SELECT *\n\t\tFROM " . PRUNE_TABLE . "\n\t\tWHERE forum_id = {$forum_id}";
    $result = $db->sql_query($sql);
    if ($row = $db->sql_fetchrow($result)) {
        if ($row['prune_freq'] && $row['prune_days']) {
            $prune_date = time() - $row['prune_days'] * 86400;
            $next_prune = time() + $row['prune_freq'] * 86400;
            if (!class_exists('class_mcp')) {
                include IP_ROOT_PATH . 'includes/class_mcp.' . PHP_EXT;
            }
            if (empty($class_mcp)) {
                $class_mcp = new class_mcp();
            }
            prune($forum_id, $prune_date);
            $class_mcp->sync('forum', $forum_id);
            $sql = "UPDATE " . FORUMS_TABLE . "\n\t\t\t\tSET prune_next = {$next_prune}\n\t\t\t\tWHERE forum_id = {$forum_id}";
            $db->sql_query($sql);
        }
    }
    return;
}
예제 #13
0
 if (isset($_POST['del_cat']) || isset($_POST['del_cat_comply'])) {
     confirm_referrer('admin_categories.php');
     $cat_to_delete = intval($_POST['cat_to_delete']);
     if ($cat_to_delete < 1) {
         message($lang->t('Bad request'));
     }
     if (isset($_POST['del_cat_comply'])) {
         @set_time_limit(0);
         $query = $db->select(array('id' => 'f.id'), 'forums AS f');
         $query->where = 'f.cat_id = :cat_id';
         $params = array(':cat_id' => $cat_to_delete);
         $result = $query->run($params);
         unset($query, $params);
         foreach ($result as $cur_forum) {
             // Prune all posts and topics
             prune($cur_forum['id'], 1, -1);
             // Delete the forum
             $query = $db->delete('forums');
             $query->where = 'id = :forum_id';
             $params = array(':forum_id' => $cur_forum['id']);
             $query->run($params);
             unset($query, $params);
         }
         unset($result);
         // Locate any "orphaned redirect topics" and delete them
         $query = $db->select(array('id' => 't1.id'), 'topics AS t1');
         $query->leftJoin('t1', 'topics AS t2', 't1.moved_to = t2.id');
         $query->where = 't2.id IS NULL AND t1.moved_to IS NOT NULL';
         $result = $query->run();
         unset($query);
         if (!empty($result)) {
예제 #14
0
/**
* Function auto_prune(), this function now relies on passed vars
*/
function auto_prune($forum_id, $prune_mode, $prune_flags, $prune_days, $prune_freq)
{
	global $db;

	$sql = 'SELECT forum_name
		FROM ' . FORUMS_TABLE . "
		WHERE forum_id = $forum_id";
	$result = $db->sql_query($sql, 3600);
	$row = $db->sql_fetchrow($result);
	$db->sql_freeresult($result);

	if ($row)
	{
		$prune_date = time() - ($prune_days * 86400);
		$next_prune = time() + ($prune_freq * 86400);

		prune($forum_id, $prune_mode, $prune_date, $prune_flags, true);

		$sql = 'UPDATE ' . FORUMS_TABLE . "
			SET prune_next = $next_prune
			WHERE forum_id = $forum_id";
		$db->sql_query($sql);

		add_log('admin', 'LOG_AUTO_PRUNE', $row['forum_name']);
	}

	return;
}
예제 #15
0
function auto_prune($forum_id = 0)
{
    global $db, $lang;
    $sql = "SELECT *\n\t\tFROM " . PRUNE_TABLE . "\n\t\tWHERE forum_id = {$forum_id}";
    if (!($result = $db->sql_query($sql))) {
        message_die(GENERAL_ERROR, 'Could not read auto_prune table', '', __LINE__, __FILE__, $sql);
    }
    if ($row = $db->sql_fetchrow($result)) {
        if ($row['prune_freq'] && $row['prune_days']) {
            $prune_date = time() - $row['prune_days'] * 86400;
            $next_prune = time() + $row['prune_freq'] * 86400;
            prune($forum_id, $prune_date);
            sync('forum', $forum_id);
            $sql = "UPDATE " . FORUMS_TABLE . " \n\t\t\t\tSET prune_next = {$next_prune} \n\t\t\t\tWHERE forum_id = {$forum_id}";
            if (!$db->sql_query($sql)) {
                message_die(GENERAL_ERROR, 'Could not update forum table', '', __LINE__, __FILE__, $sql);
            }
        }
    }
    return;
}
예제 #16
0
function delete_item($old, $new = '', $topic_dest = '')
{
    global $db;
    // no changes
    if ($old == $new) {
        return;
    }
    // old type and id
    $old_type = substr($old, 0, 1);
    $old_id = intval(substr($old, 1));
    // new type and id
    $new_type = substr($new, 0, 1);
    $new_id = intval(substr($new, 1));
    if ($new_id == 0 || !in_array($new_type, array(POST_FORUM_URL, POST_CAT_URL))) {
        $new_type = POST_CAT_URL;
        $new_id = 0;
    }
    // topic dest
    $dst_type = substr($topic_dest, 0, 1);
    $dst_id = intval(substr($topic_dest, 1));
    if ($dst_id == 0 || $dst_type != POST_FORUM_URL) {
        $topic_dest = '';
    }
    // re-attach all the content to the new id
    if (!empty($new)) {
        // forums
        if (defined('SUB_FORUM_ATTACH')) {
            $sql = "UPDATE " . FORUMS_TABLE . "\n                        SET main_type = '{$new_type}', cat_id = {$new_id}\n                        WHERE main_type = '{$old_type}' AND cat_id = {$old_id}";
            if (!$db->sql_query($sql)) {
                message_die(GENERAL_ERROR, 'Couldn\'t update forum attachement', '', __LINE__, __FILE__, $sql);
            }
        } else {
            if ($old_type == POST_CAT_URL) {
                if ($new_type == POST_CAT_URL && $new_id != 0) {
                    $sql = "UPDATE " . FORUMS_TABLE . "\n                            SET cat_id = {$new_id}\n                            WHERE cat_id = {$old_id}";
                    if (!$db->sql_query($sql)) {
                        message_die(GENERAL_ERROR, 'Couldn\'t update forum attachement', '', __LINE__, __FILE__, $sql);
                    }
                } else {
                    if ($new_type == POST_FORUM_URL || $new_id == 0) {
                        // check if forum attached
                        $sql = "SELECT * FROM " . FORUMS_TABLE . " WHERE cat_id = {$old_id} LIMIT 0, 1";
                        if (!($result = $db->sql_query($sql))) {
                            message_die(GENERAL_ERROR, 'Couldn\'t read forums attachement', '', __LINE__, __FILE__, $sql);
                        }
                        if ($row = $db->sql_fetchrow($result)) {
                            message_die(GENERAL_ERROR, 'Attempt to attach a forum to root index or to a forum');
                        }
                    }
                }
            }
        }
        // categories
        $sql = "UPDATE " . CATEGORIES_TABLE . "\n                    SET cat_main_type = '{$new_type}', cat_main = {$new_id}\n                    WHERE cat_main_type = '{$old_type}' AND cat_main = {$old_id}";
        if (!$db->sql_query($sql)) {
            message_die(GENERAL_ERROR, 'Couldn\'t update categories attachement', '', __LINE__, __FILE__, $sql);
        }
    }
    // topics move
    if (!empty($topic_dest) && $dst_type == POST_FORUM_URL) {
        if ($dst_type == POST_FORUM_URL && $old_type == POST_FORUM_URL) {
            // topics
            $sql = "UPDATE " . TOPICS_TABLE . " SET forum_id = {$dst_id} WHERE forum_id = {$old_id}";
            if (!$db->sql_query($sql)) {
                message_die(GENERAL_ERROR, 'Couldn\'t move topics to other forum', '', __LINE__, __FILE__, $sql);
            }
            // posts
            $sql = "UPDATE " . POSTS_TABLE . " SET forum_id = {$dst_id} WHERE forum_id = {$old_id}";
            if (!$db->sql_query($sql)) {
                message_die(GENERAL_ERROR, "Couldn't move posts to other forum", "", __LINE__, __FILE__, $sql);
            }
            sync('forum', $dst_id);
        }
    }
    // all what is attached to a forum
    if ($old_type == POST_FORUM_URL) {
        // read current moderators for the old forum
        $sql = "SELECT ug.user_id FROM " . AUTH_ACCESS_TABLE . " a, " . USER_GROUP_TABLE . " ug\n                    WHERE a.forum_id = {$old_id}\n                        AND a.auth_mod = 1\n                        AND ug.group_id = a.group_id";
        if (!($result = $db->sql_query($sql))) {
            message_die(GENERAL_ERROR, 'Couldn\'t obtain moderator list', '', __LINE__, __FILE__, $sql);
        }
        $user_ids = array();
        while ($row = $db->sql_fetchrow($result)) {
            $user_ids[] = $row['user_id'];
        }
        // remove moderator status for those ones
        if (!empty($user_ids)) {
            $old_moderators = implode(', ', $user_ids);
            // check which ones remain moderators
            $sql = "SELECT ug.user_id FROM " . AUTH_ACCESS_TABLE . " a, " . USER_GROUP_TABLE . " ug\n                        WHERE a.forum_id <> {$old_id}\n                            AND a.auth_mod = 1\n                            AND ug.group_id = a.group_id\n                            AND ug.user_id IN ({$old_moderators})";
            if (!($result = $db->sql_query($sql))) {
                message_die(GENERAL_ERROR, 'Couldn\'t obtain moderator list', '', __LINE__, __FILE__, $sql);
            }
            $user_ids = array();
            while ($row = $db->sql_fetchrow($result)) {
                $user_ids[] = $row['user_id'];
            }
            $new_moderators = empty($user_ids) ? '' : implode(', ', $user_ids);
            // update users status
            $sql = "UPDATE " . USERS_TABLE . "\n                        SET user_level = " . USER . "\n                        WHERE user_id IN ({$old_moderators})\n                            AND user_level <> " . ADMIN;
            if (!$db->sql_query($sql)) {
                message_die(GENERAL_ERROR, 'Couldn\'t update users mod level', '', __LINE__, __FILE__, $sql);
            }
            if (!empty($new_moderators)) {
                $sql = "UPDATE " . USERS_TABLE . "\n                            SET user_level = " . MOD . "\n                            WHERE user_id IN ({$new_moderators})\n                            AND user_level <> " . ADMIN;
                if (!$db->sql_query($sql)) {
                    message_die(GENERAL_ERROR, 'Couldn\'t update users mod level', '', __LINE__, __FILE__, $sql);
                }
            }
        }
        // remove auth for the old forum
        $sql = "DELETE FROM " . AUTH_ACCESS_TABLE . " WHERE forum_id = {$old_id}";
        if (!$db->sql_query($sql)) {
            message_die(GENERAL_ERROR, 'Couldn\'t remove from auth table', '', __LINE__, __FILE__, $sql);
        }
        // prune table
        $sql = "DELETE FROM " . PRUNE_TABLE . " WHERE forum_id = {$old_id}";
        if (!$db->sql_query($sql)) {
            message_die(GENERAL_ERROR, 'Couldn\'t remove from prune table old forum type', '', __LINE__, __FILE__, $sql);
        }
        // polls
        $sql = "SELECT v.vote_id FROM " . VOTE_DESC_TABLE . " v, " . TOPICS_TABLE . " t\n                    WHERE t.forum_id = {$old_id}\n                        AND v.topic_id = t.topic_id";
        if (!($result = $db->sql_query($sql))) {
            message_die(GENERAL_ERROR, 'Couldn\'t obtain list of vote ids', '', __LINE__, __FILE__, $sql);
        }
        $vote_ids = array();
        while ($row = $db->sql_fetchrow($result)) {
            $vote_ids[] = $row['vote_id'];
        }
        $s_vote_ids = empty($vote_ids) ? '' : implode(', ', $vote_ids);
        if (!empty($s_vote_ids)) {
            $sql = "DELETE FROM " . VOTE_RESULTS_TABLE . " WHERE vote_id IN ({$s_vote_ids})";
            if (!($result = $db->sql_query($sql))) {
                message_die(GENERAL_ERROR, 'Couldn\'t remove from vote results table', '', __LINE__, __FILE__, $sql);
            }
            $sql = "DELETE FROM " . VOTE_USERS_TABLE . " WHERE vote_id IN ({$s_vote_ids})";
            if (!($result = $db->sql_query($sql))) {
                message_die(GENERAL_ERROR, 'Couldn\'t remove from vote results table', '', __LINE__, __FILE__, $sql);
            }
            $sql = "DELETE FROM " . VOTE_DESC_TABLE . " WHERE vote_id IN ({$s_vote_ids})";
            if (!($result = $db->sql_query($sql))) {
                message_die(GENERAL_ERROR, 'Couldn\'t remove from vote desc table', '', __LINE__, __FILE__, $sql);
            }
        }
        // topics
        prune($old_id, 0, true);
        // Delete everything from forum
    }
    // delete the old one
    if ($old_type == POST_FORUM_URL) {
        $sql = "DELETE FROM " . FORUMS_TABLE . " WHERE forum_id = {$old_id}";
    } else {
        $sql = "DELETE FROM " . CATEGORIES_TABLE . " WHERE cat_id = {$old_id}";
    }
    if (!$db->sql_query($sql)) {
        message_die(GENERAL_ERROR, 'Couldn\'t delete old forum/category', '', __LINE__, __FILE__, $sql);
    }
}
예제 #17
0
    if (!defined('FORUM_CACHE_FUNCTIONS_LOADED')) {
        require PUN_ROOT . 'include/cache.php';
    }
    generate_quickjump_cache();
    redirect('admin_forums.php', $lang_admin_forums['Forum added redirect']);
} else {
    if (isset($_GET['del_forum'])) {
        confirm_referrer('admin_forums.php');
        $forum_id = intval($_GET['del_forum']);
        if ($forum_id < 1) {
            message($lang_common['Bad request'], false, '404 Not Found');
        }
        if (isset($_POST['del_forum_comply'])) {
            @set_time_limit(0);
            // Prune all posts and topics
            prune($forum_id, 1, -1);
            // Locate any "orphaned redirect topics" and delete them
            $result = $db->query('SELECT t1.id FROM ' . $db->prefix . 'topics AS t1 LEFT JOIN ' . $db->prefix . 'topics AS t2 ON t1.moved_to=t2.id WHERE t2.id IS NULL AND t1.moved_to IS NOT NULL') or error('Unable to fetch redirect topics', __FILE__, __LINE__, $db->error());
            $num_orphans = $db->num_rows($result);
            if ($num_orphans) {
                for ($i = 0; $i < $num_orphans; ++$i) {
                    $orphans[] = $db->result($result, $i);
                }
                $db->query('DELETE FROM ' . $db->prefix . 'topics WHERE id IN(' . implode(',', $orphans) . ')') or error('Unable to delete redirect topics', __FILE__, __LINE__, $db->error());
            }
            // Delete the forum and any forum specific group permissions
            $db->query('DELETE FROM ' . $db->prefix . 'forums WHERE id=' . $forum_id) or error('Unable to delete forum', __FILE__, __LINE__, $db->error());
            $db->query('DELETE FROM ' . $db->prefix . 'forum_perms WHERE forum_id=' . $forum_id) or error('Unable to delete group forum permissions', __FILE__, __LINE__, $db->error());
            // Delete any subscriptions for this forum
            $db->query('DELETE FROM ' . $db->prefix . 'forum_subscriptions WHERE forum_id=' . $forum_id) or error('Unable to delete subscriptions', __FILE__, __LINE__, $db->error());
            // Regenerate the quick jump cache
예제 #18
0
     $template->set_filenames(array("body" => "admin/forum_delete_body.tpl"));
     $s_hidden_fields = '<input type="hidden" name="mode" value="' . $newmode . '" /><input type="hidden" name="from_id" value="' . $forum_id . '" />';
     $template->assign_vars(array('NAME' => $name, 'L_FORUM_DELETE' => $lang['Forum_delete'], 'L_FORUM_DELETE_EXPLAIN' => $lang['Forum_delete_explain'], 'L_MOVE_CONTENTS' => $lang['Move_contents'], 'L_FORUM_NAME' => $lang['Forum_name'], "S_HIDDEN_FIELDS" => $s_hidden_fields, 'S_FORUM_ACTION' => append_sid("admin_forums.php"), 'S_SELECT_TO' => $select_to, 'S_SUBMIT_VALUE' => $buttonvalue));
     $template->pparse("body");
     break;
 case 'movedelforum':
     //
     // Move or delete a forum in the DB
     //
     $from_id = intval($HTTP_POST_VARS['from_id']);
     $to_id = intval($HTTP_POST_VARS['to_id']);
     $delete_old = intval($HTTP_POST_VARS['delete_old']);
     // Either delete or move all posts in a forum
     if ($to_id == -1) {
         include $phpbb_root_path . "includes/prune.php";
         prune($from_id, 0);
         // Delete everything from forum
     } else {
         $sql = "SELECT *\r\n\t\t\t\t\tFROM " . FORUMS_TABLE . "\r\n\t\t\t\t\tWHERE forum_id IN ({$from_id}, {$to_id})";
         if (!($result = $db->sql_query($sql))) {
             message_die(GENERAL_ERROR, "Couldn't verify existence of forums", "", __LINE__, __FILE__, $sql);
         }
         if ($db->sql_numrows($result) != 2) {
             message_die(GENERAL_ERROR, "Ambiguous forum ID's", "", __LINE__, __FILE__);
         }
         $sql = "UPDATE " . TOPICS_TABLE . "\r\n\t\t\t\t\tSET forum_id = {$to_id}\r\n\t\t\t\t\tWHERE forum_id = {$from_id}";
         if (!($result = $db->sql_query($sql))) {
             message_die(GENERAL_ERROR, "Couldn't move topics to other forum", "", __LINE__, __FILE__, $sql);
         }
         $sql = "UPDATE " . POSTS_TABLE . "\r\n\t\t\t\t\tSET\tforum_id = {$to_id}\r\n\t\t\t\t\tWHERE forum_id = {$from_id}";
         if (!($result = $db->sql_query($sql))) {
function auto_prune($forum_id, $prune_mode, $prune_flags, $prune_days, $prune_freq)
{
    global $_CLASS;
    $sql = 'SELECT forum_name
		FROM ' . FORUMS_TABLE . "\n\t\tWHERE forum_id = {$forum_id}";
    $result = $_CLASS['core_db']->query($sql);
    if ($row = $_CLASS['core_db']->fetch_row_assoc($result)) {
        $prune_date = time() - $prune_days * 86400;
        $next_prune = time() + $prune_freq * 86400;
        prune($forum_id, $prune_mode, $prune_date, $prune_flags, true);
        $sql = 'UPDATE ' . FORUMS_TABLE . "\n\t\t\tSET prune_next = {$next_prune}\n\t\t\tWHERE forum_id = {$forum_id}";
        $_CLASS['core_db']->query($sql);
        add_log('admin', 'LOG_AUTO_PRUNE', $row['forum_name']);
    }
    $_CLASS['core_db']->free_result($result);
    return;
}
예제 #20
0
			$template->pparse("body");
			break;

		case 'movedelforum':
			//
			// Move or delete a forum in the DB
			//
			$from_id = intval($HTTP_POST_VARS['from_id']);
			$to_id = intval($HTTP_POST_VARS['to_id']);
			$delete_old = intval($HTTP_POST_VARS['delete_old']);

			// Either delete or move all posts in a forum
			if($to_id == -1)
			{
				include($phpbb_root_path . "includes/prune.php");
				prune($from_id, 0); // Delete everything from forum
			}
			else
			{
				$sql = "SELECT *
					FROM " . FORUMS_TABLE . "
					WHERE forum_id IN ($from_id, $to_id)";
				if( !$result = $db->sql_query($sql) )
				{
					message_die(GENERAL_ERROR, "Couldn't verify existence of forums", "", __LINE__, __FILE__, $sql);
				}
				if($db->sql_numrows($result) != 2)
				{
					message_die(GENERAL_ERROR, "Ambiguous forum ID's", "", __LINE__, __FILE__);
				}
				$sql = "UPDATE " . TOPICS_TABLE . "
예제 #21
0
파일: acp_prune.php 프로젝트: hgchen/phpbb
    /**
     * Prune forums
     */
    function prune_forums($id, $mode)
    {
        global $db, $user, $auth, $template, $cache, $phpbb_log, $request;
        global $config, $phpbb_root_path, $phpbb_admin_path, $phpEx;
        $all_forums = $request->variable('all_forums', 0);
        $forum_id = $request->variable('f', array(0));
        $submit = isset($_POST['submit']) ? true : false;
        if ($all_forums) {
            $sql = 'SELECT forum_id
				FROM ' . FORUMS_TABLE . '
				ORDER BY left_id';
            $result = $db->sql_query($sql);
            $forum_id = array();
            while ($row = $db->sql_fetchrow($result)) {
                $forum_id[] = $row['forum_id'];
            }
            $db->sql_freeresult($result);
        }
        if ($submit) {
            if (confirm_box(true)) {
                $prune_posted = $request->variable('prune_days', 0);
                $prune_viewed = $request->variable('prune_vieweddays', 0);
                $prune_all = !$prune_posted && !$prune_viewed ? true : false;
                $prune_flags = 0;
                $prune_flags += $request->variable('prune_old_polls', 0) ? 2 : 0;
                $prune_flags += $request->variable('prune_announce', 0) ? 4 : 0;
                $prune_flags += $request->variable('prune_sticky', 0) ? 8 : 0;
                // Convert days to seconds for timestamp functions...
                $prunedate_posted = time() - $prune_posted * 86400;
                $prunedate_viewed = time() - $prune_viewed * 86400;
                $template->assign_vars(array('S_PRUNED' => true));
                $sql_forum = sizeof($forum_id) ? ' AND ' . $db->sql_in_set('forum_id', $forum_id) : '';
                // Get a list of forum's or the data for the forum that we are pruning.
                $sql = 'SELECT forum_id, forum_name
					FROM ' . FORUMS_TABLE . '
					WHERE forum_type = ' . FORUM_POST . "\n\t\t\t\t\t\t{$sql_forum}\n\t\t\t\t\tORDER BY left_id ASC";
                $result = $db->sql_query($sql);
                if ($row = $db->sql_fetchrow($result)) {
                    $prune_ids = array();
                    $p_result['topics'] = 0;
                    $p_result['posts'] = 0;
                    $log_data = '';
                    do {
                        if (!$auth->acl_get('f_list', $row['forum_id'])) {
                            continue;
                        }
                        if ($prune_all) {
                            $p_result = prune($row['forum_id'], 'posted', time(), $prune_flags, false);
                        } else {
                            if ($prune_posted) {
                                $return = prune($row['forum_id'], 'posted', $prunedate_posted, $prune_flags, false);
                                $p_result['topics'] += $return['topics'];
                                $p_result['posts'] += $return['posts'];
                            }
                            if ($prune_viewed) {
                                $return = prune($row['forum_id'], 'viewed', $prunedate_viewed, $prune_flags, false);
                                $p_result['topics'] += $return['topics'];
                                $p_result['posts'] += $return['posts'];
                            }
                        }
                        $prune_ids[] = $row['forum_id'];
                        $template->assign_block_vars('pruned', array('FORUM_NAME' => $row['forum_name'], 'NUM_TOPICS' => $p_result['topics'], 'NUM_POSTS' => $p_result['posts']));
                        $log_data .= ($log_data != '' ? ', ' : '') . $row['forum_name'];
                    } while ($row = $db->sql_fetchrow($result));
                    // Sync all pruned forums at once
                    sync('forum', 'forum_id', $prune_ids, true, true);
                    $phpbb_log->add('admin', $user->data['user_id'], $user->ip, 'LOG_PRUNE', false, array($log_data));
                }
                $db->sql_freeresult($result);
                return;
            } else {
                confirm_box(false, $user->lang['PRUNE_FORUM_CONFIRM'], build_hidden_fields(array('i' => $id, 'mode' => $mode, 'submit' => 1, 'all_forums' => $all_forums, 'f' => $forum_id, 'prune_days' => $request->variable('prune_days', 0), 'prune_vieweddays' => $request->variable('prune_vieweddays', 0), 'prune_old_polls' => $request->variable('prune_old_polls', 0), 'prune_announce' => $request->variable('prune_announce', 0), 'prune_sticky' => $request->variable('prune_sticky', 0))));
            }
        }
        // If they haven't selected a forum for pruning yet then
        // display a select box to use for pruning.
        if (!sizeof($forum_id)) {
            $template->assign_vars(array('U_ACTION' => $this->u_action, 'S_SELECT_FORUM' => true, 'S_FORUM_OPTIONS' => make_forum_select(false, false, false)));
        } else {
            $sql = 'SELECT forum_id, forum_name
				FROM ' . FORUMS_TABLE . '
				WHERE ' . $db->sql_in_set('forum_id', $forum_id);
            $result = $db->sql_query($sql);
            $row = $db->sql_fetchrow($result);
            if (!$row) {
                $db->sql_freeresult($result);
                trigger_error($user->lang['NO_FORUM'] . adm_back_link($this->u_action), E_USER_WARNING);
            }
            $forum_list = $s_hidden_fields = '';
            do {
                $forum_list .= ($forum_list != '' ? ', ' : '') . '<b>' . $row['forum_name'] . '</b>';
                $s_hidden_fields .= '<input type="hidden" name="f[]" value="' . $row['forum_id'] . '" />';
            } while ($row = $db->sql_fetchrow($result));
            $db->sql_freeresult($result);
            $l_selected_forums = sizeof($forum_id) == 1 ? 'SELECTED_FORUM' : 'SELECTED_FORUMS';
            $template->assign_vars(array('L_SELECTED_FORUMS' => $user->lang[$l_selected_forums], 'U_ACTION' => $this->u_action, 'U_BACK' => $this->u_action, 'FORUM_LIST' => $forum_list, 'S_HIDDEN_FIELDS' => $s_hidden_fields));
        }
    }
예제 #22
0
파일: forums.php 프로젝트: vebnz/lifelitup
    redirect(forum_link($forum_url['admin_forums']), $lang_admin_forums['Forum added'] . ' ' . $lang_admin_common['Redirect']);
} else {
    if (isset($_GET['del_forum'])) {
        $forum_to_delete = intval($_GET['del_forum']);
        if ($forum_to_delete < 1) {
            message($lang_common['Bad request']);
        }
        // User pressed the cancel button
        if (isset($_POST['del_forum_cancel'])) {
            redirect(forum_link($forum_url['admin_forums']), $lang_admin_common['Cancel redirect']);
        }
        ($hook = get_hook('afo_del_forum_form_submitted')) ? eval($hook) : null;
        if (isset($_POST['del_forum_comply'])) {
            @set_time_limit(0);
            // Prune all posts and topics
            prune($forum_to_delete, 1, -1);
            delete_orphans();
            // Delete the forum and any forum specific group permissions
            $query = array('DELETE' => 'forums', 'WHERE' => 'id=' . $forum_to_delete);
            ($hook = get_hook('afo_del_forum_qr_delete_forum')) ? eval($hook) : null;
            $forum_db->query_build($query) or error(__FILE__, __LINE__);
            $query = array('DELETE' => 'forum_perms', 'WHERE' => 'forum_id=' . $forum_to_delete);
            ($hook = get_hook('afo_del_forum_qr_delete_forum_perms')) ? eval($hook) : null;
            $forum_db->query_build($query) or error(__FILE__, __LINE__);
            // Regenerate the quickjump cache
            if (!defined('FORUM_CACHE_FUNCTIONS_LOADED')) {
                require FORUM_ROOT . 'include/cache.php';
            }
            generate_quickjump_cache();
            ($hook = get_hook('afo_del_forum_pre_redirect')) ? eval($hook) : null;
            redirect(forum_link($forum_url['admin_forums']), $lang_admin_forums['Forum deleted'] . ' ' . $lang_admin_common['Redirect']);
예제 #23
0
     }
     if ($row = $db->sql_fetchrow($result)) {
         $vote_ids = '';
         do {
             $vote_ids = ($vote_ids != '' ? ', ' : '') . $row['vote_id'];
         } while ($row = $db->sql_fetchrow($result));
         $sql = "DELETE FROM " . VOTE_DESC_TABLE . " \n\t\t\t\t\t\tWHERE vote_id IN ({$vote_ids})";
         $db->sql_query($sql);
         $sql = "DELETE FROM " . VOTE_RESULTS_TABLE . " \n\t\t\t\t\t\tWHERE vote_id IN ({$vote_ids})";
         $db->sql_query($sql);
         $sql = "DELETE FROM " . VOTE_USERS_TABLE . " \n\t\t\t\t\t\tWHERE vote_id IN ({$vote_ids})";
         $db->sql_query($sql);
     }
     $db->sql_freeresult($result);
     include $phpbb_root_path . "includes/prune.{$phpEx}";
     prune($from_id, 0, true);
     // Delete everything from forum
 } else {
     $sql = "SELECT *\n\t\t\t\t\tFROM " . FORUMS_TABLE . "\n\t\t\t\t\tWHERE forum_id IN ({$from_id}, {$to_id})";
     if (!($result = $db->sql_query($sql))) {
         message_die(GENERAL_ERROR, "Couldn't verify existence of forums", "", __LINE__, __FILE__, $sql);
     }
     if ($db->sql_numrows($result) != 2) {
         message_die(GENERAL_ERROR, "Ambiguous forum ID's", "", __LINE__, __FILE__);
     }
     $sql = "UPDATE " . TOPICS_TABLE . "\n\t\t\t\t\tSET forum_id = {$to_id}\n\t\t\t\t\tWHERE forum_id = {$from_id}";
     if (!($result = $db->sql_query($sql))) {
         message_die(GENERAL_ERROR, "Couldn't move topics to other forum", "", __LINE__, __FILE__, $sql);
     }
     $sql = "UPDATE " . POSTS_TABLE . "\n\t\t\t\t\tSET\tforum_id = {$to_id}\n\t\t\t\t\tWHERE forum_id = {$from_id}";
     if (!($result = $db->sql_query($sql))) {
예제 #24
0
 if (isset($_POST['prune_comply'])) {
     confirm_referrer('backstage/prune.php');
     $prune_days = intval($_POST['prune_days']);
     $prune_date = $prune_days ? time() - $prune_days * 86400 : -1;
     @set_time_limit(0);
     if ($prune_from == 'all') {
         $result = $db->query('SELECT id FROM ' . $db->prefix . 'forums') or error('Unable to fetch forum list', __FILE__, __LINE__, $db->error());
         $num_forums = $db->num_rows($result);
         for ($i = 0; $i < $num_forums; ++$i) {
             $fid = $db->result($result, $i);
             prune($fid, $prune_pinned, $prune_date);
             update_forum($fid);
         }
     } else {
         $prune_from = intval($prune_from);
         prune($prune_from, $prune_pinned, $prune_date);
         update_forum($prune_from);
     }
     // Locate any "orphaned redirect threads" and delete them
     $result = $db->query('SELECT t1.id FROM ' . $db->prefix . 'threads AS t1 LEFT JOIN ' . $db->prefix . 'threads AS t2 ON t1.moved_to=t2.id WHERE t2.id IS NULL AND t1.moved_to IS NOT NULL') or error('Unable to fetch redirect threads', __FILE__, __LINE__, $db->error());
     $num_orphans = $db->num_rows($result);
     if ($num_orphans) {
         for ($i = 0; $i < $num_orphans; ++$i) {
             $orphans[] = $db->result($result, $i);
         }
         $db->query('DELETE FROM ' . $db->prefix . 'threads WHERE id IN(' . implode(',', $orphans) . ')') or error('Unable to delete redirect threads', __FILE__, __LINE__, $db->error());
     }
     redirect('backstage/prune.php');
 }
 $prune_days = luna_trim($_POST['req_prune_days']);
 if ($prune_days == '' || preg_match('%[^0-9]%', $prune_days)) {
예제 #25
0
     confirm_referrer('admin_prune.php');
     $prune_from = $_POST['prune_from'];
     $prune_days = intval($_POST['prune_days']);
     $prune_date = $prune_days ? time() - $prune_days * 86400 : -1;
     @set_time_limit(0);
     if ($prune_from == 'all') {
         $result = $db->query('SELECT id FROM ' . $db->prefix . 'forums') or error('Unable to fetch forum list', __FILE__, __LINE__, $db->error());
         $num_forums = $db->num_rows($result);
         for ($i = 0; $i < $num_forums; ++$i) {
             $fid = $db->result($result, $i);
             prune($fid, $_POST['prune_sticky'], $prune_date);
             update_forum($fid);
         }
     } else {
         $prune_from = intval($prune_from);
         prune($prune_from, $_POST['prune_sticky'], $prune_date);
         update_forum($prune_from);
     }
     // Locate any "orphaned redirect topics" and delete them
     $result = $db->query('SELECT t1.id FROM ' . $db->prefix . 'topics AS t1 LEFT JOIN ' . $db->prefix . 'topics AS t2 ON t1.moved_to=t2.id WHERE t2.id IS NULL AND t1.moved_to IS NOT NULL') or error('Unable to fetch redirect topics', __FILE__, __LINE__, $db->error());
     $num_orphans = $db->num_rows($result);
     if ($num_orphans) {
         for ($i = 0; $i < $num_orphans; ++$i) {
             $orphans[] = $db->result($result, $i);
         }
         $db->query('DELETE FROM ' . $db->prefix . 'topics WHERE id IN(' . implode(',', $orphans) . ')') or error('Unable to delete redirect topics', __FILE__, __LINE__, $db->error());
     }
     redirect('admin_prune.php', 'Posts pruned. Redirecting &hellip;');
 }
 $prune_days = $_POST['req_prune_days'];
 if (!@preg_match('#^\\d+$#', $prune_days)) {
예제 #26
0
    redirect('admin_categories.php', 'Category added. Redirecting &hellip;');
} else {
    if (isset($_POST['del_cat']) || isset($_POST['del_cat_comply'])) {
        confirm_referrer('admin_categories.php');
        $cat_to_delete = intval($_POST['cat_to_delete']);
        if ($cat_to_delete < 1) {
            message($lang_common['Bad request']);
        }
        if (isset($_POST['del_cat_comply'])) {
            @set_time_limit(0);
            $result = $db->query('SELECT id FROM ' . $db->prefix . 'forums WHERE cat_id=' . $cat_to_delete) or error('Unable to fetch forum list', __FILE__, __LINE__, $db->error());
            $num_forums = $db->num_rows($result);
            for ($i = 0; $i < $num_forums; ++$i) {
                $cur_forum = $db->result($result, $i);
                // Prune all posts and topics
                prune($cur_forum, 1, -1);
                // Delete the forum
                $db->query('DELETE FROM ' . $db->prefix . 'forums WHERE id=' . $cur_forum) or error('Unable to delete forum', __FILE__, __LINE__, $db->error());
            }
            // Locate any "orphaned redirect topics" and delete them
            $result = $db->query('SELECT t1.id FROM ' . $db->prefix . 'topics AS t1 LEFT JOIN ' . $db->prefix . 'topics AS t2 ON t1.moved_to=t2.id WHERE t2.id IS NULL AND t1.moved_to IS NOT NULL') or error('Unable to fetch redirect topics', __FILE__, __LINE__, $db->error());
            $num_orphans = $db->num_rows($result);
            if ($num_orphans) {
                for ($i = 0; $i < $num_orphans; ++$i) {
                    $orphans[] = $db->result($result, $i);
                }
                $db->query('DELETE FROM ' . $db->prefix . 'topics WHERE id IN(' . implode(',', $orphans) . ')') or error('Unable to delete redirect topics', __FILE__, __LINE__, $db->error());
            }
            // Delete the category
            $db->query('DELETE FROM ' . $db->prefix . 'categories WHERE id=' . $cat_to_delete) or error('Unable to delete category', __FILE__, __LINE__, $db->error());
            // Regenerate the quickjump cache
예제 #27
0
/**
* Function auto_prune(), this function now relies on passed vars
*/
function auto_prune($forum_id, $prune_mode, $prune_flags, $prune_days, $prune_freq)
{
    global $db, $user, $phpbb_log;
    $sql = 'SELECT forum_name
		FROM ' . FORUMS_TABLE . "\n\t\tWHERE forum_id = {$forum_id}";
    $result = $db->sql_query($sql, 3600);
    $row = $db->sql_fetchrow($result);
    $db->sql_freeresult($result);
    if ($row) {
        $prune_date = time() - $prune_days * 86400;
        $next_prune = time() + $prune_freq * 86400;
        prune($forum_id, $prune_mode, $prune_date, $prune_flags, true);
        $sql = 'UPDATE ' . FORUMS_TABLE . "\n\t\t\tSET prune_next = {$next_prune}\n\t\t\tWHERE forum_id = {$forum_id}";
        $db->sql_query($sql);
        $phpbb_log->add('admin', $user->data['user_id'], $user->ip, 'LOG_AUTO_PRUNE', false, array($row['forum_name']));
    }
    return;
}
예제 #28
0
#!/usr/local/bin/php -f
<?php 
// $Horde: horde/scripts/make-snaps.php,v 1.16 2004/03/06 15:25:02 chuck Exp $
$modules = array('accounts', 'agora', 'ansel', 'babel', 'chora', 'forwards', 'framework', 'genie', 'giapeto', 'gollem', 'hermes', 'horde', 'HordeConduit', 'imapproxy', 'imp', 'ingo', 'jeta', 'jonah', 'juno', 'klutz', 'kronolith', 'luxor', 'midas', 'mimp', 'mnemo', 'moment', 'mottle', 'nag', 'nic', 'odin', 'orator', 'passwd', 'rakim', 'sam', 'scry', 'skeleton', 'swoosh', 'thor', 'trean', 'troll', 'turba', 'ulaform', 'vacation', 'vilma', 'whups', 'whupsey', 'wicked');
$stable = array('accounts' => 'RELENG_2', 'chora' => 'RELENG_1', 'forwards' => 'RELENG_2', 'horde' => 'RELENG_2', 'imp' => 'RELENG_3', 'ingo' => 'RELENG_1', 'klutz' => 'RELENG_1', 'kronolith' => 'RELENG_1', 'mnemo' => 'RELENG_1', 'nag' => 'RELENG_1', 'passwd' => 'RELENG_2', 'turba' => 'RELENG_1', 'vacation' => 'RELENG_2');
$dir = date('Y-m-d');
if (!is_dir($dir)) {
    mkdir($dir);
}
exportCVS();
makeTarballs();
cleanup();
prune(7);
// Update latest/ symlink.
system("ln -sfh {$dir} latest");
/**
 * Functions
 */
function exportCVS()
{
    global $dir, $modules, $stable;
    foreach ($modules as $module) {
        system("cd {$dir}; cvs -Q export -r HEAD {$module} > /dev/null");
        if (array_key_exists($module, $stable)) {
            system("cd {$dir}; cvs -Q export -r {$stable[$module]} -d {$module}-RELENG {$module}");
        }
    }
}
function makeTarballs()
{
    global $dir, $modules, $stable;