本文整理汇总了PHP中db_saq函数的典型用法代码示例。如果您正苦于以下问题:PHP db_saq函数的具体用法?PHP db_saq怎么用?PHP db_saq使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了db_saq函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: ignore_alias_fetch
function ignore_alias_fetch($al, &$is_mod)
{
if (!($tmp = db_saq("SELECT id, (users_opt & 1048576) FROM phpgw_fud_users WHERE alias='" . addslashes(htmlspecialchars($al)) . "'"))) {
return;
}
$is_mod = $tmp[1];
return $tmp[0];
}
示例2: all_hooks
function all_hooks($args)
{
if (!function_exists('db_saq')) {
fud_use('db.inc');
}
$GLOBALS['adm_file'] = array();
list($GLOBALS['fudh_uopt'], $theme_name) = db_saq("SELECT u.users_opt, t.name FROM phpgw_fud_users u INNER JOIN phpgw_fud_themes t ON t.id=u.theme WHERE u.id!=1 AND u.egw_id=" . (int) $GLOBALS['phpgw_info']['user']['account_id']);
$GLOBALS['fudh_uopt'] = (int) $GLOBALS['fudh_uopt'];
if (!empty($GLOBALS['phpgw_info']['user']['apps']['admin'])) {
$GLOBALS['fudh_uopt'] |= 1048576;
}
include_once $GLOBALS['DATA_DIR'] . 'include/theme/' . str_replace(' ', '_', $theme_name) . '/usercp.inc';
/* regular user links */
//print_r ($GLOBALS);
if (!empty($GLOBALS['t']) && $GLOBALS['last_loginid'] != 'anonymous') {
display_sidebox('fudforum', lang('Preferences'), $GLOBALS['usr_file']);
}
/* admin stuff */
if ($GLOBALS['adm_file']) {
display_sidebox('fudforum', lang('Administration'), $GLOBALS['adm_file']);
}
}
示例3: unset
}
if (strncmp($msg_subject, 'Re: ', 4)) {
$old_subject = $msg_subject = 'Re: ' . $msg_subject;
}
$msg_ref_msg_id = 'R' . $reply;
unset($msg_r);
} else {
if ($forward && strncmp($msg_subject, 'Fwd: ', 5)) {
$old_subject = $msg_subject = 'Fwd: ' . $msg_subject;
$msg_ref_msg_id = 'F' . $forward;
}
}
}
} else {
if (isset($_GET['reply']) && ($reply = (int) $_GET['reply'])) {
if ($msg_r = db_saq('SELECT p.subject, u.alias FROM phpgw_fud_pmsg p INNER JOIN phpgw_fud_users u ON p.ouser_id=u.id WHERE p.id=' . $reply . ' AND p.duser_id=' . _uid)) {
$msg_subject = $msg_r[0];
$msg_to_list = $msg_r[1];
if (strncmp($msg_subject, 'Re: ', 4)) {
$old_subject = $msg_subject = 'Re: ' . $msg_subject;
}
reverse_fmt($msg_subject);
unset($msg_r);
$msg_ref_msg_id = 'R' . $reply;
}
}
}
}
/* restore file attachments */
if (!empty($msg_r->attach_cnt) && $PRIVATE_ATTACHMENTS > 0) {
$c = uq('SELECT id FROM phpgw_fud_attach WHERE message_id=' . $msg_r->id . ' AND attach_opt=1');
示例4: get_prev_next_th_id
function get_prev_next_th_id(&$frm, &$prev, &$next)
{
/* determine previous thread */
if ($frm->th_page == 1 && $frm->th_pos == 1) {
$prev = '';
} else {
if ($frm->th_pos - 1 == 0) {
$page = $frm->th_page - 1;
$pos = $GLOBALS['THREADS_PER_PAGE'];
} else {
$page = $frm->th_page;
$pos = $frm->th_pos - 1;
}
$p = db_saq('SELECT m.id, m.subject FROM phpgw_fud_thread_view tv INNER JOIN phpgw_fud_thread t ON tv.thread_id=t.id INNER JOIN phpgw_fud_msg m ON t.root_msg_id=m.id WHERE tv.forum_id=' . $frm->forum_id . ' AND tv.page=' . $page . ' AND tv.pos=' . $pos);
$prev = $p ? '<tr><td align=right class="GenText">Previous Topic:</td><td class="GenText" align=left><a href="/egroupware/fudforum/3814588639/index.php?t=' . $_GET['t'] . '&goto=' . $p[0] . '&' . _rsid . '" class="GenLink">' . $p[1] . '</a></td></tr>' : '';
}
/* determine next thread */
if ($frm->th_pos + 1 > $GLOBALS['THREADS_PER_PAGE']) {
$page = $frm->th_page + 1;
$pos = 1;
} else {
$page = $frm->th_page;
$pos = $frm->th_pos + 1;
}
$n = db_saq('SELECT m.id, m.subject FROM phpgw_fud_thread_view tv INNER JOIN phpgw_fud_thread t ON tv.thread_id=t.id INNER JOIN phpgw_fud_msg m ON t.root_msg_id=m.id WHERE tv.forum_id=' . $frm->forum_id . ' AND tv.page=' . $page . ' AND tv.pos=' . $pos);
$next = $n ? '<tr><td class="GenText" align=right>Next Topic:</td><td class="GenText" align=left><a class="GenLink" href="/egroupware/fudforum/3814588639/index.php?t=' . $_GET['t'] . '&goto=' . $n[0] . '&' . _rsid . '">' . $n[1] . '</a></td></tr>' : '';
}
示例5: alt_var
}
function alt_var($key)
{
if (!isset($GLOBALS['_ALTERNATOR_'][$key])) {
$args = func_get_args();
array_shift($args);
$GLOBALS['_ALTERNATOR_'][$key] = array('p' => 1, 't' => count($args), 'v' => $args);
return $args[0];
}
$k =& $GLOBALS['_ALTERNATOR_'][$key];
if ($k['p'] == $k['t']) {
$k['p'] = 0;
}
return $k['v'][$k['p']++];
}
if (!isset($_GET['id']) || !($tmp = db_saq('SELECT id, alias, posted_msg_count, join_date FROM phpgw_fud_users WHERE id=' . (int) $_GET['id']))) {
invl_inp_err();
} else {
$uid = $tmp[0];
$u_alias = $tmp[1];
$u_pcount = $tmp[2];
$u_reg_date = $tmp[3];
}
$TITLE_EXTRA = ': Show Posts by: ' . $u_alias;
ses_update_status($usr->sid, 'Viewing posts by: <a class="GenLink" href="/egroupware/fudforum/3814588639/index.php?t=usrinfo&id=' . $uid . '">' . $u_alias . '</a>');
if (!isset($_GET['start']) || !($start = (int) $_GET['start'])) {
$start = 0;
}
if (!($usr->users_opt & 1048576)) {
$fids = implode(',', array_keys(get_all_read_perms(_uid, $usr->users_opt & 524288)));
}
示例6: approve
//.........这里部分代码省略.........
}
/* handle notifications */
if ($mtf->root_msg_id == $mtf->id) {
if (empty($mtf->frm_last_post_date)) {
$mtf->frm_last_post_date = 0;
}
/* send new thread notifications to forum subscribers */
$c = uq('SELECT u.email, u.icq, u.users_opt
FROM phpgw_fud_forum_notify fn
INNER JOIN phpgw_fud_users u ON fn.user_id=u.id
LEFT JOIN phpgw_fud_forum_read r ON r.forum_id=fn.forum_id AND r.user_id=fn.user_id
INNER JOIN phpgw_fud_group_cache g1 ON g1.user_id=2147483647 AND g1.resource_id=' . $mtf->forum_id . '
LEFT JOIN phpgw_fud_group_cache g2 ON g2.user_id=fn.user_id AND g2.resource_id=' . $mtf->forum_id . '
WHERE
fn.forum_id=' . $mtf->forum_id . ' AND fn.user_id!=' . (int) $mtf->poster_id . '
AND (CASE WHEN (r.last_view IS NULL AND (u.last_read=0 OR u.last_read >= ' . $mtf->frm_last_post_date . ')) OR r.last_view > ' . $mtf->frm_last_post_date . ' THEN 1 ELSE 0 END)=1
AND ((CASE WHEN g2.id IS NOT NULL THEN g2.group_cache_opt ELSE g1.group_cache_opt END) & 2) > 0');
$notify_type = 'frm';
} else {
/* send new reply notifications to thread subscribers */
$c = uq('SELECT u.email, u.icq, u.users_opt, r.msg_id, u.id
FROM phpgw_fud_thread_notify tn
INNER JOIN phpgw_fud_users u ON tn.user_id=u.id
LEFT JOIN phpgw_fud_read r ON r.thread_id=tn.thread_id AND r.user_id=tn.user_id
INNER JOIN phpgw_fud_group_cache g1 ON g1.user_id=2147483647 AND g1.resource_id=' . $mtf->forum_id . '
LEFT JOIN phpgw_fud_group_cache g2 ON g2.user_id=tn.user_id AND g2.resource_id=' . $mtf->forum_id . '
WHERE
tn.thread_id=' . $mtf->thread_id . ' AND tn.user_id!=' . (int) $mtf->poster_id . '
AND (r.msg_id=' . $mtf->last_post_id . ' OR (r.msg_id IS NULL AND ' . $mtf->post_stamp . ' > u.last_read))
AND ((CASE WHEN g2.id IS NOT NULL THEN g2.group_cache_opt ELSE g1.group_cache_opt END) & 2) > 0');
$notify_type = 'thr';
}
while ($r = db_rowarr($c)) {
if ($r[2] & 16) {
$to['EMAIL'] = $r[0];
} else {
$to['ICQ'] = $r[1] . '@pager.icq.com';
}
if (isset($r[4]) && is_null($r[3])) {
$tl[] = $r[4];
}
}
unset($c);
if (isset($tl)) {
/* this allows us to mark the message we are sending notification about as read, so that we do not re-notify the user
* until this message is read.
*/
q('INSERT INTO phpgw_fud_read (thread_id, msg_id, last_view, user_id) SELECT ' . $mtf->thread_id . ', 0, 0, id FROM phpgw_fud_users WHERE id IN(' . implode(',', $tl) . ')');
}
if (isset($to)) {
send_notifications($to, $mtf->id, $mtf->subject, $mtf->alias, $notify_type, $notify_type == 'thr' ? $mtf->thread_id : $mtf->forum_id, $mtf->frm_name, $mtf->forum_id);
}
// Handle Mailing List and/or Newsgroup syncronization.
if (($mtf->nntp_id || $mtf->mlist_id) && !$mtf->mlist_msg_id) {
fud_use('email_msg_format.inc', true);
reverse_fmt($mtf->alias);
$from = $mtf->poster_id ? $mtf->alias . ' <' . $mtf->email . '>' : $GLOBALS['ANON_NICK'] . ' <' . $GLOBALS['NOTIFY_FROM'] . '>';
$body = $mtf->body . ($mtf->msg_opt & 1 && $mtf->sig ? "\n--\n" . $mtf->sig : '');
plain_text($body);
plain_text($subject);
if ($mtf->reply_to) {
$replyto_id = q_singleval('SELECT mlist_msg_id FROM phpgw_fud_msg WHERE id=' . $mtf->reply_to);
} else {
$replyto_id = 0;
}
if ($mtf->attach_cnt) {
$r = uq("SELECT a.id, a.original_name,\n\t\t\t\t\t\tCASE WHEN m.mime_hdr IS NULL THEN 'application/octet-stream' ELSE m.mime_hdr END\n\t\t\t\t\t\tFROM phpgw_fud_attach a\n\t\t\t\t\t\tLEFT JOIN phpgw_fud_mime m ON a.mime_type=m.id\n\t\t\t\t\t\tWHERE a.message_id=" . $mtf->id . " AND a.attach_opt=0");
while ($ent = db_rowarr($r)) {
$attach[$ent[1]] = file_get_contents($GLOBALS['FILE_STORE'] . $ent[0] . '.atch');
if ($mtf->mlist_id) {
$attach_mime[$ent[1]] = $ent[2];
}
}
} else {
$attach_mime = $attach = null;
}
if ($mtf->nntp_id) {
fud_use('nntp.inc', true);
$nntp_adm = db_sab('SELECT * FROM phpgw_fud_nntp WHERE id=' . $mtf->nntp_id);
$nntp = new fud_nntp();
$nntp->server = $nntp_adm->server;
$nntp->newsgroup = $nntp_adm->newsgroup;
$nntp->port = $nntp_adm->port;
$nntp->timeout = $nntp_adm->timeout;
$nntp->nntp_opt = $nntp_adm->nntp_opt;
$nntp->login = $nntp_adm->login;
$nntp->pass = $nntp_adm->pass;
define('sql_p', 'phpgw_fud_');
$lock = $nntp->get_lock();
$nntp->post_message($mtf->subject, $body, $from, $mtf->id, $replyto_id, $attach);
$nntp->close_connection();
$nntp->release_lock($lock);
} else {
fud_use('mlist_post.inc', true);
$GLOBALS['CHARSET'] = 'ISO-8859-15';
$r = db_saq('SELECT name, additional_headers FROM phpgw_fud_mlist WHERE id=' . $mtf->mlist_id);
mail_list_post($r[0], $from, $mtf->subject, $body, $mtf->id, $replyto_id, $attach, $attach_mime, $r[1]);
}
}
}
示例7: q
$c = q('SELECT poll_id FROM phpgw_fud_msg WHERE thread_id IN(' . $tl . ') AND apr=1 AND poll_id>0');
while ($r = db_rowarr($c)) {
$p[] = $r[0];
}
unset($c);
if (count($p)) {
q('UPDATE phpgw_fud_poll SET forum_id=' . $forum . ' WHERE id IN(' . implode(',', $p) . ')');
}
}
q("UPDATE phpgw_fud_msg SET thread_id={$new_th} WHERE thread_id IN({$tl})");
q("DELETE FROM phpgw_fud_thread WHERE id IN({$tl})");
rebuild_forum_view($forum);
if ($forum != $frm) {
rebuild_forum_view($frm);
foreach (array($frm, $forum) as $v) {
$r = db_saq("SELECT MAX(last_post_id), SUM(replies), COUNT(*) FROM phpgw_fud_thread INNER JOIN phpgw_fud_msg ON root_msg_id=phpgw_fud_msg.id AND phpgw_fud_msg.apr=1 WHERE forum_id={$v}");
if (empty($r[2])) {
$r = array(0, 0, 0);
}
q("UPDATE phpgw_fud_forum SET thread_count={$r[2]}, post_count={$r[1]}, last_post_id={$r[0]} WHERE id={$v}");
}
} else {
q("UPDATE phpgw_fud_forum SET thread_count=thread_count-" . (count($_POST['sel_th']) - 1) . " WHERE id={$frm}");
}
db_unlock();
logaction(_uid, 'THRMERGE', $new_th, count($_POST['sel_th']));
unset($_POST['sel_th']);
}
}
}
/* fetch a list of accesible forums */
示例8: rebuild_stats_cache
function rebuild_stats_cache($last_msg_id)
{
$tm_expire = __request_timestamp__ - $GLOBALS['LOGEDIN_TIMEOUT'] * 60;
list($obj->last_user_id, $obj->user_count) = db_saq('SELECT MAX(id), count(*)-1 FROM phpgw_fud_users');
$obj->online_users_anon = q_singleval('SELECT count(*) FROM phpgw_fud_ses s WHERE time_sec>' . $tm_expire . ' AND user_id>2000000000');
$obj->online_users_hidden = q_singleval('SELECT count(*) FROM phpgw_fud_ses s INNER JOIN phpgw_fud_users u ON u.id=s.user_id WHERE s.time_sec>' . $tm_expire . ' AND (u.users_opt & 32768) > 0');
$obj->online_users_reg = q_singleval('SELECT count(*) FROM phpgw_fud_ses s INNER JOIN phpgw_fud_users u ON u.id=s.user_id WHERE s.time_sec>' . $tm_expire . ' AND (u.users_opt & 32768)=0');
$c = uq('SELECT u.id, u.alias, u.users_opt, u.custom_color FROM phpgw_fud_ses s INNER JOIN phpgw_fud_users u ON u.id=s.user_id WHERE s.time_sec>' . $tm_expire . ' AND (u.users_opt & 32768)=0 ORDER BY s.time_sec DESC LIMIT ' . $GLOBALS['MAX_LOGGEDIN_USERS']);
while ($r = db_rowarr($c)) {
$obj->online_users_text[$r[0]] = draw_user_link($r[1], $r[2], $r[3]);
}
q('UPDATE phpgw_fud_stats_cache SET
cache_age=' . __request_timestamp__ . ',
last_user_id=' . (int) $obj->last_user_id . ',
user_count=' . (int) $obj->user_count . ',
online_users_anon=' . (int) $obj->online_users_anon . ',
online_users_hidden=' . (int) $obj->online_users_hidden . ',
online_users_reg=' . (int) $obj->online_users_reg . ',
online_users_text=' . strnull(addslashes(@serialize($obj->online_users_text))));
$obj->last_user_alias = q_singleval('SELECT alias FROM phpgw_fud_users WHERE id=' . $obj->last_user_id);
$obj->last_msg_subject = q_singleval('SELECT subject FROM phpgw_fud_msg WHERE id=' . $last_msg_id);
return $obj;
}
示例9: q
} else {
if (isset($_POST['btn_submit']) && $c_ext) {
q('INSERT INTO ' . $tbl . 'ext_block (ext) VALUES(\'' . addslashes($c_ext) . '\')');
} else {
if (isset($_GET['del'])) {
q('DELETE FROM ' . $tbl . 'ext_block WHERE id=' . (int) $_GET['del']);
} else {
$nada = 1;
}
}
}
if (!isset($nada) && db_affected()) {
ext_cache_rebuild();
}
if (isset($_GET['edit'])) {
list($edit, $c_ext) = db_saq('SELECT id, ext FROM ' . $tbl . 'ext_block WHERE id=' . (int) $_GET['edit']);
} else {
$edit = $c_ext = '';
}
include $WWW_ROOT_DISK . 'adm/admpanel.php';
?>
<h2>Allowed Extensions</h2>
<form method="post" action="admext.php">
<table class="datatable solidtable">
<tr class="tutor">
<td colspan=2><b>note:</b> if no file extension is entered, all files will be allowed</td>
</tr>
<tr class="field">
<td>Extension:</td>
<td><input type="text" name="c_ext" value="<?php
echo htmlspecialchars($c_ext);
示例10: fud_egw
* (at your option) any later version.
***************************************************************************/
require './GLOBALS.php';
fud_egw();
fud_use('adm.inc', true);
fud_use('widgets.inc', true);
if (isset($_POST['lev_submit'])) {
q("INSERT INTO " . $DBHOST_TBL_PREFIX . "level (name, img, level_opt, post_count) VALUES ('" . addslashes($_POST['lev_name']) . "', " . strnull(addslashes($_POST['lev_img'])) . ", " . (int) $_POST['lev_level_opt'] . ", " . (int) $_POST['lev_post_count'] . ")");
} else {
if (isset($_POST['edit'], $_POST['lev_update'])) {
q("UPDATE " . $DBHOST_TBL_PREFIX . "level SET name='" . addslashes($_POST['lev_name']) . "', img=" . strnull(addslashes($_POST['lev_img'])) . ", level_opt=" . (int) $_POST['lev_level_opt'] . ", post_count=" . (int) $_POST['lev_post_count'] . " WHERE id=" . (int) $_POST['edit']);
}
}
if (isset($_GET['edit'])) {
$edit = (int) $_GET['edit'];
list($lev_name, $lev_img, $lev_level_opt, $lev_post_count) = db_saq('SELECT name, img, level_opt, post_count FROM ' . $DBHOST_TBL_PREFIX . 'level WHERE id=' . (int) $_GET['edit']);
} else {
$edit = $lev_name = $lev_img = $lev_level_opt = $lev_post_count = '';
}
if (isset($_GET['del'])) {
q('DELETE FROM ' . $DBHOST_TBL_PREFIX . 'level WHERE id=' . (int) $_GET['del']);
}
if (isset($_GET['rebuild_levels'])) {
$pl = 2000000000;
$c = q('SELECT id, post_count FROM ' . $DBHOST_TBL_PREFIX . 'level ORDER BY post_count DESC');
while ($r = db_rowarr($c)) {
q('UPDATE ' . $DBHOST_TBL_PREFIX . 'users SET level_id=' . $r[0] . ' WHERE posted_msg_count<' . $pl . ' AND posted_msg_count>=' . $r[1]);
$pl = $r[1];
}
unset($c);
}
示例11: header
/* sanity check */
if (!$data->replies) {
header('Location: /egroupware/fudforum/3814588639/index.php?t=' . d_thread_view . '&th=' . $th_id . '&' . _rsidl);
exit;
}
apply_custom_replace($_POST['new_title']);
if ($mc != $data->replies + 1) {
/* check that we need to move the entire thread */
db_lock('phpgw_fud_thread_view WRITE, phpgw_fud_thread WRITE, phpgw_fud_forum WRITE, phpgw_fud_msg WRITE, phpgw_fud_poll WRITE');
$new_th = th_add($start, $forum, $data->new_th_lps, 0, 0, $mc - 1, $data->new_th_lpi);
/* Deal with the new thread */
q('UPDATE phpgw_fud_msg SET thread_id=' . $new_th . ' WHERE id IN (' . $mids . ')');
q('UPDATE phpgw_fud_msg SET reply_to=' . $start . ' WHERE thread_id=' . $new_th . ' AND reply_to NOT IN (' . $mids . ')');
q("UPDATE phpgw_fud_msg SET reply_to=0, subject='" . addslashes(htmlspecialchars($_POST['new_title'])) . "' WHERE id=" . $start);
/* Deal with the old thread */
list($lpi, $lpd) = db_saq("SELECT id, post_stamp FROM phpgw_fud_msg WHERE thread_id=" . $data->id . " AND apr=1 ORDER BY post_stamp DESC LIMIT 1");
$old_root_msg_id = q_singleval("SELECT id FROM phpgw_fud_msg WHERE thread_id=" . $data->id . " AND apr=1 ORDER BY post_stamp ASC LIMIT 1");
q("UPDATE phpgw_fud_msg SET reply_to=" . $old_root_msg_id . " WHERE thread_id=" . $data->id . " AND reply_to IN(" . $mids . ")");
q('UPDATE phpgw_fud_msg SET reply_to=0 WHERE id=' . $old_root_msg_id);
q('UPDATE phpgw_fud_thread SET root_msg_id=' . $old_root_msg_id . ', replies=replies-' . $mc . ', last_post_date=' . $lpd . ', last_post_id=' . $lpi . ' WHERE id=' . $data->id);
if ($forum != $data->forum_id) {
$c = q('SELECT poll_id FROM phpgw_fud_msg WHERE thread_id=' . $new_th . ' AND apr=1 AND poll_id>0');
while ($r = db_rowarr($c)) {
$p[] = $r[0];
}
unset($c);
if (isset($p)) {
q('UPDATE phpgw_fud_poll SET forum_id=' . $data->forum_id . ' WHERE id IN(' . implode(',', $p) . ')');
}
/* deal with the source forum */
if ($data->src_lpi != $data->last_post_id || $data->last_post_date <= $lpd) {
示例12: fud_egw
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
***************************************************************************/
@set_time_limit(6000);
require './GLOBALS.php';
fud_egw();
fud_use('adm.inc', true);
if (isset($_POST['tname'], $_POST['tlang'], $_POST['ret'])) {
header('Location: ' . $_POST['ret'] . '.php?tname=' . $_POST['tname'] . '&tlang=' . $_POST['tlang'] . '&' . _rsidl);
exit;
}
$ret = isset($_GET['ret']) ? $_GET['ret'] : 'tmpllist';
require $WWW_ROOT_DISK . 'adm/admpanel.php';
list($def_thm, $def_tmpl) = db_saq('SELECT name, lang FROM ' . $GLOBALS['DBHOST_TBL_PREFIX'] . 'themes WHERE theme_opt=3');
?>
<h3>Template Set Selection</h3>
<form method="post" action="admthemesel.php">
<input type="hidden" name="ret" value="<?php
echo $ret;
?>
">
<table class="datatable solidtable">
<tr class="field">
<?php
echo _hs;
$path = $GLOBALS['DATA_DIR'] . '/thm';
$dp = opendir($path);
echo '<td>Template Set:</td><td><select name="tname">';
while ($de = readdir($dp)) {
示例13: q
q('UPDATE ' . $tbl . 'thread SET root_msg_id=' . $root . ' WHERE id=' . $r[2]);
}
} else {
$r2 = db_saq('SELECT id, post_stamp FROM ' . $tbl . 'msg WHERE thread_id=' . $r[2] . ' ORDER BY post_stamp DESC LIMIT 1');
if (!$r2) {
q('DELETE FROM ' . $tbl . 'thread WHERE id=' . $r[2]);
} else {
q('UPDATE ' . $tbl . 'thread SET last_post_id=' . $r2[0] . ', last_post_date=' . $r2[1] . ' WHERE id=' . $r[2]);
}
}
}
draw_stat('Done: Checking thread last & first post ids');
draw_stat('Checking forum & topic relations');
$c = q('SELECT id FROM ' . $tbl . 'forum');
while ($f = db_rowarr($c)) {
$r = db_saq('select SUM(replies), COUNT(*) FROM ' . $tbl . 'thread t INNER JOIN ' . $tbl . 'msg m ON t.root_msg_id=m.id AND m.apr=1 WHERE t.forum_id=' . $f[0]);
if (!$r[1]) {
q('UPDATE ' . $tbl . 'forum SET thread_count=0, post_count=0, last_post_id=0 WHERE id=' . $f[0]);
} else {
$lpi = q_singleval('SELECT MAX(last_post_id) FROM ' . $tbl . 'thread WHERE forum_id=' . $f[0] . ' AND moved_to=0');
q('UPDATE ' . $tbl . 'forum SET thread_count=' . $r[1] . ', post_count=' . ($r[0] + $r[1]) . ', last_post_id=' . (int) $lpi . ' WHERE id=' . $f[0]);
}
}
unset($c);
draw_stat('Done: Checking forum & topic relations');
draw_stat('Validating Forum Order');
$cat = 0;
$c = q('SELECT id, cat_id, view_order FROM ' . $tbl . 'forum WHERE cat_id>0 ORDER BY cat_id, view_order');
while ($f = db_rowarr($c)) {
if ($cat != $f[1]) {
$i = 0;
示例14: fud_use
fud_use('widgets.inc', true);
$tbl = $GLOBALS['DBHOST_TBL_PREFIX'];
$smiley_dir = '../images/smiley_icons/';
if (isset($_GET['del'])) {
db_lock($tbl . 'smiley WRITE');
if ($im = q_singleval('SELECT img FROM ' . $tbl . 'smiley WHERE id=' . (int) $_GET['del'])) {
q('DELETE FROM ' . $tbl . 'smiley WHERE id=' . (int) $_GET['del']);
if (db_affected()) {
q('UPDATE ' . $tbl . 'smiley SET vieworder=vieworder-1 WHERE id>' . (int) $_GET['del']);
}
@unlink($GLOBALS['WWW_ROOT_DISK'] . 'images/smiley_icons/' . $im);
}
db_unlock();
}
if (isset($_GET['edit'])) {
list($sml_code, $sml_img, $sml_descr) = db_saq('SELECT code, img, descr FROM ' . $tbl . 'smiley WHERE id=' . (int) $_GET['edit']);
$edit = (int) $_GET['edit'];
} else {
$edit = $sml_code = $sml_img = $sml_descr = '';
}
if (isset($_FILES['icoul']) && $_FILES['icoul']['size'] && preg_match('!\\.(jpg|jpeg|gif|png)$!i', $_FILES['icoul']['name'])) {
move_uploaded_file($_FILES['icoul']['tmp_name'], $GLOBALS['WWW_ROOT_DISK'] . 'images/smiley_icons/' . $_FILES['icoul']['name']);
if (empty($_POST['avt_img'])) {
$_POST['avt_img'] = $_FILES['icoul']['name'];
}
$sml_img = $_FILES['icoul']['name'];
}
if (isset($_POST['btn_update'], $_POST['edit']) && !empty($_POST['sml_img']) && !empty($_POST['sml_code'])) {
q('UPDATE ' . $tbl . 'smiley SET code=' . strnull(addslashes($_POST['sml_code'])) . ', img=' . strnull(addslashes($_POST['sml_img'])) . ', descr=' . strnull(addslashes($_POST['sml_descr'])) . ' WHERE id=' . (int) $_POST['edit']);
} else {
if (isset($_POST['btn_submit']) && !empty($_POST['sml_img']) && !empty($_POST['sml_code'])) {
示例15: fud_egw
require './GLOBALS.php';
fud_egw();
fud_use('adm.inc', true);
fud_use('widgets.inc', true);
$tbl = $GLOBALS['DBHOST_TBL_PREFIX'];
if (isset($_GET['del'])) {
if ($im = q_singleval('SELECT img FROM ' . $tbl . 'avatar WHERE id=' . (int) $_GET['del'])) {
q('DELETE FROM ' . $tbl . 'avatar WHERE id=' . (int) $_GET['del']);
if (db_affected()) {
q('UPDATE ' . $tbl . 'users SET avatar_loc=NULL, avatar=0, users_opt=(users_opt & ~ (8388608|16777216)) | 4194304 WHERE avatar=' . (int) $_GET['del']);
}
@unlink($GLOBALS['WWW_ROOT_DISK'] . 'images/avatars/' . $im);
}
}
if (isset($_GET['edit'])) {
list($avt_img, $avt_descr) = db_saq('SELECT img, descr FROM ' . $tbl . 'avatar WHERE id=' . (int) $_GET['edit']);
$edit = (int) $_GET['edit'];
} else {
$edit = $avt_img = $avt_descr = '';
}
if (isset($_FILES['icoul']) && $_FILES['icoul']['size'] && preg_match('!\\.(jpg|jpeg|gif|png)$!i', $_FILES['icoul']['name'])) {
move_uploaded_file($_FILES['icoul']['tmp_name'], $GLOBALS['WWW_ROOT_DISK'] . 'images/avatars/' . $_FILES['icoul']['name']);
if (empty($_POST['avt_img'])) {
$_POST['avt_img'] = $_FILES['icoul']['name'];
}
}
if (isset($_POST['btn_update'], $_POST['edit']) && !empty($_POST['avt_img'])) {
$old_img = q_singleval('SELECT img FROM ' . $tbl . 'avatar WHERE id=' . (int) $_POST['edit']);
q('UPDATE ' . $tbl . 'avatar SET img=' . strnull(addslashes($_POST['avt_img'])) . ', descr=' . strnull(addslashes($_POST['avt_descr'])) . ' WHERE id=' . (int) $_POST['edit']);
if (db_affected() && $old_img != $_POST['avt_img']) {
$size = getimagesize($GLOBALS['WWW_ROOT_DISK'] . 'images/avatars/' . $_POST['avt_img']);