Example #1
0
 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);
 }
Example #2
0
 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');
         }
     }
 }
Example #3
0
 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;
 }
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();
    }
}
Example #5
0
 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']);
     }
 }
Example #6
0
 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();
 }
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);
    }
}
Example #8
0
 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;
 }
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));
}
             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 */
Example #11
0
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';
}
Example #12
0
        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">
              Количество записей:&nbsp;&nbsp;<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">
              Отображать:&nbsp;&nbsp;<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>');
                }
                println('</div>');
            } else {
                println('<center><i>Файл журнала пуст</i></center>');
            }
            formc();
        }
Example #13
0
 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>');
     }
 }
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 
Example #15
0
 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'];
 }
Example #16
0
 function Solution_DrawInformation($solution_id)
 {
     global $redirect;
     $allow = $this->GetAllowed('SOLUTIONS.MANAGE') || $this->IsContestJudge();
     $r = db_row_value('tester_solutions', "`id`={$solution_id}");
     if (db_affected() <= 0) {
         return;
     }
     $r['parameters'] = unserialize($r['parameters']);
     $detail = false;
     if (!$allow) {
         if ($r['user_id'] != user_id()) {
             return;
         }
         $c = WT_contest_by_id($r['contest_id']);
         if ($c['settings']['viewdetail']) {
             $detail = true;
         }
     } else {
         $detail = true;
     }
     $this->CPrintLn(stencil_formo('title=Информация о попытке;'));
     $this->InsertTemplate('solution.info', array('lib' => $this, 'data' => $r, 'backlink' => $redirect, 'detail' => $detail));
     $this->CPrintLn(stencil_formc());
 }
Example #17
0
 * Gate - Wiki engine and web-interface for WebTester Server
 *
 * Script for displaying list of datatypes
 *
 * Copyright (c) 2008-2009 Sergey I. Sharybin <*****@*****.**>
 *
 * This program can be distributed under the terms of the GNU GPL.
 * See the file COPYING.
 */
if ($PHP_SELF != '') {
    print 'HACKERS?';
    die;
}
formo('title=Список существующих типов данных;');
$i = 1;
$n = db_affected();
?>
  <table class="list smb">
    <tr class="h"><th class="n first">№</th><th width="40%">Название</th><th>Базовый класс</th><th width="48" class="last">&nbsp;</th></tr>
<?php 
while ($r = db_row($q)) {
    $class = manage_datatype_get_by_name($r['class']);
    $d = $r['refcount'] == 0;
    ?>
    <tr<?php 
    echo $i < $n ? '' : ' class="last"';
    ?>
><td class="n"><?php 
    echo $i;
    ?>
.</td><td><a href=".?action=edit&id=<?php 
Example #18
0
 function Test_Obtained($contest_id = -1, $user_id = -1)
 {
     global $WT_TESTING_Cache;
     if ($contest_id < 0) {
         $contest_id = $_SESSION['WT_contest_id'];
     }
     if ($user_id < 0) {
         $user_id = user_id();
     }
     if (isset($WT_TESTING_Cache['Test.Obtained'][$contest_id][$user_id])) {
         return $WT_TESTING_Cache['Test.Obtained'][$contest_id][$user_id];
     }
     $res = false;
     if (!isset($WT_TESTING_Cache['Test.Obtained.Data'][$contest_id][$user_id])) {
         $r = db_row_value('tester_solutions', "(`contest_id`={$contest_id}) AND " . "(`user_id`={$user_id})", 'ORDER BY `id` DESC LIMIT 1');
         $r['parameters'] = unserialize($r['parameters']);
     } else {
         $r = $WT_TESTING_Cache['Test.Obtained.Data'][$contest_id][$user_id];
     }
     if (!$this->Test_CheckTimers($r)) {
         $WT_TESTING_Cache['Test.Obtained.Data'][$contest_id][$user_id]['parameters']['interrupted'] = 1;
         return false;
     }
     $s = $r['parameters'];
     if (db_affected() > 0 && !$s['finished'] && !$s['interrupted']) {
         $res = true;
     }
     $WT_TESTING_Cache['Test.Obtained'][$contest_id][$user_id] = $res;
     $WT_TESTING_Cache['Test.Obtained.Data'][$contest_id][$user_id] = $r;
     return $res;
 }
        }
        break;
}
$search_error = $login_error = '';
if ($usr_id) {
    /* deal with custom tags */
    if (!empty($_POST['c_tag'])) {
        q('INSERT INTO ' . $DBHOST_TBL_PREFIX . 'custom_tags (name, user_id) VALUES(' . strnull(addslashes($_POST['c_tag'])) . ', ' . $usr_id . ')');
    } else {
        if (!empty($_GET['deltag'])) {
            q('DELETE FROM ' . $DBHOST_TBL_PREFIX . 'custom_tags WHERE id=' . (int) $_GET['deltag']);
        } else {
            $nada = 1;
        }
    }
    if (!isset($nada) && db_affected()) {
        ctag_rebuild_cache($usr_id);
    }
} else {
    if (!empty($_POST['usr_email']) || !empty($_POST['usr_login'])) {
        /* user searching logic */
        $item = !empty($_POST['usr_email']) ? $_POST['usr_email'] : $_POST['usr_login'];
        $field = !empty($_POST['usr_email']) ? 'email' : ($FUD_OPT_2 & 128 ? 'alias' : 'login');
        if (strpos($item, '*') !== false) {
            $like = 1;
            $item = str_replace('*', '%', $item);
            $item_s = str_replace('\\', '\\\\', $item);
            if ($FUD_OPT_2 & 128) {
                $item_s = htmlspecialchars($item_s);
            }
        } else {
Example #20
0
 function DeletePublication($id, $update = false)
 {
     if (!$this->GetAllowed('DELETEINFO')) {
         return;
     }
     $r = db_row(db_select($this->settings['content'], array('*'), '`id`=' . $id));
     if (db_affected() <= 1 && !$this->GetAllowed('DELETE')) {
         return;
     }
     $this->dataset->SetFieldValues($r);
     $this->dataset->FreeContent();
     db_delete($this->settings['content'], '`id`=' . $id);
     if ($update) {
         $this->ReceiveContent();
     }
 }
        $c = uq('SELECT id, name, count FROM phpgw_fud_poll_opt WHERE poll_id=' . $poll_id);
        while ($r = db_rowarr($c)) {
            $data[$r[0]] = array($r[1], $r[2]);
        }
        if (!$data) {
            $data = null;
        }
    } else {
        /* register single vote */
        $data[$poll_id][1] += 1;
    }
}
if (isset($_GET['del']) && ($del = (int) $_GET['del'])) {
    if ($usr->users_opt & 1048576 || q_singleval('SELECT mr.id FROM phpgw_fud_msg_report mr INNER JOIN phpgw_fud_msg m ON m.id=mr.msg_id INNER JOIN phpgw_fud_thread t ON t.id=m.thread_id INNER JOIN phpgw_fud_mod mm ON mm.forum_id=t.forum_id AND mm.user_id=' . _uid . ' WHERE mr.id=' . $del)) {
        q('DELETE FROM phpgw_fud_msg_report WHERE id=' . $del);
        if (db_affected()) {
            logaction(_uid, 'DELREPORT');
        }
    } else {
        std_error('access');
    }
}
$r = $query_type('SELECT
			m.*,
			t.thread_opt, t.root_msg_id, t.last_post_id, t.forum_id,
			f.message_threshold, f.name AS frm_name,
			u.id AS user_id, u.alias AS login, u.avatar_loc, u.email, u.posted_msg_count, u.join_date, u.location,
			u.sig, u.custom_status, u.icq, u.jabber, u.affero, u.aim, u.msnm, u.yahoo, u.users_opt, u.last_visit AS time_sec,
			l.name AS level_name, l.level_opt, l.img AS level_img,
			p.max_votes, p.expiry_date, p.creation_date, p.name AS poll_name, p.total_votes,
			mr.id AS report_id, mr.stamp AS report_stamp, mr.reason AS report_reason,
Example #22
0
 function opt_set($ident, $v)
 {
     $q = db_query('SELECT `id`, `ident`, `class` FROM `settings` ' . 'WHERE `ident`="' . $ident . '"');
     if (db_affected() <= 0) {
         return false;
     }
     $r = db_row($q);
     $t = new $r['class']();
     $t->Init($r['ident']);
     $t->SetValue($v);
     db_update('settings', array('settings' => '"' . addslashes($t->SerializeSettings()) . '"'), '`id`=' . $r['id']);
     return true;
 }