コード例 #1
0
ファイル: do_deletetopic.php プロジェクト: shiyake/php-ihome
function deleteposts($tagid, $pids)
{
    global $_SGLOBAL;
    //整理
    $nums = renum($postnums);
    foreach ($nums[0] as $pnum) {
        $_SGLOBAL['db']->query("UPDATE " . tname('thread') . " SET replynum=replynum-{$pnum} WHERE tid IN (" . simplode($tids) . ")");
    }
    //删除
    $_SGLOBAL['db']->query("DELETE FROM " . tname('post') . " WHERE pid IN (" . simplode($pids) . ")");
    return true;
}
コード例 #2
0
ファイル: function_delete.php プロジェクト: NaturalWill/UCQA
function deleteposts($tagid, $pids)
{
    global $_SGLOBAL;
    //统计
    $postnums = $mpostnums = $tids = $delposts = $newids = $spaces = array();
    $ismanager = $allowmanage = checkperm('managethread');
    $managebatch = checkperm('managebatch');
    $delnum = 0;
    //群主
    $wheresql = '';
    if (empty($allowmanage) && $tagid) {
        $mtag = getmtag($tagid);
        if ($mtag['grade'] >= 8) {
            $allowmanage = 1;
            $managebatch = 1;
            $wheresql = " AND p.tagid='{$tagid}'";
        }
    }
    //获取积分
    $reward = getreward('delcomment', 0);
    $query = $_SGLOBAL['db']->query("SELECT p.* FROM " . tname('post') . " p WHERE p.pid IN (" . simplode($pids) . ") {$wheresql} ORDER BY p.isthread DESC");
    while ($value = $_SGLOBAL['db']->fetch_array($query)) {
        if ($allowmanage || $value['uid'] == $_SGLOBAL['supe_uid']) {
            if (!$managebatch && $value['uid'] != $_SGLOBAL['supe_uid']) {
                $delnum++;
            }
            $postarr[] = $value;
        }
    }
    if (!$managebatch && $delnum > 1) {
        return array();
    }
    foreach ($postarr as $key => $value) {
        if ($value['isthread']) {
            $tids[] = $value['tid'];
        } else {
            if (!in_array($value['tid'], $tids)) {
                $newids[] = $value['pid'];
                $delposts[] = $value;
                $postnums[$value['tid']]++;
                if ($ismanager && $value['uid'] != $_SGLOBAL['supe_uid']) {
                    //扣除积分
                    $_SGLOBAL['db']->query("UPDATE " . tname('space') . " SET credit=credit-{$reward['credit']}, experience=experience-{$reward['experience']} WHERE uid='{$value['uid']}'");
                }
            }
        }
    }
    $delthreads = array();
    if ($tids) {
        $delthreads = deletethreads($tagid, $tids);
    }
    if (empty($delposts)) {
        return $delthreads;
    }
    //整理
    $nums = renum($postnums);
    foreach ($nums[0] as $pnum) {
        $_SGLOBAL['db']->query("UPDATE " . tname('thread') . " SET replynum=replynum-{$pnum} WHERE tid IN (" . simplode($nums[1][$pnum]) . ")");
    }
    //删除
    $_SGLOBAL['db']->query("DELETE FROM " . tname('post') . " WHERE pid IN (" . simplode($newids) . ")");
    return $delposts;
}
コード例 #3
0
ファイル: function_admincp.php プロジェクト: softhui/discuz
function album_picnum_stat($start, $perpage)
{
    global $_G;
    $next = false;
    $updates = array();
    $query = C::t('home_album')->range($start, $perpage);
    foreach ($query as $value) {
        $next = true;
        $count = C::t('home_pic')->check_albumpic($value['albumid']);
        if ($count != $value['picnum']) {
            $updates[$value['albumid']] = $count;
        }
    }
    if (empty($updates)) {
        return $next;
    }
    $nums = renum($updates);
    foreach ($nums[0] as $count) {
        C::t('home_album')->update($nums[1][$count], array('picnum' => $count));
    }
    return $next;
}
コード例 #4
0
function album_picnum_stat($start, $perpage)
{
    global $_G;
    $next = false;
    $updates = array();
    $query = DB::query("SELECT albumid, picnum FROM " . DB::table('home_album') . " LIMIT {$start},{$perpage}");
    while ($value = DB::fetch($query)) {
        $next = true;
        $count = DB::result(DB::query("SELECT COUNT(*) FROM " . DB::table('home_pic') . " WHERE albumid='{$value['albumid']}'"), 0);
        if ($count != $value['picnum']) {
            $updates[$value['albumid']] = $count;
        }
    }
    if (empty($updates)) {
        return $next;
    }
    $nums = renum($updates);
    foreach ($nums[0] as $count) {
        DB::query("UPDATE " . DB::table('home_album') . " SET picnum={$count} WHERE albumid IN (" . dimplode($nums[1][$count]) . ")");
    }
    return $next;
}
コード例 #5
0
ファイル: function_delete.php プロジェクト: softhui/discuz
function deletecomments($cids)
{
    global $_G;
    $blognums = $newcids = $dels = $counts = array();
    $allowmanage = checkperm('managecomment');
    $query = C::t('home_comment')->fetch_all($cids);
    $deltypes = array();
    foreach ($query as $value) {
        if ($allowmanage || $value['authorid'] == $_G['uid'] || $value['uid'] == $_G['uid']) {
            $dels[] = $value;
            $newcids[] = $value['cid'];
            $deltypes[] = $value['idtype'] . '_cid';
            if ($value['authorid'] != $_G['uid'] && $value['uid'] != $_G['uid']) {
                $counts[$value['authorid']]['coef'] -= 1;
            }
            if ($value['idtype'] == 'blogid') {
                $blognums[$value['id']]++;
            }
        }
    }
    if (empty($dels)) {
        return array();
    }
    C::t('home_comment')->delete($newcids);
    for ($i = 0; $i < count($newcids); $i++) {
        C::t('common_moderate')->delete($newcids[$i], $deltypes[$i]);
    }
    if ($counts) {
        foreach ($counts as $uid => $setarr) {
            batchupdatecredit('comment', $uid, array(), $setarr['coef']);
        }
    }
    if ($blognums) {
        $nums = renum($blognums);
        foreach ($nums[0] as $num) {
            C::t('home_blog')->increase($nums[1][$num], 0, array('replynum' => -$num));
        }
    }
    return $dels;
}
コード例 #6
0
ファイル: cron_viewlog.php プロジェクト: Kingson4Wu/php_demo
if (!defined('IN_DISCUZ')) {
    exit('Access Denied');
}
$perbatch = 200;
$logs = array();
$maxnum = $maxlogid = 0;
$query = DB::query("SELECT logid, id, idtype FROM " . DB::table('viewlog') . " ORDER BY logid ASC LIMIT 0,{$perbatch}");
while ($value = DB::fetch($query)) {
    $logs[$value['idtype']][$value['id']]++;
    $maxnum++;
    $maxlogid = $value['logid'];
}
if ($maxnum) {
    if ($maxnum < $perbatch) {
        DB::query("TRUNCATE TABLE " . DB::table('viewlog'));
    } else {
        DB::query("DELETE FROM " . DB::table('viewlog') . " WHERE logid<='{$maxlogid}'");
    }
}
if ($logs['uid']) {
    $nums = renum($logs['uid']);
    foreach ($nums[0] as $num) {
        DB::query("UPDATE " . DB::table('common_member') . " SET viewnum=viewnum+{$num} WHERE uid IN (" . dimplode($nums[1][$num]) . ")");
    }
}
if ($logs['blogid']) {
    $nums = renum($logs['blogid']);
    foreach ($nums[0] as $num) {
        DB::query("UPDATE " . DB::table('home_blog') . " SET viewnum=viewnum+{$num} WHERE blogid IN (" . dimplode($nums[1][$num]) . ")");
    }
}
コード例 #7
0
function deletecomments($cids)
{
    global $_G;
    $blognums = $newcids = $dels = $counts = array();
    $allowmanage = checkperm('managecomment');
    $query = DB::query("SELECT * FROM " . DB::table('home_comment') . " WHERE cid IN (" . dimplode($cids) . ")");
    while ($value = DB::fetch($query)) {
        if ($allowmanage || $value['authorid'] == $_G['uid'] || $value['uid'] == $_G['uid']) {
            $dels[] = $value;
            $newcids[] = $value['cid'];
            if ($value['authorid'] != $_G['uid'] && $value['uid'] != $_G['uid']) {
                $counts[$value['authorid']]['coef'] -= 1;
            }
            if ($value['idtype'] == 'blogid') {
                $blognums[$value['id']]++;
            }
        }
    }
    if (empty($dels)) {
        return array();
    }
    DB::delete('home_comment', "cid IN (" . dimplode($newcids) . ")");
    DB::delete('common_moderate', "id IN (" . dimplode($newcids) . ") AND idtype='cid'");
    if ($counts) {
        foreach ($counts as $uid => $setarr) {
            batchupdatecredit('comment', $uid, array(), $setarr['coef']);
        }
    }
    if ($blognums) {
        $nums = renum($blognums);
        foreach ($nums[0] as $num) {
            DB::query("UPDATE " . DB::table('home_blog') . " SET replynum=replynum-{$num} WHERE blogid IN (" . dimplode($nums[1][$num]) . ")");
        }
    }
    return $dels;
}
コード例 #8
0
function tag_blognum_stat($start, $perpage) {
	global $_SGLOBAL;
	
	$next = false;
	$updates = array();
	$query = $_SGLOBAL['db']->query("SELECT tagid, blognum FROM ".tname('tag')." LIMIT $start,$perpage");
	while ($value = $_SGLOBAL['db']->fetch_array($query)) {
		$next = true;
		$count = getcount('tagblog', array('tagid'=>$value['tagid']));
		if($count != $value['blognum']) {
			$updates[$value['tagid']] = $count;
		}
	}
	if(empty($updates)) return $next;

	$nums = renum($updates);
	foreach ($nums[0] as $count) {
		$_SGLOBAL['db']->query("UPDATE ".tname('tag')." SET blognum=$count WHERE tagid IN (".simplode($nums[1][$count]).")");
	}
	return $next;
}
コード例 #9
0
function updatespaces($spaces, $type)
{
    global $_SGLOBAL;
    //空间数据
    if (!($credit = creditrule('pay', $type))) {
        return false;
        //删除不扣分
    }
    $nums = renum($spaces);
    foreach ($nums[0] as $num) {
        //积分
        $newcredit = $num * $credit;
        $_SGLOBAL['db']->query("UPDATE " . tname('space') . " SET credit=credit-{$newcredit} WHERE uid IN (" . simplode($nums[1][$num]) . ")");
    }
}
コード例 #10
0
ファイル: change_rows.php プロジェクト: lopacinski/WebFinance
    die("invoice does not exist");
}
if (!in_array($action, $authorized)) {
    die("action does not exist");
}
function renum($id_facture, $id_facture_ligne, $order = 'DESC')
{
    $sens = $order == 'DESC' ? '<=' : '>=';
    $query = sprintf("SELECT id_facture_ligne, ordre " . "FROM webfinance_invoice_rows " . "WHERE id_facture = %d " . "AND ordre %s (" . "   SELECT ordre " . "   FROM webfinance_invoice_rows " . "   WHERE id_facture_ligne = %d " . ") " . "ORDER BY ordre %s LIMIT 2", $id_facture, $sens, $id_facture_ligne, $order);
    $result = mysql_query($query);
    if (mysql_num_rows($result) != 2) {
        return false;
    }
    $query = "UPDATE webfinance_invoice_rows " . "SET ordre = %d " . "WHERE id_facture_ligne = %d ";
    mysql_query(sprintf($query, mysql_result($result, 0, "ordre"), mysql_result($result, 1, "id_facture_ligne"))) or wf_mysqldie();
    mysql_query(sprintf($query, mysql_result($result, 1, "ordre"), mysql_result($result, 0, "id_facture_ligne"))) or wf_mysqldie();
}
switch ($action) {
    case "raise":
        renum($id_facture, $id_facture_ligne);
        break;
    case "lower":
        renum($id_facture, $id_facture_ligne, 'ASC');
        break;
    case "delete":
        $query = "DELETE FROM webfinance_invoice_rows WHERE id_facture_ligne=" . $id_facture_ligne;
        mysql_query($query) or wf_mysqldie();
        break;
}
header('Location: /prospection/edit_facture.php?id_facture=' . $id_facture . '&id_facture_ligne=' . $id_facture_ligne);
exit;