function sanitize_uri()
{
    global $PATH_INFO, $SCRIPT_NAME, $REQUEST_URI;
    if (isset($PATH_INFO) && $PATH_INFO != "") {
        $SCRIPT_NAME = $PATH_INFO;
        $REQUEST_URI = "";
    }
    if ($REQUEST_URI == "") {
        //necessary for some IIS installations (CGI in particular)
        $get = httpallget();
        if (count($get) > 0) {
            $REQUEST_URI = $SCRIPT_NAME . "?";
            reset($get);
            $i = 0;
            while (list($key, $val) = each($get)) {
                if ($i > 0) {
                    $REQUEST_URI .= "&";
                }
                $REQUEST_URI .= "{$key}=" . URLEncode($val);
                $i++;
            }
        } else {
            $REQUEST_URI = $SCRIPT_NAME;
        }
        $_SERVER['REQUEST_URI'] = $REQUEST_URI;
    }
    $SCRIPT_NAME = substr($SCRIPT_NAME, strrpos($SCRIPT_NAME, "/") + 1);
    if (strpos($REQUEST_URI, "?")) {
        $REQUEST_URI = $SCRIPT_NAME . substr($REQUEST_URI, strpos($REQUEST_URI, "?"));
    } else {
        $REQUEST_URI = $SCRIPT_NAME;
    }
}
示例#2
0
 function export()
 {
     $model = M("Customer");
     $where['is_del'] = 0;
     $list = $model->where($where)->select();
     Vendor('Excel.PHPExcel');
     //导入thinkphp第三方类库
     $inputFileName = "Public/templete/customer.xlsx";
     $objPHPExcel = PHPExcel_IOFactory::load($inputFileName);
     $objPHPExcel->getProperties()->setCreator("smeoa")->setLastModifiedBy("smeoa")->setTitle("Office 2007 XLSX Test Document")->setSubject("Office 2007 XLSX Test Document")->setDescription("Test document for Office 2007 XLSX, generated using PHP classes.")->setKeywords("office 2007 openxml php")->setCategory("Test result file");
     // Add some data
     $i = 1;
     //dump($list);
     foreach ($list as $val) {
         $i++;
         $objPHPExcel->setActiveSheetIndex(0)->setCellValue("A{$i}", $val["name"])->setCellValue("B{$i}", $val["short"])->setCellValue("C{$i}", $val["biz_license"])->setCellValue("D{$i}", $val["payment"])->setCellValue("E{$i}", $val["address"])->setCellValue("F{$i}", $val["salesman"])->setCellValue("G{$i}", $val["contact"])->setCellValue("H{$i}", $val["email"])->setCellValue("I{$i}", $val["office_tel"])->setCellValue("J{$i}", $val["mobile_tel"])->setCellValue("J{$i}", $val["fax"])->setCellValue("L{$i}", $val["im"])->setCellValue("M{$i}", $val["remark"]);
     }
     // Rename worksheet
     $objPHPExcel->getActiveSheet()->setTitle('Customer');
     // Set active sheet index to the first sheet, so Excel opens this as the first sheet
     $objPHPExcel->setActiveSheetIndex(0);
     $file_name = "customer.xlsx";
     // Redirect output to a client’s web browser (Excel2007)
     header("Content-Type: application/force-download");
     header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
     header("Content-Disposition:attachment;filename =" . str_ireplace('+', '%20', URLEncode($file_name)));
     header('Cache-Control: max-age=0');
     $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');
     $objWriter->save('php://output');
     exit;
 }
function asides_dohook($hookname, $args)
{
    global $session;
    switch ($hookname) {
        case "viewcommentary":
            $tloc = get_module_pref("loc", "commentaryinfo");
            $sloc = get_module_pref("loc", "commentaryinfo", $args['acctid']);
            break;
        case "commentaryoptions":
            if (!strpos($_SERVER['REQUEST_URI'], "char=" . $session['user']['acctid'] . "&")) {
                $link = "bio.php?char=" . $session['user']['acctid'] . "&ret=" . URLEncode($_SERVER['REQUEST_URI']);
                $total = get_module_pref("total");
                $seen = get_module_pref("seen");
                output("`n`n<a href=\"{$link}\">View my Bio</a>", true);
                if ($seen != $total) {
                    $new = $total - $seen;
                    if ($new == 1) {
                        output("(1 unread Natter)");
                    } else {
                        output("(%s unread Natters)", $new);
                    }
                }
                addnav("", $link);
            }
            break;
    }
    return $args;
}
function viewmybio_dohook($hookname, $args)
{
    global $session;
    switch ($hookname) {
        case "commentaryoptions":
            $link = "bio.php?char=" . $session['user']['acctid'] . "&ret=" . URLEncode($_SERVER['REQUEST_URI']);
            output("`n`n<a href=\"{$link}\">View my Bio</a>", true);
            addnav("", $link);
            break;
    }
    return $args;
}
function biochat_dohook($hookname, $args)
{
    global $session;
    switch ($hookname) {
        case "bioend":
            require_once "lib/commentary.php";
            output("`n`n`0%s`0's Natter feed:`n", $args['name']);
            addcommentary();
            $section = "bio-" . $args['acctid'];
            viewcommentary($section, "Natter!", 25);
            if (!strpos(httpget('ret'), "bio.php")) {
                set_module_pref("lastplace", httpget('ret'));
            }
            $sql = "SELECT COUNT(commentid) AS totalcomments FROM " . db_prefix("commentary") . " WHERE section='{$section}'";
            $result = db_query($sql);
            $row = db_fetch_assoc($result);
            $all = $row['totalcomments'];
            set_module_pref("total", $all, "biochat", $args['acctid']);
            if ($args['acctid'] == $session['user']['acctid']) {
                //this is the player looking at his or her own bio
                set_module_pref("seen", $all);
            }
            $return = get_module_pref("lastplace");
            if ($return) {
                $return = substr($return, strrpos($return, "/") + 1);
                addnav("Been clicking around Bios and Nattering for a while?");
                addnav("Go `iright`i back to where you came from", $return);
            }
            debug($return);
            break;
        case "commentaryoptions":
            if (!strpos($_SERVER['REQUEST_URI'], "char=" . $session['user']['acctid'] . "&")) {
                $link = "bio.php?char=" . $session['user']['acctid'] . "&ret=" . URLEncode($_SERVER['REQUEST_URI']);
                $total = get_module_pref("total");
                $seen = get_module_pref("seen");
                output("<a href=\"{$link}\">View my Bio</a> ", true);
                if ($seen != $total) {
                    $new = $total - $seen;
                    if ($new == 1) {
                        output("(1 unread Natter) ");
                    } else {
                        output("(%s unread Natters) ", $new);
                    }
                }
                addnav("", $link);
            }
            break;
    }
    return $args;
}
function viewmybio_dohook($hookname, $args)
{
    global $session;
    switch ($hookname) {
        case "commentaryoptions":
            require_once "lib/commentary.php";
            $link = "bio.php?char=" . $session['user']['acctid'] . "&ret=" . URLEncode(buildcommentarylink("&frombio=true", $_SERVER['REQUEST_URI']));
            debug($link);
            output("`n`n<a href=\"{$link}\">View my Bio</a>", true);
            addnav("", $link);
            break;
    }
    return $args;
}
示例#7
0
function s_users_by_uids(&$uids, $encoded = false)
{
    if (!s_bad_array($uids) || !($uids = array_unique($uids)) || !($uids = array_values($uids)) || empty($uids)) {
        return false;
    }
    //看cache中是否存在
    asort($uids);
    $mem = mem_cache_share();
    $key = md5(MEM_CACHE_KEY_PREFIX . "_user_by_uids_" . implode(",", $uids) . strval($encoded));
    if ($data = $mem->get($key)) {
        //缓存中已经存在
        $data = json_decode($data, true);
    }
    if (!$data) {
        //缓存中没有,请求服务器
        $max = 20;
        $time = 0;
        $times = ceil(count($uids) / $max);
        $list = array();
        do {
            $ids = array();
            $num0 = $time * $max;
            $num1 = ($time + 1) * $max - 1;
            foreach (range($num0, $num1) as $index) {
                if (!isset($uids[$index]) || intval($uids[$index]) <= 0) {
                    break;
                }
                $ids[] = $uids[$index];
            }
            $params = array("uids" => implode(",", $ids), "source" => APP_KEY, "cookie" => array("SUE" => $_COOKIE["SUE"], "SUP" => $_COOKIE["SUP"]));
            $data = s_http_get();
            $req = new HTTP_Request('http://i2.api.weibo.com/2/users/show_batch.json');
            $req->setMethod(HTTP_REQUEST_METHOD_GET);
            $req->addCookie("SUE", URLEncode($_COOKIE["SUE"]));
            $req->addCookie("SUP", URLEncode($_COOKIE["SUP"]));
            $req->addQueryString('uids', implode(",", $ids));
            $req->addQueryString('is_encoded', $encoded === false ? 0 : 1);
            $req->addQueryString('source', MBLOG_APP_KEY);
            $rs = $req->sendRequest();
            if (PEAR::isError($rs) || !($ret = json_decode($req->getResponseBody(), true)) || isset($ret["error_code"])) {
                return false;
            }
            //有可能是空数组
            if (isset($ret["users"])) {
                $list = array_merge($list, $ret["users"]);
            }
            unset($ret);
        } while (++$time < $times);
        $data = array();
        //重新组合成uid => array()
        foreach ($list as &$item) {
            if (isset($item["id"]) && $item["idstr"] > 0) {
                $data[$item["idstr"]] = $item;
            }
            unset($item);
        }
        //检查自己是否在数组中
        if (false !== ($me = login_user_info()) && ($meid = $me["uniqueid"]) && in_array($meid, $uids) && ($me = get_user_by_token(intval($meid)))) {
            $data[$me["id"]] = $me;
        }
        unset($list);
        //缓存十小时
        $mem->set($key, json_encode($data), 0, MEM_CACHE_LIFETIME_LUCKY);
    }
    return $data;
}
示例#8
0
<?php

if (!defined("B_PROLOG_INCLUDED") || B_PROLOG_INCLUDED !== true) {
    die;
}
$arParams["FILTER_NAME"] = trim($arParams["FILTER_NAME"]);
$arParams["LIST_URL"] = trim($arParams["LIST_URL"]);
if (strlen($arParams["FILTER_NAME"]) > 0 && strlen($arParams["LIST_URL"]) > 0) {
    foreach ($arResult["MONTH"] as $week => $arWeek) {
        foreach ($arWeek as $day => $arDay) {
            if (count($arDay["events"]) > 0) {
                $timeFROM = mktime(0, 0, 0, $arResult["currentMonth"], $arDay["day"], $arResult["currentYear"]);
                $timeTO = mktime(0, 0, 0, $arResult["currentMonth"], $arDay["day"] + 1, $arResult["currentYear"]);
                $strFROM = date($GLOBALS["DB"]->DateFormatToPHP(CLang::GetDateFormat("SHORT")), $timeFROM);
                $strTO = date($GLOBALS["DB"]->DateFormatToPHP(CLang::GetDateFormat("SHORT")), $timeTO);
                $LIST_URL = $arParams["LIST_URL"];
                if (strpos($LIST_URL, "?") === false) {
                    $LIST_URL .= "?";
                }
                if (strpos($LIST_URL, "&") !== false) {
                    $LIST_URL .= "&";
                }
                $LIST_URL .= URLEncode($arParams["FILTER_NAME"] . "[>=" . $arParams["DATE_FIELD"] . "]") . "=" . URLEncode($strFROM);
                $LIST_URL .= "&" . URLEncode($arParams["FILTER_NAME"] . "[<" . $arParams["DATE_FIELD"] . "]") . "=" . URLEncode($strTO);
                $arResult["MONTH"][$week][$day]["events"][0]["url"] = htmlspecialcharsbx($LIST_URL);
                $arResult["MONTH"][$week][$day]["events"][0]["title"] = "";
            }
        }
    }
}
示例#9
0
 private function _folder_export($model, $map)
 {
     $list = $model->where($map)->select();
     //导入thinkphp第三方类库
     Vendor('Excel.PHPExcel');
     //$inputFileName = "Public/templete/contact.xlsx";
     //$objPHPExcel = PHPExcel_IOFactory::load($inputFileName);
     $objPHPExcel = new PHPExcel();
     $objPHPExcel->getProperties()->setCreator("小微OA")->setLastModifiedBy("小微OA")->setTitle("Office 2007 XLSX Test Document")->setSubject("Office 2007 XLSX Test Document")->setDescription("Test document for Office 2007 XLSX, generated using PHP classes.")->setKeywords("office 2007 openxml php")->setCategory("Test result file");
     // Add some data
     $i = 1;
     //dump($list);
     //编号,类型,标题,登录时间,部门,登录人,状态,审批,协商,抄送,审批情况,自定义字段
     $objPHPExcel->setActiveSheetIndex(0)->setCellValue("A{$i}", "编号")->setCellValue("B{$i}", "类型")->setCellValue("C{$i}", "标题")->setCellValue("D{$i}", "登录时间")->setCellValue("E{$i}", "部门")->setCellValue("F{$i}", "登录人")->setCellValue("G{$i}", "状态")->setCellValue("H{$i}", "审批")->setCellValue("I{$i}", "协商")->setCellValue("J{$i}", "抄送")->setCellValue("J{$i}", "审批情况");
     foreach ($list as $val) {
         $i++;
         //dump($val);
         $id = $val['id'];
         $doc_no = $val["doc_no"];
         //编号
         $name = $val["name"];
         //标题
         $confirm_name = strip_tags($val["confirm_name"]);
         //审批
         $consult_name = strip_tags($val["consult_name"]);
         //协商
         $refer_name = strip_tags($val["refer_name"]);
         //协商
         $type_name = $val["type_name"];
         //流程类型
         $user_name = $val["user_name"];
         //登记人
         $dept_name = $val["dept_name"];
         //不美分
         $create_time = $val["create_time"];
         $create_time = toDate($val["create_time"], 'Y-m-d H:i:s');
         //创建时间
         $step = show_step_type($val["step"]);
         //
         //编号,类型,标题,登录时间,部门,登录人,状态,审批,协商,抄送,审批情况,自定义字段
         $objPHPExcel->setActiveSheetIndex(0)->setCellValue("A{$i}", $doc_no)->setCellValue("B{$i}", $type_name)->setCellValue("C{$i}", $name)->setCellValue("D{$i}", $create_time)->setCellValue("E{$i}", $dept_name)->setCellValue("F{$i}", $user_name)->setCellValue("G{$i}", $step)->setCellValue("H{$i}", $confirm_name)->setCellValue("I{$i}", $consult_name);
         $model_flow_field = D("FlowField");
         $field_list = $model_flow_field->get_data_list($id);
         //	dump($field_list);
         $k = 0;
         if (!empty($field_list)) {
             foreach ($field_list as $field) {
                 $k++;
                 $field_data = $field['name'] . ":" . $field['val'];
                 $location = get_cell_location("J", $i, $k);
                 $objPHPExcel->setActiveSheetIndex(0)->setCellValue($location, $field_data);
             }
         }
     }
     // Rename worksheet
     $objPHPExcel->getActiveSheet()->setTitle('流程统计');
     // Set active sheet index to the first sheet, so Excel opens this as the first sheet
     $objPHPExcel->setActiveSheetIndex(0);
     $file_name = "流程统计.xlsx";
     // Redirect output to a client’s web browser (Excel2007)
     header("Content-Type: application/force-download");
     header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
     header("Content-Disposition:attachment;filename =" . str_ireplace('+', '%20', URLEncode($file_name)));
     header('Cache-Control: max-age=0');
     $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');
     //readfile($filename);
     $objWriter->save('php://output');
     exit;
 }
function commentaryinfo_dohook($hookname, $args)
{
    global $session;
    switch ($hookname) {
        case "viewcommentary":
            if (get_module_pref("user_usecommentaryextras") == 0) {
                break;
            }
            if (preg_match('/bio\\.php\\?char=(\\d+)\\&ret/', $args['commentline'], $matches)) {
                $userid = $matches[1];
            }
            if ($userid == 0) {
                if (get_module_pref("user_linebreak") == 1) {
                    rawoutput("<br />");
                }
                break;
            }
            $sql = "SELECT race, sex, donation, weapon, loggedin, laston FROM " . db_prefix("accounts") . " WHERE acctid = {$userid}";
            $result = db_fetch_assoc(db_query_cached($sql, "commentaryinfo-{$userid}"));
            if (!get_module_pref("user_hidemyinfo", "commentaryinfo", $userid)) {
                $racefilename = strtolower($result['race']);
                $racefilename = strtr($racefilename, " '-_.!,", "");
                $racefilename = str_replace(" ", "", $racefilename);
                if ($result['sex'] == 0) {
                    $gender = "m";
                    $gendertitle = "Male";
                } else {
                    $gender = "f";
                    $gendertitle = "Female";
                }
                $racefilename .= $gender;
                $race = "<img src=\"/images/races/" . $racefilename . ".png\" alt=\"" . $gendertitle . " " . $result['race'] . "\" title=\"" . $gendertitle . " " . $result['race'] . "\">";
                $weaponfilename = strtolower($result['weapon']);
                $weaponfilename = strtr($weaponfilename, " '-_.!+1234567890,", "                  ");
                $weaponfilename = str_replace(" ", "", $weaponfilename);
                $weaponfilename = "images/weapons/" . $weaponfilename . ".png";
                if (file_exists($weaponfilename)) {
                    $weapon = "<img src=\"" . $weaponfilename . "\" alt=\"Weapon: " . $result['weapon'] . "\" title=\"Weapon: " . $result['weapon'] . "\">";
                } else {
                    $weapon = "Weapon: " . $result['weapon'];
                }
            }
            $offline = date("Y-m-d H:i:s", strtotime("-" . getsetting("LOGINTIMEOUT", 900) . " seconds"));
            if ($result['laston'] > $offline && $result['loggedin'] == 1) {
                if (get_module_pref("loc", "commentaryinfo", $userid) == get_module_pref("loc", "commentaryinfo")) {
                    $online = "<img src=\"/modules/commentaryinfo/nearby.png\" alt=\"Nearby\" title=\"Nearby\">";
                    if ($userid != $session['user']['acctid']) {
                        $ret = URLEncode($_SERVER['REQUEST_URI']);
                        if (!strpos($ret, "bio.php") && !strpos($ret, "commentaryinfo")) {
                            $online = "<a href=\"runmodule.php?module=commentaryinfo&op=closetalk&player={$userid}&ret={$ret}\"><img src=\"/modules/commentaryinfo/nearby.png\" alt=\"Nearby (click to whisper)\" title=\"Nearby (click to whisper)\"></a>";
                            addnav("", "runmodule.php?module=commentaryinfo&op=closetalk&player={$userid}&ret={$ret}");
                        }
                    }
                } else {
                    $online = "<img src=\"/modules/commentaryinfo/online.png\" alt=\"Logged In\" title=\"Logged In\">";
                }
            } else {
                $online = "<img src=\"/modules/commentaryinfo/offline.png\" alt=\"Logged Out\" title=\"Logged Out\">";
            }
            if ($result['donation'] > 100) {
                $donation = "<img src=\"/modules/commentaryinfo/donator1.png\" alt=\"Site Supporter\" title=\"Site Supporter\">";
            }
            if ($result['donation'] > 1000) {
                $donation = "<img src=\"/modules/commentaryinfo/donator2.png\" alt=\"Extra Awesome Site Supporter\" title=\"Extra Awesome Site Supporter\">";
            }
            if ($result['donation'] > 2000) {
                $donation = "<img src=\"/modules/commentaryinfo/donator3.png\" alt=\"Ultra Awesome Site Supporter\" title=\"Ultra Awesome Site Supporter\">";
            }
            if (get_module_pref("user_linebreak") == 1) {
                $out .= "<br />";
            }
            $out .= "{$online} {$close} {$race} {$donation}";
            if (get_module_pref("user_showweapons") == 1) {
                $out .= " {$weapon}";
            }
            if (get_module_pref("user_showinline") == 0) {
                $out .= "<br />";
            }
            rawoutput("{$out}");
            break;
        case "forest":
        case "worldnav":
            clear_module_pref("loc");
            break;
        case "viewcommentaryheader":
            set_module_pref("loc", $args['section']);
            invalidatedatacache("commentaryinfo-" . $session['user']['acctid']);
            break;
    }
    return $args;
}
示例#11
0
function _book($from_Content, $fromUsername, $toUsername, $time)
{
    ini_set('default_charset', 'utf-8');
    // 1. 初始化
    /*Cache配置信息,可查询Cache详情页*/
    $cacheid = 'XXX';
    $host = 'cache.duapp.com';
    $port = '20243';
    $user = '******';
    $pwd = 'XXX';
    $mc = new BaeMemcache($cacheid, $host . ': ' . $port, $user, $pwd);
    //以下的几个语句,用作拥有自定义菜单的,可以设置对书名,作者,任意词对应查询,当然需要在消息处理页面设置对应memcache
    // 2. 设置选项,包括URL
    $sch_url = "http://202.121.55.6:8080/opac/";
    $type = any;
    $shu = 120;
    curl_setopt($ch, CURLOPT_URL, $sch_url . "openlink.php?strSearchType=title&match_flag=forward&historyCount=1&strText=" . $from_Content . "&doctype=ALL&displaypg=120&showmode=list&sort=CATA_DATE&orderby=desc&location=ALL");
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_HEADER, 0);
    // 3. 执行并获取HTML文档内容
    $output = curl_exec($ch);
    // 4. 释放curl句柄
    curl_close($ch);
    $key = $from_Content;
    $pattern = '/<table.*?>(.+?)<\\/table>/is';
    //正则表达式,不同的图书馆根据代码内容可对应修改
    preg_match($pattern, $output, $match);
    //$match[0] 即为<table></table>之间代码
    //然后再提取<tr></tr>之间的内容
    $pattern = '/<tr.*?>(.+?)<\\/tr>/is';
    preg_match_all($pattern, $match[0], $results, PREG_SET_ORDER);
    $s = $results;
    for ($i = 1; $i <= 120; $i++) {
        $pattern = '/<a href=.*?>(.+?)<\\/a>/is';
        //书名
        preg_match_all($pattern, $s[$i - 1][1], $results, PREG_SET_ORDER);
        $arr_title[$i] = html_entity_decode($results[0][1], ENT_QUOTES, 'utf-8');
        $pattern1 = '/<\\/span.*?>(.+?)<br.*?>/is';
        //作者
        preg_match_all($pattern1, $s[$i - 1][1], $results, PREG_SET_ORDER);
        $arr_zuozhe[$i] = html_entity_decode($results[1][1], ENT_QUOTES, 'utf-8');
        $preg = '/<a .*?href="(.*?)".*?>/is';
        //提取链接
        preg_match_all($preg, $s[$i - 1][1], $results, PREG_SET_ORDER);
        $arr_url[$i] = "http://202.121.55.6:8080/opac/" . $results[0][1];
    }
    memcache_set($mc, $from_Content . "_title", $arr_title);
    memcache_set($mc, $from_Content . "_zuozhe", $arr_zuozhe);
    memcache_set($mc, $from_Content . "_url", $arr_url);
    //计算出有多少结果
    $count;
    for ($i = 10; $i >= 0; $i--) {
        if ($arr_title[$i]) {
            $count = $i;
            break;
        } else {
            continue;
        }
    }
    $from_Content = URLEncode($from_Content);
    //经测试微信图文链接无法传递汉字参数
    if ($count >= 10) {
        $resultStr = "<xml>\n           <ToUserName><![CDATA[" . $fromUsername . "]]></ToUserName>\n           <FromUserName><![CDATA[" . $toUsername . "]]></FromUserName>\n<CreateTime>{$time}</CreateTime>\n<MsgType><![CDATA[news]]></MsgType>\n<ArticleCount>{$count}</ArticleCount>\n<Articles>\n<item>\n           <Title><![CDATA[1." . $arr_title[1] . "  --" . $arr_zuozhe[1] . "]]></Title> \n         <PicUrl><![CDATA[http://1.shnupartner.sinaapp.com/images/lib.png]]></PicUrl> \n         <Url><![CDATA[http://shnucs.duapp.com/library/lib_data.php?url=" . $arr_url[1] . "&title=" . URLEncode($arr_title[1]) . "]]></Url>\n</item>\n\n<item>\n     <Title><![CDATA[2." . $arr_title[2] . "  --" . $arr_zuozhe[2] . "]]></Title> \n      \n    <Url><![CDATA[http://shnucs.duapp.com/library/lib_data.php?url=" . $arr_url[2] . "&title=" . URLEncode($arr_title[2]) . "]]></Url>\n</item>\n<item>\n     <Title><![CDATA[3." . $arr_title[3] . "  --" . $arr_zuozhe[3] . "]]></Title>   \n    <Url><![CDATA[http://shnucs.duapp.com/library/lib_data.php?url=" . $arr_url[3] . "&title=" . URLEncode($arr_title[3]) . "]]></Url>\n</item>\n<item>\n    <Title><![CDATA[4." . $arr_title[4] . "  --" . $arr_zuozhe[4] . "]]></Title>       \n    <Url><![CDATA[http://shnucs.duapp.com/library/lib_data.php?url=" . $arr_url[4] . "&title=" . URLEncode($arr_title[4]) . "]]></Url>\n</item>\n<item>\n     <Title><![CDATA[5." . $arr_title[5] . "  --" . $arr_zuozhe[5] . "]]></Title> \n    <Url><![CDATA[http://shnucs.duapp.com/library/lib_data.php?url=" . $arr_url[5] . "&title=" . URLEncode($arr_title[5]) . "]]></Url>\n</item>\n<item>\n     <Title><![CDATA[6." . $arr_title[6] . "  --" . $arr_zuozhe[6] . "]]></Title> \n    \n    <Url><![CDATA[http://shnucs.duapp.com/library/lib_data.php?url=" . $arr_url[6] . "&title=" . URLEncode($arr_title[6]) . "]]></Url>\n</item>\n<item>\n     <Title><![CDATA[7." . $arr_title[7] . "  --" . $arr_zuozhe[7] . "]]></Title> \n    \n    <Url><![CDATA[http://shnucs.duapp.com/library/lib_data.php?url=" . $arr_url[7] . "&title=" . URLEncode($arr_title[7]) . "]]></Url>\n</item>\n<item>\n     <Title><![CDATA[8." . $arr_title[8] . "  --" . $arr_zuozhe[8] . "]]></Title>      \n    <Url><![CDATA[http://shnucs.duapp.com/library/lib_data.php?url=" . $arr_url[8] . "&title=" . URLEncode($arr_title[8]) . "]]></Url>\n</item>\n<item>\n    <Title><![CDATA[9." . $arr_title[9] . "  --" . $arr_zuozhe[9] . "]]></Title> \n    \n    <Url><![CDATA[http://shnucs.duapp.com/library/lib_data.php?url=" . $arr_url[9] . "&title=" . URLEncode($arr_title[9]) . "]]></Url>\n</item>\n<item>\n    <Title><![CDATA[点击查看更多相关书籍]]></Title>\n      \n    <Url><![CDATA[http://shnucs.duapp.com/library/more.php?key=" . $from_Content . "&sch_url=" . $sch_url . "&type=" . $type . "]]></Url>\n</item>\n\n\n\n</Articles>\n</xml>  ";
        echo $resultStr;
        exit;
    } else {
        $resultStr = "<xml>\n           <ToUserName><![CDATA[" . $fromUsername . "]]></ToUserName>\n           <FromUserName><![CDATA[" . $toUsername . "]]></FromUserName>\n<CreateTime>.time().</CreateTime>\n<MsgType><![CDATA[news]]></MsgType>\n<ArticleCount>{$count}</ArticleCount>\n<Articles>\n\n<item>\n           <Title><![CDATA[1." . $arr_title[1] . "  --" . $arr_zuozhe[1] . "]]></Title> \n         <PicUrl><![CDATA[http://1.shnupartner.sinaapp.com/images/lib.png]]></PicUrl> \n         <Url><![CDATA[http://1.shnupartner.sinaapp.com/library/lib_data.php?url=" . $arr_url[1] . "&title=" . URLEncode($arr_title[1]) . "]]></Url>\n</item>\n\n<item>\n     <Title><![CDATA[2." . $arr_title[2] . "  --" . $arr_zuozhe[2] . "]]></Title> \n      \n    <Url><![CDATA[http://1.shnupartner.sinaapp.com/library/lib_data.php?url=" . $arr_url[2] . "&title=" . URLEncode($arr_title[2]) . "]]></Url>\n</item>\n<item>\n     <Title><![CDATA[3." . $arr_title[3] . "  --" . $arr_zuozhe[3] . "]]></Title>   \n    <Url><![CDATA[http://1.shnupartner.sinaapp.com/library/lib_data.php?url=" . $arr_url[3] . "&title=" . URLEncode($arr_title[3]) . "]]></Url>\n</item>\n<item>\n    <Title><![CDATA[4." . $arr_title[4] . "  --" . $arr_zuozhe[4] . "]]></Title>       \n    <Url><![CDATA[http://1.shnupartner.sinaapp.com/library/lib_data.php?url=" . $arr_url[4] . "&title=" . URLEncode($arr_title[4]) . "]]></Url>\n</item>\n<item>\n     <Title><![CDATA[5." . $arr_title[5] . "  --" . $arr_zuozhe[5] . "]]></Title> \n    <Url><![CDATA[http://1.shnupartner.sinaapp.com/library/lib_data.php?url=" . $arr_url[5] . "&title=" . URLEncode($arr_title[5]) . "]]></Url>\n</item>\n<item>\n     <Title><![CDATA[6." . $arr_title[6] . "  --" . $arr_zuozhe[6] . "]]></Title> \n    \n    <Url><![CDATA[http://1.shnupartner.sinaapp.com/library/lib_data.php?url=" . $arr_url[6] . "&title=" . URLEncode($arr_title[6]) . "]]></Url>\n</item>\n<item>\n     <Title><![CDATA[7." . $arr_title[7] . "  --" . $arr_zuozhe[7] . "]]></Title> \n    \n    <Url><![CDATA[http://1.shnupartner.sinaapp.com/library/lib_data.php?url=" . $arr_url[7] . "&title=" . URLEncode($arr_title[7]) . "]]></Url>\n</item>\n<item>\n     <Title><![CDATA[8." . $arr_title[8] . "  --" . $arr_zuozhe[8] . "]]></Title>      \n    <Url><![CDATA[http://1.shnupartner.sinaapp.com/library/lib_data.php?url=" . $arr_url[8] . "&title=" . URLEncode($arr_title[8]) . "]]></Url>\n</item>\n<item>\n    <Title><![CDATA[9." . $arr_title[9] . "  --" . $arr_zuozhe[9] . "]]></Title> \n    \n    <Url><![CDATA[http://1.shnupartner.sinaapp.com/library/lib_data.php?url=" . $arr_url[9] . "&title=" . URLEncode($arr_title[9]) . "]]></Url>\n</item>\n<item>\n    <Title><![CDATA[9." . $arr_title[10] . "  --" . $arr_zuozhe[10] . "]]></Title> \n    \n    <Url><![CDATA[http://1.shnupartner.sinaapp.com/library/lib_data.php?url=" . $arr_url[10] . "&title=" . URLEncode($arr_title[10]) . "]]></Url>\n</item>\n</Articles>\n</xml>  ";
        echo $resultStr;
        exit;
    }
}
示例#12
0
文件: wow.php 项目: qaz734913414/wow
            }
        </style>
    </head>
    <body bgcolor = "black">
            <h1>MINI WOW: <div class = "right">Welcome: <?php 
session_start();
echo $_SESSION['person'];
?>
 | 
            <a href = "wow_information.php" target = "_blank">人物信息</a> | <a class = "open_fb" >展开/收缩副本</a></div></h1>
            <?php 
header('Content-Type:text/html;charset = utf8');
include_once 'database.php';
$fb_list = mysql_query('SELECT DISTINCT Name ,Instruction FROM `FB`', $link);
while ($row = mysql_fetch_object($fb_list)) {
    echo '<h3 class = "bg">', $row->Name, '</h3>';
    echo '<div class = "bolder">';
    echo '<img class = "left" src = "/wow/wow/' . $row->Name . '.jpg" width = "300" height = "150"">';
    echo '副本名称:', $row->Name, '</br>';
    echo '副本介绍:', $row->Instruction, '</br>副本BOSS:';
    $boss = mysql_query('SELECT Name FROM `boss` WHERE FB="' . $row->Name . '"', $link);
    while ($row_boss = mysql_fetch_object($boss)) {
        echo $row_boss->Name, '  ';
    }
    echo '</br><a href = "wowenter.php?boss=' . URLEncode($row->Name) . '">点击进入</a>';
    echo '</div>';
}
?>
    </body>
<html>
    for ($i = 0; $i < $number; $i++) {
        $row = db_fetch_assoc($result);
        $site = str_replace("http://", "", $row['uri']);
        if (strpos($site, "/")) {
            $site = substr($site, 0, strpos($site, "/"));
        }
        $sql = "UPDATE " . db_prefix("referers") . " SET site='" . addslashes($site) . "' WHERE refererid='{$row['refererid']}'";
        db_query($sql);
    }
}
require_once "lib/superusernav.php";
superusernav();
addnav("Referer Options");
addnav("", $_SERVER['REQUEST_URI']);
$sort = httpget('sort');
addnav("Refresh", "referers.php?sort=" . URLEncode($sort) . "");
addnav("C?Sort by Count", "referers.php?sort=count" . ($sort == "count DESC" ? "" : "+DESC"));
addnav("U?Sort by URL", "referers.php?sort=uri" . ($sort == "uri" ? "+DESC" : ""));
addnav("T?Sort by Time", "referers.php?sort=last" . ($sort == "last DESC" ? "" : "+DESC"));
addnav("Rebuild Sites", "referers.php?op=rebuild");
page_header("Referers");
$order = "count DESC";
if ($sort != "") {
    $order = $sort;
}
$sql = "SELECT SUM(count) AS count, MAX(last) AS last,site FROM " . db_prefix("referers") . " GROUP BY site ORDER BY {$order} LIMIT 100";
$count = translate_inline("Count");
$last = translate_inline("Last");
$dest = translate_inline("Destination");
$none = translate_inline("`iNone`i");
$notset = translate_inline("`iNot set`i");
    output("`@Date: `^`b%s`b (%s)`n", $row['date'], relativedate($row['date']));
    output("`@Status: %s`n", $statuses[$row['status']]);
    if ($row['closedate'] != '0000-00-00 00:00:00') {
        output("`@Last Update: `^%s`@ on `^%s (%s)`n", $row['closer'], $row['closedate'], dhms(strtotime('now') - strtotime($row['closedate']), true));
    }
    output("`@Body:`^`n");
    $body = htmlentities(stripslashes($row['body']), ENT_COMPAT, getsetting("charset", "ISO-8859-1"));
    $body = preg_replace("'([[:alnum:]_.-]+[@][[:alnum:]_.-]{2,}([.][[:alnum:]_.-]{2,})+)'i", "<a href='mailto:\\1?subject=RE: {$peti}&body=" . str_replace("+", " ", URLEncode("\n\n----- {$yourpeti} -----\n" . $row['body'])) . "'>\\1</a>", $body);
    $body = preg_replace("'([\\[][[:alnum:]_.-]+[\\]])'i", "<span class='colLtRed'>\\1</span>", $body);
    rawoutput("<span style='font-family: fixed-width'>" . nl2br($body) . "</span>");
    commentdisplay("`n`@Commentary:`0`n", "pet-{$id}", "Add information", 200);
    if ($viewpageinfo) {
        output("`n`n`@Page Info:`&`n");
        $row['pageinfo'] = stripslashes($row['pageinfo']);
        $body = HTMLEntities($row['pageinfo'], ENT_COMPAT, getsetting("charset", "ISO-8859-1"));
        $body = preg_replace("'([[:alnum:]_.-]+[@][[:alnum:]_.-]{2,}([.][[:alnum:]_.-]{2,})+)'i", "<a href='mailto:\\1?subject=RE: {$peti}&body=" . str_replace("+", " ", URLEncode("\n\n----- {$yourpeti} -----\n" . $row['body'])) . "'>\\1</a>", $body);
        $body = preg_replace("'([\\[][[:alnum:]_.-]+[\\]])'i", "<span class='colLtRed'>\\1</span>", $body);
        rawoutput("<pre>" . nl2br($body) . "</pre>");
    }
}
if ($id && $op != "") {
    $prevsql = "SELECT p1.petitionid, p1.status FROM " . db_prefix("petitions") . " AS p1, " . db_prefix("petitions") . " AS p2\n            WHERE p1.petitionid<'{$id}' AND p2.petitionid='{$id}' AND p1.status=p2.status ORDER BY p1.petitionid DESC LIMIT 1";
    $prevresult = db_query($prevsql);
    $prevrow = db_fetch_assoc($prevresult);
    if ($prevrow) {
        $previd = $prevrow['petitionid'];
        $s = $prevrow['status'];
        $status = $statuses[$s];
        addnav("Navigation");
        addnav(array("Previous %s", $status), "viewpetition.php?op=view&id={$previd}");
    }
示例#15
0
             saveuser();
             header("Location: {$session['user']['restorepage']}");
             exit;
             //redirect($session['user']['page']);//"badnav.php");
         }
         db_query("UPDATE accounts SET loggedin=" . true . ", location=0 WHERE acctid = " . $session['user']['acctid']);
         $session['user']['loggedin'] = true;
         $location = $session['user']['location'];
         $session['user']['location'] = 0;
         if ($session['user']['alive'] == 0 && $session['user']['slainby'] != "") {
             //they're not really dead, they were killed in pvp.
             $session['user']['alive'] = true;
         }
         if (getsetting("logdnet", 0)) {
             //register with LoGDnet
             @file(getsetting("logdnetserver", "http://lotgd.net/") . "logdnet.php?addy=" . URLEncode(getsetting("serverurl", "http://" . $_SERVER['SERVER_NAME'] . dirname($_SERVER['REQUEST_URI']))) . "&desc=" . URLEncode(getsetting("serverdesc", "Another LoGD Server")) . "");
         }
         if ($location == 0) {
             redirect("news.php");
         } else {
             if ($location == 1) {
                 redirect("inn.php?op=strolldown");
             } else {
                 saveuser();
                 header("Location: {$session['user']['restorepage']}");
                 exit;
             }
         }
     }
 } else {
     $session[message] = "`4Error, your login was incorrect`0";
    if ($row['acctid'] > 0) {
        addnav("Edit User Record", "user.php?op=edit&userid={$row['acctid']}&returnpetition={$_GET['id']}");
    }
    output("`@From: ");
    $row[body] = stripslashes($row[body]);
    if ($row['login'] > "") {
        output("<a href=\"mail.php?op=write&to=" . rawurlencode($row[login]) . "&body=" . URLEncode("\n\n----- Your Petition -----\n" . $row[body]) . "&subject=RE:+Petition\" target=\"_blank\" onClick=\"" . popup("mail.php?op=write&to=" . rawurlencode($row[login]) . "&body=" . URLEncode("\n\n----- Your Petition -----\n" . $row[body]) . "&subject=RE:+Petition") . ";return false;\"><img src='images/newscroll.png' width='16' height='16' alt='Write Mail' border='0'></a>", true);
    }
    output("`^`b{$row['name']}`b`n");
    output("`@Date: `^`b{$row['date']}`b`n");
    output("`@Body:`^`n");
    $body = HTMLEntities($row[body]);
    $body = preg_replace("'([[:alnum:]_.-]+[@][[:alnum:]_.-]{2,}([.][[:alnum:]_.-]{2,})+)'i", "<a href='mailto:\\1?subject=RE: Petition&body=" . str_replace("+", " ", URLEncode("\n\n----- Your Petition -----\n" . $row[body])) . "'>\\1</a>", $body);
    $body = preg_replace("'([\\[][[:alnum:]_.-]+[\\]])'i", "<span class='colLtRed'>\\1</span>", $body);
    $output .= "<span style='font-family: fixed-width'>" . nl2br($body) . "</span>";
    output("`n`@Commentary:`n");
    viewcommentary("pet-{$_GET['id']}", "Add", 200);
    if ($_GET['viewpageinfo']) {
        output("`n`n`@Page Info:`&`n");
        $row[pageinfo] = stripslashes($row[pageinfo]);
        $body = HTMLEntities($row[pageinfo]);
        $body = preg_replace("'([[:alnum:]_.-]+[@][[:alnum:]_.-]{2,}([.][[:alnum:]_.-]{2,})+)'i", "<a href='mailto:\\1?subject=RE: Petition&body=" . str_replace("+", " ", URLEncode("\n\n----- Your Petition -----\n" . $row[body])) . "'>\\1</a>", $body);
        $body = preg_replace("'([\\[][[:alnum:]_.-]+[\\]])'i", "<span class='colLtRed'>\\1</span>", $body);
        $output .= "<span style='font-family: fixed-width'>" . nl2br($body) . "</span>";
    }
    if ($row[status] == 0) {
        $sql = "UPDATE petitions SET status=1 WHERE petitionid='{$_GET['id']}'";
        $result = db_query($sql);
    }
}
page_footer();
示例#17
0
 protected function _down()
 {
     $attach_id = $_REQUEST["attach_id"];
     $file_id = f_decode($attach_id);
     $File = M("File")->find($file_id);
     $filepath = get_save_path() . $File['savename'];
     $filePath = realpath($filepath);
     $fp = fopen($filePath, 'rb');
     $ua = $_SERVER["HTTP_USER_AGENT"];
     if (!preg_match("/MSIE/", $ua)) {
         header("Content-Length: " . filesize($filePath));
         Header("Content-type: application/octet-stream");
         header("Content-Length: " . filesize($filePath));
         header("Accept-Ranges: bytes");
         header("Accept-Length: " . filesize($filePath));
     }
     header("Content-Disposition:attachment;filename =" . str_ireplace('+', '%20', URLEncode($File['name'])));
     header('Cache-Control:must-revalidate, post-check=0,pre-check=0');
     header('Expires:     0');
     header('Pragma:     public');
     //echo $query;
     fpassthru($fp);
     exit;
 }
function viewcommentary($section, $message = "Interject your own commentary?", $limit = 10, $talkline = "says", $schema = false)
{
    global $session, $REQUEST_URI, $doublepost, $translation_namespace;
    global $emptypost;
    rawoutput("<a name='{$section}'></a>");
    // Let's add a hook for modules to block commentary sections
    $args = modulehook("blockcommentarea", array("section" => $section));
    if (isset($args['block']) && $args['block'] == "yes") {
        return;
    }
    if ($schema === false) {
        $schema = $translation_namespace;
    }
    tlschema("commentary");
    $nobios = array("motd.php" => true);
    if (!array_key_exists(basename($_SERVER['SCRIPT_NAME']), $nobios)) {
        $nobios[basename($_SERVER['SCRIPT_NAME'])] = false;
    }
    if ($nobios[basename($_SERVER['SCRIPT_NAME'])]) {
        $linkbios = false;
    } else {
        $linkbios = true;
    }
    if ($message == "X") {
        $linkbios = true;
    }
    if ($doublepost) {
        output("`\$`bDouble post?`b`0`n");
    }
    if ($emptypost) {
        output("`\$`bWell, they say silence is a virtue.`b`0`n");
    }
    $clanrankcolors = array("`!", "`#", "`^", "`&", "`\$");
    // Needs to be here because scrolling through the commentary pages, entering a bio, then scrolling again forward
    // then re-entering another bio will lead to $com being smaller than 0 and this will lead to an SQL error later on.
    $com = (int) httpget("comscroll");
    if ($com < 0) {
        $com = 0;
    }
    $cc = false;
    if (httpget("comscroll") !== false && (int) $session['lastcom'] == $com + 1) {
        $cid = (int) $session['lastcommentid'];
    } else {
        $cid = 0;
    }
    $session['lastcom'] = $com;
    if ($com > 0 || $cid > 0) {
        // Find newly added comments.
        $sql = "SELECT COUNT(commentid) AS newadded FROM " . db_prefix("commentary") . " LEFT JOIN " . db_prefix("accounts") . " ON " . db_prefix("accounts") . ".acctid = " . db_prefix("commentary") . ".author WHERE section='{$section}' AND " . "(" . db_prefix("accounts") . ".locked=0 or " . db_prefix('accounts') . ".locked is null) AND commentid > '{$cid}'";
        $result = db_query($sql);
        $row = db_fetch_assoc($result);
        $newadded = $row['newadded'];
    } else {
        $newadded = 0;
    }
    $commentbuffer = array();
    if ($cid == 0) {
        $sql = "SELECT " . db_prefix("commentary") . ".*, " . db_prefix("accounts") . ".name, " . db_prefix("accounts") . ".acctid, " . db_prefix("accounts") . ".clanrank, " . db_prefix("clans") . ".clanshort FROM " . db_prefix("commentary") . " LEFT JOIN " . db_prefix("accounts") . " ON " . db_prefix("accounts") . ".acctid = " . db_prefix("commentary") . ".author LEFT JOIN " . db_prefix("clans") . " ON " . db_prefix("clans") . ".clanid=" . db_prefix("accounts") . ".clanid WHERE section = '{$section}' AND " . "( " . db_prefix("accounts") . ".locked=0 OR " . db_prefix("accounts") . ".locked is null ) " . "ORDER BY commentid DESC LIMIT " . $com * $limit . ",{$limit}";
        if ($com == 0 && strstr($_SERVER['REQUEST_URI'], "/moderate.php") !== $_SERVER['REQUEST_URI']) {
            $result = db_query_cached($sql, "comments-{$section}");
        } else {
            $result = db_query($sql);
        }
        while ($row = db_fetch_assoc($result)) {
            $commentbuffer[] = $row;
        }
    } else {
        $sql = "SELECT " . db_prefix("commentary") . ".*, " . db_prefix("accounts") . ".name, " . db_prefix("accounts") . ".acctid, " . db_prefix("accounts") . ".clanrank, " . db_prefix("clans") . ".clanshort FROM " . db_prefix("commentary") . " LEFT JOIN " . db_prefix("accounts") . " ON " . db_prefix("accounts") . ".acctid = " . db_prefix("commentary") . ".author LEFT JOIN " . db_prefix("clans") . " ON " . db_prefix("clans") . ".clanid=" . db_prefix("accounts") . ".clanid WHERE section = '{$section}' AND " . "( " . db_prefix("accounts") . ".locked=0 OR " . db_prefix("accounts") . ".locked is null ) " . "AND commentid > '{$cid}' " . "ORDER BY commentid ASC LIMIT {$limit}";
        $result = db_query($sql);
        while ($row = db_fetch_assoc($result)) {
            $commentbuffer[] = $row;
        }
        $commentbuffer = array_reverse($commentbuffer);
    }
    $rowcount = count($commentbuffer);
    if ($rowcount > 0) {
        $session['lastcommentid'] = $commentbuffer[0]['commentid'];
    }
    $counttoday = 0;
    for ($i = 0; $i < $rowcount; $i++) {
        $row = $commentbuffer[$i];
        $row['comment'] = comment_sanitize($row['comment']);
        $commentids[$i] = $row['commentid'];
        if (date("Y-m-d", strtotime($row['postdate'])) == date("Y-m-d")) {
            if ($row['name'] == $session['user']['name']) {
                $counttoday++;
            }
        }
        $x = 0;
        $ft = "";
        for ($x = 0; strlen($ft) < 5 && $x < strlen($row['comment']); $x++) {
            if (substr($row['comment'], $x, 1) == "`" && strlen($ft) == 0) {
                $x++;
            } else {
                $ft .= substr($row['comment'], $x, 1);
            }
        }
        $link = "bio.php?char=" . $row['acctid'] . "&ret=" . URLEncode($_SERVER['REQUEST_URI']);
        if (substr($ft, 0, 2) == "::") {
            $ft = substr($ft, 0, 2);
        } elseif (substr($ft, 0, 1) == ":") {
            $ft = substr($ft, 0, 1);
        } elseif (substr($ft, 0, 3) == "/me") {
            $ft = substr($ft, 0, 3);
        }
        $row['comment'] = holidayize($row['comment'], 'comment');
        $row['name'] = holidayize($row['name'], 'comment');
        if ($row['clanrank']) {
            $row['name'] = ($row['clanshort'] > "" ? "{$clanrankcolors[ceil($row['clanrank'] / 10)]}&lt;`2{$row['clanshort']}{$clanrankcolors[ceil($row['clanrank'] / 10)]}&gt; `&" : "") . $row['name'];
        }
        if ($ft == "::" || $ft == "/me" || $ft == ":") {
            $x = strpos($row['comment'], $ft);
            if ($x !== false) {
                if ($linkbios) {
                    $op[$i] = str_replace("&amp;", "&", HTMLEntities(substr($row['comment'], 0, $x), ENT_COMPAT, getsetting("charset", "ISO-8859-1"))) . "`0<a href='{$link}' style='text-decoration: none'>\n`&{$row['name']}`0</a>\n`& " . str_replace("&amp;", "&", HTMLEntities(substr($row['comment'], $x + strlen($ft)), ENT_COMPAT, getsetting("charset", "ISO-8859-1"))) . "`0`n";
                } else {
                    $op[$i] = str_replace("&amp;", "&", HTMLEntities(substr($row['comment'], 0, $x), ENT_COMPAT, getsetting("charset", "ISO-8859-1"))) . "`0`&{$row['name']}`0`& " . str_replace("&amp;", "&", HTMLEntities(substr($row['comment'], $x + strlen($ft)), ENT_COMPAT, getsetting("charset", "ISO-8859-1"))) . "`0`n";
                }
                $rawc[$i] = str_replace("&amp;", "&", HTMLEntities(substr($row['comment'], 0, $x), ENT_COMPAT, getsetting("charset", "ISO-8859-1"))) . "`0`&{$row['name']}`0`& " . str_replace("&amp;", "&", HTMLEntities(substr($row['comment'], $x + strlen($ft)), ENT_COMPAT, getsetting("charset", "ISO-8859-1"))) . "`0`n";
            }
        }
        if ($ft == "/game" && !$row['name']) {
            $x = strpos($row['comment'], $ft);
            if ($x !== false) {
                $op[$i] = str_replace("&amp;", "&", HTMLEntities(substr($row['comment'], 0, $x), ENT_COMPAT, getsetting("charset", "ISO-8859-1"))) . "`0`&" . str_replace("&amp;", "&", HTMLEntities(substr($row['comment'], $x + strlen($ft)), ENT_COMPAT, getsetting("charset", "ISO-8859-1"))) . "`0`n";
            }
        }
        if (!isset($op) || !is_array($op)) {
            $op = array();
        }
        if (!array_key_exists($i, $op) || $op[$i] == "") {
            if ($linkbios) {
                $op[$i] = "`0<a href='{$link}' style='text-decoration: none'>`&{$row['name']}`0</a>`3 says, \"`#" . str_replace("&amp;", "&", HTMLEntities($row['comment'], ENT_COMPAT, getsetting("charset", "ISO-8859-1"))) . "`3\"`0`n";
            } elseif (substr($ft, 0, 5) == '/game' && !$row['name']) {
                $op[$i] = str_replace("&amp;", "&", HTMLEntities($row['comment'], ENT_COMPAT, getsetting("charset", "ISO-8859-1")));
            } else {
                $op[$i] = "`&{$row['name']}`3 says, \"`#" . str_replace("&amp;", "&", HTMLEntities($row['comment'], ENT_COMPAT, getsetting("charset", "ISO-8859-1"))) . "`3\"`0`n";
            }
            $rawc[$i] = "`&{$row['name']}`3 says, \"`#" . str_replace("&amp;", "&", HTMLEntities($row['comment'], ENT_COMPAT, getsetting("charset", "ISO-8859-1"))) . "`3\"`0`n";
        }
        if (!array_key_exists('timestamp', $session['user']['prefs'])) {
            $session['user']['prefs']['timestamp'] = 0;
        }
        $session['user']['prefs']['timeoffset'] = round($session['user']['prefs']['timeoffset'], 1);
        if ($session['user']['prefs']['timestamp'] == 1) {
            if (!isset($session['user']['prefs']['timeformat'])) {
                $session['user']['prefs']['timeformat'] = "[m/d h:ia]";
            }
            $time = strtotime($row['postdate']) + $session['user']['prefs']['timeoffset'] * 60 * 60;
            $s = date("`7" . $session['user']['prefs']['timeformat'] . "`0 ", $time);
            $op[$i] = $s . $op[$i];
        } elseif ($session['user']['prefs']['timestamp'] == 2) {
            $s = reltime(strtotime($row['postdate']));
            $op[$i] = "`7({$s})`0 " . $op[$i];
        }
        if ($message == "X") {
            $op[$i] = "`0({$row['section']}) " . $op[$i];
        }
        if ($row['postdate'] >= $session['user']['recentcomments']) {
            $op[$i] = "<img src='images/new.gif' alt='&gt;' width='3' height='5' align='absmiddle'> " . $op[$i];
        }
        addnav("", $link);
        $auth[$i] = $row['author'];
        if (isset($rawc[$i])) {
            $rawc[$i] = full_sanitize($rawc[$i]);
            $rawc[$i] = htmlentities($rawc[$i], ENT_QUOTES, getsetting("charset", "ISO-8859-1"));
        }
    }
    $i--;
    $outputcomments = array();
    $sect = "x";
    $moderating = false;
    if ($session['user']['superuser'] & SU_EDIT_COMMENTS && $message == "X") {
        $moderating = true;
    }
    $del = translate_inline("Del");
    $scriptname = substr($_SERVER['SCRIPT_NAME'], strrpos($_SERVER['SCRIPT_NAME'], "/") + 1);
    $pos = strpos($_SERVER['REQUEST_URI'], "?");
    $return = $scriptname . ($pos == false ? "" : substr($_SERVER['REQUEST_URI'], $pos));
    $one = strstr($return, "?") == false ? "?" : "&";
    for (; $i >= 0; $i--) {
        $out = "";
        if ($moderating) {
            if ($session['user']['superuser'] & SU_EDIT_USERS) {
                $out .= "`0[ <input type='checkbox' name='comment[{$commentids[$i]}]'> | <a href='user.php?op=setupban&userid=" . $auth[$i] . "&reason=" . rawurlencode($rawc[$i]) . "'>Ban</a> ]&nbsp;";
                addnav("", "user.php?op=setupban&userid={$auth[$i]}&reason=" . rawurlencode($rawc[$i]));
            } else {
                $out .= "`0[ <input type='checkbox' name='comment[{$commentids[$i]}]'> ]&nbsp;";
            }
            $matches = array();
            preg_match("/[(]([^)]*)[)]/", $op[$i], $matches);
            $sect = trim($matches[1]);
            if (substr($sect, 0, 5) != "clan-" || $sect == $section) {
                if (substr($sect, 0, 4) != "pet-") {
                    $out .= $op[$i];
                    if (!isset($outputcomments[$sect]) || !is_array($outputcomments[$sect])) {
                        $outputcomments[$sect] = array();
                    }
                    array_push($outputcomments[$sect], $out);
                }
            }
        } else {
            if ($session['user']['superuser'] & SU_EDIT_COMMENTS) {
                $out .= "`2[<a href='" . $return . $one . "removecomment={$commentids[$i]}&section={$section}&returnpath=" . URLEncode($return) . "'>{$del}</a>`2]`0&nbsp;";
                addnav("", $return . $one . "removecomment={$commentids[$i]}&section={$section}&returnpath=" . URLEncode($return) . "");
            }
            $out .= $op[$i];
            if (!array_key_exists($sect, $outputcomments) || !is_array($outputcomments[$sect])) {
                $outputcomments[$sect] = array();
            }
            array_push($outputcomments[$sect], $out);
        }
    }
    if ($moderating) {
        $scriptname = substr($_SERVER['SCRIPT_NAME'], strrpos($_SERVER['SCRIPT_NAME'], "/") + 1);
        addnav("", "{$scriptname}?op=commentdelete&return=" . URLEncode($_SERVER['REQUEST_URI']));
        $mod_Del1 = htmlentities(translate_inline("Delete Checked Comments"), ENT_COMPAT, getsetting("charset", "ISO-8859-1"));
        $mod_Del2 = htmlentities(translate_inline("Delete Checked & Ban (3 days)"), ENT_COMPAT, getsetting("charset", "ISO-8859-1"));
        $mod_Del_confirm = addslashes(htmlentities(translate_inline("Are you sure you wish to ban this user and have you specified the exact reason for the ban, i.e. cut/pasted their offensive comments?"), ENT_COMPAT, getsetting("charset", "ISO-8859-1")));
        $mod_reason = translate_inline("Reason:");
        $mod_reason_desc = htmlentities(translate_inline("Banned for comments you posted."), ENT_COMPAT, getsetting("charset", "ISO-8859-1"));
        output_notl("<form action='{$scriptname}?op=commentdelete&return=" . URLEncode($_SERVER['REQUEST_URI']) . "' method='POST'>", true);
        output_notl("<input type='submit' class='button' value=\"{$mod_Del1}\">", true);
        output_notl("<input type='submit' class='button' name='delnban' value=\"{$mod_Del2}\" onClick=\"return confirm('{$mod_Del_confirm}');\">", true);
        output_notl("`n{$mod_reason} <input name='reason0' size='40' value=\"{$mod_reason_desc}\" onChange=\"document.getElementById('reason').value=this.value;\">", true);
    }
    //output the comments
    ksort($outputcomments);
    reset($outputcomments);
    $sections = commentarylocs();
    $needclose = 0;
    while (list($sec, $v) = each($outputcomments)) {
        if ($sec != "x") {
            if ($needclose) {
                modulehook("}collapse");
            }
            output_notl("`n<hr><a href='moderate.php?area=%s'>`b`^%s`0`b</a>`n", $sec, isset($sections[$sec]) ? $sections[$sec] : "({$sec})", true);
            addnav("", "moderate.php?area={$sec}");
            modulehook("collapse{", array("name" => "com-" . $sec));
            $needclose = 1;
        } else {
            modulehook("collapse{", array("name" => "com-" . $section));
            $needclose = 1;
        }
        reset($v);
        while (list($key, $val) = each($v)) {
            $args = array('commentline' => $val);
            $args = modulehook("viewcommentary", $args);
            $val = $args['commentline'];
            output_notl($val, true);
        }
    }
    if ($moderating && $needclose) {
        modulehook("}collapse");
        $needclose = 0;
    }
    if ($moderating) {
        output_notl("`n");
        rawoutput("<input type='submit' class='button' value=\"{$mod_Del1}\">");
        rawoutput("<input type='submit' class='button' name='delnban' value=\"{$mod_Del2}\" onClick=\"return confirm('{$mod_Del_confirm}');\">");
        output_notl("`n%s ", $mod_reason);
        rawoutput("<input name='reason' size='40' id='reason' value=\"{$mod_reason_desc}\">");
        rawoutput("</form>");
        output_notl("`n");
    }
    if ($session['user']['loggedin']) {
        $args = modulehook("insertcomment", array("section" => $section));
        if (array_key_exists("mute", $args) && $args['mute'] && !($session['user']['superuser'] & SU_EDIT_COMMENTS)) {
            output_notl("%s", $args['mutemsg']);
        } elseif ($counttoday < $limit / 2 || $session['user']['superuser'] & ~SU_DOESNT_GIVE_GROTTO || !getsetting('postinglimit', 1)) {
            if ($message != "X") {
                $message = "`n`@{$message}`n";
                output($message);
                talkform($section, $talkline, $limit, $schema);
            }
        } else {
            $message = "`n`@{$message}`n";
            output($message);
            output("Sorry, you've exhausted your posts in this section for now.`0`n");
        }
    }
    $jump = false;
    if (!isset($session['user']['prefs']['nojump']) || $session['user']['prefs']['nojump'] == false) {
        $jump = true;
    }
    $firstu = translate_inline("&lt;&lt; First Unseen");
    $prev = translate_inline("&lt; Previous");
    $ref = translate_inline("Refresh");
    $next = translate_inline("Next &gt;");
    $lastu = translate_inline("Last Page &gt;&gt;");
    if ($rowcount >= $limit || $cid > 0) {
        $sql = "SELECT count(commentid) AS c FROM " . db_prefix("commentary") . " WHERE section='{$section}' AND postdate > '{$session['user']['recentcomments']}'";
        $r = db_query($sql);
        $val = db_fetch_assoc($r);
        $val = round($val['c'] / $limit + 0.5, 0) - 1;
        if ($val > 0) {
            $first = comscroll_sanitize($REQUEST_URI) . "&comscroll=" . $val;
            $first = str_replace("?&", "?", $first);
            if (!strpos($first, "?")) {
                $first = str_replace("&", "?", $first);
            }
            $first .= "&refresh=1";
            if ($jump) {
                $first .= "#{$section}";
            }
            output_notl("<a href=\"{$first}\">{$firstu}</a>", true);
            addnav("", $first);
        } else {
            output_notl($firstu, true);
        }
        $req = comscroll_sanitize($REQUEST_URI) . "&comscroll=" . ($com + 1);
        $req = str_replace("?&", "?", $req);
        if (!strpos($req, "?")) {
            $req = str_replace("&", "?", $req);
        }
        $req .= "&refresh=1";
        if ($jump) {
            $req .= "#{$section}";
        }
        output_notl("<a href=\"{$req}\">{$prev}</a>", true);
        addnav("", $req);
    } else {
        output_notl("{$firstu} {$prev}", true);
    }
    $last = appendlink(comscroll_sanitize($REQUEST_URI), "refresh=1");
    // Okay.. we have some smart-ass (or stupidass, you guess) players
    // who think that the auto-reload firefox plugin is a good way to
    // avoid our timeouts.  Won't they be surprised when I take that little
    // hack away.
    $last = appendcount($last);
    $last = str_replace("?&", "?", $last);
    if ($jump) {
        $last .= "#{$section}";
    }
    //if (!strpos($last,"?")) $last = str_replace("&","?",$last);
    //debug($last);
    output_notl("&nbsp;<a href=\"{$last}\">{$ref}</a>&nbsp;", true);
    addnav("", $last);
    if ($com > 0 || $cid > 0 && $newadded > $limit) {
        $req = comscroll_sanitize($REQUEST_URI) . "&comscroll=" . ($com - 1);
        $req = str_replace("?&", "?", $req);
        if (!strpos($req, "?")) {
            $req = str_replace("&", "?", $req);
        }
        $req .= "&refresh=1";
        if ($jump) {
            $req .= "#{$section}";
        }
        output_notl(" <a href=\"{$req}\">{$next}</a>", true);
        addnav("", $req);
        output_notl(" <a href=\"{$last}\">{$lastu}</a>", true);
    } else {
        output_notl("{$next} {$lastu}", true);
    }
    if (!$cc) {
        db_free_result($result);
    }
    tlschema();
    if ($needclose) {
        modulehook("}collapse");
    }
}
示例#19
0
function viewcommentary($section, $message = "Interject your own commentary?", $limit = 10, $talkline = "says")
{
    global $HTTP_POST_VARS, $session, $REQUEST_URI, $HTTP_GET_VARS, $doublepost;
    $nobios = array("motd.php" => true);
    if ($nobios[basename($_SERVER['SCRIPT_NAME'])]) {
        $linkbios = false;
    } else {
        $linkbios = true;
    }
    //output("`b".basename($_SERVER['SCRIPT_NAME'])."`b`n");
    if ($doublepost) {
        output("`\$`bDouble post?`b`0`n");
    }
    $message = translate($message);
    if ((int) getsetting("expirecontent", 180) > 0) {
        $sql = "DELETE FROM commentary WHERE postdate<'" . date("Y-m-d H:i:s", strtotime("-" . getsetting("expirecontent", 180) . " days")) . "'";
        db_query($sql);
    }
    $com = (int) $HTTP_GET_VARS['comscroll'];
    $sql = "SELECT commentary.*, \n\t               accounts.name,\n\t               accounts.login\n\t          FROM commentary\n\t         INNER JOIN accounts\n\t            ON accounts.acctid = commentary.author\n\t         WHERE section = '{$section}'\n\t           AND accounts.locked=0 \n\t         ORDER BY commentid DESC\n\t         LIMIT " . $com * $limit . ",{$limit}";
    $result = db_query($sql) or die(db_error(LINK));
    $counttoday = 0;
    for ($i = 0; $i < db_num_rows($result); $i++) {
        $row = db_fetch_assoc($result);
        $row['comment'] = preg_replace("'[`][^1234567!@#\$%^&]'", "", $row['comment']);
        $commentids[$i] = $row['commentid'];
        if (date("Y-m-d", strtotime($row['postdate'])) == date("Y-m-d")) {
            if ($row['name'] == $session['user']['name'] && $climit == "0") {
                $counttoday++;
            }
        }
        $x = 0;
        $ft = "";
        for ($x = 0; strlen($ft) < 3 && $x < strlen($row['comment']); $x++) {
            if (substr($row['comment'], $x, 1) == "`" && strlen($ft) == 0) {
                $x++;
            } else {
                $ft .= substr($row['comment'], $x, 1);
            }
        }
        $link = "bio.php?char=" . rawurlencode($row[login]) . "&ret=" . URLEncode($_SERVER['REQUEST_URI']);
        if (substr($ft, 0, 2) == "::") {
            $ft = substr($ft, 0, 2);
        } else {
            if (substr($ft, 0, 1) == ":") {
                $ft = substr($ft, 0, 1);
            }
        }
        if ($ft == "::" || $ft == "/me" || $ft == ":") {
            $x = strpos($row['comment'], $ft);
            if ($x !== false) {
                if ($linkbios) {
                    $op[$i] = str_replace("&amp;", "&", HTMLEntities(substr($row[comment], 0, $x))) . "`0<a href='{$link}' style='text-decoration: none'>\n`&{$row['name']}`0</a>\n`& " . str_replace("&amp;", "&", HTMLEntities(substr($row[comment], $x + strlen($ft)))) . "`0`n";
                } else {
                    $op[$i] = str_replace("&amp;", "&", HTMLEntities(substr($row[comment], 0, $x))) . "`0\n`&{$row['name']}`0\n`& " . str_replace("&amp;", "&", HTMLEntities(substr($row[comment], $x + strlen($ft)))) . "`0`n";
                }
            }
        }
        if ($op[$i] == "") {
            if ($linkbios) {
                $op[$i] = "`0<a href='{$link}' style='text-decoration: none'>`&{$row['name']}`0</a>`3 says, \"`#" . str_replace("&amp;", "&", HTMLEntities($row[comment])) . "`3\"`0`n";
            } else {
                $op[$i] = "`0`&{$row['name']}`0`3 says, \"`#" . str_replace("&amp;", "&", HTMLEntities($row[comment])) . "`3\"`0`n";
            }
        }
        if ($message == "X") {
            $op[$i] = "`0({$row['section']}) " . $op[$i];
        }
        if ($row['postdate'] >= $session['user']['recentcomments']) {
            $op[$i] = "<img src='images/new.png' alt='&gt;' width='3' height='5' align='middle'> " . $op[$i];
        }
        addnav("", $link);
    }
    $i--;
    $outputcomments = array();
    $sect = "x";
    for (; $i >= 0; $i--) {
        $out = "";
        if ($session['user']['superuser'] >= 3 && $message == "X") {
            $out .= "`0[ <a href='superuser.php?op=commentdelete&commentid={$commentids[$i]}&return=" . URLEncode($_SERVER['REQUEST_URI']) . "'>Del</a> ]&nbsp;";
            addnav("", "superuser.php?op=commentdelete&commentid={$commentids[$i]}&return=" . URLEncode($_SERVER['REQUEST_URI']));
            $matches = array();
            preg_match("/[(][^)]*[)]/", $op[$i], $matches);
            $sect = $matches[0];
        }
        //output($op[$i],true);
        $out .= $op[$i];
        if (!is_array($outputcomments[$sect])) {
            $outputcomments[$sect] = array();
        }
        array_push($outputcomments[$sect], $out);
    }
    ksort($outputcomments);
    reset($outputcomments);
    while (list($sec, $v) = each($outputcomments)) {
        if ($sec != "x") {
            output("`n`b{$sec}`b`n");
        }
        reset($v);
        while (list($key, $val) = each($v)) {
            output($val, true);
        }
    }
    if ($session['user']['loggedin']) {
        if ($counttoday < $limit / 2 || $session['user']['superuser'] >= 2) {
            if ($message != "X") {
                if ($talkline != "says") {
                    $tll = strlen($talkline) + 11;
                } else {
                    $tll = 0;
                }
                output("<form action=\"{$REQUEST_URI}\" method='POST'>`@{$message}`n.<input name='insertcommentary[{$section}]' size='40' maxlength='" . (200 - $tll) . "'><input type='hidden' name='talkline' value='{$talkline}'><input type='hidden' name='section' value='{$section}'><input type='submit' class='button' value='Add'>`n" . (round($limit / 2, 0) - $counttoday < 3 ? "`)(You have " . (round($limit / 2, 0) - $counttoday) . " posts left today)" : "") . "`0`n</form>", true);
                addnav("", $REQUEST_URI);
            }
        } else {
            output("`@{$message}`nSorry, you've exhausted your posts in this section for now.`0`n");
        }
    }
    if (db_num_rows($result) >= $limit) {
        $req = preg_replace("'[&]?c(omscroll)?=([[:digit:]-])*'", "", $REQUEST_URI) . "&comscroll=" . ($com + 1);
        //$req = substr($REQUEST_URI,0,strpos($REQUEST_URI,"c="))."&c=$HTTP_GET_VARS[c]"."&comscroll=".($com+1);
        $req = str_replace("?&", "?", $req);
        if (!strpos($req, "?")) {
            $req = str_replace("&", "?", $req);
        }
        output("<a href=\"{$req}\">&lt;&lt; Previous</a>", true);
        addnav("", $req);
    }
    $req = preg_replace("'[&]?c(omscroll)?=([[:digit:]]|-)*'", "", $REQUEST_URI) . "&comscroll=0";
    //$req = substr($REQUEST_URI,0,strpos($REQUEST_URI,"c="))."&c=$HTTP_GET_VARS[c]"."&comscroll=".($com-1);
    $req = str_replace("?&", "?", $req);
    if (!strpos($req, "?")) {
        $req = str_replace("&", "?", $req);
    }
    output("&nbsp;<a href=\"{$req}\">Refresh</a>&nbsp;", true);
    addnav("", $req);
    if ($com > 0) {
        $req = preg_replace("'[&]?c(omscroll)?=([[:digit:]]|-)*'", "", $REQUEST_URI) . "&comscroll=" . ($com - 1);
        //$req = substr($REQUEST_URI,0,strpos($REQUEST_URI,"c="))."&c=$HTTP_GET_VARS[c]"."&comscroll=".($com-1);
        $req = str_replace("?&", "?", $req);
        if (!strpos($req, "?")) {
            $req = str_replace("&", "?", $req);
        }
        output(" <a href=\"{$req}\">Next &gt;&gt;</a>", true);
        addnav("", $req);
    }
    db_free_result($result);
}
示例#20
0
文件: icontact.php 项目: grlf/eyedock
 public function getContactId($email)
 {
     $res = $this->callResource('/contacts/?email=' . URLEncode($email));
     $contactId = null;
     if (!empty($res['contacts'][0]['contactId'])) {
         $contactId = $res['contacts'][0]['contactId'];
     }
     return $contactId;
 }
示例#21
0
	}
}elseif($_GET[op]=="delban"){
	$sql = "DELETE FROM bans WHERE ipfilter = '$_GET[ipfilter]' AND uniqueid = '$_GET[uniqueid]'";
	db_query($sql);
	//output($sql);
	redirect("user.php?op=removeban");
}elseif($_GET[op]=="removeban"){	
	db_query("DELETE FROM bans WHERE banexpire < \"".date("Y-m-d")."\" AND banexpire>'0000-00-00'");
	
	$sql = "SELECT * FROM bans ORDER BY banexpire";
	$result = db_query($sql) or die(db_error(LINK));
	output("<table><tr><td>Ops</td><td>IP/ID</td><td>Duration</td><td>Message</td><td>Affects:</td></tr>",true);
	for ($i=0;$i<db_num_rows($result);$i++){
		$row = db_fetch_assoc($result);
		output("<tr class='".($i%2?"trlight":"trdark")."'><td><a href='user.php?op=delban&ipfilter=".URLEncode($row[ipfilter])."&uniqueid=".URLEncode($row[uniqueid])."'>Lift&nbsp;ban</a>",true);
		addnav("","user.php?op=delban&ipfilter=".URLEncode($row[ipfilter])."&uniqueid=".URLEncode($row[uniqueid]));
		output("</td><td>",true);
		output($row[ipfilter]);
		output($row[uniqueid]);
		output("</td><td>",true);
		$expire=round((strtotime($row[banexpire])-strtotime("now")) / 86400,0)." days";
		if (substr($expire,0,2)=="1 ") $expire="1 day";
		if (date("Y-m-d",strtotime($row[banexpire])) == date("Y-m-d")) $expire="Today";
		if (date("Y-m-d",strtotime($row[banexpire])) == date("Y-m-d",strtotime("1 day"))) $expire="Tomorrow";
		if ($row[banexpire]=="0000-00-00") $expire="Never";
		output($expire);
		output("</td><td>",true);
		output($row[banreason]);
		output("</td><td>",true);
		$sql = "SELECT DISTINCT accounts.name FROM bans, accounts WHERE (ipfilter='".addslashes($row['ipfilter'])."' AND bans.uniqueid='".addslashes($row['uniqueid'])."') AND ((substring(accounts.lastip,1,length(ipfilter))=ipfilter AND ipfilter<>'') OR (bans.uniqueid=accounts.uniqueid AND bans.uniqueid<>''))";
		$r = db_query($sql);
示例#22
0
    $sql .= " WHERE (file_active=1)";
} else {
    query_db("UPDATE tag SET tag_requests = tag_requests+1 WHERE tag.tag='{$tag}'");
    $sql .= " INNER JOIN file_tag ON (file.file_id = file_tag.file_id)";
    $sql .= " WHERE (file_active=1) AND (file_tag.tag='{$tag}')";
}
$sql .= " GROUP BY file.file_id ORDER BY popularity DESC;";
$total = 0;
$result = query_db($sql);
$count = mysqli_num_rows($result);
echo "<h2> {$count} tutorials</h2>";
while ($record = mysqli_fetch_array($result)) {
    $file_id = $record["file_id"];
    $file_author = $record["file_author"];
    $file = $record["file_path"] . "/" . $record["file_name"] . ".xml";
    $url = $htURL . 'run/elcid.html?file=' . URLEncode($file);
    $js = "runTutorial('{$file}'); return false;";
    $tagset = $record["tagset"];
    if (!$tagset) {
        $tagset = "no tags";
    }
    ?>
         <div class="panel col-md-3" style="margin:5px;">
            <h3><a onClick="<?php 
    echo $js;
    ?>
" class="label label-primary" href='<?php 
    echo $url;
    ?>
'>
               <?php 
if ($_GET['op']=="rebuild"){
	$sql = "SELECT * FROM referers";
	$result = db_query($sql);
	for ($i=0;$i<db_num_rows($result);$i++){
		$row = db_fetch_assoc($result);
		$site = str_replace("http://","",$row['uri']);
		if (strpos($site,"/")) $site = substr($site,0,strpos($site,"/"));
		$sql = "UPDATE referers SET site='".addslashes($site)."' WHERE refererid='{$row['refererid']}'";
		db_query($sql);
	}
}
addnav("G?Return to the Grotto","superuser.php");
addnav("M?Return to the Mundane","village.php");
addnav("Referer Options");
addnav("",$_SERVER['REQUEST_URI']);
addnav("Refresh","referers.php?sort=".URLEncode($_GET['sort'])."");
addnav("C?Sort by Count","referers.php?sort=count".($_GET['sort']=="count DESC"?"":"+DESC"));
addnav("U?Sort by URL","referers.php?sort=uri".($_GET['sort']=="uri"?"+DESC":""));
addnav("T?Sort by Time","referers.php?sort=last".($_GET['sort']=="last DESC"?"":"+DESC"));

addnav("Rebuild Sites","referers.php?op=rebuild");

page_header("Referers");
$order = "count DESC";
if ($_GET['sort']!="") $order=$_GET['sort'];
$sql = "SELECT SUM(count) AS count, MAX(last) AS last,site FROM referers GROUP BY site ORDER BY $order";
output("<table><tr><td>Count</td><td>Last</td><td>URL</td></tr>",true);
$result = db_query($sql);
for ($i=0;$i<db_num_rows($result);$i++){
	$row = db_fetch_assoc($result);
	output("<tr class='trdark'><td valign='top'>`b",true);
示例#24
0
            }
            if ($rec_n['secret'] == 2) {
                echo ' (soukromá)';
            }
            ?>
</h4>
				<div><?php 
            echo StripSlashes($rec_n['note']);
            ?>
</div>
				<span class="poznamka-edit-buttons"><?php 
            if ($rec_n['iduser'] == $usrinfo['id'] || $usrinfo['right_text']) {
                echo '<a class="edit" href="editnote.php?rid=' . $rec_n['id'] . '&amp;itemid=' . $_REQUEST['rid'] . '&amp;idtable=4" title="upravit"><span class="button-text">upravit</span></a> ';
            }
            if ($rec_n['iduser'] == $usrinfo['id'] || $usrinfo['right_power']) {
                echo '<a class="delete" href="procnote.php?deletenote=' . $rec_n['id'] . '&amp;itemid=' . $_REQUEST['rid'] . '&amp;backurl=' . URLEncode('editactrep.php?rid=' . $_REQUEST['rid']) . '" onclick="' . "return confirm('Opravdu smazat poznámku &quot;" . StripSlashes($rec_n['title']) . "&quot; náležící k hlášení?');" . '" title="smazat"><span class="button-text">smazat</span></a>';
            }
            ?>
				</span>
			</div>
			<!-- end of .poznamka -->
		<?php 
        }
        if ($i != 0) {
            ?>
		</div>
		<!-- end of #poznamky -->
		<?php 
        } else {
            ?>
<br />
示例#25
0
 }
 if ($pageoffset > 0) {
     $pageoffset--;
 }
 $pageoffset *= $newsperpage;
 $sql = "SELECT * FROM news WHERE newsdate='" . date("Y-m-d", $timestamp) . "' ORDER BY newsid DESC LIMIT {$pageoffset},{$newsperpage}";
 $result = db_query($sql) or die(db_error(LINK));
 page_header("TDS News");
 $date = date("D, M j, Y", $timestamp);
 output("`c`b`!News for {$date}" . ($totaltoday > $newsperpage ? " (Items " . ($pageoffset + 1) . " - " . min($pageoffset + $newsperpage, $totaltoday) . " of {$totaltoday})" : "") . "`c`b`0");
 for ($i = 0; $i < db_num_rows($result); $i++) {
     $row = db_fetch_assoc($result);
     output("`c`2-=-`@=-=`2-=-`@=-=`2-=-`@=-=`2-=-`0`c");
     if ($session['user']['superuser'] >= 3) {
         output("[ <a href='superuser.php?op=newsdelete&newsid={$row['newsid']}&return=" . URLEncode($_SERVER['REQUEST_URI']) . "'>Del</a> ]&nbsp;", true);
         addnav("", "superuser.php?op=newsdelete&newsid={$row['newsid']}&return=" . URLEncode($_SERVER['REQUEST_URI']));
     }
     output("{$row['newstext']}`n");
 }
 if (db_num_rows($result) == 0) {
     output("`c`2-=-`@=-=`2-=-`@=-=`2-=-`@=-=`2-=-`0`c");
     output("`1`b`c Nothing of note happened this day.  All in all a boring day. `c`b`0");
 }
 output("`c`2-=-`@=-=`2-=-`@=-=`2-=-`@=-=`2-=-`0`c");
 if ($totaltoday > $newsperpage) {
     addnav("Today's news");
     for ($i = 0; $i < $totaltoday; $i += $newsperpage) {
         addnav("Page " . ($i / $newsperpage + 1), "news.php?offset={$offset}&page=" . ($i / $newsperpage + 1));
     }
     addnav("Other");
 }
 case "bio":
     output("`bNatter Overview`b`n`n");
     $sql = "SELECT DISTINCT section FROM " . db_prefix("commentary") . " WHERE section LIKE 'bio%' ORDER BY section DESC";
     $result = db_query($sql);
     $locations = array();
     while ($row = db_fetch_assoc($result)) {
         $locations[] = $row['section'];
     }
     foreach ($locations as $key => $loc) {
         $acctid = substr($loc, 4);
         $login = moderate_getlogin($acctid);
         if ($login == "Unknown") {
             output("`b%s`b`n", $loc);
         } else {
             //				output("`b%s`0`b`n",$login);
             $link = "bio.php?char=" . $acctid . "&ret=" . URLEncode($_SERVER['REQUEST_URI']);
             output("<a href=\"{$link}\">`b{$login}`b`n</a>", true);
             addnav("", $link);
         }
         viewcommentary($loc, "Intervene:", 25);
         rawoutput("<hr style=\"border-bottom: 1px dotted #333333; border-top: 0; border-left: 0; border-right: 0;\" />");
     }
     break;
 case "dwell":
     output("`bDwellings Lookup`b`n`n");
     output("Enter map coordinates:`n");
     rawoutput("<form action='moderate.php?op=listdwell' method='POST'>");
     // Note: Width 2 means a 2-digit number. Set the default location to 13,11 Improbable Central.
     rawoutput("X = <input name='mapX' width='2'> , Y = <input name='mapY' width='2'><br/><br/>");
     //		rawoutput("X = <input name='mapX' width='2'> , Y = <input name='mapY' width='2'>, Z = <input name='mapZ' width='2' value='1'><br/><br/>");
     rawoutput("<input type='submit' class='button' value='" . translate_inline("List Dwellings") . "'>");
示例#27
0
 public function down($file_id)
 {
     $file_id = f_decode($file_id);
     $File = M("File")->find($file_id);
     $filepath = C("SAVE_PATH") . $File['savename'];
     $filePath = realpath($filepath);
     $fp = fopen($filePath, 'rb');
     $ext = $File['ext'];
     //$filePath = realpath($filepath);
     $query = file_get_contents($filepath);
     //$query = file_get_contents($filepath);
     $filetype['chm'] = 'application/octet-stream';
     $filetype['ppt'] = 'application/vnd.ms-powerpoint';
     $filetype['xls'] = 'application/vnd.ms-excel';
     $filetype['doc'] = 'application/msword';
     $filetype['pptx'] = 'application/vnd.ms-powerpoint';
     $filetype['xlsx'] = 'application/vnd.ms-excel';
     $filetype['docx'] = 'application/msword';
     $filetype['exe'] = 'application/octet-stream';
     $filetype['rar'] = 'application/octet-stream';
     $filetype['js'] = "javascript/js";
     $filetype['css'] = "text/css";
     $filetype['hqx'] = "application/mac-binhex40";
     $filetype['bin'] = "application/octet-stream";
     $filetype['oda'] = "application/oda";
     $filetype['pdf'] = "application/pdf";
     $filetype['ai'] = "application/postsrcipt";
     $filetype['eps'] = "application/postsrcipt";
     $filetype['es'] = "application/postsrcipt";
     $filetype['rtf'] = "application/rtf";
     $filetype['mif'] = "application/x-mif";
     $filetype['csh'] = "application/x-csh";
     $filetype['dvi'] = "application/x-dvi";
     $filetype['hdf'] = "application/x-hdf";
     $filetype['nc'] = "application/x-netcdf";
     $filetype['cdf'] = "application/x-netcdf";
     $filetype['latex'] = "application/x-latex";
     $filetype['ts'] = "application/x-troll-ts";
     $filetype['src'] = "application/x-wais-source";
     $filetype['zip'] = "application/zip";
     $filetype['bcpio'] = "application/x-bcpio";
     $filetype['cpio'] = "application/x-cpio";
     $filetype['gtar'] = "application/x-gtar";
     $filetype['shar'] = "application/x-shar";
     $filetype['sv4cpio'] = "application/x-sv4cpio";
     $filetype['sv4crc'] = "application/x-sv4crc";
     $filetype['tar'] = "application/x-tar";
     $filetype['ustar'] = "application/x-ustar";
     $filetype['man'] = "application/x-troff-man";
     $filetype['sh'] = "application/x-sh";
     $filetype['tcl'] = "application/x-tcl";
     $filetype['tex'] = "application/x-tex";
     $filetype['texi'] = "application/x-texinfo";
     $filetype['texinfo'] = "application/x-texinfo";
     $filetype['t'] = "application/x-troff";
     $filetype['tr'] = "application/x-troff";
     $filetype['roff'] = "application/x-troff";
     $filetype['shar'] = "application/x-shar";
     $filetype['me'] = "application/x-troll-me";
     $filetype['ts'] = "application/x-troll-ts";
     $filetype['gif'] = "image/gif";
     $filetype['jpeg'] = "image/pjpeg";
     $filetype['jpg'] = "image/pjpeg";
     $filetype['jpe'] = "image/pjpeg";
     $filetype['ras'] = "image/x-cmu-raster";
     $filetype['pbm'] = "image/x-portable-bitmap";
     $filetype['ppm'] = "image/x-portable-pixmap";
     $filetype['xbm'] = "image/x-xbitmap";
     $filetype['xwd'] = "image/x-xwindowdump";
     $filetype['ief'] = "image/ief";
     $filetype['tif'] = "image/tiff";
     $filetype['tiff'] = "image/tiff";
     $filetype['pnm'] = "image/x-portable-anymap";
     $filetype['pgm'] = "image/x-portable-graymap";
     $filetype['rgb'] = "image/x-rgb";
     $filetype['xpm'] = "image/x-xpixmap";
     $filetype['txt'] = "text/plain";
     $filetype['c'] = "text/plain";
     $filetype['cc'] = "text/plain";
     $filetype['h'] = "text/plain";
     $filetype['html'] = "text/html";
     $filetype['htm'] = "text/html";
     $filetype['htl'] = "text/html";
     $filetype['rtx'] = "text/richtext";
     $filetype['etx'] = "text/x-setext";
     $filetype['tsv'] = "text/tab-separated-values";
     $filetype['mpeg'] = "video/mpeg";
     $filetype['mpg'] = "video/mpeg";
     $filetype['mpe'] = "video/mpeg";
     $filetype['avi'] = "video/x-msvideo";
     $filetype['qt'] = "video/quicktime";
     $filetype['mov'] = "video/quicktime";
     $filetype['moov'] = "video/quicktime";
     $filetype['movie'] = "video/x-sgi-movie";
     $filetype['au'] = "audio/basic";
     $filetype['snd'] = "audio/basic";
     $filetype['wav'] = "audio/x-wav";
     $filetype['aif'] = "audio/x-aiff";
     $filetype['aiff'] = "audio/x-aiff";
     $filetype['aifc'] = "audio/x-aiff";
     $filetype['swf'] = "application/x-shockwave-flash";
     $ua = $_SERVER["HTTP_USER_AGENT"];
     if (!preg_match("/MSIE/", $ua)) {
         header("Content-Length: " . filesize($filePath));
         header("Content-type:" . $filetype[$ext]);
         header("Content-Length: " . filesize($filePath));
         header("Accept-Ranges: bytes");
         header("Accept-Length: " . filesize($filePath));
     }
     header("Content-Disposition:attachment;filename =" . str_ireplace('+', '%20', URLEncode($File['name'])));
     header('Cache-Control:must-revalidate, post-check=0,pre-check=0');
     header('Expires:     0');
     header('Pragma:     public');
     //echo $query;
     fpassthru($fp);
     exit;
 }
function viewcommentary($section, $message = "Interject your own commentary?", $limit = 10, $talkline = "says", $schema = false)
{
    global $session, $REQUEST_URI, $doublepost, $translation_namespace;
    global $emptypost;
    // *** DRAGONBG.COM CORE PATCH START ***
    if ($section) {
        rawoutput("<a name='{$section}'></a>");
        // Let's add a hook for modules to block commentary sections
        $args = modulehook("blockcommentarea", array("section" => $section));
        if (isset($args['block']) && $args['block'] == "yes") {
            return;
        }
    }
    // *** DRAGONBG.COM CORE PATCH END ***
    if ($schema === false) {
        $schema = $translation_namespace;
    }
    tlschema("commentary");
    $nobios = array("motd.php" => true);
    if (!array_key_exists(basename($_SERVER['SCRIPT_NAME']), $nobios)) {
        $nobios[basename($_SERVER['SCRIPT_NAME'])] = false;
    }
    if ($nobios[basename($_SERVER['SCRIPT_NAME'])]) {
        $linkbios = false;
    } else {
        $linkbios = true;
    }
    if ($message == "X") {
        $linkbios = true;
    }
    if ($doublepost) {
        output("`\$`bDouble post?`b`0`n");
    }
    if ($emptypost) {
        output("`\$`bWell, they say silence is a virtue.`b`0`n");
    }
    // *** DRAGONBG.COM CORE PATCH START ***
    $clanrankcolors = array(CLAN_APPLICANT => "`!", CLAN_MEMBER => "`#", CLAN_OFFICER => "`^", CLAN_LEADER => "`&", CLAN_FOUNDER => "`\$");
    $args = modulehook("clanrankcolors", array("clanrankcolors" => $clanrankcolors, "clanid" => $session['user']['clanid']));
    $clanrankcolors = $args['clanrankcolors'];
    // *** DRAGONBG.COM CORE PATCH END ***
    // Needs to be here because scrolling through the commentary pages, entering a bio, then scrolling again forward
    // then re-entering another bio will lead to $com being smaller than 0 and this will lead to an SQL error later on.
    $com = (int) httpget("comscroll");
    if ($com < 0) {
        $com = 0;
    }
    $cc = false;
    if (httpget("comscroll") !== false && (int) $session['lastcom'] == $com + 1) {
        $cid = (int) $session['lastcommentid'];
    } else {
        $cid = 0;
    }
    $session['lastcom'] = $com;
    if ($com > 0 || $cid > 0) {
        // Find newly added comments.
        // *** DRAGONBG.COM CORE PATCH START ***
        $sql = "SELECT COUNT(commentid) AS newadded FROM " . db_prefix("commentary") . " LEFT JOIN " . db_prefix("accounts") . " ON " . db_prefix("accounts") . ".acctid = " . db_prefix("commentary") . ".author WHERE " . ($section ? "section='{$section}' AND " : '') . "(" . db_prefix("accounts") . ".locked=0 or " . db_prefix('accounts') . ".locked is null) AND commentid > '{$cid}'";
        $result = db_query($sql);
        $row = db_fetch_assoc($result);
        $newadded = $row['newadded'];
        // *** DRAGONBG.COM CORE PATCH END ***
    } else {
        $newadded = 0;
    }
    $commentbuffer = array();
    if ($cid == 0) {
        $sql = "SELECT " . db_prefix("commentary") . ".*, " . db_prefix("accounts") . ".name, " . db_prefix("accounts") . ".acctid, " . db_prefix("accounts") . ".clanrank, " . db_prefix("clans") . ".clanshort FROM " . db_prefix("commentary") . " LEFT JOIN " . db_prefix("accounts") . " ON " . db_prefix("accounts") . ".acctid = " . db_prefix("commentary") . ".author LEFT JOIN " . db_prefix("clans") . " ON " . db_prefix("clans") . ".clanid=" . db_prefix("accounts") . ".clanid WHERE " . ($section ? "section='{$section}' AND " : '') . "( " . db_prefix("accounts") . ".locked=0 OR " . db_prefix("accounts") . ".locked is null ) " . "ORDER BY commentid DESC LIMIT " . $com * $limit . ",{$limit}";
        // *** DRAGONBG.COM CORE PATCH END ***
        if ($com == 0 && strstr($_SERVER['REQUEST_URI'], "/moderate.php") !== $_SERVER['REQUEST_URI']) {
            $result = db_query_cached($sql, "comments-{$section}");
        } else {
            $result = db_query($sql);
        }
        while ($row = db_fetch_assoc($result)) {
            $commentbuffer[] = $row;
        }
    } else {
        // *** DRAGONBG.COM CORE PATCH START ***
        $sql = "SELECT " . db_prefix("commentary") . ".*, " . db_prefix("accounts") . ".name, " . db_prefix("accounts") . ".acctid, " . db_prefix("accounts") . ".clanrank, " . db_prefix("clans") . ".clanshort FROM " . db_prefix("commentary") . " LEFT JOIN " . db_prefix("accounts") . " ON " . db_prefix("accounts") . ".acctid = " . db_prefix("commentary") . ".author LEFT JOIN " . db_prefix("clans") . " ON " . db_prefix("clans") . ".clanid=" . db_prefix("accounts") . ".clanid WHERE " . ($section ? "section='{$section}' AND " : '') . "( " . db_prefix("accounts") . ".locked=0 OR " . db_prefix("accounts") . ".locked is null ) " . "AND commentid > '{$cid}' " . "ORDER BY commentid ASC LIMIT {$limit}";
        // *** DRAGONBG.COM CORE PATCH END ***
        $result = db_query($sql);
        while ($row = db_fetch_assoc($result)) {
            $commentbuffer[] = $row;
        }
        $commentbuffer = array_reverse($commentbuffer);
    }
    $rowcount = count($commentbuffer);
    if ($rowcount > 0) {
        $session['lastcommentid'] = $commentbuffer[0]['commentid'];
    }
    $counttoday = 0;
    $commentbuffer = modulehook("pagecommentary", $commentbuffer);
    // debug($commentbuffer);
    for ($i = 0; $i < $rowcount; $i++) {
        $row = $commentbuffer[$i];
        $row['comment'] = comment_sanitize($row['comment']);
        $commentids[$i] = $row['commentid'];
        if (date("Y-m-d", strtotime($row['postdate'])) == date("Y-m-d")) {
            if ($row['name'] == $session['user']['name']) {
                $counttoday++;
            }
        }
        $x = 0;
        $ft = "";
        for ($x = 0; strlen($ft) < 5 && $x < strlen($row['comment']); $x++) {
            if (substr($row['comment'], $x, 1) == "`" && strlen($ft) == 0) {
                $x++;
            } else {
                $ft .= substr($row['comment'], $x, 1);
            }
        }
        $link = "bio.php?char=" . $row['acctid'] . "&ret=" . URLEncode($_SERVER['REQUEST_URI']);
        if (substr($ft, 0, 2) == "::") {
            $ft = substr($ft, 0, 2);
        } elseif (substr($ft, 0, 1) == ":") {
            $ft = substr($ft, 0, 1);
        } elseif (substr($ft, 0, 3) == "/me") {
            $ft = substr($ft, 0, 3);
        }
        if ($row['clanrank']) {
            $row['name'] = ($row['clanshort'] > "" ? "{$clanrankcolors[$row['clanrank']]}&lt;`2{$row['clanshort']}{$clanrankcolors[$row['clanrank']]}&gt; `&" : "") . $row['name'];
        }
        if ($ft == "::" || $ft == "/me" || $ft == ":") {
            $x = strpos($row['comment'], $ft);
            if ($x !== false) {
                if ($linkbios) {
                    $op[$i] = str_replace("&amp;", "&", htmlentities(substr($row['comment'], 0, $x), ENT_COMPAT, getsetting("charset", "ISO-8859-1"))) . "`0<a href='{$link}' style='text-decoration: none'>\n`&{$row['name']}`0</a>\n`& " . str_replace("&amp;", "&", htmlentities(substr($row['comment'], $x + strlen($ft)), ENT_COMPAT, getsetting("charset", "ISO-8859-1"))) . "`0`n";
                } else {
                    $op[$i] = str_replace("&amp;", "&", htmlentities(substr($row['comment'], 0, $x), ENT_COMPAT, getsetting("charset", "ISO-8859-1"))) . "`0`&{$row['name']}`0`& " . str_replace("&amp;", "&", htmlentities(substr($row['comment'], $x + strlen($ft)), ENT_COMPAT, getsetting("charset", "ISO-8859-1"))) . "`0`n";
                }
                $rawc[$i] = str_replace("&amp;", "&", htmlentities(substr($row['comment'], 0, $x), ENT_COMPAT, getsetting("charset", "ISO-8859-1"))) . "`0`&{$row['name']}`0`& " . str_replace("&amp;", "&", htmlentities(substr($row['comment'], $x + strlen($ft)), ENT_COMPAT, getsetting("charset", "ISO-8859-1"))) . "`0`n";
            }
        }
        if ($ft == "/game" && !$row['name']) {
            $x = strpos($row['comment'], $ft);
            if ($x !== false) {
                $op[$i] = str_replace("&amp;", "&", htmlentities(substr($row['comment'], 0, $x), ENT_COMPAT, getsetting("charset", "ISO-8859-1"))) . "`0`&" . str_replace("&amp;", "&", htmlentities(substr($row['comment'], $x + strlen($ft)), ENT_COMPAT, getsetting("charset", "ISO-8859-1"))) . "`0`n";
            }
        }
        if (!isset($op) || !is_array($op)) {
            $op = array();
        }
        if (!array_key_exists($i, $op) || $op[$i] == "") {
            if ($linkbios) {
                $op[$i] = "`0<a href='{$link}' style='text-decoration: none'>`&{$row['name']}`0</a>`3 says, \"`#" . str_replace("&amp;", "&", htmlentities($row['comment'], ENT_COMPAT, getsetting("charset", "ISO-8859-1"))) . "`3\"`0`n";
            } elseif (substr($ft, 0, 5) == '/game' && !$row['name']) {
                $op[$i] = str_replace("&amp;", "&", htmlentities($row['comment'], ENT_COMPAT, getsetting("charset", "ISO-8859-1")));
            } else {
                $op[$i] = "`&{$row['name']}`3 says, \"`#" . str_replace("&amp;", "&", htmlentities($row['comment'], ENT_COMPAT, getsetting("charset", "ISO-8859-1"))) . "`3\"`0`n";
            }
            $rawc[$i] = "`&{$row['name']}`3 says, \"`#" . str_replace("&amp;", "&", htmlentities($row['comment'], ENT_COMPAT, getsetting("charset", "ISO-8859-1"))) . "`3\"`0`n";
        }
        if (!array_key_exists('timestamp', $session['user']['prefs'])) {
            $session['user']['prefs']['timestamp'] = 0;
        }
        $session['user']['prefs']['timeoffset'] = round($session['user']['prefs']['timeoffset'], 1);
        if ($session['user']['prefs']['timestamp'] == 1) {
            if (!isset($session['user']['prefs']['timeformat'])) {
                $session['user']['prefs']['timeformat'] = "[m/d h:ia]";
            }
            $time = strtotime($row['postdate']) + $session['user']['prefs']['timeoffset'] * 60 * 60;
            $s = date("`7" . $session['user']['prefs']['timeformat'] . "`0 ", $time);
            $op[$i] = $s . $op[$i];
        } elseif ($session['user']['prefs']['timestamp'] == 2) {
            $s = reltime(strtotime($row['postdate']));
            $op[$i] = "`7({$s})`0 " . $op[$i];
        }
        if ($message == "X") {
            $op[$i] = "`0({$row['section']}) " . $op[$i];
        }
        if ($row['postdate'] >= $session['user']['recentcomments']) {
            $op[$i] = "<img src='images/new.gif' alt='&gt;' width='3' height='5' align='absmiddle'> " . $op[$i];
        }
        addnav("", $link);
        $auth[$i] = $row['author'];
        if (isset($rawc[$i])) {
            $rawc[$i] = full_sanitize($rawc[$i]);
            $rawc[$i] = htmlentities($rawc[$i], ENT_QUOTES, getsetting("charset", "ISO-8859-1"));
        }
    }
    $i--;
    $outputcomments = array();
    $sect = "x";
    $moderating = false;
    if ($session['user']['superuser'] & SU_EDIT_COMMENTS && $message == "X") {
        $moderating = true;
    }
    $del = translate_inline("Del");
    $scriptname = substr($_SERVER['SCRIPT_NAME'], strrpos($_SERVER['SCRIPT_NAME'], "/") + 1);
    $pos = strpos($_SERVER['REQUEST_URI'], "?");
    $return = $scriptname . ($pos == false ? "" : substr($_SERVER['REQUEST_URI'], $pos));
    $one = strstr($return, "?") == false ? "?" : "&";
    for (; $i >= 0; $i--) {
        $out = "";
        if ($moderating) {
            if ($session['user']['superuser'] & SU_EDIT_USERS) {
                $out .= "`0[ <input type='checkbox' name='comment[{$commentids[$i]}]'> | <a href='user.php?op=setupban&userid=" . $auth[$i] . "&reason=" . rawurlencode($rawc[$i]) . "'>Ban</a> ]&nbsp;";
                addnav("", "user.php?op=setupban&userid={$auth[$i]}&reason=" . rawurlencode($rawc[$i]));
            } else {
                $out .= "`0[ <input type='checkbox' name='comment[{$commentids[$i]}]'> ]&nbsp;";
            }
            $matches = array();
            preg_match("/[(]([^)]*)[)]/", $op[$i], $matches);
            $sect = trim($matches[1]);
            if (substr($sect, 0, 5) != "clan-" || $sect == $section) {
                if (substr($sect, 0, 4) != "pet-") {
                    $out .= $op[$i];
                    if (!isset($outputcomments[$sect]) || !is_array($outputcomments[$sect])) {
                        $outputcomments[$sect] = array();
                    }
                    array_push($outputcomments[$sect], $out);
                }
            }
        } else {
            if ($session['user']['superuser'] & SU_EDIT_COMMENTS) {
                $out .= "`2[<a href='" . $return . $one . "removecomment={$commentids[$i]}&section={$section}&returnpath=" . URLEncode($return) . "'>{$del}</a>`2]`0&nbsp;";
                addnav("", $return . $one . "removecomment={$commentids[$i]}&section={$section}&returnpath=" . URLEncode($return) . "");
            }
            $out .= $op[$i];
            if (!array_key_exists($sect, $outputcomments) || !is_array($outputcomments[$sect])) {
                $outputcomments[$sect] = array();
            }
            array_push($outputcomments[$sect], $out);
        }
    }
    if ($moderating) {
        $scriptname = substr($_SERVER['SCRIPT_NAME'], strrpos($_SERVER['SCRIPT_NAME'], "/") + 1);
        addnav("", "{$scriptname}?op=commentdelete&return=" . URLEncode($_SERVER['REQUEST_URI']));
        $mod_Del1 = htmlentities(translate_inline("Delete Checked Comments"), ENT_COMPAT, getsetting("charset", "ISO-8859-1"));
        $mod_Del2 = htmlentities(translate_inline("Delete Checked & Ban (3 days)"), ENT_COMPAT, getsetting("charset", "ISO-8859-1"));
        $mod_Del_confirm = addslashes(htmlentities(translate_inline("Are you sure you wish to ban this user and have you specified the exact reason for the ban, i.e. cut/pasted their offensive comments?"), ENT_COMPAT, getsetting("charset", "ISO-8859-1")));
        $mod_reason = translate_inline("Reason:");
        $mod_reason_desc = htmlentities(translate_inline("Banned for comments you posted."), ENT_COMPAT, getsetting("charset", "ISO-8859-1"));
        // *** DRAGONBG.COM CORE PATCH START ***
        output_notl("<form action='{$scriptname}?op=commentdelete&return=" . URLEncode($_SERVER['REQUEST_URI']) . "' method='POST' id='comments'>", true);
        // *** DRAGONBG.COM CORE PATCH END ***
        output_notl("<input type='submit' class='button' value=\"{$mod_Del1}\">", true);
        output_notl("<input type='submit' class='button' name='delnban' value=\"{$mod_Del2}\" onClick=\"return confirm('{$mod_Del_confirm}');\">", true);
        // *** DRAGONBG.COM CORE PATCH START ***
        $mod_checkall = htmlspecialchars(translate_inline("Check all"));
        // Check all - by Pr0t3ct0r
        output_notl('<script type="text/javascript">function checkall() { 
			var isChecked = document.getElementById("CheckAllID").checked 
			var f = document.getElementById("comments") 
			for (var i=0;i<f.length;i++) { 
			  if (f.elements[i].type == "checkbox"){ 
				  f.elements[i].checked = isChecked 
			  }
			} 
		}</script>', true);
        output_notl("<input type='checkbox' id='CheckAllID' onclick='checkall()' /> {$mod_checkall}", true);
        output_notl("`n{$mod_reason} <input name='reason0' id='reason0' size='40' value=\"{$mod_reason_desc}\" onChange=\"document.getElementById('reason').value=this.value;\">", true);
        // *** DRAGONBG.COM CORE PATCH END ***
    }
    //output the comments
    ksort($outputcomments);
    reset($outputcomments);
    $sections = commentarylocs();
    $needclose = 0;
    while (list($sec, $v) = each($outputcomments)) {
        if ($sec != "x") {
            output_notl("`n<hr><a href='moderate.php?area=%s'>`b`^%s`0`b</a>`n", $sec, isset($sections[$sec]) ? $sections[$sec] : "({$sec})", true);
            addnav("", "moderate.php?area={$sec}");
        }
        reset($v);
        while (list($key, $val) = each($v)) {
            $args = array('commentline' => $val, 'area' => $section);
            $args = modulehook("viewcommentary", $args);
            $val = $args['commentinfo'] . $args['commentline'];
            output_notl($val, true);
        }
    }
    $sql = "SELECT count(commentid) AS c FROM " . db_prefix("commentary") . " WHERE section='{$section}'";
    $r = db_query($sql);
    $val = db_fetch_assoc($r);
    $val = round($val['c'] / $limit + 0.5, 0) - 1;
    rawoutput("<table cellpadding=0 cellspacing=5 width=100%><tr><td valign=\"top\" width=50%>");
    // *** AJAX CHAT MOD START ***
    if (round($limit / 2, 0) - $counttoday < 3) {
        output("`)(You have %s posts left today)`n`0", round($limit / 2, 0) - $counttoday);
    }
    rawoutput('</div>');
    // *** AJAX CHAT MOD END ***
    if ($moderating && $needclose) {
        modulehook("}collapse");
        $needclose = 0;
    }
    if ($moderating) {
        output_notl("`n");
        rawoutput("<input type='submit' class='button' value=\"{$mod_Del1}\">");
        rawoutput("<input type='submit' class='button' name='delnban' value=\"{$mod_Del2}\" onClick=\"return confirm('{$mod_Del_confirm}');\">");
        output_notl("`n%s ", $mod_reason);
        // *** DRAGONBG.COM CORE PATCH START ***
        rawoutput("<input name='reason' size='40' id='reason' value=\"{$mod_reason_desc}\" onchange=\"document.getElementById('reason0').value=this.value;\">");
        // *** DRAGONBG.COM CORE PATCH END ***
        rawoutput("</form>");
        output_notl("`n");
    }
    if ($session['user']['loggedin']) {
        $args = modulehook("insertcomment", array("section" => $section));
        if (array_key_exists("mute", $args) && $args['mute'] && !($session['user']['superuser'] & SU_EDIT_COMMENTS)) {
            output_notl("%s", $args['mutemsg']);
        } elseif ($counttoday < $limit / 2 || $session['user']['superuser'] & ~SU_DOESNT_GIVE_GROTTO || !getsetting('postinglimit', 1)) {
            if ($message != "X") {
                $message = "`n`@{$message}`n";
                output($message);
                talkform($section, $talkline, $limit, $schema);
            }
        } else {
            $message = "`n`@{$message}`n";
            output($message);
            output("Sorry, you've exhausted your posts in this section for now.`0`n");
        }
    }
    $jump = false;
    if (!isset($session['user']['prefs']['nojump']) || $session['user']['prefs']['nojump'] == false) {
        $jump = true;
    }
    //new-style commentary display with page numbers
    if (!$cc) {
        db_free_result($result);
    }
    tlschema();
    if ($needclose) {
        modulehook("}collapse");
    }
    rawoutput("</td><td valign=\"top\" width=50%>");
    $nlink = comscroll_sanitize($REQUEST_URI);
    $nlink = str_replace("?&", "?", $nlink);
    if (!strpos($nlink, "?")) {
        $nlink = str_replace("&", "?", $nlink);
    }
    $nlink .= "&refresh=1";
    //reinstating back and forward links
    output_notl("`n");
    $prev = translate_inline("&lt;&lt;");
    $next = translate_inline("&gt;&gt;");
    if ($rowcount >= $limit || $cid > 0) {
        $req = comscroll_sanitize($REQUEST_URI) . "&comscroll=" . ($com + 1);
        $req = str_replace("?&", "?", $req);
        if (!strpos($req, "?")) {
            $req = str_replace("&", "?", $req);
        }
        $req .= "&refresh=1";
        if ($jump) {
            $req .= "#{$section}";
        }
        output_notl("<a href=\"{$req}\">{$prev}</a> ", true);
        addnav("", $req);
    }
    output_notl("<a href=\"{$nlink}\">Refresh Commentary</a>", true);
    if ($com > 0 || $cid > 0 && $newadded > $limit) {
        $req = comscroll_sanitize($REQUEST_URI) . "&comscroll=" . ($com - 1);
        $req = str_replace("?&", "?", $req);
        if (!strpos($req, "?")) {
            $req = str_replace("&", "?", $req);
        }
        $req .= "&refresh=1";
        if ($jump) {
            $req .= "#{$section}";
        }
        output_notl(" <a href=\"{$req}\">{$next}</a>", true);
        addnav("", $req);
    }
    //
    addnav("", $nlink);
    output("`n`n`0Jump to commentary page:");
    for ($i = $val; $i >= 0; $i--) {
        $nlink = comscroll_sanitize($REQUEST_URI) . "&comscroll=" . $i;
        $nlink = str_replace("?&", "?", $nlink);
        if (!strpos($nlink, "?")) {
            $nlink = str_replace("&", "?", $nlink);
        }
        $nlink .= "&refresh=1";
        if ($jump) {
            $nlink .= "#{$section}";
        }
        $ndisp = 1 + $val - $i;
        if (httpget('comscroll') != $i) {
            output_notl("<a href=\"{$nlink}\">{$ndisp}</a> ", true);
            addnav("", $nlink);
        } else {
            output_notl("`@{$ndisp}`0 ", true);
        }
    }
    modulehook("commentaryoptions");
    rawoutput("</td></tr></table");
    // *** AJAX CHAT MOD START ***
    modulehook("viewcommentaryfooter");
    // *** AJAX CHAT MOD END ***
}
$bauth = translate_inline("Ban Author");
$ipd = translate_inline("IP/ID");
$dur = translate_inline("Duration");
$mssg = translate_inline("Message");
$aff = translate_inline("Affects");
$l = translate_inline("Last");
rawoutput("<tr class='trhead'><td>{$ops}</td><td>{$bauth}</td><td>{$ipd}</td><td>{$dur}</td><td>{$mssg}</td><td>{$aff}</td><td>{$l}</td></tr>");
$i = 0;
while ($row = db_fetch_assoc($result)) {
    $liftban = translate_inline("Lift&nbsp;ban");
    $showuser = translate_inline("Click&nbsp;to&nbsp;show&nbsp;users");
    rawoutput("<tr class='" . ($i % 2 ? "trlight" : "trdark") . "'>");
    rawoutput("<td><a href='user.php?op=delban&ipfilter=" . URLEncode($row['ipfilter']) . "&uniqueid=" . URLEncode($row['uniqueid']) . "'>");
    output_notl("%s", $liftban, true);
    rawoutput("</a>");
    addnav("", "user.php?op=delban&ipfilter=" . URLEncode($row['ipfilter']) . "&uniqueid=" . URLEncode($row['uniqueid']));
    rawoutput("</td><td>");
    output_notl("`&%s`0", $row['banner']);
    rawoutput("</td><td>");
    output_notl("%s", $row['ipfilter']);
    output_notl("%s", $row['uniqueid']);
    rawoutput("</td><td>");
    // "43200" used so will basically round to nearest day rather than floor number of days
    $expire = sprintf_translate("%s days", round((strtotime($row['banexpire']) + 43200 - strtotime("now")) / 86400, 0));
    if (substr($expire, 0, 2) == "1 ") {
        $expire = translate_inline("1 day");
    }
    if (date("Y-m-d", strtotime($row['banexpire'])) == date("Y-m-d")) {
        $expire = translate_inline("Today");
    }
    if (date("Y-m-d", strtotime($row['banexpire'])) == date("Y-m-d", strtotime("1 day"))) {
function commentaryfooter($section, $message = "Interject your own commentary?", $limit = 25, $talkline = "says", $schema = false)
{
    global $session, $REQUEST_URI, $doublepost, $translation_namespace;
    global $emptypost;
    global $chatloc, $moderating, $bottomcid;
    //Output page jumpers
    $com = httpget('comscroll');
    if ($section == "all") {
        $sql = "SELECT count(commentid) AS c FROM " . db_prefix("commentary") . " WHERE section NOT LIKE 'dwelling%' AND section NOT LIKE 'clan%' AND section NOT LIKE 'pet-%'";
    } else {
        $sql = "SELECT count(commentid) AS c FROM " . db_prefix("commentary") . " WHERE section='{$section}'";
    }
    $r = db_query_cached($sql, "commentary/commentarycount_" . $section, 60);
    //$r = db_query($sql);
    $val = db_fetch_assoc($r);
    $rowcount = $val['c'];
    $val = round($val['c'] / $limit + 0.5, 0) - 1;
    $returnlink = URLEncode($_SERVER['REQUEST_URI']);
    $returnlink = URLEncode(buildcommentarylink("&frombio=true", $returnlink));
    $hook = array("section" => $section, "message" => $message, "talkline" => $talkline, "returnlink" => $returnlink);
    $hook = modulehook("commentary_talkform", $hook);
    $section = $hook['section'];
    $message = $hook['message'];
    $talkline = $hook['talkline'];
    if ($session['user']['loggedin']) {
        if ($message != "X") {
            $message = "`n`@{$message}`0`n";
            output($message, true);
            if (!$hook['blocktalkform']) {
                talkform($section, $talkline, $limit, $schema);
            }
        }
    }
    $jump = false;
    if (!isset($session['user']['prefs']['nojump']) || $session['user']['prefs']['nojump'] == false) {
        $jump = true;
    }
    //new-style commentary display with page numbers
    $nlink = buildcommentarylink("&refresh=1");
    //reinstating back and forward links
    output_notl("`n");
    $prev = translate_inline("`0&lt;&lt;");
    $next = translate_inline("`0&gt;&gt;");
    if ($rowcount >= $limit && $com != $val) {
        $req = buildcommentarylink("&comscroll=" . ($com + 1));
        output_notl("<a href=\"{$req}\">{$prev}</a> ", true);
        addnav("", $req);
    }
    $cplink = buildcommentarylink("&comscroll=" . $com . "&refresh=1");
    addnav("", $cplink);
    output_notl("`0<a href=\"{$cplink}\">Refresh</a> | <a href=\"{$nlink}\">Latest</a>", true);
    if ($com > 0) {
        $req = buildcommentarylink("&comscroll=" . ($com - 1));
        output_notl(" <a href=\"{$req}\">{$next}</a>", true);
        addnav("", $req);
    }
    output_notl("`n");
    if ($session['user']['prefs']['commentary_auto_update']) {
        $req = buildcommentarylink("&disable_auto_update=true");
        addnav("", $req);
        output_notl(" <a href=\"{$req}\">Disable Auto-Update</a>", true);
        $jsec = strtolower($section);
        $jsec = str_replace("_", "", $jsec);
        $jsec = str_replace("-", "", $jsec);
        $jsec = str_replace(",", "0", $jsec);
        rawoutput("<div id =\"ajaxcommentarynoticediv" . $jsec . "\"></div>");
    } else {
        $req = buildcommentarylink("&enable_auto_update=true");
        output_notl(" <a href=\"{$req}\">Enable Auto-Update</a>", true);
        addnav("", $req);
    }
    $jsec = strtolower($section);
    $jsec = str_replace("_", "", $jsec);
    $jsec = str_replace("-", "", $jsec);
    $jsec = str_replace(",", "0", $jsec);
    rawoutput("<div id=\"typedisplay" . $jsec . "\"></div>");
    addnav("", $nlink);
    output("`n`n`0Jump to commentary page: ");
    $start = microtime(true);
    $nlink = buildcommentarylink("&refresh=1&comscroll=");
    for ($i = $val; $i >= 0; $i--) {
        // $nlink = buildcommentarylink("&comscroll=".$i."&refresh=1");
        $ndisp = 1 + $val - $i;
        if ($com != $i) {
            output_notl("<a href=\"" . $nlink . $i . "\">{$ndisp}</a> ", true);
            addnav("", $nlink . $i);
        } else {
            output_notl("`@{$ndisp}`0 ", true);
        }
    }
    $end = microtime(true);
    $tot = $end - $start;
    //debug("commentary footer page numbers loop: ".$tot);
    output_notl("`n");
    if ($moderating) {
        //		output("`bLast Comment ID shown on this page: %s`b`n",number_format($bottomcid));
    } else {
        modulehook("commentaryoptions");
    }
}