Ejemplo n.º 1
1
function popular($skin_dir = 'basic', $pop_cnt = 7, $date_cnt = 3)
{
    global $config, $g5;
    if (!$skin_dir) {
        $skin_dir = 'basic';
    }
    $date_gap = date("Y-m-d", G5_SERVER_TIME - $date_cnt * 86400);
    $sql = " select pp_word, count(*) as cnt from {$g5['popular_table']} where pp_date between '{$date_gap}' and '" . G5_TIME_YMD . "' group by pp_word order by cnt desc, pp_word limit 0, {$pop_cnt} ";
    $result = sql_query($sql);
    for ($i = 0; $row = sql_fetch_array($result); $i++) {
        $list[$i] = $row;
        // 스크립트등의 실행금지
        $list[$i]['pp_word'] = get_text($list[$i]['pp_word']);
    }
    ob_start();
    if (G5_IS_MOBILE) {
        $popular_skin_path = G5_MOBILE_PATH . '/' . G5_SKIN_DIR . '/popular/' . $skin_dir;
        $popular_skin_url = G5_MOBILE_URL . '/' . G5_SKIN_DIR . '/popular/' . $skin_dir;
    } else {
        $popular_skin_path = G5_SKIN_PATH . '/popular/' . $skin_dir;
        $popular_skin_url = G5_SKIN_URL . '/popular/' . $skin_dir;
    }
    include_once $popular_skin_path . '/popular.skin.php';
    $content = ob_get_contents();
    ob_end_clean();
    return $content;
}
Ejemplo n.º 2
0
function sql_fetch($sql, $error = G5_DISPLAY_SQL_ERROR)
{
    $result = sql_query($sql, $error);
    //$row = @sql_fetch_array($result) or die("<p>$sql<p>" . mysql_errno() . " : " .  mysql_error() . "<p>error file : $_SERVER['SCRIPT_NAME']");
    $row = sql_fetch_array($result);
    return $row;
}
Ejemplo n.º 3
0
function latest($skin_dir = "", $bo_table, $rows = 10, $subject_len = 40, $options = "")
{
    global $g4;
    if ($skin_dir) {
        $GLOBALS['latest_skin_path'] = $latest_skin_path = "{$g4['path']}/skin/latest/{$skin_dir}";
    } else {
        $GLOBALS['latest_skin_path'] = $latest_skin_path = "{$g4['path']}/skin/latest/basic";
    }
    $list = array();
    $sql = " select * from {$g4['board_table']} where bo_table = '{$bo_table}'";
    $board = sql_fetch($sql);
    $tmp_write_table = $g4['write_prefix'] . $bo_table;
    // 게시판 테이블 전체이름
    $sql = " select * from {$tmp_write_table} where wr_is_comment = 0 order by wr_num limit 0, {$rows} ";
    //explain($sql);
    $result = sql_query($sql);
    for ($i = 0; $row = sql_fetch_array($result); $i++) {
        $list[$i] = get_list($row, $board, $latest_skin_path, $subject_len);
    }
    ob_start();
    include "{$latest_skin_path}/latest.skin.php";
    $content = ob_get_contents();
    ob_end_clean();
    return $content;
}
Ejemplo n.º 4
0
function checksuspended()
{
    testremote();
    $db_a = tDataConnect();
    $m_conn = mDataConnect();
    $query_local = "select * from suspendedtoday";
    $query_remote = "select * from " . trim($_SESSION["mServer"]) . "." . trim($_SESSION["mDatabase"]) . ".dbo.suspendedtoday";
    $query = "select * from suspendedlist";
    if ($_SESSION["standalone"] == 1) {
        if ($_SESSION["remoteDBMS"] == "mssql") {
            $result = mssql_query($query_local, $db_a);
        } else {
            $result = mysql_query($query, $db_a);
        }
    } else {
        if ($_SESSION["remoteDBMS"] == "mssql") {
            $result = sql_query($query_remote, $db_a);
        } else {
            $result = mysql_query($query, $m_conn);
        }
    }
    $num_rows = sql_fetch_array($result);
    if ($num_rows == 0) {
        return 0;
    } else {
        return 1;
    }
    sql_close($db_a);
}
Ejemplo n.º 5
0
 public static function getFromCache($cacheid)
 {
     $rs = sql("SELECT latitude, longitude FROM caches WHERE cache_id = &1", $cacheid);
     $r = sql_fetch_array($rs);
     mysql_free_result($rs);
     return new Coordinate_Coordinate($r['latitude'], $r['longitude']);
 }
Ejemplo n.º 6
0
function object_list()
{
    global $dbi;
    $eventsResult = sql_query('SELECT id, version, typactive, typdesc, ttypeliga.mgroup_id FROM ttypeliga LEFT JOIN tmessagegroup ON ttypeliga.mgroup_id = tmessagegroup.mgroup_id', $dbi);
    # Table header
    $ret = '<table id="eventtable"><tr>';
    $ret = $ret . '<td class="thead">Id</td>';
    $ret = $ret . '<td class="thead">Version</td>';
    $ret = $ret . '<td class="thead">Active</td>';
    $ret = $ret . '<td class="thead">Description</td>';
    $ret = $ret . '<td class="thead">Message group id</td>';
    $ret = $ret . '<td class="thead">Edit</td>';
    $ret = $ret . '<td class="thead">Delete</td>';
    while (list($id, $version, $typactive, $typdesc, $mgroup_id) = sql_fetch_row($eventsResult, $dbi)) {
        $ret = $ret . '<tr>';
        $ret = $ret . '<td>' . $id . '</td>';
        $ret = $ret . '<td>' . $version . '</td>';
        $ret = $ret . '<td>' . ($typactive == 1 ? 'Ja' : 'Nein') . '</td>';
        $ret = $ret . '<td>' . $typdesc . '</td>';
        $mgroup_result = sql_query('SELECT mgroupname FROM tmessagegroup WHERE mgroup_id = ' . $mgroup_id, $dbi);
        $mgroup_name = sql_fetch_array($mgroup_result, $dbi);
        $ret = $ret . '<td>' . $mgroup_name[0] . '</td>';
        $ret = $ret . '<td><img src="images/edit24.png" style="cursor: pointer;" onclick="window.location.href = \'admin_liga_types.php?op=edit&id=' . $id . '\'" /></td>';
        $ret = $ret . '<td align="center"><img src="images/del_icon.png" style="cursor: pointer;" onclick="window.location.href = \'admin_liga_types.php?op=delete&id=' . $id . '\'" /></td>';
        $ret = $ret . '</tr>';
    }
    return $ret . '</table>';
}
Ejemplo n.º 7
0
function listposts(){
	global $db;
	$locality=GETSTR('locality');
	if(!$locality){echo json_encode(array("success"=>"false"));}
	$query="select * from artworks where locality='$locality' order by likes desc";
	$rs=sql_query($query, $db);
	if(!$rs){echo json_encode(array("success:false"));die();}
	$data=array();
	while($myrow=sql_fetch_array($rs)){
		array_push($data, array(
			"artworkid"=>$myrow['artworkid']+0,
			"createdate"=>$myrow['createdate']+0,
			"userid"=>$myrow['userid'],
			"price"=>$myrow['price']+0,
			"likes"=>$myrow['likes']+0,
			"geolat"=>$myrow['geolat']+0,
			"geolong"=>$myrow['geolong']+0,
			"image"=>$myrow['image'],
			"onsale"=>$myrow['onsale']+0,
			"title"=>$myrow['title'],
			"locality"=>$myrow['locality']
		));
	}
	$stats=array("itemcount"=>sql_affected_rows($db,$rs));
	$response=array("data"=>$data, "stats"=>$stats);
	echo json_encode($response);
}
 function t($message, $style, $resource_name, $line, $plural = '', $count = 1, $lang = null)
 {
     global $opt, $locale;
     // $locale is for lib1 compatibility
     if ($message == '') {
         return '';
     }
     if ($plural != '' && $count != 1) {
         $message = $plural;
     }
     $search = $this->prepare_text($message);
     $loc = isset($opt['template']['locale']) ? $opt['template']['locale'] : $locale;
     if (!$lang || $lang == $loc) {
         $trans = gettext($search);
     } else {
         // do not use sql_value(), as this is also used from lib1
         $rs = sql("SELECT IFNULL(`sys_trans_text`.`text`, '&3')\n\t\t\t             FROM `sys_trans` \n\t\t\t        LEFT JOIN `sys_trans_text` ON `sys_trans`.`id`=`sys_trans_text`.`trans_id` AND `sys_trans_text`.`lang`='&1'\n\t\t\t\t\t\t\t\t\tWHERE `sys_trans`.`text`='&2' LIMIT 1", $lang, $search, $message);
         if ($r = sql_fetch_array($rs)) {
             $trans = $r[0];
         } else {
             $trans = '';
         }
         sql_free_result($rs);
     }
     // safe w/o mb because asc(%) < 128
     if (strpos($trans, "%") >= 0) {
         $trans = $this->v($trans);
     }
     return $trans;
 }
Ejemplo n.º 9
0
 public function getCacheNote($userid, $cacheid)
 {
     $rs = sql("SELECT id, latitude, longitude, description FROM coordinates WHERE user_id = &1 AND cache_id = &2 AND type = &3", $userid, $cacheid, Coordinate_Type::UserNote);
     $ret = $this->recordToArray(sql_fetch_array($rs));
     mysql_free_result($rs);
     return $ret;
 }
Ejemplo n.º 10
0
function CheckThrottle()
{
    global $opt, $tpl;
    $ip_string = $_SERVER['REMOTE_ADDR'];
    $ip_blocks = mb_split('\\.', $ip_string);
    $ip_numeric = $ip_blocks[3] + $ip_blocks[2] * 256 + $ip_blocks[1] * 65536 + $ip_blocks[0] * 16777216;
    sql('CREATE TABLE IF NOT EXISTS &tmpdb.`sys_accesslog`
        (`id` INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY, `ip` INT UNSIGNED NOT NULL,
         `access_time` TIMESTAMP NOT NULL, INDEX (`access_time`), INDEX (`ip`)) ENGINE = MEMORY');
    $rsStaus = sql("SHOW STATUS LIKE 'Threads_connected'");
    $rStatus = sql_fetch_array($rsStaus);
    sql_free_result($rsStaus);
    if ($rStatus) {
        if ($rStatus[1] > $opt['db']['throttle_connection_count']) {
            $access_count = sql_value("SELECT COUNT(*) FROM &tmpdb.`sys_accesslog` WHERE ip ='&1'", 0, $ip_numeric);
            if ($access_count > $opt['db']['throttle_access_count']) {
                $tpl->error(ERROR_THROOTLE);
            }
        }
    }
    // remove old entries every 100st call
    if (mt_rand(0, 100) == 50) {
        sql("DELETE FROM &tmpdb.`sys_accesslog` WHERE `access_time`<CURRENT_TIMESTAMP()-'&2'", $ip_numeric, $opt['db']['throttle_access_time']);
    }
    sql("INSERT INTO &tmpdb.`sys_accesslog` (`ip`, `access_time`) VALUES ('&1', CURRENT_TIMESTAMP())", $ip_numeric);
}
Ejemplo n.º 11
0
function suspendorder()
{
    testremote();
    $query_a = "select emp_no, trans_no from localtemptrans";
    $db_a = tDataConnect();
    $result_a = sql_query($query_a, $db_a);
    $row_a = sql_fetch_array($result_a);
    $cashier_no = substr("000" . $row_a["emp_no"], -2);
    $trans_no = substr("0000" . $row_a["trans_no"], -4);
    if ($_SESSION["standalone"] == 0) {
        if ($_SESSION["remoteDBMS"] == "mssql") {
            $query = "insert " . trim($_SESSION["mServer"]) . "." . trim($_SESSION["mDatabase"]) . ".dbo.suspended select * from localtemptrans";
            $result = sql_query($query, $db_a);
        } else {
            $query = "insert suspended select * from localtemptrans";
            $result = sql_query($query, $db_a);
            if (uploadtable("suspended") == 1) {
                cleartemptrans();
            }
        }
    } else {
        $query = "insert suspended select * from localtemptrans";
        $result = sql_query($query, $db_a);
    }
    $_SESSION["plainmsg"] = "transaction suspended";
    $_SESSION["msg"] = 2;
    receipt("suspended");
    $recall_line = $_SESSION["standalone"] . " " . $_SESSION["laneno"] . " " . $cashier_no . " " . $trans_no;
    gohome();
    sql_close($db_a);
}
Ejemplo n.º 12
0
function check_user_level($user_id)
{
    if (!$user_id) {
        throw new UnexpectedValueException();
    }
    $r = sql_fetch_array(sql_query("SELECT user_rating10, user_level, user_shown_level FROM users WHERE user_id={$user_id} LIMIT 1"));
    $next_level = $r['user_level'];
    if (!$next_level) {
        throw new Exception();
    }
    $last_shown_level = $r['user_shown_level'];
    if ($next_level > $last_shown_level) {
        return $next_level;
    }
    while (true) {
        $points_for_next_level = get_rating4level($next_level);
        if (floor($r['user_rating10'] / 10) >= $points_for_next_level) {
            $next_level++;
            continue;
        }
        break;
    }
    $next_level--;
    if ($next_level == $r['user_level']) {
        return 0;
    }
    return $next_level;
}
Ejemplo n.º 13
0
/**
*
* 연혁 출력
*
* @param string $his_id
* @param string $skin_dir
* @return string $content
*/
function history($his_id, $skin_dir = '', $group = null)
{
    global $g5;
    $sql = "select * from `{$g5['history_master_table']}` where his_id = '{$his_id}'";
    $history = sql_fetch($sql);
    if (!$skin_dir) {
        $skin_dir = $history['his_skin'];
    }
    $history_skin_path = get_skin_path('history', $skin_dir);
    $history_skin_url = get_skin_url('history', $skin_dir);
    $sortable = "order by his_item_year " . $history['his_sort'] . ', his_item_month ' . $history['his_sort'] . ', his_item_day ' . $history['his_sort'];
    $histories = array();
    $group_histories = array();
    for ($i = $history['his_start_year'], $y = $history['his_end_year']; $i <= $history['his_end_year'], $y >= $history['his_start_year']; $i++, $y--) {
        $history_item = array();
        $conditions = array("his_item_disable = ''", "his_id = '{$his_id}'");
        if (!is_null($group)) {
            $conditions['group'] = "his_group_id = '{$group}'";
        }
        if ($history['his_sort'] == 'asc') {
            $item_year = $i;
        } else {
            $item_year = $y;
        }
        $conditions[] = "his_item_year = '{$item_year}'";
        $condition = count($conditions) > 0 ? 'where ' . implode(' and ', $conditions) : '';
        $sql = "select * from `{$g5['history_item_table']}` {$condition} {$sortable}";
        $result = sql_query($sql);
        while ($item = sql_fetch_array($result)) {
            switch ($history['his_output_type']) {
                case 'a':
                    $item['date'] = $item['his_item_year'] . '.' . $item['his_item_month'] . '.' . $item['his_item_day'];
                    break;
                case 'y':
                    $item['date'] = '';
                    break;
                case 'm':
                    $item['date'] = $item['his_item_month'];
                    break;
                case 'd':
                    $item['date'] = $item['his_item_month'] . '.' . $item['his_item_day'];
                    break;
                case 'i':
                    $item['date'] = $item['his_item_date'];
                    break;
            }
            $history_item[] = $item;
            $all_history_item[] = $item;
        }
        $histories[$item_year] = $history_item;
    }
    $histories = array_filter($histories);
    ob_start();
    include $history_skin_path . '/history.skin.php';
    $content = ob_get_contents();
    ob_end_clean();
    return $content;
}
Ejemplo n.º 14
0
function get_npas($cache_id)
{
    $rsNPA = sql("SELECT `npa_areas`.`name` AS `npaName`, `npa_types`.`name` AS `npaTypeName`\n\t             FROM `cache_npa_areas`\n\t       INNER JOIN `npa_areas` ON `cache_npa_areas`.`npa_id`=`npa_areas`.`id`\n\t       INNER JOIN `npa_types` ON `npa_areas`.`type_id`=`npa_types`.`id`\n\t            WHERE `cache_npa_areas`.`cache_id`='&1'\n\t         GROUP BY `npa_areas`.`type_id`, `npa_areas`.`name`\n\t         ORDER BY `npa_types`.`ordinal` ASC", $cache_id);
    $npas = array();
    while ($rNPA = sql_fetch_array($rsNPA)) {
        $npas[] = $rNPA;
    }
    sql_free_result($rsNPA);
    return $npas;
}
Ejemplo n.º 15
0
 public function getChildWps($cacheid)
 {
     $rs = sql("SELECT id, cache_id, subtype, latitude, longitude, description FROM coordinates WHERE cache_id = &1 AND type = &2", $cacheid, Coordinate_Type::ChildWaypoint);
     $ret = array();
     while ($r = sql_fetch_array($rs)) {
         $ret[] = $this->recordToArray($r);
     }
     mysql_free_result($rs);
     return $ret;
 }
Ejemplo n.º 16
0
function eb_banner($loccd)
{
    global $g5, $theme, $eb, $member;
    $link_path = G5_DATA_URL . '/banner/';
    if (!$member['mb_level']) {
        $member['mb_level'] = 1;
    }
    // 배너위치로 등록된 배너 불러오기
    $sql = "select * from {$g5['eyoom_banner']} where bn_view_level <= '{$member['mb_level']}' and bn_theme='{$theme}' and bn_location = '" . $loccd . "' and bn_state = '1' order by bn_regdt desc";
    $result = sql_query($sql, false);
    $this_date = date('Ymd');
    for ($i = 0; $row = sql_fetch_array($result); $i++) {
        if ($row['bn_period'] == '2') {
            if ($this_date >= $row['bn_start'] && $this_date <= $row['bn_end']) {
                $banner[$i][$row['bn_no']] = $row;
            } else {
                continue;
            }
        } else {
            $banner[$i][$row['bn_no']] = $row;
        }
    }
    $max_num = count($banner) - 1;
    mt_srand((double) microtime() * 1000000);
    $num = mt_rand(0, $max_num);
    $bn = $banner[$num];
    $bn_no = key($bn);
    $data = $banner[$num][$bn_no];
    unset($banner);
    if ($data) {
        if ($data['bn_type'] == 'intra') {
            $img = $data['bn_img'];
            $data['image'] = $link_path . $theme . '/' . $img;
            if ($data['bn_link'] == '') {
                $data['bn_link'] = 'nolink';
            }
            $data['tag_img'] = '<img class="img-responsive full-width" src="' . $data['image'] . '" align="absmiddle">';
            if ($data['bn_link'] != '' && $data['bn_link'] != 'nolink') {
                $tocken = $eb->encrypt_md5($bn_no . "||" . $_SERVER['REMOTE_ADDR'] . "||" . $data['bn_link']);
                $data['html'] = '<a id="banner_' . $data['bn_no'] . '" href="' . G5_BBS_URL . '/banner.php?tocken=' . $tocken . '" target="' . $data['bn_target'] . '">';
                $data['html'] .= $data['tag_img'];
                $data['html'] .= '</a>';
            } else {
                $data['html'] = $data['tag_img'];
            }
        } else {
            if ($data['bn_type'] == 'extra') {
                $data['html'] = stripslashes($data['bn_code']);
            }
        }
        $banner[] = $data;
    }
    sql_query("update {$g5['eyoom_banner']} set bn_exposed = bn_exposed + 1 where bn_no = '{$bn_no}'");
    return $banner;
}
Ejemplo n.º 17
0
function search_output()
{
    global $sqldebug;
    /*
        cacheid
        name
        latitude
        longitude
        type
        size
        difficulty
        terrain
        username
        waypoint
    */
    $sql = '
		SELECT
			&searchtmp.`cache_id` `cacheid`,
			&searchtmp.`longitude`,
			&searchtmp.`latitude`,
			`caches`.`name`,
			`caches`.`wp_oc`,
			`caches`.`terrain`,
			`caches`.`difficulty`,
			`cache_type`.`short` `typedesc`,
			`cache_size`.`name` `sizedesc`,
			`user`.`username`
		FROM
			&searchtmp,
			`caches`,
			`cache_type`,
			`cache_size`,
			`user`
		WHERE
			&searchtmp.`cache_id`=`caches`.`cache_id` AND
			&searchtmp.`type`=`cache_type`.`id` AND
			&searchtmp.`size`=`cache_size`.`id` AND
			&searchtmp.`user_id`=`user`.`user_id`';
    $rs = sql_slave($sql, $sqldebug);
    while ($r = sql_fetch_array($rs)) {
        $lat = sprintf('%07d', $r['latitude'] * 100000);
        $lon = sprintf('%07d', $r['longitude'] * 100000);
        $name = convert_string($r['name']);
        $username = convert_string($r['username']);
        $type = convert_string($r['typedesc']);
        $size = convert_string($r['sizedesc']);
        $difficulty = sprintf('%01.1f', $r['difficulty'] / 2);
        $terrain = sprintf('%01.1f', $r['terrain'] / 2);
        $cacheid = convert_string($r['wp_oc']);
        $line = "{$name} by {$username}, {$type}, {$size}, {$cacheid}";
        $record = pack("CLllA*x", 2, 1 + 4 + 4 + 4 + strlen($line) + 1, (int) $lon, (int) $lat, $line);
        append_output($record);
    }
    mysql_free_result($rs);
}
Ejemplo n.º 18
0
 function run()
 {
     $rsPublish = sql("SELECT `cache_id`, `user_id` FROM `caches` WHERE `status`=5 AND NOT ISNULL(`date_activate`) AND `date_activate`<=NOW()");
     while ($rPublish = sql_fetch_array($rsPublish)) {
         $userid = $rPublish['user_id'];
         $cacheid = $rPublish['cache_id'];
         // update cache status to active
         sql("UPDATE `caches` SET `status`=1, `date_activate`=NULL WHERE `cache_id`='&1'", $cacheid);
     }
     sql_free_result($rsPublish);
 }
Ejemplo n.º 19
0
/**
*	purpose:	NEW request speichern - status creation, sowie erzeugen der dummyobj childtabellen
* 	params:		vid,request formular
*	returns:	unique req_id
* 	rem:		we pass the vid from the form, enabling the Admin to change it
*/
function _saverequest($req_type, $v_id)
{
    global $dbi, $usertoken;
    if (!$req_type > 0) {
        debug('Error :: Request Type not set ...');
        return;
    }
    if (!$v_id > 0) {
        debug('Error :: Verein not set ...');
        return;
    }
    $rkey = 'r' . time();
    $d = getdate();
    $rtdate = $d['year'] . '-' . $d['mon'] . '-' . $d['mday'];
    if (is_array($usertoken)) {
        $uid = $usertoken['id'];
    } else {
        die('E1');
    }
    /*
     * create request with STATUS=CREATE, using the param: v_id instead of the usertoken ...
     */
    $qry = 'insert into wfrequest(wfrequest_id,reqdate,user_id,verein_id,wfrequesttype_id,wfstate_id,rkey)' . ' values(0,\'' . $rtdate . '\',' . $usertoken['id'] . ',' . $v_id . ',' . $req_type . ',1,\'' . $rkey . '\')';
    #debug($qry);
    $prec = sql_query($qry, $dbi);
    # get ID
    $p = sql_query('select R.*,T.wftablename wfobject from wfrequest R,wfrequesttype T where R.wfrequesttype_id=T.wfrequesttype_id and rkey=\'' . $rkey . '\'', $dbi);
    $ret = sql_fetch_array($p, $dbi);
    if (sizeof($ret) < 2) {
        die('<h3>Error creating initial request object</h3>');
    }
    // create child records ...
    switch ($ret['wfobject']) {
        case 'wflineup':
            $qry = 'INSERT INTO wflineup(wflineup_id,wfrequest_id,rkey) VALUES (0,' . $ret['wfrequest_id'] . ',\'' . $rkey . '\')';
            $p = sql_query($qry, $dbi);
            break;
        case 'wfplayer':
            $qry = 'INSERT INTO wfplayer(wfplayer_id,wfrequest_id,rkey) VALUES (0,' . $ret['wfrequest_id'] . ',\'' . $rkey . '\')';
            $p = sql_query($qry, $dbi);
            break;
        case 'wfteam':
            // create empty wfteam
            $qry = 'INSERT INTO wfteam(wfteam_id,wfrequest_id,rkey) VALUES (0,' . $ret['wfrequest_id'] . ',\'' . $rkey . '\')';
            $p = sql_query($qry, $dbi);
            break;
        case 'wfmessage':
            // create empty wfmessage
            $qry = 'INSERT INTO wfmessage(wfmessage_id,wfrequest_id,rkey) VALUES (0,' . $ret['wfrequest_id'] . ',\'' . $rkey . '\')';
            $p = sql_query($qry, $dbi);
            break;
    }
    return $ret['wfrequest_id'];
}
Ejemplo n.º 20
0
 public function outputFeed()
 {
     header('Content-type: application/rss+xml; charset="utf-8"');
     $content = $this->getRssHeader();
     $rs = $this->feed_data->getItems();
     while ($r = sql_fetch_array($rs)) {
         $content .= $this->getItemLine($r);
     }
     mysql_free_result($rs);
     $content .= "\n  </channel>\n</rss>";
     echo $content;
 }
Ejemplo n.º 21
0
function auth_UsernameFromID($userid)
{
    //select the right user
    $rs = sql("SELECT `username` FROM `user` WHERE `user_id`='&1'", $userid);
    if (mysql_num_rows($rs) > 0) {
        $record = sql_fetch_array($rs);
        return $record['username'];
    } else {
        //user not exists
        return false;
    }
}
Ejemplo n.º 22
0
function couponcode($upc)
{
    $man_id = substr($upc, 3, 5);
    $fam = substr($upc, 8, 3);
    $val = substr($upc, -2);
    $db = pDataConnect();
    $query = "select * from couponcodes where code = '" . $val . "'";
    $result = sql_query($query, $db);
    $num_rows = sql_num_rows($result);
    if ($num_rows == 0) {
        boxMsg("coupon type unknown<br>please enter coupon<br>manually");
    } else {
        $row = sql_fetch_array($result);
        $value = $row["Value"];
        $qty = $row["Qty"];
        if ($fam == "992") {
            $value = truncate2($value);
            $_SESSION["couponupc"] = $upc;
            $_SESSION["couponamt"] = $value;
            maindisplay("coupondeptsearch.php");
        } else {
            sql_close($db);
            $fam = substr($fam, 0, 2);
            $query = "select " . "max(unitPrice) as total, " . "max(department) as department, " . "sum(ItemQtty) as qty, " . "sum(case when trans_status = 'C' then -1 else quantity end) as couponqtty " . "from localtemptrans where substring(upc, 4, 5) = '" . $man_id . "' " . "group by substring(upc, 4, 5)";
            $db = tDataConnect();
            $result = sql_query($query, $db);
            $num_rows = sql_num_rows($result);
            if ($num_rows > 0) {
                $row = sql_fetch_array($result);
                if ($row["couponqtty"] < 1) {
                    boxMsg("Coupon already applied<BR>for this item");
                } else {
                    $dept = $row["department"];
                    $act_qty = $row["qty"];
                    if ($qty <= $act_qty) {
                        if ($value == 0) {
                            $value = -1 * $row["total"];
                        }
                        $value = truncate2($value);
                        addcoupon($upc, $dept, $value);
                        lastpage();
                    } else {
                        boxMsg("coupon requires " . $qty . "items<BR>there are only " . $act_qty . " item(s)<BR>in this transaction");
                    }
                }
            } else {
                boxMsg("product not found<BR>in transaction");
            }
            // sql_close($db);
        }
    }
}
Ejemplo n.º 23
0
function admin_getpaypaltransactions($currency = false, $from = false, $to = false)
{
    $qu = sql_exec("select xid,min(time) as time," . "subtract_money('',sum_money(change)) as change " . "from transaction_log where " . "xid in (select xid from transaction_log where " . "(account like 'anon-deposits:%' or " . "account like 'deposits:%' or " . "account like 'subscription-payments:%' or " . "account like 'withdrawals:%')" . ($currency === false ? "" : " and change like '%" . sql_escape($currency) . "'") . ($from === false ? "" : " and time >= " . intval($from)) . ($to === false ? "" : " and time < " . intval($to)) . ") and (account like 'anon-deposits:%' or " . "account like 'deposits:%' or " . "account='paypal-fee' or " . "account like 'subscription-payments:%' or " . "account like 'withdrawals:%') " . "group by xid order by xid");
    if ($qu === false) {
        return private_dberr();
    }
    $transactions = array();
    for ($i = 0; $i < sql_numrows($qu); $i++) {
        $row = sql_fetch_array($qu, $i);
        $transactions[intval($row["xid"])] = array("xid" => intval($row["xid"]), "time" => intval($row["time"]), "change" => "{$row['change']}");
    }
    return array(0, $transactions);
}
Ejemplo n.º 24
0
function nexttransno()
{
    $next_trans_no = 1;
    $db = pDataConnect();
    sql_query("update globalvalues set transno = transno + 1", $db);
    $result = sql_query("select transno from globalvalues", $db);
    $num_rows = sql_num_rows($result);
    if ($num_rows != 0) {
        $row = sql_fetch_array($result);
        $next_trans_no = $row["transno"];
    }
    sql_close($db);
}
Ejemplo n.º 25
0
 public function run()
 {
     global $login;
     $rsPublish = sql("SELECT `cache_id`, `user_id`\n            FROM `caches`\n            WHERE `status`=5\n            AND NOT ISNULL(`date_activate`)\n            AND `date_activate`<=NOW()");
     while ($rPublish = sql_fetch_array($rsPublish)) {
         $userid = $rPublish['user_id'];
         $cacheid = $rPublish['cache_id'];
         // update cache status to active
         sql("SET @STATUS_CHANGE_USER_ID='&1'", $login->userid);
         sql("UPDATE `caches` SET `status`=1, `date_activate`=NULL WHERE `cache_id`='&1'", $cacheid);
     }
     sql_free_result($rsPublish);
 }
Ejemplo n.º 26
0
    function __construct($nUserId = ID_NEW)
    {
        $this->nUserId = $nUserId + 0;
        if ($nUserId == ID_NEW) {
            $rs = sqll('SELECT `id`, `name`, `default_value`, `check_regex`, `option_order`, 0 AS `option_visible`, `internal_use`, `default_value` AS `option_value` 
			             FROM `profile_options`');
        } else {
            $rs = sqll("SELECT `p`.`id`, `p`.`name`, `p`.`default_value`, `p`.`check_regex`, `p`.`option_order`, IFNULL(`u`.`option_visible`, 0) AS `option_visible`, `p`.`internal_use`, IFNULL(`u`.`option_value`, `p`.`default_value`) AS `option_value`\r\n\t\t\t\t\t\tFROM `profile_options` AS `p`\r\n\t\t\t\t\t\tLEFT JOIN `user_options` AS `u` ON `p`.`id`=`u`.`option_id` AND (`u`.`user_id` IS NULL OR `u`.`user_id`='&1')\r\n\t\t\t\t\tUNION \r\n\t\t\t\t\t\tSELECT `u`.`option_id` AS `id`, `p`.`name`, `p`.`default_value`, `p`.`check_regex`, `p`.`option_order`, `u`.`option_visible`, `p`.`internal_use`, IFNULL(`u`.`option_value`, `p`.`default_value`) AS `option_value`\r\n\t\t\t\t\t\tFROM `user_options` AS `u`\r\n\t\t\t\t\t\tLEFT JOIN `profile_options` AS `p` ON `p`.`id`=`u`.`option_id`\r\n\t\t\t\t\t\tWHERE `u`.`user_id`='&1'", $this->nUserId);
        }
        while ($record = sql_fetch_array($rs)) {
            $this->nOptions[$record['id']] = $record;
        }
        sql_free_result($rs);
    }
Ejemplo n.º 27
0
 function getbyKEY($keyval)
 {
     // tested OK
     // retrieve data and put into associative array
     if (sizeof($this->appkeyfield) > 1) {
         if (strlen($keyval) > 0) {
             $sSQL = 'select * from ' . $this->dataTable . ' WHERE ' . $this->appkeyfield . '=\'' . $keyval . '\'';
             $rec = sql_query($sSQL, $this->DB);
             $this->aDATA = sql_fetch_array($rec, $this->DB);
         }
     } else {
         $this->pError = 'No appkey defined';
     }
 }
Ejemplo n.º 28
0
function landkreisFromLocid($locid)
{
    global $dblink;
    if (!is_numeric($locid)) {
        return '';
    }
    $locid = $locid + 0;
    $rs = sql("SELECT `rb`.`text_val` `regierungsbezirk` FROM `geodb_textdata` `ct`, `geodb_textdata` `rb`, `geodb_hierarchies` `hr` WHERE `ct`.`loc_id`=`hr`.`loc_id` AND `hr`.`id_lvl5`=`rb`.`loc_id` AND `ct`.`text_type`=500100000 AND `rb`.`text_type`=500100000 AND `ct`.`loc_id`='&1' AND `hr`.`id_lvl5`!=0", $locid);
    if ($r = sql_fetch_array($rs)) {
        return $r['regierungsbezirk'];
    } else {
        return 0;
    }
}
Ejemplo n.º 29
0
function clubCard($intItemNum)
{
    $query = "select * from localtemptrans where trans_id = " . $intItemNum;
    $connection = tDataConnect();
    $result = sql_query($query, $connection);
    $row = sql_fetch_array($result);
    $num_rows = sql_num_rows($result);
    if ($num_rows > 0) {
        $strUPC = $row["upc"];
        $strDescription = $row["description"];
        $dblVolSpecial = $row["VolSpecial"];
        $dblquantity = -0.5 * $row["quantity"];
        $dblTotal = truncate2(-1 * 0.5 * $row["total"]);
        // invoked truncate2 rounding function to fix half-penny errors apbw 3/7/05
        $strCardNo = $_SESSION["memberID"];
        $dblDiscount = $row["discount"];
        $dblmemDiscount = $row["memDiscount"];
        $intDiscountable = $row["discountable"];
        $dblUnitPrice = $row["unitPrice"];
        $intScale = nullwrap($row["scale"]);
        if ($row["foodstamp"] != 0) {
            $intFoodStamp = 1;
        } else {
            $intFoodStamp = 0;
        }
        $intdiscounttype = nullwrap($row["discounttype"]);
        if ($row["voided"] == 20) {
            boxMsg("Discount already taken");
        } elseif ($row["trans_type"] == "T" or $row["trans_status"] == "D" or $row["trans_status"] == "V" or $row["trans_status"] == "C") {
            boxMsg("Item cannot be discounted");
        } elseif (strncasecmp($strDescription, "Club Card", 9) == 0) {
            //----- edited by abpw 2/15/05 -----
            boxMsg("Item cannot be discounted");
        } elseif ($_SESSION["tenderTotal"] < 0 and $intFoodStamp == 1 and -1 * $dblTotal > $_SESSION["fsEligible"]) {
            boxMsg("Item already paid for");
        } elseif ($_SESSION["tenderTotal"] < 0 and -1 * $dblTotal > $_SESSION["runningTotal"] - $_SESSION["taxTotal"]) {
            boxMsg("Item already paid for");
        } else {
            // --- added partial item desc to club card description - apbw 2/15/05 ---
            addItem($strUPC, "Club Card: " . substr($strDescription, 0, 19), "I", "", "J", $row["department"], $dblquantity, $dblUnitPrice, $dblTotal, 0.5 * $row["regPrice"], $intScale, $row["tax"], $intFoodStamp, $dblDiscount, $dblmemDiscount, $intDiscountable, $intdiscounttype, $dblquantity, $row["volDiscType"], $row["volume"], $dblVolSpecial, 0, 0, 0);
            $update = "update localtemptrans set voided = 20 where trans_id = " . $intItemNum;
            $connection = tDataConnect();
            sql_query($update, $connection);
            $_SESSION["TTLflag"] = 0;
            $_SESSION["TTLRequested"] = 0;
            lastpage();
        }
    }
}
Ejemplo n.º 30
0
function setDrawerKickLater()
{
    // 	this more complex version can be modified to kick the drawer under whatever circumstances the FE Mgr sees fit
    //	it currently kicks the drawer *only* for cash in & out
    $db = tDataConnect();
    $query = "select * from localtemptrans where trans_subtype = 'CA' and total <> 0";
    $result = sql_query($query, $db);
    $num_rows = sql_num_rows($result);
    $row = sql_fetch_array($result);
    if ($num_rows != 0) {
        $_SESSION["kick"] = 1;
    } else {
        $_SESSION["kick"] = 0;
    }
}