function stepCounter($file)
{
    if (file_exists($file)) {
        $value = getCount($file);
        file_put_contents($file, ++$value);
    }
}
Пример #2
0
 protected function _initialize()
 {
     parent::_initialize();
     $this->openuid = I('get.openuid');
     if (getUidByOpenuid($this->openuid)) {
         $this->uid = getUidByOpenuid($this->openuid);
     } else {
         $this->error('您无权访问当前页面!');
     }
     $this->assign('openuid', $this->openuid);
     //会员信息
     $this->memberDetail = D('Home/User')->find($this->uid);
     //烘焙作品数
     $this->hbworksnum = getCount('Works', array('userid' => $this->uid, 'type' => 1));
     //随拍作品
     $this->spworksnum = getCount('Copy', array('userid' => $this->uid));
     //关注数
     $this->attentionnum = getCount('UserFans', array('myid' => $this->uid));
     //被关注数
     $this->fansnum = getCount('UserFans', array('userid' => $this->uid));
     //是否关注
     $this->isfans = getCount('UserFans', array('myid' => $this->userid, 'userid' => $this->uid, 'status' => true));
     //中间广告
     $this->midad = parent::getAdvert(9, 1, 0, 1);
 }
Пример #3
0
function discuss($ID)
{
    global $comments_disabled_after;
    $preview = ps('preview');
    extract(safe_row("Annotate,AnnotateInvite,unix_timestamp(Posted) as uPosted", "textpattern", "ID='{$ID}'"));
    $darr = !$preview ? fetchComments($ID) : array(psas(array('name', 'email', 'web', 'message', 'parentid', 'remember')));
    $out = n . '<h3 style="margin-top:2em" id="comment">' . $AnnotateInvite . '</h3>' . n;
    if ($darr) {
        $out .= '<ol>' . n;
        $out .= formatComments($darr);
        $out .= n . '</ol>';
    }
    $wasAnnotated = !$Annotate ? getCount('txp_discuss', "parentid={$ID}") : '';
    if (!$Annotate) {
        $out .= graf(gTxt("comments_closed"));
    } else {
        if ($comments_disabled_after) {
            $lifespan = $comments_disabled_after * 86400;
            $timesince = time() - $uPosted;
            if ($lifespan > $timesince) {
                $out .= commentForm($ID);
            } else {
                $out .= graf(gTxt("comments_closed"));
            }
        } else {
            $out .= commentForm($ID);
        }
    }
    return $out;
}
Пример #4
0
function createTables()
{
    $division = $_SESSION['division'];
    $date = $_SESSION['date'];
    $count = getCount();
    global $conn;
    //check if import.csv is a new carrier or existing, create tableset if new
    $getDivisionAll = mysqli_query($conn, "SELECT division from Division_All");
    $getDivisionCount = mysqli_query($conn, "SELECT division, countImported, importDate from Division_Metadata");
    $results = array();
    while ($row = mysqli_fetch_array($getDivisionAll)) {
        $results[] = $row[0];
    }
    if (!in_array($division, $results)) {
        createTableSet($division, $conn);
        mysqli_query($conn, "INSERT INTO Division_All VALUES (id, '{$division}')");
        mysqli_query($conn, "INSERT INTO Division_Metadata VALUES (id, '{$division}', '{$date}', {$count})");
        return $count;
    } else {
        $exists = mysqli_query($conn, "SELECT * from  Division_Metadata where division = '{$division}'\n    and countImported = {$count} and importDate = '{$date}'");
        $row_cnt = $exists->num_rows;
        if ($row_cnt < 1) {
            mysqli_query($conn, "INSERT INTO Division_Metadata VALUES (id, '{$division}', '{$date}', {$count})");
            return $count;
        } else {
            header("location:index.php?status=duplicate&division={$division}&count={$count}");
        }
    }
}
Пример #5
0
function list_list($message = "", $post = '')
{
    extract(get_prefs());
    $lvars = array("page", "sort", "dir", "crit", 'method');
    extract(gpsa($lvars));
    global $statuses, $step;
    pagetop("Textpattern", $message);
    $total = getCount('textpattern', "1");
    $limit = $article_list_pageby ? $article_list_pageby : 25;
    $numPages = ceil($total / $limit);
    $page = !$page ? 1 : $page;
    $offset = ($page - 1) * $limit;
    if (!$sort) {
        $sort = "Posted";
    }
    if (!$dir) {
        $dir = "desc";
    }
    if ($dir == "desc") {
        $linkdir = "asc";
    } else {
        $linkdir = "desc";
    }
    if ($crit) {
        $critsql = array('title_body' => "Title rlike '{$crit}' or Body rlike '{$crit}'", 'author' => "AuthorID rlike '{$crit}'", 'categories' => "Category1 rlike '{$crit}' or Category2 rlike '{$crit}'", 'section' => "Section rlike '{$crit}'", 'status' => "Status rlike '{$crit}'");
        $criteria = $critsql[$method];
        $limit = 500;
    } else {
        $criteria = 1;
    }
    $rs = safe_rows("*, unix_timestamp(Posted) as uPosted", "textpattern", "{$criteria} order by {$sort} {$dir} limit {$offset},{$limit}");
    echo !$crit ? list_nav_form($page, $numPages, $sort, $dir) : '', list_searching_form($crit, $method);
    if ($rs) {
        echo '<form action="index.php" method="post" onsubmit="return verify(\'' . gTxt('are_you_sure') . '\')">', startTable('list'), '<tr>', column_head('posted', 'Posted', 'list', 1, $linkdir), column_head('title', 'Title', 'list', 1, $linkdir), $use_sections ? column_head('section', 'Section', 'list', 1, $linkdir) : '', $use_categories ? column_head('category1', 'Category1', 'list', 1, $linkdir) . column_head('category2', 'Category2', 'list', 1, $linkdir) : '', hCell(gTxt('Author')), column_head(gTxt('status'), 'Status', 'list', 1, $linkdir), td(), '</tr>';
        foreach ($rs as $a) {
            extract($a);
            if ($use_categories == 1) {
                $cat1 = $Category1;
                $cat2 = $Category2;
            }
            $stat = !empty($Status) ? $statuses[$Status] : '';
            if ($use_sections == 1) {
                $sect = $Section;
            }
            $adate = date("d M y", $uPosted + $timeoffset);
            $alink = eLink('article', 'edit', 'ID', $ID, $adate);
            $tlink = eLink('article', 'edit', 'ID', $ID, $Title);
            $modbox = fInput('checkbox', 'selected[]', $ID);
            echo "<tr>" . n, td($alink), td($tlink, 200), $use_sections ? td($sect, 75) : '', $use_categories ? td($cat1, 75) . td($cat2, 75) : '', td($AuthorID), td($stat, 45), td($modbox), '</tr>' . n;
        }
        echo tr(tda(list_multiedit_form(), ' colspan="8" style="text-align:right;border:0px"'));
        echo "</table></form>";
        echo pageby_form('list', $article_list_pageby);
        unset($sort);
    }
}
Пример #6
0
/**
 * 文章属性调用标签
 *
 * @version        $Id: getarcattr.lib.php netman
 * @package        Stourweb.Taglib
 * @copyright      Copyright (c) 2007 - 2011, Stourweb, Inc.
 * @link           http://www.stourweb.com
 */
function lib_getarcattr(&$ctag, &$refObj)
{
    global $dsql;
    $attlist = "row|8,limit|0,flag|";
    FillAttsDefault($ctag->CAttribute->Items, $attlist);
    extract($ctag->CAttribute->Items, EXTR_SKIP);
    $innertext = trim($ctag->GetInnertext());
    $revalue = '';
    $kindid = $refObj->Fields['kindid'];
    $sql = "select * from #@__article_attr where isopen=1 and pid!=0 order by displayorder asc limit {$limit},{$row}";
    if ($flag == 'mdd') {
        $sql = "select a.*,count(b.id) as num from #@__article_attr as a inner join #@__article as b on find_in_set(a.id,b.attrid) where find_in_set({$kindid},b.kindlist) group by a.id limit {$limit},{$row}";
    }
    $dsql->SetQuery($sql);
    $dsql->Execute();
    $ctp = new STTagParse();
    $ctp->SetNameSpace("field", "[", "]");
    $ctp->LoadSource($innertext);
    $GLOBALS['autoindex'] = 0;
    while ($row = $dsql->GetArray()) {
        if (checkExist($row['id'])) {
            $destid = isset($GLOBALS['destid']) ? $GLOBALS['destid'] : 0;
            $py = Helper_Archive::getDestPinyin($destid);
            $py = !empty($py) ? $py : 'all';
            //$row['url'] = $GLOBALS['cfg_cmsurl']."/raiders/search.php?attrid={$row['id']}&destid={$destid}";
            $row['url'] = $GLOBALS['cfg_cmsurl'] . "/raiders/" . $py . '-' . $row['id'];
            $row['title'] = $row['attrname'];
            $row['number'] = getCount($row['id']);
            if ($flag == 'mdd') {
                $row['number'] = $row['num'];
            }
            foreach ($ctp->CTags as $tagid => $ctag) {
                if ($ctag->GetName() == 'array') {
                    $ctp->Assign($tagid, $row);
                } else {
                    if (!empty($row[$ctag->GetName()])) {
                        $ctp->Assign($tagid, $row[$ctag->GetName()]);
                    }
                }
            }
            $revalue .= $ctp->GetResult();
            $GLOBALS['autoindex']++;
        } else {
            continue;
        }
    }
    return $revalue;
}
Пример #7
0
function action()
{
    if ($_SERVER["REQUEST_METHOD"] != "POST") {
        die("You can only reach this page by posting from the web page.");
    }
    $where = isset($_GET["where"]) ? $_GET["where"] : "home";
    if (isset($_GET["mode"])) {
        if ($_GET["mode"] == "add") {
            addNew($where);
        }
        if ($_GET["mode"] == "getCount") {
            echo json_encode(array("count" => getCount($where)));
        }
    }
    exit;
}
Пример #8
0
function getBestSeller($count = 4)
{
    $getOrder = DB::query("SELECT order_content FROM `" . PREFIX . 'order' . "`");
    if (DB::numRows($getOrder) != 0) {
        $product = new Models_Product();
        while ($row = DB::fetchArray($getOrder)) {
            $orderData[] = unserialize(stripslashes($row['order_content']));
        }
        $res = array();
        foreach ($orderData as $k => $v) {
            foreach ($v as $key => $val) {
                $res[] = $product->getProduct($val['id']);
            }
        }
        $goodsSale = getCount($res);
        return array_slice($goodsSale, 0, $count);
    }
}
Пример #9
0
function log_list()
{
    pagetop(gTxt('visitor_logs'));
    extract(get_prefs());
    safe_delete("txp_log", "`time` < date_sub(now(),interval " . $expire_logs_after . " day)");
    safe_optimize("txp_log");
    safe_repair("txp_log");
    $page = gps('page');
    $total = getCount('txp_log', "1");
    $limit = 50;
    $numPages = ceil($total / $limit);
    $page = !$page ? 1 : $page;
    $offset = ($page - 1) * $limit;
    $nav[] = $page > 1 ? PrevNextLink("log", $page - 1, gTxt('prev'), 'prev') : '';
    $nav[] = sp . small($page . '/' . $numPages) . sp;
    $nav[] = $page != $numPages ? PrevNextLink("log", $page + 1, gTxt('next'), 'next') : '';
    $rs = safe_rows_start("*, unix_timestamp(time) as stamp", "txp_log", "1 order by time desc limit {$offset},{$limit}");
    if ($rs) {
        echo startTable('list'), assHead('time', 'host', 'page', 'referrer');
        $stamp = '';
        while ($a = nextRow($rs)) {
            extract($a);
            if ($refer) {
                $referprint = preg_replace("/^www\\./", "", chunk(htmlspecialchars($refer), 50));
                $referprint = '<a href="http://' . htmlspecialchars($refer) . '">' . $referprint . '</a>';
            } else {
                $referprint = '&#160;';
            }
            $pageprint = preg_replace('/\\/$/', '', htmlspecialchars(substr($page, 1)));
            $pageprint = $pageprint == '' ? '' : '<a href="' . htmlspecialchars($page) . '" target="_blank">' . chunk($pageprint, 50) . '</a>';
            if ($method == 'POST') {
                $pageprint = '<b>' . $pageprint . '</b>';
            }
            $fstamp = date("n/j g:i a", $stamp + tz_offset());
            $hostprint = chunk($host, 40);
            echo tr(td($fstamp) . td($hostprint) . td($pageprint) . td($referprint));
            unset($refer, $referprint, $page, $pageprint);
        }
        echo '<tr><td colspan="4" align="right" style="padding:10px">', join('', $nav), "</td></tr>", endTable();
    } else {
        echo graf(gTxt('no_refers_recorded'), ' align="center"');
    }
}
Пример #10
0
 public function index()
 {
     //测试用,清空缓存
     cache('', null);
     //幻灯片推荐作品
     $workModel = D('Home/Works');
     $this->assign('indextjwork', $workModel->indextjwork());
     //新闻模块
     //单条新闻
     $firstnews = M('News')->field('title,id')->where(array('iftj' => true, 'status' => true))->order('sort DESC')->limit(1)->find();
     $this->assign('firstnews', $firstnews);
     $this->assign('indextjnews', D('Home/News')->indextjnews());
     //每日新秀
     $this->assign('indexxinxiu', $workModel->worksxinxiu());
     //中间广告位
     $this->assign('indexmidad', parent::getAdvert(1, 1, 0, 5));
     //左侧广告位
     $this->assign('indexleftad', parent::getAdvert(1, 2, 0, 1));
     //类别每日一荐
     $this->assign('indexcatetj', $workModel->cateonework());
     //焙友动态
     $this->userDynamicData = D('Home/User')->userDynamic(5);
     //热门活动
     $this->assign('activitytj', D('Home/Activity')->activitytj(2));
     //右边上侧
     $this->assign('rightopad', parent::getAdvert(1, 3, 0, 1));
     //右边广告
     $this->assign('indexrightad', parent::getAdvert(1, 3, 1, 3));
     //分享达人
     $this->assign('sharedaren', D('Home/User')->sharedaren(5, $this->userid));
     //判断是否签到
     $stime = strtotime(date('Y-m-d 00:00:00'));
     $etime = strtotime(date('Y-m-d 23:59:59'));
     $where['userid'] = array('EQ', $this->userid);
     $where['create_time'] = array(array('GT', $stime), array('LT', $etime), 'and');
     $where['action'] = array('EQ', 'sign');
     $map['create_time'] = array(array('GT', $stime), array('LT', $etime), 'and');
     $map['action'] = array('EQ', 'sign');
     $this->mysign = getCount('UserDynamic', $where);
     $this->signcount = getCount('UserDynamic', $map);
     $this->display();
 }
Пример #11
0
/**
 *根据初始字符串来获得下面的字符串
 *@param string $str 初始字符串
 *@param integer $n   输出多少行
 *@return void
 */
function lookSee($str, $n)
{
    $result[0] = $str;
    for ($m = 0; $m < $n; $m++) {
        $str3 = '';
        for ($k = 0; $k < strlen($result[$m]); $k++) {
            var_dump($str[$k]);
            $str1 = $str[$k];
            var_dump($str1);
            if (!($str2 = getCount($str1, $str))) {
                break;
            }
            var_dump($str2);
            $str3 .= $str2 . $str1;
            //var_dump($str3);
        }
        $result[$m] = $str3;
    }
    return $result;
}
Пример #12
0
 /**
  * 会员登录页显示
  */
 public function index()
 {
     if (IS_POST) {
         //更新用户资料
         $post = I('post.');
         if (empty($post)) {
             $this->error('信息更新失败!');
         }
         $result = M('User')->where(array('userid' => $this->userid))->save($post);
         if ($result !== false) {
             $this->success('您的资料更新成功!');
         } else {
             $this->error('您的资料更新失败');
         }
     } else {
         //省份
         $this->province = M('Province')->field('province_id,province_name')->select();
         if (!empty($this->userinfo['ucity']) && !empty($this->userinfo['uprovince'])) {
             $this->ucity = M('City')->where(array('province_id' => $this->userinfo['uprovince']))->select();
         }
         if (!empty($this->userinfo['ucity']) && !empty($this->userinfo['uarea'])) {
             $this->uarea = M('Area')->where(array('city_id' => $this->userinfo['ucity']))->select();
         }
         //数量统计
         //烘焙作品数
         $this->hbworksnum = getCount('Works', array('userid' => $this->userid, 'status' => true));
         //随拍作品
         $this->spworksnum = getCount('Suipai', array('userid' => $this->userid, 'status' => true));
         //留言数
         $this->msgnum = getCount('UserMessage', array('userid' => $this->userid, 'status' => true));
         //试用报告数
         $this->reportnum = getCount('TryReport', array('userid' => $this->userid, 'status' => true));
         //收藏作品数
         $this->favoritenum = getCount('UserFavorite', array('userid' => $this->userid, 'status' => true));
         //修改头像密钥
         $this->auth_key = urlencode(\Libs\Util\Encrypt::authcode($this->userid, ''));
     }
     $this->display();
 }
Пример #13
0
function image_list($message = '')
{
    global $txpcfg, $extensions, $path_from_root, $img_dir;
    $pfr = $path_from_root;
    extract($txpcfg);
    extract(get_prefs());
    pagetop(gTxt('image'), $message);
    echo pageby_form('image', $article_list_pageby);
    echo startTable('list'), tr(tda(upload_form(gTxt('upload_file'), gTxt('upload'), 'image_insert'), ' colspan="4" style="border:0"')), tr(hCell(ucfirst(gTxt('name'))) . hCell(gTxt('image_category')) . hCell(gTxt('tags')) . hCell(gTxt('author')) . hCell(gTxt('thumbnail')) . hCell());
    $page = gps('page');
    $total = getCount('txp_image', "1");
    $limit = 15;
    $numPages = ceil($total / $limit);
    $page = !$page ? 1 : $page;
    $offset = ($page - 1) * $limit;
    $nav[] = $page > 1 ? PrevNextLink("image", $page - 1, gTxt('prev'), 'prev') : '';
    $nav[] = sp . small($page . '/' . $numPages) . sp;
    $nav[] = $page != $numPages ? PrevNextLink("image", $page + 1, gTxt('next'), 'next') : '';
    $rs = safe_rows("*", "txp_image", "1 order by category,name limit {$offset},{$limit}");
    if ($rs) {
        foreach ($rs as $a) {
            extract($a);
            $thumbnail = $thumbnail ? '<img src="' . $pfr . $img_dir . '/' . $id . 't' . $ext . '" />' : gTxt('no');
            $elink = eLink('image', 'image_edit', 'id', $id, $name);
            $txtilelink = '<a target="_blank" href="?event=tag' . a . 'name=image' . a . 'id=' . $id . a . 'ext=' . $ext . a . 'alt=' . $alt . a . 'h=' . $h . a . 'w=' . $w . a . 'type=textile" onclick="window.open(this.href, \'popupwindow\', \'width=400,height=400,scrollbars,resizable\'); return false;">Textile</a>';
            $txplink = '<a target="_blank" href="?event=tag' . a . 'name=image' . a . 'id=' . $id . a . 'type=textpattern" onclick="window.open(this.href, \'popupwindow\', \'width=400,height=400,scrollbars,resizable\'); return false;">Textpattern</a>';
            $xhtmlink = '<a target="_blank" href="?event=tag' . a . 'name=image' . a . 'id=' . $id . a . 'ext=' . $ext . a . 'h=' . $h . a . 'w=' . $w . a . 'type=xhtml" onclick="window.open(this.href, \'popupwindow\', \'width=400,height=400,scrollbars,resizable\'); return false;">XHTML</a>';
            $dlink = dLink('image', 'image_delete', 'id', $id);
            echo tr(td($elink) . td($category) . td($txtilelink . ' / ' . $txplink . ' / ' . $xhtmlink) . td($author) . td($thumbnail) . td($dlink, 10));
        }
        echo tr(tdcs(graf(join('', $nav)), 4));
    }
    echo endTable();
    $imgdir = $doc_root . $path_from_root . $img_dir;
    if (!is_dir($imgdir) or !is_writeable($imgdir)) {
        echo graf(str_replace("{imgdir}", $imgdir, gTxt('img_dir_not_writeable')), ' style="text-align:center;color:red"');
    }
}
Пример #14
0
function link_list($message = "")
{
    global $step, $link_list_pageby;
    extract(get_prefs());
    $page = gps('page');
    $total = getCount('txp_link', "1");
    $limit = $link_list_pageby;
    $numPages = ceil($total / $limit);
    $page = !$page ? 1 : $page;
    $offset = ($page - 1) * $limit;
    $sort = gps('sort');
    $dir = gps('dir');
    $sort = $sort ? $sort : 'linksort';
    $dir = $dir ? $dir : 'asc';
    if ($dir == "desc") {
        $dir = "asc";
    } else {
        $dir = "desc";
    }
    $nav[] = $page > 1 ? PrevNextLink("link", $page - 1, gTxt('prev'), 'prev') : '';
    $nav[] = sp . small($page . '/' . $numPages) . sp;
    $nav[] = $page != $numPages ? PrevNextLink("link", $page + 1, gTxt('next'), 'next') : '';
    $rs = safe_rows("*", "txp_link", "1 order by {$sort} {$dir} limit {$offset},{$limit}");
    if ($rs) {
        echo '<form action="index.php" method="post" onsubmit="return verify(\'' . gTxt('are_you_sure') . '\')">', startTable('list'), tr(column_head('link_name', 'linksort', 'link', 1, $dir) . column_head('description', 'description', 'link', 1, $dir) . column_head('link_category', 'category', 'link', 1, $dir) . td());
        foreach ($rs as $a) {
            extract($a);
            $elink = eLink('link', 'link_edit', 'id', $id, $linkname);
            $cbox = fInput('checkbox', 'selected[]', $id);
            echo tr(td($elink) . td($description) . td($category) . td($cbox));
        }
        echo tr(tda(link_multiedit_form(), ' colspan="4" style="border:0px;text-align:right"'));
        echo endTable(), '</form>';
        echo pageby_form('link', $link_list_pageby);
        echo graf(join('', $nav), ' align="center"');
    }
}
Пример #15
0
/**
 * The main author list.
 *
 * @param string|array $message The activity message
 */
function author_list($message = '')
{
    global $txp_user, $author_list_pageby;
    pagetop(gTxt('tab_site_admin'), $message);
    if (is_disabled('mail')) {
        echo graf(span(null, array('class' => 'ui-icon ui-icon-alert')) . ' ' . gTxt('warn_mail_unavailable'), array('class' => 'alert-block warning'));
    }
    echo hed(gTxt('tab_site_admin'), 1, array('class' => 'txp-heading'));
    echo n . '<div id="users_control" class="txp-control-panel">';
    $buttons = array();
    // Change password button.
    $buttons[] = sLink('admin', 'new_pass_form', gTxt('change_password'));
    if (!has_privs('admin.edit')) {
        // Change email address button.
        $buttons[] = sLink('admin', 'change_email_form', gTxt('change_email_address'));
    } else {
        // New author button.
        $buttons[] = sLink('admin', 'author_edit', gTxt('add_new_author'));
    }
    echo graf(join(n, $buttons), array('class' => 'txp-buttons'));
    // User list.
    if (has_privs('admin.list')) {
        extract(gpsa(array('page', 'sort', 'dir', 'crit', 'search_method')));
        if ($sort === '') {
            $sort = get_pref('admin_sort_column', 'name');
        }
        if ($dir === '') {
            $dir = get_pref('admin_sort_dir', 'asc');
        }
        $dir = $dir == 'desc' ? 'desc' : 'asc';
        if (!in_array($sort, array('name', 'RealName', 'email', 'privs', 'last_login'))) {
            $sort = 'name';
        }
        $sort_sql = $sort . ' ' . $dir;
        set_pref('admin_sort_column', $sort, 'admin', 2, '', 0, PREF_PRIVATE);
        set_pref('admin_sort_dir', $dir, 'admin', 2, '', 0, PREF_PRIVATE);
        $switch_dir = $dir == 'desc' ? 'asc' : 'desc';
        $criteria = 1;
        if ($search_method and $crit != '') {
            $verbatim = preg_match('/^"(.*)"$/', $crit, $m);
            $crit_escaped = $verbatim ? doSlash($m[1]) : doLike($crit);
            $critsql = $verbatim ? array('id' => "user_id in ('" . join("','", do_list($crit_escaped)) . "')", 'login' => "name = '{$crit_escaped}'", 'real_name' => "RealName = '{$crit_escaped}'", 'email' => "email = '{$crit_escaped}'", 'privs' => "convert(privs, char) in ('" . join("','", do_list($crit_escaped)) . "')") : array('id' => "user_id in ('" . join("','", do_list($crit_escaped)) . "')", 'login' => "name like '%{$crit_escaped}%'", 'real_name' => "RealName like '%{$crit_escaped}%'", 'email' => "email like '%{$crit_escaped}%'", 'privs' => "convert(privs, char) in ('" . join("','", do_list($crit_escaped)) . "')");
            if (array_key_exists($search_method, $critsql)) {
                $criteria = $critsql[$search_method];
            } else {
                $search_method = '';
                $crit = '';
            }
        } else {
            $search_method = '';
            $crit = '';
        }
        $criteria .= callback_event('admin_criteria', 'author_list', 0, $criteria);
        $total = getCount('txp_users', $criteria);
        if ($total < 1) {
            if ($criteria != 1) {
                echo n . author_search_form($crit, $search_method) . graf(gTxt('no_results_found'), ' class="indicator"') . '</div>';
            }
            return;
        }
        $limit = max($author_list_pageby, 15);
        list($page, $offset, $numPages) = pager($total, $limit, $page);
        $use_multi_edit = has_privs('admin.edit') && safe_count('txp_users', '1=1') > 1;
        echo author_search_form($crit, $search_method) . '</div>';
        $rs = safe_rows_start('*, unix_timestamp(last_access) as last_login', 'txp_users', "{$criteria} order by {$sort_sql} limit {$offset}, {$limit}");
        if ($rs) {
            echo n . tag_start('div', array('id' => 'users_container', 'class' => 'txp-container')) . n . tag_start('form', array('action' => 'index.php', 'id' => 'users_form', 'class' => 'multi_edit_form', 'method' => 'post', 'name' => 'longform')) . n . tag_start('div', array('class' => 'txp-listtables')) . n . tag_start('table', array('class' => 'txp-list')) . n . tag_start('thead') . tr(($use_multi_edit ? hCell(fInput('checkbox', 'select_all', 0, '', '', '', '', '', 'select_all'), '', ' scope="col" title="' . gTxt('toggle_all_selected') . '" class="txp-list-col-multi-edit"') : hCell('', '', ' scope="col" class="txp-list-col-multi-edit"')) . column_head('login_name', 'name', 'admin', true, $switch_dir, '', '', ('name' == $sort ? "{$dir} " : '') . 'txp-list-col-login-name name') . column_head('real_name', 'RealName', 'admin', true, $switch_dir, '', '', ('RealName' == $sort ? "{$dir} " : '') . 'txp-list-col-real-name name') . column_head('email', 'email', 'admin', true, $switch_dir, '', '', ('email' == $sort ? "{$dir} " : '') . 'txp-list-col-email') . column_head('privileges', 'privs', 'admin', true, $switch_dir, '', '', ('privs' == $sort ? "{$dir} " : '') . 'txp-list-col-privs') . column_head('last_login', 'last_login', 'admin', true, $switch_dir, '', '', ('last_login' == $sort ? "{$dir} " : '') . 'txp-list-col-last-login date')) . n . tag_end('thead') . n . tag_start('tbody');
            while ($a = nextRow($rs)) {
                extract(doSpecial($a));
                echo tr(td((has_privs('admin.edit') and $txp_user != $a['name']) ? fInput('checkbox', 'selected[]', $a['name'], 'checkbox') : '', '', 'txp-list-col-multi-edit') . hCell(has_privs('admin.edit') ? eLink('admin', 'author_edit', 'user_id', $user_id, $name) : $name, '', ' scope="row" class="txp-list-col-login-name name"') . td($RealName, '', 'txp-list-col-real-name name') . td(href($email, 'mailto:' . $email), '', 'txp-list-col-email') . td(get_priv_level($privs), '', 'txp-list-col-privs') . td($last_login ? safe_strftime('%b&#160;%Y', $last_login) : '', '', 'txp-list-col-last-login date'));
            }
            echo n . tag_end('tbody') . n . tag_end('table') . n . tag_end('div') . ($use_multi_edit ? author_multiedit_form($page, $sort, $dir, $crit, $search_method) : '') . tInput() . n . tag_end('form') . n . tag_start('div', array('id' => 'users_navigation', 'class' => 'txp-navigation')) . pageby_form('admin', $author_list_pageby) . nav_form('admin', $page, $numPages, $sort, $dir, $crit, $search_method) . n . tag_end('div') . n . tag_end('div');
        }
    } else {
        echo n . tag_end('div');
    }
}
Пример #16
0
function rss()
{
    global $prefs, $thisarticle;
    extract($prefs);
    ob_start();
    extract(doSlash(gpsa(array('category', 'section', 'limit', 'area'))));
    $area = gps('area');
    $sitename .= $section ? ' - ' . $section : '';
    $sitename .= $category ? ' - ' . $category : '';
    $out[] = tag(doSpecial($sitename), 'title');
    $out[] = tag(hu, 'link');
    $out[] = tag(doSpecial($site_slogan), 'description');
    $articles = array();
    if (!$area or $area == 'article') {
        $sfilter = $section ? "and Section = '" . $section . "'" : '';
        $cfilter = $category ? "and (Category1='" . $category . "' or Category2='" . $category . "')" : '';
        $limit = $limit ? $limit : '5';
        $frs = safe_column("name", "txp_section", "in_rss != '1'");
        if ($frs) {
            foreach ($frs as $f) {
                $query[] = "and Section != '" . $f . "'";
            }
        }
        $query[] = $sfilter;
        $query[] = $cfilter;
        $rs = safe_rows_start("*, unix_timestamp(Posted) as uPosted, ID as thisid", "textpattern", "Status = 4 " . join(' ', $query) . "and Posted < now() order by Posted desc limit {$limit}");
        if ($rs) {
            while ($a = nextRow($rs)) {
                extract($a);
                populateArticleData($a);
                $a['posted'] = $uPosted;
                $Body = !$syndicate_body_or_excerpt ? $thisarticle['body'] : $thisarticle['excerpt'];
                $Body = !trim($Body) ? $thisarticle['body'] : $Body;
                $Body = str_replace('href="/', 'href="' . hu, $Body);
                $Body = preg_replace("/href=\\\"#(.*)\"/", "href=\"" . permlinkurl($a) . "#\\1\"", $Body);
                $Body = safe_hed($Body);
                $Body = preg_replace(array('/</', '/>/', "/'/", '/"/'), array('&lt;', '&gt;', '&#039;', '&quot;'), $Body);
                // encode bare ampersands
                $Body = preg_replace("/&(?![#0-9]+;|\\w+;)/i", '&amp;', $Body);
                $uTitle = $url_title ? $url_title : stripSpace($Title);
                $uTitle = htmlspecialchars($uTitle, ENT_NOQUOTES);
                if ($show_comment_count_in_feed) {
                    $dc = getCount('txp_discuss', "parentid={$ID} and visible=1");
                    $count = $dc > 0 ? ' [' . $dc . ']' : '';
                } else {
                    $count = '';
                }
                $Title = doSpecial($Title) . $count;
                $permlink = permlinkurl($a);
                $item = tag(strip_tags($Title), 'title') . n . tag($Body, 'description') . n . tag($permlink, 'link');
                $articles[$ID] = tag($item, 'item');
                $etags[$ID] = strtoupper(dechex(crc32($articles[$ID])));
                $dates[$ID] = $uPosted;
            }
        }
    } elseif ($area == 'link') {
        $cfilter = $category ? "category='{$category}'" : '1';
        $limit = $limit ? $limit : 15;
        $rs = safe_rows_start("*", "txp_link", "{$cfilter} order by date desc limit {$limit}");
        if ($rs) {
            while ($a = nextRow($rs)) {
                extract($a);
                $item = tag(doSpecial($linkname), 'title') . n . tag(doSpecial($description), 'description') . n . tag(doSpecial($url), 'link');
                $articles[$id] = tag($item, 'item');
                $etags[$id] = strtoupper(dechex(crc32($articles[$id])));
                $dates[$id] = $date;
            }
        }
    }
    //turn on compression if we aren't using it already
    if (extension_loaded('zlib') && ini_get("zlib.output_compression") == 0 && ini_get('output_handler') != 'ob_gzhandler' && !headers_sent()) {
        ob_start("ob_gzhandler");
    }
    $last = fetch('unix_timestamp(val)', 'txp_prefs', 'name', 'lastmod');
    $last = gmdate("D, d M Y H:i:s \\G\\M\\T", $last);
    header("Last-Modified: {$last}");
    $expires = gmdate('D, d M Y H:i:s \\G\\M\\T', time() + 3600 * 1);
    header("Expires: {$expires}");
    $hims = serverset('HTTP_IF_MODIFIED_SINCE');
    if ($hims == $last) {
        header("HTTP/1.1 304 Not Modified");
        exit;
    }
    $imsd = @strtotime($hims);
    if (is_callable('apache_request_headers')) {
        $headers = apache_request_headers();
        if (isset($headers["A-IM"])) {
            $canaim = strpos($headers["A-IM"], "feed");
        } else {
            $canaim = false;
        }
    } else {
        $canaim = false;
    }
    $hinm = stripslashes(serverset('HTTP_IF_NONE_MATCH'));
    $cutarticles = false;
    if ($canaim !== false) {
        foreach ($articles as $id => $thing) {
            if (strpos($hinm, $etags[$id]) !== false) {
                unset($articles[$id]);
                $cutarticles = true;
                $cut_etag = true;
            }
            if ($dates[$id] < $imsd) {
                unset($articles[$id]);
                $cutarticles = true;
                $cut_time = true;
            }
        }
    }
    if (isset($cut_etag) && isset($cut_time)) {
        header("Vary: If-None-Match, If-Modified-Since");
    } else {
        if (isset($cut_etag)) {
            header("Vary: If-None-Match");
        } else {
            if (isset($cut_time)) {
                header("Vary: If-Modified-Since");
            }
        }
    }
    $etag = @join("-", $etags);
    if (strstr($hinm, $etag)) {
        header("HTTP/1.1 304 Not Modified");
        exit;
    }
    if ($cutarticles) {
        //header("HTTP/1.1 226 IM Used");
        //This should be used as opposed to 200, but Apache doesn't like it.
        //http://intertwingly.net/blog/2004/09/11/Vary-ETag/ says that the status code should be 200.
        header("Cache-Control: no-store, im");
        header("IM: feed");
    }
    $out = array_merge($out, $articles);
    header("Content-Type: application/rss+xml; charset=utf-8");
    if ($etag) {
        header('ETag: "' . $etag . '"');
    }
    return '<rss version="0.92">' . tag(join(n, $out), 'channel') . '</rss>';
}
Пример #17
0
function author_list()
{
    global $txp_user, $author_list_pageby;
    extract(gpsa(array('page', 'sort', 'dir', 'crit', 'search_method')));
    if (!in_array($sort, array('name', 'RealName', 'email', 'privs', 'last_login'))) {
        $sort = 'name';
    }
    $dir = $dir == 'desc' ? 'desc' : 'asc';
    $sort_sql = $sort . ' ' . $dir;
    $switch_dir = $dir == 'desc' ? 'asc' : 'desc';
    $total = getCount('txp_users', '1=1');
    $limit = max($author_list_pageby, 15);
    list($page, $offset, $numPages) = pager($total, $limit, $page);
    $rs = safe_rows_start('*, unix_timestamp(last_access) as last_login', 'txp_users', '1 = 1 order by ' . $sort_sql . ' limit ' . $offset . ', ' . $limit);
    if ($rs) {
        echo '<form action="index.php" method="post" name="longform" onsubmit="return verify(\'' . gTxt('are_you_sure') . '\')">' . startTable('list') . tr(column_head('login_name', 'name', 'admin', true, $switch_dir, '', '', 'name' == $sort ? $dir : '') . column_head('real_name', 'RealName', 'admin', true, $switch_dir, '', '', 'RealName' == $sort ? $dir : '') . column_head('email', 'email', 'admin', true, $switch_dir, '', '', 'email' == $sort ? $dir : '') . column_head('privileges', 'privs', 'admin', true, $switch_dir, '', '', 'privs' == $sort ? $dir : '') . column_head('last_login', 'last_login', 'admin', true, $switch_dir, '', '', 'last_login' == $sort ? $dir : '') . hCell() . hCell());
        while ($a = nextRow($rs)) {
            extract(doSpecial($a));
            echo tr(td($name) . td($RealName) . td('<a href="mailto:' . $email . '">' . $email . '</a>') . td(get_priv_level($privs)) . td($last_login ? safe_strftime('%b&#160;%Y', $last_login) : '') . td(has_privs('admin.edit') ? eLink('admin', 'author_edit', 'user_id', $user_id, gTxt('edit')) : '') . td((has_privs('admin.edit') and $txp_user != $a['name']) ? fInput('checkbox', 'selected[]', $a['name']) : ''));
        }
        echo n . n . tr(tda(select_buttons() . author_multiedit_form($page, $sort, $dir, $crit, $search_method), ' colspan="6" style="text-align: right; border: none;"')) . endTable() . '</form>' . nav_form('admin', $page, $numPages, $sort, $dir, $crit, $search_method) . pageby_form('admin', $author_list_pageby);
    }
}
Пример #18
0
function link_list($message = '')
{
    global $step, $link_list_pageby;
    extract(gpsa(array('page', 'sort', 'dir', 'crit', 'search_method')));
    $dir = $dir == 'desc' ? 'desc' : 'asc';
    switch ($sort) {
        case 'id':
            $sort_sql = 'id ' . $dir;
            break;
        case 'description':
            $sort_sql = 'description ' . $dir . ', id asc';
            break;
        case 'category':
            $sort_sql = 'category ' . $dir . ', id asc';
            break;
        case 'date':
            $sort_sql = 'date ' . $dir . ', id asc';
            break;
        default:
            $sort = 'name';
            $sort_sql = 'linksort ' . $dir . ', id asc';
            break;
    }
    $switch_dir = $dir == 'desc' ? 'asc' : 'desc';
    $criteria = 1;
    if ($search_method and $crit) {
        $crit_escaped = doSlash($crit);
        $critsql = array('id' => "ID in ('" . join("','", do_list($crit_escaped)) . "')", 'name' => "linkname like '%{$crit_escaped}%'", 'description' => "description like '%{$crit_escaped}%'", 'category' => "category like '%{$crit_escaped}%'");
        if (array_key_exists($search_method, $critsql)) {
            $criteria = $critsql[$search_method];
        } else {
            $search_method = '';
            $crit = '';
        }
    } else {
        $search_method = '';
        $crit = '';
    }
    $total = getCount('txp_link', $criteria);
    if ($total < 1) {
        if ($criteria != 1) {
            echo n . link_search_form($crit, $search_method) . n . graf(gTxt('no_results_found'), ' class="indicator"');
        } else {
            echo n . graf(gTxt('no_links_recorded'), ' class="indicator"');
        }
        return;
    }
    $limit = max($link_list_pageby, 15);
    list($page, $offset, $numPages) = pager($total, $limit, $page);
    echo link_search_form($crit, $search_method);
    $rs = safe_rows_start('*, unix_timestamp(date) as uDate', 'txp_link', "{$criteria} order by {$sort_sql} limit {$offset}, {$limit}");
    if ($rs) {
        echo n . n . '<form action="index.php" method="post" name="longform" onsubmit="return verify(\'' . gTxt('are_you_sure') . '\')">', startTable('list') . n . tr(column_head('ID', 'id', 'link', true, $switch_dir, $crit, $search_method, 'id' == $sort ? $dir : '') . hCell() . column_head('link_name', 'name', 'link', true, $switch_dir, $crit, $search_method, 'name' == $sort ? $dir : '') . column_head('description', 'description', 'link', true, $switch_dir, $crit, $search_method, 'description' == $sort ? $dir : '') . column_head('link_category', 'category', 'link', true, $switch_dir, $crit, $search_method, 'category' == $sort ? $dir : '') . column_head('date', 'date', 'link', true, $switch_dir, $crit, $search_method, 'date' == $sort ? $dir : '') . hCell());
        while ($a = nextRow($rs)) {
            extract($a);
            $edit_url = '?event=link' . a . 'step=link_edit' . a . 'id=' . $id . a . 'sort=' . $sort . a . 'dir=' . $dir . a . 'page=' . $page . a . 'search_method=' . $search_method . a . 'crit=' . $crit;
            echo tr(n . td($id, 20) . td(n . '<ul>' . n . t . '<li>' . href(gTxt('edit'), $edit_url) . '</li>' . n . t . '<li>' . href(gTxt('view'), $url) . '</li>' . n . '</ul>', 35) . td(href(htmlspecialchars($linkname), $edit_url), 125) . td(htmlspecialchars($description), 150) . td('<span title="' . htmlspecialchars(fetch_category_title($category, 'link')) . '">' . $category . '</span>', 125) . td(gTime($uDate), 75) . td(fInput('checkbox', 'selected[]', $id)));
        }
        echo n . n . tr(tda(select_buttons() . link_multiedit_form($page, $sort, $dir, $crit, $search_method), ' colspan="7" style="text-align: right; border: none;"')) . endTable() . '</form>' . n . nav_form('link', $page, $numPages, $sort, $dir, $crit, $search_method, $total, $limit) . pageby_form('link', $link_list_pageby);
    }
}
Пример #19
0
}
/**
 Get the number of results  by using the google API
*/
function getCount($fp, $obj)
{
    $url = "http://ajax.googleapis.com/ajax/services/search/web?v=1.0&q=" . $obj;
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_REFERER, 'http://blog.Stackr.fr');
    $body = curl_exec($ch);
    curl_close($ch);
    // Decode the JSON string to an associative array
    $json = json_decode($body, true);
    // Fetch the number of results
    fprintf($fp, $obj . '; ' . $json['responseData']['cursor']['estimatedResultCount'] . "\n");
}
/**
* Main part of the code : words generation & getCount calls
*/
$letters = array("A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z");
foreach ($letters as $fLetter) {
    foreach ($letters as $sLetter) {
        foreach ($letters as $tLetter) {
            foreach ($letters as $foLetter) {
                getCount($fp, $fLetter . $sLetter . $tLetter . $foLetter);
            }
        }
    }
}
Пример #20
0
function link_list($message = '')
{
    global $event, $step, $link_list_pageby, $txp_user;
    pagetop(gTxt('tab_link'), $message);
    extract(gpsa(array('page', 'sort', 'dir', 'crit', 'search_method')));
    if ($sort === '') {
        $sort = get_pref('link_sort_column', 'name');
    }
    if ($dir === '') {
        $dir = get_pref('link_sort_dir', 'asc');
    }
    $dir = $dir == 'desc' ? 'desc' : 'asc';
    switch ($sort) {
        case 'id':
            $sort_sql = 'id ' . $dir;
            break;
        case 'description':
            $sort_sql = 'description ' . $dir . ', id asc';
            break;
        case 'url':
            $sort_sql = 'url ' . $dir . ', id asc';
            break;
        case 'category':
            $sort_sql = 'category ' . $dir . ', id asc';
            break;
        case 'date':
            $sort_sql = 'date ' . $dir . ', id asc';
            break;
        case 'author':
            $sort_sql = 'author ' . $dir . ', id asc';
            break;
        default:
            $sort = 'name';
            $sort_sql = 'linksort ' . $dir . ', id asc';
            break;
    }
    set_pref('link_sort_column', $sort, 'link', 2, '', 0, PREF_PRIVATE);
    set_pref('link_sort_dir', $dir, 'link', 2, '', 0, PREF_PRIVATE);
    $switch_dir = $dir == 'desc' ? 'asc' : 'desc';
    $criteria = 1;
    if ($search_method and $crit != '') {
        $verbatim = preg_match('/^"(.*)"$/', $crit, $m);
        $crit_escaped = doSlash($verbatim ? $m[1] : str_replace(array('\\', '%', '_', '\''), array('\\\\', '\\%', '\\_', '\\\''), $crit));
        $critsql = $verbatim ? array('id' => "ID in ('" . join("','", do_list($crit_escaped)) . "')", 'name' => "linkname = '{$crit_escaped}'", 'description' => "description = '{$crit_escaped}'", 'url' => "url = '{$crit_escaped}'", 'category' => "category = '{$crit_escaped}'", 'author' => "author = '{$crit_escaped}'") : array('id' => "ID in ('" . join("','", do_list($crit_escaped)) . "')", 'name' => "linkname like '%{$crit_escaped}%'", 'description' => "description like '%{$crit_escaped}%'", 'url' => "url like '%{$crit_escaped}%'", 'category' => "category like '%{$crit_escaped}%'", 'author' => "author like '%{$crit_escaped}%'");
        if (array_key_exists($search_method, $critsql)) {
            $criteria = $critsql[$search_method];
        } else {
            $search_method = '';
            $crit = '';
        }
    } else {
        $search_method = '';
        $crit = '';
    }
    $criteria .= callback_event('admin_criteria', 'link_list', 0, $criteria);
    $total = getCount('txp_link', $criteria);
    echo '<h1 class="txp-heading">' . gTxt('tab_link') . '</h1>';
    echo '<div id="' . $event . '_control" class="txp-control-panel">';
    if (has_privs('link.edit')) {
        echo graf(sLink('link', 'link_edit', gTxt('add_new_link')), ' class="txp-buttons"');
    }
    if ($total < 1) {
        if ($criteria != 1) {
            echo n . link_search_form($crit, $search_method) . n . graf(gTxt('no_results_found'), ' class="indicator"') . '</div>';
        } else {
            echo n . graf(gTxt('no_links_recorded'), ' class="indicator"') . '</div>';
        }
        return;
    }
    $limit = max($link_list_pageby, 15);
    list($page, $offset, $numPages) = pager($total, $limit, $page);
    echo link_search_form($crit, $search_method) . '</div>';
    $rs = safe_rows_start('*, unix_timestamp(date) as uDate', 'txp_link', "{$criteria} order by {$sort_sql} limit {$offset}, {$limit}");
    if ($rs) {
        $show_authors = !has_single_author('txp_link');
        echo n . '<div id="' . $event . '_container" class="txp-container">';
        echo n . n . '<form action="index.php" id="links_form" class="multi_edit_form" method="post" name="longform">', n . '<div class="txp-listtables">' . n . startTable('', '', 'txp-list') . n . '<thead>' . n . tr(n . hCell(fInput('checkbox', 'select_all', 0, '', '', '', '', '', 'select_all'), '', ' title="' . gTxt('toggle_all_selected') . '" class="multi-edit"') . n . column_head('ID', 'id', 'link', true, $switch_dir, $crit, $search_method, ('id' == $sort ? "{$dir} " : '') . 'id') . n . column_head('link_name', 'name', 'link', true, $switch_dir, $crit, $search_method, ('name' == $sort ? "{$dir} " : '') . 'name') . n . column_head('description', 'description', 'link', true, $switch_dir, $crit, $search_method, ('description' == $sort ? "{$dir} " : '') . 'links_detail description') . n . column_head('link_category', 'category', 'link', true, $switch_dir, $crit, $search_method, ('category' == $sort ? "{$dir} " : '') . 'category') . n . column_head('url', 'url', 'link', true, $switch_dir, $crit, $search_method, ('url' == $sort ? "{$dir} " : '') . 'url') . n . column_head('date', 'date', 'link', true, $switch_dir, $crit, $search_method, ('date' == $sort ? "{$dir} " : '') . 'links_detail date created') . ($show_authors ? n . column_head('author', 'author', 'link', true, $switch_dir, $crit, $search_method, ('author' == $sort ? "{$dir} " : '') . 'author') : '')) . n . '</thead>';
        echo '<tbody>';
        $validator = new Validator();
        while ($a = nextRow($rs)) {
            extract($a, EXTR_PREFIX_ALL, 'link');
            $edit_url = '?event=link' . a . 'step=link_edit' . a . 'id=' . $link_id . a . 'sort=' . $sort . a . 'dir=' . $dir . a . 'page=' . $page . a . 'search_method=' . $search_method . a . 'crit=' . $crit;
            $validator->setConstraints(array(new CategoryConstraint($link_category, array('type' => 'link'))));
            $vc = $validator->validate() ? '' : ' error';
            $can_edit = has_privs('link.edit') || $link_author == $txp_user && has_privs('link.edit.own');
            $view_url = txpspecialchars($link_url);
            echo tr(n . td(fInput('checkbox', 'selected[]', $link_id), '', 'multi-edit') . n . td($can_edit ? href($link_id, $edit_url, ' title="' . gTxt('edit') . '"') : $link_id, '', 'id') . td($can_edit ? href(txpspecialchars($link_linkname), $edit_url, ' title="' . gTxt('edit') . '"') : txpspecialchars($link_linkname), '', 'name') . td(txpspecialchars($link_description), '', 'links_detail description') . td('<span title="' . txpspecialchars(fetch_category_title($link_category, 'link')) . '">' . $link_category . '</span>', '', 'category' . $vc) . td('<a rel="external" target="_blank" href="' . $view_url . '">' . $view_url . '</a>', '', 'url') . td(gTime($link_uDate), '', 'links_detail date created') . ($show_authors ? td('<span title="' . txpspecialchars(get_author_name($link_author)) . '">' . txpspecialchars($link_author) . '</span>', '', 'author') : ''));
        }
        echo '</tbody>', n, endTable(), n, '</div>', n, link_multiedit_form($page, $sort, $dir, $crit, $search_method), n, tInput(), n, '</form>', n, graf(toggle_box('links_detail'), ' class="detail-toggle"'), n, '<div id="' . $event . '_navigation" class="txp-navigation">', n, nav_form('link', $page, $numPages, $sort, $dir, $crit, $search_method, $total, $limit), n, pageby_form('link', $link_list_pageby), n, '</div>', n, '</div>';
    }
}
	}
    ?>
       
        <b>Agent Seal No.</b>&nbsp;<?php 
echo $agent_seal_no;
?>
      
        <br/>
    </td>
    <td valign="top"><b><?php 
echo $no_pkg;
?>
</b> STANDARD EXPORT SEAWORTHY PALLENTS&nbsp;</td>
    <td valign="top" style="border-right:#000000 solid thin;" class="print_text">
	<?php 
echo getCount('Count', 'rec_id', $row_detail['CountId']);
?>
&nbsp;<?php 
echo getProduct('ProductName', 'rec_id', $row_detail['ProductId']);
?>
<br/><br/>
    <b>H.S. CODE :</b> <?php 
echo $hs_code;
?>
    </td>
    <td valign="top" style="border-right:#000000 solid thin;" class="print_text"><?php 
echo $row_detail['NowOfferedQty'];
?>
</td>
    <td valign="top" style="border-right:#000000 solid thin;" align="center"><span class="print_text"><?php 
echo $row_detail['Price'];
Пример #22
0
                    <td align="center" style="border-bottom:#000000 solid 1px;"><span class="print_text">AMOUNT (Rs.)</span></td>
                </tr>
		<?
            $sql_detail = "select * from ".$mysql_adm_table_prefix."pi_detail where PiId = '$rec_id'"; 
            $result_detail = mysql_query($sql_detail) or die("Error in Query : ".$sql_detail."<br/>".mysql_error()."<br/>".mysql_errno());
            $i = 1;
			$total_qty = 0;
			$total_amount = 0;
			$no_pck = 0;
            while($row_detail = mysql_fetch_array($result_detail))
            {
        
        ?>                
                <tr style="vertical-align:top">
                	<td align="center" style="border-right:#000000 solid 1px;"><span class="print_text"><?=$i?></span></td>
                    <td class="print_text" style="border-right:#000000 solid 1px;"><?=getCount('Count','rec_id',$row_detail['CountId'])?>&nbsp;<?=getProduct('ProductName','rec_id',$row_detail['ProductId'])?></td>
                    <td align="center" style="border-right:#000000 solid 1px;"><span class="print_text"><?=$no_pck?>&nbsp;</span></td>
                    <td align="center" style="border-right:#000000 solid 1px;"><span class="print_text"><?=$row_detail['Quantity']?></span></td>
                    <td align="right" style="border-right:#000000 solid 1px;padding-right:5px;"><span class="print_text"><?=$row_detail['Price']?></span></td>
                    <td align="right" style="padding-right:5px;"><span class="print_text"><? $amount = round($row_detail['Quantity']*$row_detail['Price']);echo $amount;?></span></td>
                </tr>
		<?
            $i++;
			$total_qty = $total_qty+$row_detail['Quantity'];
			$total_amount = $total_amount+$amount;
            }
        ?>                
                <tr style="height:30px;">
                	<td class="print_text" style="border-right:#000000 solid 1px;padding-top:10px;">&nbsp;</td>
                    <td align="right" style="border-right:#000000 solid 1px;padding-right:5px;padding-top:10px;"><span class="print_text"><b>Total</b></span></td>
                    <td align="center" style="border-right:#000000 solid 1px;padding-top:10px;"><span class="print_text"><?=$no_pck?></span>&nbsp;</td>
                                                                    
                                                                    <td class="gredBg">
                                                                        <strong>Closing Bags</strong>
                                                                    </td>
                                                                    
                                                                </tr>-->
                                                            <?
																$sno = 1;
                                                                while($row = mysql_fetch_array($result))
                                                                {
                                                                    $CountId = $row["CountId"];
                                                            ?>
                                                                <tr <? if ($sno%2==1) { ?> bgcolor="#F5F2F1" <? } ?>>
                                                                    <td class="text_1">
                                                                        <?php 
echo getCount('Count', 'rec_id', $CountId);
?>
                                                                    </td>
                                                                    <td class="text_1">
                                                                        <?php 
echo $row["LotNumber"];
?>
                                                                    </td>
                                                                    
                                                                    
                                                                    <td class="text_1">
                                                                        <?php 
echo $row["StockInKgs"];
?>
                                                                    </td>
                                                                    <td class="text_1">
Пример #24
0
function getHeadHunters($logos = 0, $random = 0)
{
    global $objDb;
    $head_hunters = array();
    if ($logos == 1) {
        $sqlRec = "select * from job_recruiter where rec_status=1 and comp_logo!='' order by rand()";
    } else {
        $sqlRec = "select * from job_recruiter where rec_status=1 order by rand()";
    }
    $resultRec = $objDb->ExecuteQuery($sqlRec);
    while ($rsRec = mysql_fetch_object($resultRec)) {
        $rec_id = $rsRec->rec_id;
        //get last invoice details
        $sqlLastInvoice = "select * from job_rec_invoices i where i.invoice_type=1 and i.rec_id=" . $rec_id . " and (select count(*) from job_rec_payments where invoice_id=i.invoice_id)>0 order by i.invoice_id desc";
        $resultLastInvoice = $objDb->ExecuteQuery($sqlLastInvoice);
        if ($rsLastInvoice = mysql_fetch_object($resultLastInvoice)) {
            //get first payment details for last invoice of plan purchased.
            $sqlFirstPay = "select * from job_rec_payments where invoice_id=" . $rsLastInvoice->invoice_id . " and pay_status=1 order by pay_id";
            $resultFirstPay = $objDb->ExecuteQuery($sqlFirstPay);
            if ($rsFirstPay = mysql_fetch_object($resultFirstPay)) {
                $first_pay_date = $rsFirstPay->pay_date;
                //get the shortlisted jobseekers count
                $cntShortlisted = getCount("select * from job_shortlisted_jobseekers j, job_rec_invoices i, job_rec_payments p where p.invoice_id=i.invoice_id and i.invoice_id=j.invoice_id and i.invoice_date>=" . $first_pay_date . " and i.invoice_id>" . $rsLastInvoice->invoice_id . " and i.rec_id=" . $rec_id);
                //check account expired or not
                $activated_before = 1;
                $date2 = date("Y-m-d");
                $date1 = $rsFirstPay->pay_date;
                $difference = abs(strtotime($date2) - strtotime($date1));
                //calculate the number of days
                $days = round($difference / 60 / 60 / 24, 0);
                if ($days <= 30) {
                    $expired = 0;
                    $head_hunters[$rec_id] = $cntShortlisted;
                }
            }
        }
    }
    if ($random == 0) {
        arsort($head_hunters);
    }
    return $head_hunters;
}
Пример #25
0
 /**
  * 作品详情展示
  */
 public function detail()
 {
     $workid = I('get.workid');
     if (empty($workid)) {
         $this->error('您访问的页面不存在');
     }
     //增加点击数
     M('Works')->where(array('workid' => $workid))->setInc('clicknum');
     $detail = D('Works')->relation(true)->find($workid);
     if (!$detail) {
         $this->error('您访问的作品不存在');
     }
     //start yf
     $yf_thumb = array();
     $yf_pic = array();
     if (!empty($detail['all_pic'])) {
         $yf_arr = json_decode($detail['all_pic'], true);
         $yf_temp = array();
         foreach ($yf_arr as $k => $v) {
             $yf_thumb[] = $v;
             $yf_ex = explode("/", $v);
             $yf_ex[count($yf_ex) - 1] = str_replace("yf_", "", $yf_ex[count($yf_ex) - 1]);
             $yf_pic[] = implode("/", $yf_ex);
         }
     } else {
         $yf_arr = array();
         $yf_thumb[] = $yf_pic[] = $detail['image'];
     }
     $detail['pic_num'] = count($yf_thumb);
     $detail['thumb'] = implode(",", $yf_thumb);
     $detail['pic'] = implode(",", $yf_pic);
     $detail['WorksMaterials_count'] = count($detail['WorksMaterials']);
     //end
     $this->assign('data', $detail);
     //点赞总数
     $this->digallnum = $detail['goodnum'] + $detail['badnum'];
     //综合评价
     if ($detail['goodnum'] == 0 && $detail['badnum'] == 0) {
         $dig['digavg'] = 0;
         $dig['goodprecent'] = 50;
         $dig['badprecent'] = 50;
     } else {
         $digavg = round($detail['goodnum'] / ($detail['goodnum'] + $detail['badnum']), 2);
         $dig['digavg'] = $digavg * 10;
         $dig['goodprecent'] = $digavg * 100;
         $dig['badprecent'] = (1 - $digavg) * 100;
     }
     $this->dig = $dig;
     //点赞判断
     $this->digtype = M('Dig')->field('digtype,id')->where(array('userid' => $this->userid, 'status' => true, 'infoid' => $workid))->find();
     //收藏判断
     $this->favoritenum = getCount('UserFavorite', array('userid' => $this->userid, 'status' => true, 'infoid' => $workid));
     //右侧广告
     $this->rightad = parent::getAdvert(8, 3, 0, 2);
     //点赞人员列表
     $diguser = new Model();
     $diguerlist = $diguser->table(array(C('DB_PREFIX') . 'dig' => 'D', C('DB_PREFIX') . 'user' => 'U'))->where('D.userid=U.userid and D.status=true and D.digtype=1 and D.infoid=' . $workid . '')->field('U.uavatar,U.openuid')->select();
     $this->assign('diglist', $diguerlist);
     //评论
     $where['infoid'] = $workid;
     $where['type'] = 1;
     $where['parent_id'] = 0;
     $count = M('UserMessage')->where($where)->count();
     // $limitRows = 5; // 设置每页记录数
     $limitRows = C('YF_PAGE');
     $page = $this->ajaxpage($count, $limitRows, '#msg', 'ajax_div', 'ajax_page_div');
     $Model = new Model();
     $message = $Model->table(array(C('DB_PREFIX') . 'user_message' => 'M', C('DB_PREFIX') . 'user' => 'U'))->where('M.userid=U.userid and M.status=true and M.infoid=' . $workid . ' and M.type=1 and M.parent_id=0')->field('M.create_time,M.content,U.nickname,U.uavatar,U.openuid,U.uprovince,U.ucity,U.userid,M.id,M.touserid,U.ifrz')->order('M.create_time DESC')->limit($page->firstRow . ',' . $page->listRows)->select();
     foreach ($message as $k => $v) {
         $child_temp = array();
         $child_temp = $Model->table(C('DB_PREFIX') . 'user_message')->field('*')->where(array('parent_id' => $v['id']))->order('create_time ASC')->select();
         $message[$k]['childlist'] = array();
         if ($child_temp) {
             foreach ($child_temp as $yk => $yv) {
                 if ($yv['userid'] == 0) {
                     $child_temp[$yk]['nickname'] = "烘焙圈";
                     $child_temp[$yk]['openuid'] = 0;
                 } else {
                     $yf_user = array();
                     $yf_user = M('User')->field('openuid, nickname, uprovince, ucity, uavatar, ifrz')->where(array('userid' => $yv['userid']))->find();
                     $child_temp[$yk]['nickname'] = $yf_user['nickname'];
                     $child_temp[$yk]['openuid'] = $yf_user['openuid'];
                     $child_temp[$yk]['uprovince'] = $yf_user['uprovince'];
                     $child_temp[$yk]['ucity'] = $yf_user['ucity'];
                     $child_temp[$yk]['uavatar'] = $yf_user['uavatar'];
                     $child_temp[$yk]['ifrz'] = $yf_user['ifrz'];
                 }
                 if ($yv['touserid'] != 0) {
                     $child_temp[$yk]['touser'] = M('User')->field('openuid,nickname')->where(array('userid' => $yv['touserid']))->find();
                 } else {
                     $child_temp[$yk]['touser']['nickname'] = "烘焙圈";
                     $child_temp[$yk]['touser']['openuid'] = 0;
                 }
             }
             $message[$k]['childlist'] = $child_temp;
         }
         $message[$k]['tempname'] = hy_substr($v['nickname'], 4, true);
         //$message[$k]['tempname'] = $v['nickname'];
         $message[$k]['touser'] = array();
         if (!empty($v['touserid'])) {
             $message[$k]['touser'] = M('User')->field('openuid,nickname')->where(array('userid' => $v['touserid']))->find();
         }
     }
     unset($where['parent_id']);
     $this->msgcount = M('UserMessage')->where($where)->count();
     $this->msgtype = 1;
     $this->assign('msglist', $message);
     $this->assign('page', $page->show());
     if (IS_AJAX) {
         exit($this->fetch('msglist'));
     }
     //参照做出的作品
     $copylist = $Model->table(array(C('DB_PREFIX') . 'works' => 'W', C('DB_PREFIX') . 'user' => 'U'))->where('W.userid=U.userid and W.status=true and W.type=2 and W.copyid=' . $workid)->field('U.openuid,U.nickname,U.uavatar,W.title,W.image,W.workid,W.create_time,W.title')->order('W.workid DESC')->limit(2)->select();
     $this->copylist = $copylist;
     $this->display();
 }
Пример #26
0
function get_pref($thing, $default = '', $from_db = 0)
{
    global $prefs;
    if ($from_db) {
        $name = doSlash($thing);
        $exists = getCount('txp_prefs', "name='{$name}'");
        if ($exists) {
            $prefs[$thing] = safe_field('val', 'txp_prefs', "name='{$name}'");
        }
    }
    return isset($prefs[$thing]) ? $prefs[$thing] : $default;
}
Пример #27
0
        if ($sno % 2 == 1) {
            ?>
 bgcolor="#F5F2F1" <?php 
        }
        ?>
>
                                                                        <td align="center" class="tableText"><?php 
        echo $sno;
        ?>
</td>
                                                                        <td align="center" class="tableText"><?php 
        echo getProduct('ProductName', 'rec_id', getCount("ProductId", "rec_id", $row["CountId"]));
        ?>
</td>
                                                                        <td align="center" class="tableText"><?php 
        echo getCount("Count", "rec_id", $row["CountId"]);
        ?>
</td>
                                                                        <td align="center" class="tableText"><?php 
        echo $row['StockInKgs'];
        ?>
&nbsp;Kg</td>
                                                                        <td align="center" class="tableText"><?php 
        echo $row['StockInBale'];
        ?>
&nbsp;Bale</td>
                                                                        <td align="center" class="tableText"><?php 
        echo $row["Date"];
        ?>
</td>
                                                                        <td align="center" class="tableText"><?php 
Пример #28
0
function rss()
{
    global $prefs, $txpac;
    extract($prefs);
    ob_start();
    extract(doSlash(gpsa(array('category', 'section', 'limit', 'area'))));
    // send a 304 if nothing has changed since the last visit
    $last = fetch('unix_timestamp(val)', 'txp_prefs', 'name', 'lastmod');
    $last = gmdate("D, d M Y H:i:s \\G\\M\\T", $last);
    header("Last-Modified: {$last}");
    $hims = serverset('HTTP_IF_MODIFIED_SINCE');
    if ($hims == $last) {
        header("HTTP/1.1 304 Not Modified");
        exit;
    }
    $area = gps('area');
    $sitename .= $section ? ' - ' . $section : '';
    $sitename .= $category ? ' - ' . $category : '';
    $out[] = tag(doSpecial($sitename), 'title');
    $out[] = tag('http://' . $siteurl . $path_from_root, 'link');
    $out[] = tag(doSpecial($site_slogan), 'description');
    if (!$area or $area == 'article') {
        $sfilter = $section ? "and Section = '" . $section . "'" : '';
        $cfilter = $category ? "and (Category1='" . $category . "' or Category2='" . $category . "')" : '';
        $limit = $limit ? $limit : '5';
        $frs = safe_column("name", "txp_section", "in_rss != '1'");
        if ($frs) {
            foreach ($frs as $f) {
                $query[] = "and Section != '" . $f . "'";
            }
        }
        $query[] = $sfilter;
        $query[] = $cfilter;
        $rs = safe_rows("*", "textpattern", "Status = 4 " . join(' ', $query) . "and Posted < now() order by Posted desc limit {$limit}");
        if ($rs) {
            foreach ($rs as $a) {
                extract($a);
                $Body = !$txpac['syndicate_body_or_excerpt'] ? $Body_html : $Excerpt;
                $Body = !trim($Body) ? $Body_html : $Body;
                $Body = str_replace('href="/', 'href="http://' . $siteurl . '/', $Body);
                $Body = htmlspecialchars($Body, ENT_NOQUOTES);
                $link = $url_mode == 0 ? 'http://' . $siteurl . $path_from_root . 'index.php?id=' . $ID : 'http://' . $siteurl . $path_from_root . $Section . '/' . $ID . '/';
                if ($txpac['show_comment_count_in_feed']) {
                    $dc = getCount('txp_discuss', "parentid={$ID} and visible=1");
                    $count = $dc > 0 ? ' [' . $dc . ']' : '';
                } else {
                    $count = '';
                }
                $Title = doSpecial($Title) . $count;
                $item = tag(strip_tags($Title), 'title') . n . tag($Body, 'description') . n . tag($link, 'link');
                $out[] = tag($item, 'item');
            }
            header("Content-Type: text/xml");
            return '<rss version="0.92">' . tag(join(n, $out), 'channel') . '</rss>';
        }
    } elseif ($area == 'link') {
        $cfilter = $category ? "category='{$category}'" : '1';
        $limit = $limit ? $limit : 15;
        $rs = safe_rows("*", "txp_link", "{$cfilter} order by date desc limit {$limit}");
        if ($rs) {
            foreach ($rs as $a) {
                extract($a);
                $item = tag(doSpecial($linkname), 'title') . n . tag(doSpecial($description), 'description') . n . tag($url, 'link');
                $out[] = tag($item, 'item');
            }
            header("Content-Type: text/xml");
            return '<rss version="0.92">' . tag(join(n, $out), 'channel') . '</rss>';
        }
    }
    return 'no articles recorded yet';
}
Пример #29
0
<?php

include "inc/check_session.php";
include "inc/dbconnection.php";
include "inc/adm_function.php";
$StockId = $_GET["id"];
$i = $_GET["i"];
$CountId = $_GET["CountId"];
$Date = $_GET["Date"];
$CountName = getCount("Count", "rec_id", $CountId);
$sql_count = "select * from " . $mysql_adm_table_prefix . "count_master where Count = '{$CountName}' and rec_id != '{$CountId}'";
//echo "<br><br>";
$result_count = mysql_query($sql_count) or die("Error in query:" . $sql_count . "<br>" . mysql_error() . ":" . mysql_errno());
$SwitchCountId = "";
if (mysql_num_rows($result_count) > 0) {
    $row_count = mysql_fetch_array($result_count);
    $SwitchCountId = $row_count["rec_id"];
    $sql_update = "update " . $mysql_adm_table_prefix . "stock_master set CountId = '{$SwitchCountId}' where rec_id = '{$StockId}'";
    mysql_query($sql_update) or die("Error in Query:" . $sql_update . "<br>" . mysql_errno() . ":" . mysql_error());
}
$sql_stock = "SELECT * FROM  " . $mysql_adm_table_prefix . "stock_master where CountId = '{$CountId}' and Date = '{$Date}' order by Date ";
$result_stock = mysql_query($sql_stock) or die("Error in Query:" . $sql_stock . "<br>" . mysql_errno() . ":" . mysql_error());
if (mysql_num_rows($result_stock) > 0) {
    ?>
	<table align="center" width="100%" cellpadding="0" cellspacing="0" border="0" class="border">
		<tr>
			<td colspan="7" class="blackHead">Stock Detail</td>
		</tr>
		<tr>
			<td align="center">
			<span class="text_1"><b>Lot Number</b></span>
Пример #30
0
 /**
  * 随拍作品详情
  */
 public function detail()
 {
     $workid = I('get.workid');
     if (empty($workid)) {
         $this->error('您访问的页面不存在');
     }
     //增加点击数
     M('Works')->where(array('workid' => $workid))->setInc('clicknum');
     $detail = D('Works')->relation(true)->find($workid);
     if (!$detail) {
         $this->error('您访问的作品不存在');
     }
     $img_temp = explode("/", $detail['image']);
     $img_temp[count($img_temp) - 1] = str_replace("yf_", "", $img_temp[count($img_temp) - 1]);
     $detail['image'] = implode("/", $img_temp);
     $this->assign('data', $detail);
     $user = M('User')->where(array('userid' => $detail['userid']))->field("openuid, nickname, uavatar")->find();
     //print_r($user);
     $this->assign("user", $user);
     $copyinfo = M('Works')->where(array('workid' => $detail['copyid']))->field("title, image, userid")->find();
     $mname = M('WorksMaterials')->where(array('workid' => $detail['copyid']))->field("mname")->select();
     //print_r($mname);
     //print_r($copyinfo);
     $copyinfo['materials'] = array();
     if ($mname) {
         $temp_mater = array();
         foreach ($mname as $mk => $mv) {
             $temp_mater[] = $mv['mname'];
         }
         $copyinfo['materials'] = implode("、", $temp_mater);
         //$copyinfo['materials'] = "高筋粉(金像,焙食尚各一半)、细砂糖、可可粉、盐、干酵母、水(我们";
         $copyinfo['materials'] = hy_substr($copyinfo['materials'], 32, true);
     }
     $copyinfo['donum'] = M('Works')->where(array('copyid' => $detail['copyid']))->count();
     $seven = time() - 7 * 24 * 60 * 60;
     $copyinfo['nownum'] = M('Works')->where("copyid=%d and create_time > %s", array($detail['copyid'], $seven))->count();
     $this->assign("copyinfo", $copyinfo);
     $copyuser = M('User')->where(array('userid' => $copyinfo['userid']))->field("nickname, openuid")->find();
     $this->assign("copyuser", $copyuser);
     //点赞总数
     $this->digallnum = $detail['goodnum'] + $detail['badnum'];
     //点赞判断
     $this->dignum = M('Dig')->where(array('userid' => $this->userid, 'status' => true, 'infoid' => $workid))->count();
     //收藏判断
     $this->favoritenum = getCount('UserFavorite', array('userid' => $this->userid, 'status' => true, 'infoid' => $workid));
     //右侧广告
     $this->rightad = parent::getAdvert(8, 3, 0, 2);
     //点赞人员列表
     $diguser = new Model();
     $diguerlist = $diguser->table(array(C('DB_PREFIX') . 'dig' => 'D', C('DB_PREFIX') . 'user' => 'U'))->where('D.userid=U.userid and D.status=true and D.digtype=1 and D.infoid=' . $workid . '')->field('U.uavatar,U.openuid')->select();
     $this->assign('diglist', $diguerlist);
     //评论
     //         $where['infoid']=$workid;
     //         $where['type']=1;
     //         $count = M('UserMessage')->where($where)->count();
     //         $limitRows = 10; // 设置每页记录数
     //         $page = $this->ajaxpage($count,$limitRows,'type=msg','ajax_div','ajax_page_div');
     //         $msgModel=new Model();
     //         $message=$msgModel
     //             ->table(array(
     //                     C('DB_PREFIX').'user_message'=>'M',
     //                     C('DB_PREFIX').'user'=>'U',
     //                 )
     //             )
     //             ->where('M.userid=U.userid and M.status=true and M.infoid='.$workid.' and M.type=1')
     //             ->field('M.create_time,M.content,U.nickname,U.uavatar,U.openuid,U.uprovince,U.ucity,U.userid,M.id,M.touserid')
     //             ->order('M.create_time DESC')
     //             ->limit($page->firstRow . ',' . $page->listRows)
     //             ->select();
     //         foreach($message as $k=>$v){
     //             $message[$k]['touser']=M('User')->field('openuid,nickname')->where(array('userid'=>$v['touserid']))->find();
     //         }
     $where['infoid'] = $workid;
     $where['type'] = 1;
     $where['parent_id'] = 0;
     $count = M('UserMessage')->where($where)->count();
     // $limitRows = 5; // 设置每页记录数
     $limitRows = C('YF_PAGE');
     $page = $this->ajaxpage($count, $limitRows, '#msg', 'ajax_div', 'ajax_page_div');
     $Model = new Model();
     $message = $Model->table(array(C('DB_PREFIX') . 'user_message' => 'M', C('DB_PREFIX') . 'user' => 'U'))->where('M.userid=U.userid and M.status=true and M.infoid=' . $workid . ' and M.type=1 and M.parent_id=0')->field('M.create_time,M.content,U.nickname,U.uavatar,U.openuid,U.uprovince,U.ucity,U.userid,M.id,M.touserid,U.ifrz')->order('M.create_time DESC')->limit($page->firstRow . ',' . $page->listRows)->select();
     foreach ($message as $k => $v) {
         $child_temp = array();
         $child_temp = $Model->table(C('DB_PREFIX') . 'user_message')->field('*')->where(array('parent_id' => $v['id']))->order('create_time ASC')->select();
         $message[$k]['childlist'] = array();
         if ($child_temp) {
             foreach ($child_temp as $yk => $yv) {
                 if ($yv['userid'] == 0) {
                     $child_temp[$yk]['nickname'] = "烘焙圈";
                     $child_temp[$yk]['openuid'] = 0;
                 } else {
                     $yf_user = array();
                     $yf_user = M('User')->field('openuid, nickname, uprovince, ucity, uavatar, ifrz')->where(array('userid' => $yv['userid']))->find();
                     $child_temp[$yk]['nickname'] = $yf_user['nickname'];
                     $child_temp[$yk]['openuid'] = $yf_user['openuid'];
                     $child_temp[$yk]['uprovince'] = $yf_user['uprovince'];
                     $child_temp[$yk]['ucity'] = $yf_user['ucity'];
                     $child_temp[$yk]['uavatar'] = $yf_user['uavatar'];
                     $child_temp[$yk]['ifrz'] = $yf_user['ifrz'];
                 }
                 if ($yv['touserid'] != 0) {
                     $child_temp[$yk]['touser'] = M('User')->field('openuid,nickname')->where(array('userid' => $yv['touserid']))->find();
                 } else {
                     $child_temp[$yk]['touser']['nickname'] = "烘焙圈";
                     $child_temp[$yk]['touser']['openuid'] = 0;
                 }
             }
             $message[$k]['childlist'] = $child_temp;
         }
         $message[$k]['tempname'] = hy_substr($v['nickname'], 4, true);
         //$message[$k]['tempname'] = $v['nickname'];
         $message[$k]['touser'] = array();
         if (!empty($v['touserid'])) {
             $message[$k]['touser'] = M('User')->field('openuid,nickname')->where(array('userid' => $v['touserid']))->find();
         }
     }
     unset($where['parent_id']);
     $this->msgcount = M('UserMessage')->where($where)->count();
     $this->msgtype = 1;
     // $this->msgcount=$count;
     $this->assign('msglist', $message);
     $this->assign('page', $page->show());
     if (IS_AJAX) {
         exit($this->fetch('msglist'));
         //list为list.html模版
     }
     //获取会员烘焙作品数
     $this->hbworksnum = getCount('Works', array('status' => true, 'type' => 1, 'userid' => $detail['userid']));
     //获取会员随拍作品数
     $this->spworksnum = getCount('Works', array('status' => true, 'type' => 2, 'userid' => $detail['userid']));
     //是否关注
     $this->isfans = getCount('UserFans', array('myid' => $this->userid, 'userid' => $detail['userid'], 'status' => true));
     //更多随拍作品
     $map['status'] = array('EQ', true);
     $map['userid'] = array('EQ', $detail['userid']);
     $map['workid'] = array('NEQ', $workid);
     $this->moresp = M('Works')->field('image,workid,type,title')->where($map)->limit(9)->select();
     $this->display();
 }