Example #1
0
 public static function DemLuotTruyCap()
 {
     $query = "SELECT count(1) FROM online";
     $r = Query($query);
     $row = mysql_fetch_array($r);
     return $row[0];
 }
function update($sem)
{
    foreach (glob("./{$sem}/*.csv") as $filename) {
        $dept = substr($filename, 0, -4);
        if ($sem == "fall") {
            $dept = substr($dept, 7);
        } else {
            if ($sem == "winter") {
                $dept = substr($dept, 9);
            }
        }
        echo $dept . "\n";
        if (($handle = fopen($filename, "r")) !== FALSE) {
            Query("DROP TABLE IF EXISTS {$dept}");
            Query("CREATE TABLE IF NOT EXISTS {$dept} (NAME text, SECTION text, \n\t\t\t\tDAY text, START time, FINISH time, LOCATION text)");
            while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) {
                $q = "INSERT INTO {$dept} VALUES (";
                foreach ($data as $key => $value) {
                    $q .= "'{$value}',";
                }
                $q = substr($q, 0, -1);
                $q .= ")";
                Query($q);
            }
            fclose($handle);
        }
    }
}
Example #3
0
function getWikiPage($id, $rev = 0)
{
    global $canedit, $canmod;
    $ptitle = $id;
    if (!$ptitle) {
        $ptitle = 'Main_page';
    } else {
        $ptitle = title2url($ptitle);
    }
    // so that we don't have for example 'Main page' and 'Main_page' being considered different pages
    if ($rev < 0) {
        $rev = 0;
    }
    $page = Query("SELECT p.*, pt.date, pt.user, pt.text FROM {wiki_pages} p LEFT JOIN {wiki_pages_text} pt ON pt.id=p.id AND pt.revision=" . ($rev > 0 ? 'LEAST(p.revision,{1})' : 'p.revision') . " WHERE p.id={0}", $ptitle, $rev);
    if (!NumRows($page)) {
        $page = array('id' => $ptitle, 'revision' => 0, 'flags' => 0, 'text' => '', 'new' => 1);
        header('HTTP/1.1 404 Not Found');
        header('Status: 404 Not Fount');
    } else {
        $page = Fetch($page);
    }
    $page['istalk'] = strtolower(substr($ptitle, 0, 5)) == 'talk:';
    $page['ismain'] = strtolower($ptitle) == 'main_page';
    $page['canedit'] = $canedit && (!($page['flags'] & WIKI_PFLAG_SPECIAL) || HasPermission('wiki.makepagesspecial'));
    return $page;
}
Example #4
0
function printResult()
{
    $results = Query();
    foreach ($results as $row) {
        printMonster($row);
    }
}
Example #5
0
function updatePerson($personid, $name)
{
    if ($personid) {
        return Query("UPDATE `persons` SET `name`= '" . $name . "' WHERE (`personid`= " . $personid . ")", debug_backtrace());
    } else {
        return NULL;
    }
}
Example #6
0
function insert_relationtype($reltype)
{
    $reltypeid = 0;
    if (NULL == ($reltypeid = exists_relationtype($reltype))) {
        $reltypeid = Query("INSERT INTO `reltypes` (`reltype`) VALUES ('" . $reltype . "')", debug_backtrace());
    }
    return $reltypeid;
}
Example #7
0
function get_relationtypes($userid = 0)
{
    if ($userid) {
        return Query("SELECT DISTINCT reltypes.reltype\n\t\tFROM relations AS UsersToPersons,persons,relations AS PersonsToPersons,relations_reltype,reltypes\n\t\tWHERE\n\t\tUsersToPersons.table1 = 'users'\n\t\tAND UsersToPersons.table2 = 'persons'\n\t\tAND UsersToPersons.id1 = " . $userid . "\n\t\tAND UsersToPersons.id2 = persons.personid\n\t\tAND PersonsToPersons.table1 = 'persons'\n\t\tAND PersonsToPersons.table2 = 'persons'\n\t\tAND PersonsToPersons.id1 = persons.personid\n\t\tAND relations_reltype.relationid = PersonsToPersons.relationid\n\t\tAND reltypes.reltypeid = relations_reltype.reltypeid", debug_backtrace());
    } else {
        return 0;
    }
}
Example #8
0
 function FetchResult($query, $row = 0, $field = 0)
 {
     $res = Query($query);
     if (mysql_numrows($res) == 0) {
         return -1;
     }
     return mysql_result($res, $row, $field);
 }
Example #9
0
function get_phonetypes($userid = 0)
{
    if ($userid) {
        return Query("SELECT DISTINCT phones.phonetype\n\t\tFROM relations AS RELUSERS,phones,relations AS RELPHONES\n\t\tWHERE RELUSERS.id1 = " . $userid . " AND\n\t\t(RELUSERS.table1 LIKE '%users%' AND\n\t\tRELUSERS.table2 LIKE '%persons%' OR\n\t\tRELUSERS.table1 LIKE '%users%' AND\n\t\tRELUSERS.table2 LIKE '%companies%' OR\n\t\tRELUSERS.table1 LIKE '%users%' AND\n\t\tRELUSERS.table2 LIKE '%schools%') AND\n\t\tRELPHONES.table2 = 'phones' AND\n\t\tphones.phoneid = RELPHONES.id2 AND\n\t\tRELPHONES.table1 = RELUSERS.table2 AND\n\t\tRELPHONES.id1 = RELUSERS.id2\n\t\tORDER BY phones.phoneid DESC", debug_backtrace());
    } else {
        return 0;
    }
}
Example #10
0
function member($id)
{
    if ($id > 0) {
        $sql = "select * from ly_users where id='{$id}'";
        $query = Query($sql);
        $row = GetRow($query);
        return $row;
    }
}
Example #11
0
function insert_log($userid = 0, $REMOTE_ADDR, $REMOTE_PORT, $HTTP_USER_AGENT, $REQUEST_URI)
{
    if ($userid) {
        Query("INSERT INTO logs(userid,REMOTE_ADDR,REMOTE_PORT,HTTP_USER_AGENT,REQUEST_URI) VALUES(" . $userid . ",'" . $REMOTE_ADDR . "','" . $REMOTE_PORT . "','" . $HTTP_USER_AGENT . "','" . $REQUEST_URI . "')", debug_backtrace());
        return 1;
    } else {
        return NULL;
    }
}
Example #12
0
function get_person_count($userid = 0)
{
    if ($userid) {
        $Result = Query("SELECT COUNT(*) AS count\n\t\tFROM persons\n\t\tWHERE userid = " . $userid . "", debug_backtrace());
        return (int) $Result[0]['count'];
    } else {
        return NULL;
    }
}
Example #13
0
function insert_alias($alias)
{
    $alias = $alias;
    $aliasid = 0;
    if (NULL == ($aliasid = exists_alias($alias))) {
        $aliasid = Query("INSERT INTO `aliases` (`alias`) VALUES ( '" . $alias . "' )", debug_backtrace());
    }
    return $aliasid;
}
Example #14
0
 public function __construct($page = 1, $limit = 10)
 {
     $this->db = Query(array('type' => 'sqlite', 'host' => '', 'user' => '', 'pass' => '', 'port' => '', 'database' => '', 'file' => 'db/sample.db', 'prefix' => '', 'alias' => 'default'));
     $this->ret = array('status' => 'success', 'msg' => '', 'data' => '');
     $this->tbl = 'sales';
     $this->data = false;
     $this->setData = array();
     return $this;
 }
Example #15
0
function loadSmiliesOrdered()
{
    global $smiliesOrdered;
    $rSmilies = Query("select * from {smilies}");
    $smilies = array();
    while ($smiley = Fetch($rSmilies)) {
        $smiliesOrdered[] = $smiley;
    }
}
Example #16
0
 public static function XoaTatCaTheoDanhMucCon($iddmcon)
 {
     $query = "DELETE FROM binhluan join tailieu on binhluan.TaiLieu = tailieu.ID WHERE tailieu.DanhMucCon = {$iddmcon}";
     $r = Query($query);
     if (mysql_affected_rows() > 0) {
         return 1;
     } else {
         return 0;
     }
 }
Example #17
0
function deletePerson($personid)
{
    $response = NULL;
    if ($personid) {
        $response = Query("DELETE FROM `persons` WHERE (`personid`= " . $personid . ")", debug_backtrace());
    } else {
        return NULL;
    }
    return errorChecking($response);
}
function updateDichVu()
{
    $strSQL = "update dichvu set status= '-1' where  ADDDATE(ngaydang, INTERVAL thoihantin MONTH)<CURDATE()";
    Query($strSQL);
    if (mysql_affected_rows() == 0) {
        $result = false;
    } else {
        $result = true;
    }
    return $result;
}
Example #19
0
function check($post_data)
{
    $link = mysqli_connect(HOST, USER, PASS, DATABASE);
    mysqli_select_db($link, DATABASE);
    $result = Query($post_data[POST_CLIENT], $post_data[POST_SERIAL], $link);
    if ($result > 0) {
        return true;
    } else {
        return false;
    }
}
Example #20
0
function MakeOptions($catid)
{
    $sel[$catid] = " selected=\"true\"";
    $qFora = "select id,name from categories";
    $rFora = Query($qFora);
    $result = "<select name=\"category\" size=\"1\">";
    while ($forum = Fetch($rFora)) {
        $result .= "<option value=\"" . $forum['id'] . "\"" . $sel[$forum['id']] . "\\>" . $forum['name'] . "</option>";
    }
    $result .= "</select>";
    return $result;
}
Example #21
0
function loadBlockLayouts()
{
    global $blocklayouts, $loguserid;
    if (isset($blocklayouts)) {
        return;
    }
    $rBlocks = Query("select * from {blockedlayouts} where blockee = {0}", $loguserid);
    $blocklayouts = array();
    while ($block = Fetch($rBlocks)) {
        $blocklayouts[$block['user']] = 1;
    }
}
Example #22
0
 function HandleUsernameColor($field, $item)
 {
     global $user, $canhavenamecolor;
     if ($canhavenamecolor) {
         $unc = $_POST['color'];
         if ($unc != '') {
             $unc = filterPollColors(str_pad($unc, 6, '0'));
         }
         Query("UPDATE {users} SET color={0s} WHERE id={1}", $unc, $user['id']);
     }
     return true;
 }
Example #23
0
function insert_phone($phone, $type = 0, $userid = 0)
{
    if ($userid) {
        if ($phone) {
            if (NULL == ($phoneid = exists_phone_for_user($phone, $userid))) {
                return Query("INSERT INTO `phones` (`phone`,`type`) \n\t\t\t\tVALUES ('" . $phone . "','" . $type . "')", debug_backtrace());
            }
        }
    } else {
        return 0;
    }
}
Example #24
0
function ircForumPrefix($forum)
{
    global $forumBoards;
    $prefix = '';
    if ($forum['board'] != '') {
        $prefix = $forumBoards[$forum['board']] . ' > ';
    }
    $parents = Query("SELECT title FROM {forums} WHERE l<{0} AND r>{1} ORDER BY l", $forum['l'], $forum['r']);
    while ($p = Fetch($parents)) {
        $prefix .= $p['title'] . ' > ';
    }
    return $prefix;
}
Example #25
0
function loadSmilies()
{
    global $smilies, $smiliesReplaceOrig, $smiliesReplaceNew;
    $rSmilies = Query("select * from {smilies} order by length(code) desc");
    $smilies = array();
    while ($smiley = Fetch($rSmilies)) {
        $smilies[] = $smiley;
    }
    $smiliesReplaceOrig = $smiliesReplaceNew = array();
    for ($i = 0; $i < count($smilies); $i++) {
        $smiliesReplaceOrig[] = "/(?<!\\w)" . preg_quote($smilies[$i]['code'], "/") . "(?!\\w)/";
        $smiliesReplaceNew[] = "<img class=\"smiley\" alt=\"\" src=\"" . resourceLink("img/smilies/" . $smilies[$i]['image']) . "\" />";
    }
}
function fixcoldata($table, $field, $key)
{
    echo "fixing data in {$table}.{$field}...";
    $data = Query("SELECT {$field},{$key} FROM {" . $table . "}");
    while ($row = Fetch($data)) {
        // data was UTF8 stored as latin1
        // then latin1->UTF8
        // resulting in double UTF8 encoding
        // to fix, convert back to latin1
        $blarg = $row[$field];
        $blarg = utf8_decode($blarg);
        Query("UPDATE {" . $table . "} SET {$field}={0} WHERE {$key}={1}", $blarg, $row[$key]);
    }
    echo " ok<br>";
}
Example #27
0
function get_option($var_name, $user_id = 0)
{
    $response = NULL;
    if ($user_id) {
        //Επιστροφή ρυθμίσεων που αφορούν έναν συγκεκριμένο χρήστη.
        $response = Query("SELECT option_value \n\t\tFROM settings\n\t\tWHERE option_name = '{$var_name}' AND userid = '{$user_id}'", debug_backtrace());
    } else {
        //Επιστροφή γενικών ρυθμίσεων που αφορούν όλους τους χρήστες..
    }
    if (errorChecking($response) != NULL) {
        return $response[0]['option_value'];
    } else {
        return NULL;
    }
}
function bbcodeForum($contents, $arg, $parenttag)
{
    global $forumLinkCache, $loguser;
    $id = (int) $arg;
    if (!isset($forumLinkCache[$id])) {
        $rForum = Query("select id, title from {forums} where id={0} AND id IN ({1c})", $id, ForumsWithPermission('forum.viewforum'));
        if (NumRows($rForum)) {
            $forum = Fetch($rForum);
            $forumLinkCache[$id] = actionLinkTag($forum['title'], "forum", $forum['id'], '', HasPermission('forum.viewforum', $forum['id'], true) ? $forum['title'] : '');
        } else {
            $forumLinkCache[$id] = "&lt;invalid forum ID&gt;";
        }
    }
    return $forumLinkCache[$id];
}
Example #29
0
function CanUpload($sid)
{
    $userQuery = Query("SELECT * FROM users WHERE steamid='{$sid}';");
    $trackCount = Query("SELECT COUNT(*) FROM tracks WHERE steamid='{$sid}';");
    $trackRes = mysqli_fetch_array($trackCount);
    $userRes = mysqli_fetch_assoc($userQuery);
    $amountHas = intval($trackRes[0]);
    $amountAllowed = intval($userRes["authorizedfor"]);
    if ($amountAllowed == -1) {
        return true;
    }
    if ($amountHas < $amountAllowed) {
        return true;
    } else {
        return false;
    }
}
Example #30
0
function CanMod($userid, $fid)
{
    global $loguser;
    // Private messages. You cannot moderate them
    if (!$fid) {
        return false;
    }
    if ($loguser['powerlevel'] > 1) {
        return true;
    }
    if ($loguser['powerlevel'] == 1) {
        $rMods = Query("select * from {forummods} where forum={0} and user={1}", $fid, $userid);
        if (NumRows($rMods)) {
            return true;
        }
    }
    return false;
}