Example #1
0
function render($data = NULL, $layout = NULL, $sharp = 'default', $pathinfo = false)
{
    if ($layout == null) {
        if (is_ajax_request()) {
            $layout = 'ajax';
        } elseif (is_mobile_request()) {
            $layout = 'mobile';
        } else {
            $layout = 'web';
        }
    }
    $GLOBALS['layout'] = $layout;
    $GLOBALS['sharp'] = $sharp;
    $layout_file = AROOT . 'view/layout/' . $layout . '/' . $sharp . '.tpl.html';
    $data = apply_filter('CTRL_' . g('c') . '_' . g('a') . '_RENDER_FILTER', $data);
    $GLOBALS['LP_RENDER_DATA'] = $data;
    if (file_exists($layout_file)) {
        @extract($data);
        require $layout_file;
    } else {
        $layout_file = CROOT . 'view/layout/' . $layout . '/' . $sharp . '.tpl.html';
        if (file_exists($layout_file)) {
            @extract($data);
            require $layout_file;
        }
    }
}
Example #2
0
function render($data = NULL, $layout = NULL, $sharp = 'default')
{
    if ($layout == null) {
        if (is_ajax_request()) {
            $layout = 'ajax';
        } elseif (is_mobile_request()) {
            $layout = 'mobile';
        } else {
            $layout = 'web';
        }
    }
    $GLOBALS['layout'] = $layout;
    $GLOBALS['sharp'] = $sharp;
    $layout_file = AROOT . 'view/layout/' . $layout . '/' . $sharp . '.tpl.html';
    if (file_exists($layout_file)) {
        @extract($data);
        require $layout_file;
    } else {
        $layout_file = CROOT . 'view/layout/' . $layout . '/' . $sharp . '.tpl.html';
        if (file_exists($layout_file)) {
            @extract($data);
            require $layout_file;
        }
    }
}
Example #3
0
 public function __construct()
 {
     if (is_mobile_request()) {
         $params = $_GET;
         $this->redirect('Mobile/' . CONTROLLER_NAME . '/' . ACTION_NAME, $params);
     }
     parent::__construct();
     $this->assign('controller', CONTROLLER_NAME);
     //读取配置信息
     $web_stting = F('setting');
     if ($web_stting === false) {
         $params = array();
         $list = M('Setting')->getField('name,value');
         foreach ($list as $key => $val) {
             $params[$key] = unserialize($val) ? unserialize($val) : $val;
         }
         F('setting', $params);
         $web_stting = F('setting');
     }
     $this->assign('web_stting', $web_stting);
     //站点状态判断
     if ($web_stting['site_status'] != 1) {
         echo '<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />';
         echo $web_stting['closed_reason'];
         exit;
     } else {
         $link = M('Link')->where(array('status' => 1))->order('sort desc')->select();
         $this->assign('seo', seo());
         $this->assign('link', $link);
     }
 }
Example #4
0
/**
 * 模板调用
 *
 * @param $m        模块名称
 * @param $template 模版名称
 * @param $style    模版风格
 * @return string
 */
function T($m = 'content', $template = 'index', $style = 'default')
{
    $mb = false;
    if (SUPPORT_MOBILE && is_mobile_request()) {
        $tmp = $template;
        $template = 'mobile/' . $template;
        $mb = true;
    }
    $cache_file = CACHE_ROOT . 'templates/' . $style . '/' . $m . '/' . $template . '.php';
    if (!file_exists($cache_file)) {
        $tpl_file = 'templates/' . $style . '/' . $m . '/' . $template . '.html';
        if (file_exists(COREFRAME_ROOT . $tpl_file)) {
            exit('Please update template cache!');
        } elseif ($mb) {
            $cache_file = CACHE_ROOT . 'templates/' . $style . '/' . $m . '/' . $tmp . '.php';
            if (!file_exists($cache_file)) {
                $tpl_file = 'templates/' . $style . '/' . $m . '/' . $tmp . '.html';
                if (file_exists(COREFRAME_ROOT . $tpl_file)) {
                    exit('Please update template cache!');
                } else {
                    exit('Template does not exists:' . $tpl_file);
                }
            } elseif (AUTO_CACHE_TPL) {
                $c_template = load_class('template');
                $c_template->cache_template($m, $tmp, $style);
            }
        } else {
            exit('Template does not exists:' . $tpl_file);
        }
    } elseif (AUTO_CACHE_TPL) {
        $c_template = load_class('template');
        $c_template->cache_template($m, $template, $style);
    }
    return $cache_file;
}
 public function _initialize()
 {
     //判断是否是手机访问
     $check_platforms = is_mobile_request();
     if ($check_platforms) {
         $this->is_mobile = 1;
         C('DEFAULT_THEME', 'm');
     }
     $this->assign('now_action', CONTROLLER_NAME . '/' . ACTION_NAME);
 }
Example #6
0
 function index()
 {
     if (is_mobile_request()) {
         return forward('client/');
     }
     if (is_login()) {
         return forward('?c=dashboard');
     }
     // do login
     $data['title'] = $data['top_title'] = __('LOGIN_PAGE_TITLE');
     $data['css'][] = 'login_screen.css';
     $data['langs'] = @glob(AROOT . 'local/*.lang.php');
     return render($data, 'web', 'fullwidth');
 }
Example #7
0
function publish_feed($content, $uid, $type = 0, $tid = 0)
{
    if (is_mobile_request()) {
        $device = 'mobile';
    } else {
        $device = 'web';
    }
    $tid = intval($tid);
    if ($type == 2 && $tid > 0) {
        $comment_count = get_var("SELECT COUNT(*) FROM `todo_history` WHERE `tid` = '" . intval($tid) . "' AND `type` = 2 ", db());
    } else {
        $comment_count = 0;
    }
    $sql = "INSERT INTO `feed` ( `content` , `tid` , `uid` , `type` ,`timeline` , `device` , `comment_count` ) VALUES ( '" . s($content) . "' , '" . intval($tid) . "', '" . intval($uid) . "'  , '" . intval($type) . "' , NOW() , '" . s($device) . "' , '" . intval($comment_count) . "' )";
    run_sql($sql);
    $lid = last_id();
    if (db_errno() != 0) {
        return false;
    } else {
        if ($comment_count > 0 && $type == 2 && $tid > 0) {
            $sql = "UPDATE `feed` SET `comment_count` = '" . intval($comment_count) . "' WHERE `tid` = '" . intval($tid) . "' AND `comment_count` != '" . intval($comment_count) . "' ";
            run_sql($sql);
        }
        return $lid;
    }
}
Example #8
0
 /**
  * 为Feed添加评论
  *
  *
  * @param string token , 必填
  * @param string fid - 必填
  * @param string text - 必填
  * @return feed array 
  * @author EasyChen
  */
 public function feed_add_comment($text = false, $fid = false)
 {
     if (!$text) {
         $content = $text = z(t(v('text')));
     }
     if (!not_empty($content)) {
         return self::send_error(LR_API_ARGS_ERROR, __('INPUT_CHECK_BAD_ARGS', 'TEXT'));
     }
     if (!$fid) {
         $fid = intval(v('fid'));
     }
     if (intval($fid) < 1) {
         return self::send_error(LR_API_ARGS_ERROR, __('INPUT_CHECK_BAD_ARGS', 'FID'));
     }
     $finfo = get_line("SELECT * FROM `feed` WHERE `id` = '" . intval($fid) . "' LIMIT 1");
     if (is_mobile_request()) {
         $device = 'mobile';
     } else {
         $device = 'web';
     }
     $sql = "INSERT INTO `comment` ( `fid` , `uid` , `content` , `timeline` , `device` ) \n\t\tVALUES ( '" . intval($fid) . "' , '" . intval($_SESSION['uid']) . "' , '" . s($content) . "' , NOW() , '" . s($device) . "' ) ";
     run_sql($sql);
     if (db_errno() != 0) {
         return self::send_error(LR_API_DB_ERROR, __('API_MESSAGE_DATABASE_ERROR') . mysql_error());
     } else {
         $lid = last_id();
         // feed表comment_count计数增加
         $count = get_var("SELECT COUNT(*) FROM `comment` WHERE `fid` = '" . intval($fid) . "' ", db());
         $sql = "UPDATE `feed` SET `comment_count` = '" . intval($count) . "' WHERE `id` = '" . intval($fid) . "' LIMIT 1";
         run_sql($sql);
         // 向Feed作者发通知
         if ($finfo['uid'] != uid()) {
             send_notice($finfo['uid'], __('API_TEXT_COMMENT_FEED_OWNED', array(uname(), $finfo['content'], $content)), 2, array('fid' => intval($fid), 'count' => $count));
         }
         // 向参与了该Feed讨论的同学发送通知
         $sql = "SELECT `uid` FROM `comment` WHERE `fid`= '" . intval($fid) . "' ";
         if ($uitems = get_data($sql)) {
             foreach ($uitems as $uitem) {
                 if ($uitem['uid'] != uid() && $uitem['uid'] != $finfo['uid']) {
                     $myuids[] = $uitem['uid'];
                 }
             }
         }
         if (isset($myuids)) {
             $myuids = array_unique($myuids);
             foreach ($myuids as $muid) {
                 send_notice($muid, __('API_TEXT_COMMENT_FEED_IN', array(uname(), $finfo['content'], $content)), 2, array('fid' => intval($fid), 'count' => $count));
             }
         }
         // 向被@的同学,发送通知
         if ($ats = find_at($content)) {
             $sql = "SELECT `id` FROM `user` WHERE ";
             foreach ($ats as $at) {
                 $at = z(t($at));
                 if ($gname = get_group_names()) {
                     if (in_array(strtoupper($at), $gname)) {
                         if ($ndata = get_group_unames($at)) {
                             foreach ($ndata as $nname) {
                                 $names[] = $nname;
                             }
                         }
                     } else {
                         $names[] = $at;
                     }
                 } else {
                     $names[] = $at;
                 }
             }
             foreach ($names as $at) {
                 $at = z(t($at));
                 if (mb_strlen($at, 'UTF-8') < 2) {
                     continue;
                 }
                 $wsql[] = " `name` = '" . s(t($at)) . "' ";
                 if (c('at_short_name')) {
                     if (mb_strlen($at, 'UTF-8') == 2) {
                         $wsql[] = " `name` LIKE '_" . s($at) . "' ";
                     }
                 }
             }
             if (isset($wsql) && is_array($wsql)) {
                 $sql = $sql . join(' OR ', $wsql);
                 if ($udata = get_data($sql)) {
                     foreach ($udata as $uitem) {
                         $myuids[] = $uitem['id'];
                     }
                     if (isset($myuids) && is_array($myuids)) {
                         $myuids = array_unique($myuids);
                         foreach ($myuids as $muid) {
                             if ($muid != uid() && $muid != $finfo['uid']) {
                                 send_notice($muid, __('API_TEXT_AT_IN_CAST_COMMENT', array(uname(), $finfo['content'], $content)), 2, array('fid' => intval($fid), $count));
                             }
                         }
                     }
                 }
             }
         }
         if ($comment = get_line("SELECT * FROM `comment` WHERE `id` = '" . intval($lid) . "' LIMIT 1", db())) {
             $comment['user'] = get_user_info_by_id($_SESSION['uid']);
             return self::send_result($comment);
         } else {
             if (db_errno() != 0) {
                 return self::send_error(LR_API_DB_ERROR, __('API_MESSAGE_DATABASE_ERROR') . mysql_error());
             } else {
                 return self::send_error(LR_API_DB_EMPTY_RESULT, __('API_MESSAGE_EMPTY_RESULT_DATA'));
             }
         }
     }
 }
Example #9
0
<?php

$member = get_member_account(true, true);
$openid = $member['openid'];
$member = member_get($openid);
$paymentconfig = "";
if (strpos($_SERVER['HTTP_USER_AGENT'], 'MicroMessenger')) {
    $paymentconfig = " and code!='alipay'";
} else {
    if (is_mobile_request()) {
        $paymentconfig = " and code!='weixin'";
    }
}
$paymentlist = mysqld_selectall("select * from " . table("payment") . " where `enabled`=1  and `code`!='gold' and `online`=1 {$paymentconfig} ");
$paymentscount = mysqld_selectcolumn("select count(id) from " . table("payment") . " where `enabled`=1  and `code`!='gold' and `online`=1 {$paymentconfig} ");
if (empty($paymentscount)) {
    message("未找到可用的在线支付方式,暂时不支持余额充值。");
}
if (checksubmit("submit")) {
    if (empty($_GP['charge']) || round($_GP['charge'], 2) <= 0) {
        message("请输入要充值的金额");
    }
    $paytypecode = $_GP['paymentcode'];
    if (empty($paytypecode)) {
        message("请选择充值方式。");
    }
    $payment = mysqld_select("select * from " . table("payment") . " where `enabled`=1 and `code`=:code and `code`!='gold' and `online`=1", array('code' => $paytypecode));
    if (empty($payment['id'])) {
        message("未找到付款方式,付款失败");
    }
    $goodtitle = "余额充值" . $_GP['charge'] . "元";
Example #10
0
function get_device()
{
    if (is_mobile_request()) {
        return 'mobile';
    } else {
        return 'web';
    }
}
Example #11
0
    // Pre-final check to reset everything if the user is on Windows
    if (strpos(strtolower($_SERVER['HTTP_USER_AGENT']), 'windows') !== false) {
        $mobile_browser = 0;
    }
    // But WP7 is also Windows, with a slightly different characteristic
    if (strpos(strtolower($_SERVER['HTTP_USER_AGENT']), 'windows phone') !== false) {
        $mobile_browser++;
    }
    if ($mobile_browser > 0) {
        return true;
    } else {
        return false;
    }
}
if (file_exists("config/install.lock")) {
    if (is_mobile_request() && ($_SERVER['REQUEST_URI'] == '/' || $_SERVER['REQUEST_URI'] == '/index.php')) {
        //手机访问的情况
        header("location:index.php?r=wap/default");
    } else {
        // change the following paths if necessary
        $yii = dirname(__FILE__) . '/framework/yii.php';
        $config = dirname(__FILE__) . '/protected/config/main.php';
        // remove the following lines when in production mode
        defined('YII_DEBUG') or define('YII_DEBUG', true);
        // specify how many levels of call stack should be shown in each log message
        defined('YII_TRACE_LEVEL') or define('YII_TRACE_LEVEL', 3);
        require_once $yii;
        Yii::createWebApplication($config)->run();
    }
} else {
    header('Location:install/index.php');
Example #12
0
<?php

header("content-type:text/html;charset=utf-8");
// 定义ThinkPHP框架路径(相对于入口文件)
define('THINK_PATH', './ThinkPHP/');
//定义项目名称
define('APP_NAME', 'wap_renrenlie');
//定义项目路径
define('APP_PATH', './Home/');
define('BACK_URL', './index.php');
define('APP_DEBUG', true);
if (is_mobile_request() === false) {
    //pc访问手机端职位详情
    if (strpos($_SERVER['REQUEST_URI'], "/Job/job_detail_new/jobid/") !== false) {
        $requesString = explode("/jobid/", $_SERVER['REQUEST_URI']);
        $requesString = explode("&share=", $requesString[1]);
        //            var_dump($requesString);die;
        //                header("Location: http://m.renrenlie.com/index.php?s=/Job/job_detail_redirect/jobid/" . $requesString[0]);
        //                die;
    }
    //        to_pc();
    //        header('Location: http://www.renrenlie.com/');
}
//加载框架入文件
require THINK_PATH . 'ThinkPHP.php';
function is_mobile_request()
{
    $_SERVER['ALL_HTTP'] = isset($_SERVER['ALL_HTTP']) ? $_SERVER['ALL_HTTP'] : '';
    $mobile_browser = '0';
    if (preg_match('/(up.browser|up.link|mmp|symbian|smartphone|midp|wap|phone|iphone|ipad|ipod|android|xoom)/i', strtolower($_SERVER['HTTP_USER_AGENT']))) {
        $mobile_browser++;
Example #13
0
function from_to_weixin()
{
    if (is_weixin() === false) {
        if (is_mobile_request() === false) {
            //                        header('Location: http://www.renrenlie.com/');
            //                        die;
        }
    }
}
 public function run($setindex = '')
 {
     IUrl::beginUrl();
     $controller = IUrl::getInfo('controller');
     $action = IUrl::getInfo('action');
     $Taction = empty($action) ? $this->defaultAction : $action;
     $info = isset($_SERVER['HTTP_X_FORWARDED_HOST']) ? $_SERVER['HTTP_X_FORWARDED_HOST'] : (isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : '');
     $sitekey = isset($this->config['sitekey']) ? $this->config['sitekey'] : '';
     //if ($this->getkey() != $sitekey) {
     //	echo 'error! 关注好资源222-www.mx800.com';
     //	exit();
     //}
     /*
     		$hostcheck = array('wmr.xiaoshuhaochi.com', 'wmr.xiaoshuhaochi.com', 'xiaoshuhaochi.com');
     
     		if (!in_array($info, $hostcheck)) {
     			echo 'error! 关注好资源111-www.mx800.com';
     			exit();
     		}*/
     if ($controller === NULL) {
         $controller = $this->defaultController;
     }
     $this->controller = $controller;
     $this->Taction = $Taction;
     if ($controller == 'site' && $Taction == 'index') {
         if (is_mobile_request()) {
             $this->controller = 'html5';
         }
     }
     spl_autoload_register('Mysite::autoload');
     $filePath = hopedir . '/lib/Smarty/libs/Smarty.class.php';
     if (!class_exists('smarty')) {
         include_once $filePath;
     }
     if ($controller == 'adminpage') {
         $smarty = new Smarty();
         $smarty->assign('siteurl', Mysite::$app->config['siteurl']);
         $smarty->cache_lifetime = 0;
         $smarty->caching = false;
         $smarty->template_dir = hopedir . '/templates/';
         $smarty->compile_dir = hopedir . '/templates_c/adminpage';
         $smarty->cache_dir = hopedir . '/smarty_cache';
         $smarty->left_delimiter = '<{';
         $smarty->right_delimiter = '}>';
         $module = IUrl::getInfo('module');
         $module = empty($module) ? 'index' : $module;
         $doaction = Mysite::$app->getAction() == 'index' ? 'system' : Mysite::$app->getAction();
         $this->Taction = $doaction;
         $this->siteset();
         if (!file_exists(hopedir . '/module/' . Mysite::$app->getAction() . '/adminmethod.php')) {
         } else {
             include hopedir . '/module/' . Mysite::$app->getAction() . '/adminmethod.php';
             $method = new method();
             $method->init();
             if (method_exists($method, $module)) {
                 call_user_func(array($method, $module));
             }
         }
         $datas = $this->getdata();
         if (is_array($datas)) {
             foreach ($datas as $key => $value) {
                 $smarty->assign($key, $value);
             }
         }
         $nowID = ICookie::get('myaddress');
         $lng = ICookie::get('lng');
         $lat = ICookie::get('lat');
         $mapname = ICookie::get('mapname');
         $adminshopid = ICookie::get('adminshopid');
         $smarty->assign('myaddress', $nowID);
         $smarty->assign('mapname', $mapname);
         $smarty->assign('adminshopid', $adminshopid);
         $smarty->assign('lng', $lng);
         $smarty->assign('lat', $lat);
         $smarty->assign('controlname', Mysite::$app->getController());
         $smarty->assign('Taction', Mysite::$app->getAction());
         $smarty->assign('urlshort', Mysite::$app->getController() . '/' . Mysite::$app->getAction());
         $templtepach = hopedir . '/templates/adminpage/' . Mysite::$app->getAction() . '/' . $module . '.html';
         if (file_exists($templtepach)) {
         } else {
             if (file_exists(hopedir . '/module/' . Mysite::$app->getAction() . '/adminpage/' . $module . '.html')) {
                 $smarty->compile_dir = hopedir . '/templates_c/adminpage/' . Mysite::$app->getAction();
                 $templtepach = hopedir . '/module/' . Mysite::$app->getAction() . '/adminpage/' . $module . '.html';
             } else {
                 logwrite('模板不存在 ');
                 $smarty->assign('msg', '模板文件不存在');
                 $smarty->assign('sitetitle', '错误提示');
                 $errorlink = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '';
                 $smarty->assign('errorlink', $errorlink);
                 $templtepach = hopedir . '/templates/adminpage/public/error.html';
             }
         }
         $smarty->assign('tmodule', $module);
         $smarty->assign('tempdir', 'adminpage');
         $smarty->registerPlugin('function', 'ofunc', 'FUNC_function');
         $smarty->registerPlugin('block', 'oblock', 'FUNC_block');
         $smarty->display($templtepach);
         exit;
     } else {
         $smarty = new Smarty();
         $smarty->assign('siteurl', Mysite::$app->config['siteurl']);
         $smarty->cache_lifetime = 0;
         $smarty->caching = false;
         $smarty->template_dir = hopedir . '/templates';
         $smarty->compile_dir = hopedir . '/templates_c/' . Mysite::$app->config['sitetemp'];
         $smarty->cache_dir = hopedir . '/smarty_cache';
         $smarty->left_delimiter = '<{';
         $smarty->right_delimiter = '}>';
         $this->siteset();
         if (!file_exists(hopedir . 'module/' . Mysite::$app->getController() . '/method.php')) {
             $this->setController = 'site';
             $this->setAction = 'error';
         } else {
             include hopedir . 'module/' . Mysite::$app->getController() . '/method.php';
             $method = new method();
             $method->init();
             if (method_exists($method, $Taction)) {
                 call_user_func(array($method, $Taction));
             }
         }
         $datas = $this->getdata();
         if (is_array($datas)) {
             foreach ($datas as $key => $value) {
                 $smarty->assign($key, $value);
             }
         }
         $nowID = ICookie::get('myaddress');
         $lng = ICookie::get('lng');
         $lat = ICookie::get('lat');
         $mapname = ICookie::get('mapname');
         $adminshopid = ICookie::get('adminshopid');
         $smarty->assign('myaddress', $nowID);
         $smarty->assign('mapname', $mapname);
         $smarty->assign('adminshopid', $adminshopid);
         $smarty->assign('lng', $lng);
         $smarty->assign('lat', $lat);
         $smarty->assign('controlname', Mysite::$app->getController());
         $smarty->assign('Taction', Mysite::$app->getAction());
         $smarty->assign('urlshort', Mysite::$app->getController() . '/' . Mysite::$app->getAction());
         $templtepach = hopedir . '/templates/' . Mysite::$app->config['sitetemp'] . '/' . Mysite::$app->getController() . '/' . Mysite::$app->getAction() . '.html';
         if (file_exists($templtepach)) {
         } else {
             if (file_exists(hopedir . '/module/' . Mysite::$app->getController() . '/template/' . Mysite::$app->getAction() . '.html')) {
                 $smarty->compile_dir = hopedir . '/templates_c/system';
                 $templtepach = hopedir . '/module/' . Mysite::$app->getController() . '/template/' . Mysite::$app->getAction() . '.html';
             } else {
                 logwrite('模板不存在 ');
                 $smarty->assign('msg', '模板文件不存在');
                 $smarty->assign('sitetitle', '错误提示');
                 $errorlink = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '';
                 $smarty->assign('errorlink', $errorlink);
                 $templtepach = hopedir . '/templates/' . Mysite::$app->config['sitetemp'] . '/public/error.html';
             }
         }
         $smarty->assign('tempdir', Mysite::$app->config['sitetemp']);
         $smarty->registerPlugin('function', 'ofunc', 'FUNC_function');
         $smarty->registerPlugin('block', 'oblock', 'FUNC_block');
         $smarty->display($templtepach);
     }
 }