本文整理汇总了PHP中prune函数的典型用法代码示例。如果您正苦于以下问题:PHP prune函数的具体用法?PHP prune怎么用?PHP prune使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了prune函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: auto_prune_shadow_topics
/**
* 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: auto_prune
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;
}
示例3: delete_item
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
//.........这里部分代码省略.........
示例4: array
$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: confirm_referrer
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']);
示例6: message_die
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: renderEngine
/**
* 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, '{'))))));
}
//.........这里部分代码省略.........
示例8: redirectMsg
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: db_all
function db_all($what) {
$res = [];
while($item = prune($what)) {
$res[] = $item;
}
return $res;
}
示例10: if
?>
</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: intval
}
$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 …');
}
$prune_days = $_POST['req_prune_days'];
示例12: auto_prune
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: confirm_referrer
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: auto_prune
/**
* 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: auto_prune
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;
}