本文整理汇总了PHP中db_affected函数的典型用法代码示例。如果您正苦于以下问题:PHP db_affected函数的具体用法?PHP db_affected怎么用?PHP db_affected使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了db_affected函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: WT_GetProblem
function WT_GetProblem()
{
global $lid;
if (!WT_IPC_CheckLogin()) {
return;
}
if ($lid == '') {
return;
}
$q = db_select('tester_problems', array('*'), '(`uploaded`=FALSE) AND (`lid`=' . $lid . ')', 'ORDER BY `id` LIMIT 1');
if (db_affected() <= 0) {
return;
}
$r = db_row($q);
$s = unserialize($r['settings']);
$arr = array();
$arr['ID'] = $r['id'];
if (isset($s['filename'])) {
$arr['FILENAME'] = $s['filename'];
}
if (preg_match('/[0-9]+/', $s['checker'])) {
$arr['CHECKER'] = $s['checker'];
}
print db_pack($arr);
}
示例2: InitInstance
function InitInstance($id = -1, $virtual = false)
{
$this->id = $id;
$this->_virtual = $virtual;
$q = db_select('service', array('*'), "`id` = {$id}");
if (db_affected() <= 0) {
$this->id = 0;
} else {
$r = db_row($q);
$this->UnserializeSettings($r['settings']);
}
if (!$virtual) {
content_url_var_push_global('action');
content_url_var_push_global('id');
editor_add_function('Управление сервисом', 'Editor_RSSManage');
editor_add_function('Разделы', 'Editor_ContentManage');
}
if ($this->id > 0) {
// Id>0 so the service has been created
$url = content_url_get_full();
if (preg_match('/^' . prepare_pattern(config_get('document-root')) . '[(\\/)|(\\/index.php)]?(\\?(.*))?$/si', $url)) {
global $CORE;
$CORE->PAGE->SetRSS($this->settings['title'], config_get('http-document-root') . '/rss.php');
}
}
}
示例3: user_authorized
function user_authorized()
{
global $user_login, $user_password, $user_authorized;
if (isset($user_authorized)) {
return $user_authorized;
}
db_query('SELECT * FROM `user` WHERE (`authorized`=1) AND (`login`="' . $user_login . '") AND (`password`=MD5("' . addslashes(user_password_hash($user_login, $user_password)) . '"))');
$user_authorized = db_affected() == 1;
return $user_authorized;
}
示例4: rebuild_forum_view
function rebuild_forum_view($forum_id, $page = 0)
{
if (!db_locked()) {
$ll = 1;
db_lock('phpgw_fud_thread_view WRITE, phpgw_fud_thread WRITE, phpgw_fud_msg WRITE, phpgw_fud_forum WRITE');
}
$tm = __request_timestamp__;
/* Remove expired moved thread pointers */
q('DELETE FROM phpgw_fud_thread WHERE forum_id=' . $forum_id . ' AND last_post_date<' . ($tm - 86400 * $GLOBALS['MOVED_THR_PTR_EXPIRY']) . ' AND moved_to!=0');
if ($aff_rows = db_affected()) {
q('UPDATE phpgw_fud_forum SET thread_count=thread_count-' . $aff_rows . ' WHERE id=' . $forum_id);
$page = 0;
}
/* De-announce expired announcments and sticky messages */
$r = q("SELECT phpgw_fud_thread.id FROM phpgw_fud_thread INNER JOIN phpgw_fud_msg ON phpgw_fud_thread.root_msg_id=phpgw_fud_msg.id WHERE phpgw_fud_thread.forum_id=" . $forum_id . " AND thread_opt>=2 AND (phpgw_fud_msg.post_stamp+phpgw_fud_thread.orderexpiry)<=" . $tm);
while ($tid = db_rowarr($r)) {
q("UPDATE phpgw_fud_thread SET orderexpiry=0, thread_opt=thread_opt & ~ (2|4) WHERE id=" . $tid[0]);
}
unset($r);
if (__dbtype__ == 'pgsql') {
$tmp_tbl_name = "phpgw_fud_ftvt_" . get_random_value();
q("CREATE TEMP TABLE " . $tmp_tbl_name . " ( forum_id INT NOT NULL, page INT NOT NULL, thread_id INT NOT NULL, pos SERIAL, tmp INT )");
if ($page) {
q("DELETE FROM phpgw_fud_thread_view WHERE forum_id=" . $forum_id . " AND page<" . ($page + 1));
q("INSERT INTO " . $tmp_tbl_name . " (thread_id,forum_id,page,tmp) SELECT phpgw_fud_thread.id, phpgw_fud_thread.forum_id, 2147483647, CASE WHEN thread_opt>=2 AND (phpgw_fud_msg.post_stamp+phpgw_fud_thread.orderexpiry>" . $tm . " OR phpgw_fud_thread.orderexpiry=0) THEN 2147483647 ELSE phpgw_fud_thread.last_post_date END AS sort_order_fld FROM phpgw_fud_thread INNER JOIN phpgw_fud_msg ON phpgw_fud_thread.root_msg_id=phpgw_fud_msg.id WHERE forum_id=" . $forum_id . " AND phpgw_fud_msg.apr=1 ORDER BY sort_order_fld DESC, phpgw_fud_thread.last_post_id DESC LIMIT " . $GLOBALS['THREADS_PER_PAGE'] * $page);
} else {
q("DELETE FROM phpgw_fud_thread_view WHERE forum_id=" . $forum_id);
q("INSERT INTO " . $tmp_tbl_name . " (thread_id,forum_id,page,tmp) SELECT phpgw_fud_thread.id, phpgw_fud_thread.forum_id, 2147483647, CASE WHEN thread_opt>=2 AND (phpgw_fud_msg.post_stamp+phpgw_fud_thread.orderexpiry>" . $tm . " OR phpgw_fud_thread.orderexpiry=0) THEN 2147483647 ELSE phpgw_fud_thread.last_post_date END AS sort_order_fld FROM phpgw_fud_thread INNER JOIN phpgw_fud_msg ON phpgw_fud_thread.root_msg_id=phpgw_fud_msg.id WHERE forum_id=" . $forum_id . " AND phpgw_fud_msg.apr=1 ORDER BY sort_order_fld DESC, phpgw_fud_thread.last_post_id DESC");
}
q("INSERT INTO phpgw_fud_thread_view (thread_id,forum_id,page,pos) SELECT thread_id,forum_id,CEIL(pos/" . $GLOBALS['THREADS_PER_PAGE'] . ".0),(pos-(CEIL(pos/" . $GLOBALS['THREADS_PER_PAGE'] . ".0)-1)*" . $GLOBALS['THREADS_PER_PAGE'] . ") FROM " . $tmp_tbl_name);
q("DROP TABLE " . $tmp_tbl_name);
return;
} else {
if (__dbtype__ == 'mysql') {
if ($page) {
q('DELETE FROM phpgw_fud_thread_view WHERE forum_id=' . $forum_id . ' AND page<' . ($page + 1));
q("INSERT INTO phpgw_fud_thread_view (thread_id,forum_id,page,tmp) SELECT phpgw_fud_thread.id, phpgw_fud_thread.forum_id, 2147483645, CASE WHEN thread_opt>=2 AND (phpgw_fud_msg.post_stamp+phpgw_fud_thread.orderexpiry>" . $tm . " OR phpgw_fud_thread.orderexpiry=0) THEN 4294967294 ELSE phpgw_fud_thread.last_post_date END AS sort_order_fld FROM phpgw_fud_thread INNER JOIN phpgw_fud_msg ON phpgw_fud_thread.root_msg_id=phpgw_fud_msg.id WHERE forum_id=" . $forum_id . " AND phpgw_fud_msg.apr=1 ORDER BY sort_order_fld DESC, phpgw_fud_thread.last_post_id DESC LIMIT 0, " . $GLOBALS['THREADS_PER_PAGE'] * $page);
q('UPDATE phpgw_fud_thread_view SET page=CEILING(pos/' . $GLOBALS['THREADS_PER_PAGE'] . '), pos=pos-(CEILING(pos/' . $GLOBALS['THREADS_PER_PAGE'] . ')-1)*' . $GLOBALS['THREADS_PER_PAGE'] . ' WHERE forum_id=' . $forum_id . ' AND page=2147483645');
} else {
q('DELETE FROM phpgw_fud_thread_view WHERE forum_id=' . $forum_id);
q("INSERT INTO phpgw_fud_thread_view (thread_id,forum_id,page,tmp) SELECT phpgw_fud_thread.id, phpgw_fud_thread.forum_id, 2147483645, CASE WHEN thread_opt>=2 AND (phpgw_fud_msg.post_stamp+phpgw_fud_thread.orderexpiry>" . $tm . " OR phpgw_fud_thread.orderexpiry=0) THEN 4294967294 ELSE phpgw_fud_thread.last_post_date END AS sort_order_fld FROM phpgw_fud_thread INNER JOIN phpgw_fud_msg ON phpgw_fud_thread.root_msg_id=phpgw_fud_msg.id WHERE forum_id=" . $forum_id . " AND phpgw_fud_msg.apr=1 ORDER BY sort_order_fld DESC, phpgw_fud_thread.last_post_id DESC");
q('UPDATE phpgw_fud_thread_view SET page=CEILING(pos/' . $GLOBALS['THREADS_PER_PAGE'] . '), pos=pos-(CEILING(pos/' . $GLOBALS['THREADS_PER_PAGE'] . ')-1)*' . $GLOBALS['THREADS_PER_PAGE'] . ' WHERE forum_id=' . $forum_id);
}
}
}
if (isset($ll)) {
db_unlock();
}
}
示例5: Init
function Init($id)
{
if (($q = db_select('datatypes', array('*'), "`id`={$id}")) && db_affected() > 0) {
$this->id = $id;
} else {
$this->id = -1;
}
if ($this->id > 0) {
$r = db_row($q);
$this->name = $r['name'];
$this->UnserializeSettings($r['settings']);
$this->data = new $r['class']();
$this->data->Init();
$this->data->UnSerializeSettings($this->settings['data']);
}
}
示例6: Editor_DrawCurrentStructure
function Editor_DrawCurrentStructure()
{
$q = db_select($this->settings['content'], array('*'), '', 'ORDER BY `id`');
if (db_affected() <= 0) {
return;
}
formo('title=Текущая структура каталога');
$interior = 0;
$full = content_url_get_full();
while ($r = db_row($q)) {
$actions = stencil_ibtnav('edit.gif', $full . '&act=edit&pid=' . $r['id']);
$actions .= stencil_ibtnav('cross.gif', $full . '&act=delete&pid=' . $r['id'], 'Удалить', 'Удалить этот подкаталог и все вложенные?');
println('<div style="margin: 2px 0 2px ' . $interion * 24 . 'px;">' . '<table class="list" width="100%"><tr class="h"><th class="first">' . $r['name'] . '</th><th width="80" style="text-align: right;" ' . 'class="last">' . $actions . '</th></tr></table></div>');
$interion++;
}
formc();
}
示例7: user_register_forum_view
function user_register_forum_view($frm_id)
{
q('UPDATE phpgw_fud_forum_read SET last_view=' . __request_timestamp__ . ' WHERE forum_id=' . $frm_id . ' AND user_id=' . _uid);
if (!db_affected()) {
db_li('INSERT INTO phpgw_fud_forum_read (forum_id, user_id, last_view) VALUES (' . $frm_id . ', ' . _uid . ', ' . __request_timestamp__ . ')', $ef);
}
}
示例8: renameNode
function renameNode($node, $new_name)
{
if (!$this->isNodeAvaliable($node)) {
return false;
}
if (db_count('xpfs_volume_' . $node['vol'], '`name`="' . addslashes($new_name) . '" AND `id`!=' . $node['id']) > 0) {
return false;
}
db_update('xpfs_volume_' . $node['vol'], array('name' => '"' . addslashes($new_name) . '"'), '`id`=' . $node['id']);
if (db_affected() > 0) {
return true;
}
return false;
}
示例9: fetch_search_cache
function fetch_search_cache($qry, $start, $count, $logic, $srch_type, $order, $forum_limiter, &$total)
{
if (strncmp($GLOBALS['usr']->lang, 'chinese', 7)) {
$cs = array('!\\W!', '!\\s+!');
$cd = array(' ', ' ');
$qry = trim(preg_replace($cs, $cd, $qry));
$w = array_unique(explode(' ', strtolower($qry)));
$qr = '';
$i = 0;
foreach ($w as $v) {
$v = trim($v);
if (strlen($v) <= 2) {
continue;
} else {
if ($i++ == 10) {
/* limit query length to 10 words */
break;
}
}
$qr .= " '" . addslashes($v) . "',";
}
if (!$qr) {
return;
} else {
$qr = substr($qr, 0, -1);
}
} else {
/* handling for multibyte languages */
fud_use('isearch.inc');
if (!($w = mb_word_split($qry))) {
return;
}
$qr = implode(',', $w);
$i = count($w);
}
if ($srch_type == 'all') {
$tbl = 'index';
$qt = '0';
} else {
$tbl = 'title_index';
$qt = '1';
}
$qry_lck = md5($qr);
/* remove expired cache */
q('DELETE FROM phpgw_fud_search_cache WHERE expiry<' . (__request_timestamp__ - $GLOBALS['SEARCH_CACHE_EXPIRY']));
if (!($total = q_singleval("SELECT count(*) FROM phpgw_fud_search_cache WHERE query_type=" . $qt . " AND srch_query='" . $qry_lck . "'"))) {
if (__dbtype__ == 'mysql') {
q("INSERT IGNORE INTO phpgw_fud_search_cache (srch_query, query_type, expiry, msg_id, n_match) SELECT '" . $qry_lck . "', " . $qt . ", " . __request_timestamp__ . ", msg_id, count(*) as word_count FROM phpgw_fud_search s INNER JOIN phpgw_fud_" . $tbl . " i ON i.word_id=s.id WHERE word IN(" . $qr . ") GROUP BY msg_id ORDER BY word_count DESC LIMIT 500");
if (!($total = (int) db_affected())) {
return;
}
} else {
q("BEGIN; DELETE FROM phpgw_fud_search_cache; INSERT INTO phpgw_fud_search_cache (srch_query, query_type, expiry, msg_id, n_match) SELECT '" . $qry_lck . "', " . $qt . ", " . __request_timestamp__ . ", msg_id, count(*) as word_count FROM phpgw_fud_search s INNER JOIN phpgw_fud_" . $tbl . " i ON i.word_id=s.id WHERE word IN(" . $qr . ") GROUP BY msg_id ORDER BY word_count DESC LIMIT 500; COMMIT;");
}
}
if ($forum_limiter) {
if ($forum_limiter[0] != 'c') {
$qry_lmt = ' AND f.id=' . (int) $forum_limiter . ' ';
} else {
$qry_lmt = ' AND c.id=' . (int) substr($forum_limiter, 1) . ' ';
}
} else {
$qry_lmt = '';
}
$qry_lck = "'" . $qry_lck . "'";
$total = q_singleval('SELECT count(*)
FROM phpgw_fud_search_cache sc
INNER JOIN phpgw_fud_msg m ON m.id=sc.msg_id
INNER JOIN phpgw_fud_thread t ON m.thread_id=t.id
INNER JOIN phpgw_fud_forum f ON t.forum_id=f.id
INNER JOIN phpgw_fud_cat c ON f.cat_id=c.id
INNER JOIN phpgw_fud_group_cache g1 ON g1.user_id=' . (_uid ? '2147483647' : '0') . ' AND g1.resource_id=f.id
LEFT JOIN phpgw_fud_mod mm ON mm.forum_id=f.id AND mm.user_id=' . _uid . '
LEFT JOIN phpgw_fud_group_cache g2 ON g2.user_id=' . _uid . ' AND g2.resource_id=f.id
WHERE
sc.query_type=' . $qt . ' AND sc.srch_query=' . $qry_lck . $qry_lmt . '
' . ($logic == 'AND' ? ' AND sc.n_match>=' . $i : '') . '
' . ($GLOBALS['usr']->users_opt & 1048576 ? '' : ' AND (mm.id IS NOT NULL OR ((CASE WHEN g2.id IS NOT NULL THEN g2.group_cache_opt ELSE g1.group_cache_opt END) & 262146) >= 262146)'));
if (!$total) {
return;
}
return uq('SELECT u.alias, f.name AS forum_name, f.id AS forum_id,
m.poster_id, m.id, m.thread_id, m.subject, m.poster_id, m.foff, m.length, m.post_stamp, m.file_id, m.icon
FROM phpgw_fud_search_cache sc
INNER JOIN phpgw_fud_msg m ON m.id=sc.msg_id
INNER JOIN phpgw_fud_thread t ON m.thread_id=t.id
INNER JOIN phpgw_fud_forum f ON t.forum_id=f.id
INNER JOIN phpgw_fud_cat c ON f.cat_id=c.id
INNER JOIN phpgw_fud_group_cache g1 ON g1.user_id=' . (_uid ? '2147483647' : '0') . ' AND g1.resource_id=f.id
LEFT JOIN phpgw_fud_users u ON m.poster_id=u.id
LEFT JOIN phpgw_fud_mod mm ON mm.forum_id=f.id AND mm.user_id=' . _uid . '
LEFT JOIN phpgw_fud_group_cache g2 ON g2.user_id=' . _uid . ' AND g2.resource_id=f.id
WHERE
sc.query_type=' . $qt . ' AND sc.srch_query=' . $qry_lck . $qry_lmt . '
' . ($logic == 'AND' ? ' AND sc.n_match>=' . $i : '') . '
' . ($GLOBALS['usr']->users_opt & 1048576 ? '' : ' AND (mm.id IS NOT NULL OR ((CASE WHEN g2.id IS NOT NULL THEN g2.group_cache_opt ELSE g1.group_cache_opt END) & 262146) >= 262146)') . '
ORDER BY sc.n_match DESC, m.post_stamp ' . $order . ' LIMIT ' . qry_limit($count, $start));
}
示例10: grp_rebuild_cache
if ($gr_ramasks) {
grp_rebuild_cache(array(0, 2147483647));
}
}
} else {
if (($frm = q_singleval('SELECT forum_id FROM ' . $DBHOST_TBL_PREFIX . 'groups WHERE id=' . $edit)) !== null) {
/* update an existing group */
if (!$res) {
$old = db_sab("SELECT groups_opt, groups_opti FROM " . $DBHOST_TBL_PREFIX . "groups WHERE id=" . $edit);
} else {
$old =& $res[$edit];
}
group_sync($edit, isset($_POST['gr_name']) ? $_POST['gr_name'] : null, $gr_inherit_id, $perm, $permi);
if (!$frm) {
q('DELETE FROM ' . $DBHOST_TBL_PREFIX . 'group_resources WHERE group_id=' . $edit);
$aff = db_affected();
if ($gr_resource) {
foreach ($gr_resource as $v) {
q('INSERT INTO ' . $DBHOST_TBL_PREFIX . 'group_resources (resource_id, group_id) VALUES(' . (int) $v . ', ' . $edit . ')');
}
}
}
/* only rebuild caches if the permissions or number of resources had changed. */
if ($perm != $old->groups_opt || $permi != $old->groups_opti || $aff != count($gr_resource)) {
rebuild_group_ih($edit, $perm ^ $old->groups_opt, $perm);
grp_rebuild_cache();
}
}
}
}
/* restore form values */
示例11: manage_datatype_received_create
global $DOCUMENT_ROOT, $CORE, $action, $id;
include $DOCUMENT_ROOT . '/admin/inc/menu.php';
include '../menu.php';
$CORE->AddScriptFile('man_dtypes.js');
$manage_menu->SetActive('to-developer');
$mandev_menu->SetActive('datatype');
if ($action == 'create') {
manage_datatype_received_create();
}
// Printing da page
print $manage_menu->InnerHTML();
print $mandev_menu->InnerHTML();
print '${information}';
// Print created datatypes
if ($action == 'edit') {
include 'edit.php';
} else {
if ($action == 'save') {
manage_datatype_update_received($id);
} else {
if ($action == 'delete') {
manage_datatype_delete($id);
}
}
$q = db_query('SELECT * FROM `datatypes` ORDER BY `name`');
if (db_affected() > 0) {
include 'list.php';
}
// Print the create form
include 'create_form.php';
}
示例12: Editor_LogView
function Editor_LogView()
{
global $CORE;
$CORE->AddStyle('log');
formo('title=Просмотр журналов');
global $count, $display;
if ($count != 512 && $count != 1024 && $count != -1) {
$count = 256;
}
$clause = '';
if ($display == 'error') {
$clause = '`status`="ERROR"';
}
if ($display == 'warning') {
$clause = '`status`="WARNING"';
}
if ($display == 'message') {
$clause = '`status`<>"WARNING" AND `status`<>"ERROR"';
}
$q = db_select('log', array('*'), $clause, 'ORDER BY `timestamp` DESC ' . ($count > 0) ? 'LIMIT ' . $count : '');
?>
<script language="JavaScript" type="text/javascript">
function update () {
var prefix = '<?php
echo content_url_get_full();
?>
';
var count = getElementById ('count').value;
var display = getElementById ('display').value;
nav (prefix + '&count=' + count + '&display = '+display);
}
</script>
<table width="100%"><tr>
<td width="196">
Количество записей: <select id="count">
<option value="256"<?php
echo $count == 256 ? ' selected' : '';
?>
>256</option>
<option value="512"<?php
echo $count == 512 ? ' selected' : '';
?>
>512</option>
<option value="1024"<?php
echo $count == 1024 ? ' selected' : '';
?>
>1024</option>
<option value="-1"<?php
echo $count == -1 ? ' selected' : '';
?>
>Все</option>
</select>
</td>
<td width="208">
Отображать: <select id="display">
<option value="all"<?php
echo $display == 'all' ? ' selected' : '';
?>
>Все сообщения</option>
<option value="warning"<?php
echo $display == 'warning' ? ' selected' : '';
?>
>Предупреждения</option>
<option value="error"<?php
echo $display == 'error' ? ' selected' : '';
?>
>Ошибки</option>
<option value="message"<?php
echo $display == 'message' ? ' selected' : '';
?>
>Сообщения</option>
</select>
</td>
<td align="right">
<button class="submitBtn" onclick="update ();">Обновить</button>
</td>
</tr></table><div id="hr"></div>
<?php
if (db_affected() > 0) {
println('<div class="scroll" style="height: 320px; margin-top: 4px;" id="log">');
while ($r = db_row($q)) {
$class = "msg";
if ($r['status'] == 'ERROR') {
$class = 'err';
}
if ($r['status'] == 'WARNING') {
$class = 'warning';
}
$status = 'Сообщение';
if ($r['status'] == 'ERROR') {
$status = 'Ошибка';
}
if ($r['status'] == 'WARNING') {
$status = 'Предупреждение';
}
println('<div class="' . $class . '"><table><tr><td class="time">' . format_ltime($r['timestamp']) . '</td><td class="module">' . $r['module'] . '</td><td class="status">' . $status . '</td><td class="msg">' . $r['message'] . '</td></tr></table></div>');
}
//.........这里部分代码省略.........
示例13: Editor_DrawHistory
function Editor_DrawHistory()
{
global $action, $id;
$del = $this->GetAllowed('DELETE');
$edit = $this->GetAllowed('EDIT');
if ($action == 'delete') {
redirector_add_skipvar('id');
if ($del) {
$this->DeleteContentById($id);
}
} else {
if ($action == 'rollback') {
redirector_add_skipvar('action', 'rollback');
redirector_add_skipvar('id');
if ($edit) {
$this->Rollback($id);
}
}
}
$q = db_select($this->settings['content'], array('*'), '', 'ORDER BY `timestamp` DESC');
if (db_affected() > 0) {
println('<ul id="history">');
$i = 0;
while ($r = db_row($q)) {
$time = format_ltime($r['timestamp']);
$time = '<a href=".?oldid=' . $r['id'] . '">' . $time . '</a>';
$user = user_generate_info_string($r['user_id']);
$actions = '';
if ($edit) {
$actions .= '[<a href=".?wiki=history&action=rollback&id=' . $r['id'] . '">Вернуться к этой версии</a>]';
}
if ($del) {
$actions .= stencil_ibtnav('minus_s.gif', content_url_get_full() . '&action=delete&id=' . $r['id'], 'Удалить', 'Удалить эту версию статьи?');
}
if ($actions != '') {
$actions = ' | ' . $actions;
}
if ($i < 2) {
println(' <li><div class="top">' . $time . ' | ' . $user . ' ' . $actions . '</div></li>');
} else {
println(' <li><div>' . $time . ' | ' . $user . ' ' . $actions . '</div></li>');
}
$i++;
}
println('</ul>');
} else {
println('<span class="contentSub2">' . '<i>Журнал изменений пуст</i></span>');
}
}
示例14: list
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']);
$new_loc = '<img src="' . $GLOBALS['WWW_ROOT'] . 'images/avatars/' . $_POST['avt_img'] . '" ' . $size[3] . ' />';
q('UPDATE ' . $tbl . 'users SET avatar_loc=\'' . $new_loc . '\' WHERE avatar=' . (int) $_POST['edit']);
}
} else {
if (isset($_POST['btn_submit']) && !empty($_POST['avt_img'])) {
q('INSERT INTO ' . $tbl . 'avatar (img, descr) VALUES (' . strnull(addslashes($_POST['avt_img'])) . ', ' . strnull(addslashes($_POST['avt_descr'])) . ')');
}
}
require $WWW_ROOT_DISK . 'adm/admpanel.php';
?>
<h2>Avatar Management System</h2>
<form name="frm_avt" method="post" action="admavatar.php" enctype="multipart/form-data">
<?php
示例15: db_func
function db_func($table, $func, $par, $clause = '')
{
$sql = "SELECT {$func}({$par}) AS `alias` FROM `{$table}`" . (trim($clause) == '' ? '' : " WHERE {$clause}");
$q = db_query($sql);
if (db_affected() <= 0) {
return '';
}
$r = db_row($q);
return $r['alias'];
}