本文整理汇总了PHP中zmf类的典型用法代码示例。如果您正苦于以下问题:PHP zmf类的具体用法?PHP zmf怎么用?PHP zmf使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了zmf类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: beforeSave
public function beforeSave()
{
$ip = Yii::app()->request->userHostAddress;
$key = 'ipInfo-' . $ip;
$ipData = zmf::getCookie($key);
if (!$ipData) {
$url = 'http://apis.baidu.com/apistore/iplookupservice/iplookup?ip=' . $ip;
// 执行HTTP请求
$header = array('apikey:e5882e7ac4b03c5d6f332b6de4469e81');
$ch = curl_init();
// 添加apikey到header
curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_URL, $url);
$res = curl_exec($ch);
$res = CJSON::decode($res, true);
$retData = array();
if ($res['errNum'] == 0) {
$retData = $res['retData'];
}
$ipData = json_encode($retData);
zmf::setCookie($key, $ipData, 2592000);
}
$this->ip = ip2long($ip);
$this->ipInfo = $ipData;
return true;
}
示例2: _referer
function _referer()
{
$currentUrl = Yii::app()->request->url;
$arr = array('/site/', '/error/', '/attachments/');
$set = true;
if (Common::checkImg($currentUrl)) {
$set = false;
}
if ($set) {
foreach ($arr as $val) {
if (!$set) {
break;
}
if (strpos($currentUrl, $val) !== false) {
$set = false;
break;
}
}
}
if ($set && Yii::app()->request->isAjaxRequest) {
$set = false;
}
$referer = zmf::getCookie('refererUrl');
if ($set) {
zmf::setCookie('refererUrl', $currentUrl, 86400);
}
if ($referer != '') {
$this->referer = $referer;
}
}
示例3: actionView
public function actionView()
{
$id = zmf::val('id', 2);
if (!$id) {
throw new CHttpException(404, 'The requested page does not exist.');
}
$info = $this->loadModel($id);
$pageSize = 30;
$comments = Comments::getCommentsByPage($id, 'posts', 1, $pageSize);
$tags = Tags::getByIds($info['tagids']);
$relatePosts = Posts::getRelations($id, 5);
if (!zmf::actionLimit('visit-Posts', $id, 5, 60)) {
Posts::updateCount($id, 'Posts', 1, 'hits');
}
$size = '600';
if ($this->isMobile) {
$size = '640';
}
$info['content'] = zmf::text(array(), $info['content'], true, $size);
$data = array('info' => $info, 'comments' => $comments, 'tags' => $tags, 'relatePosts' => $relatePosts, 'loadMore' => count($comments) == $pageSize ? 1 : 0);
$this->favorited = Favorites::checkFavored($id, 'post');
$this->pageTitle = $info['title'];
$this->selectNav = 'posts';
$this->render('view', $data);
}
示例4: actionIndex
public function actionIndex()
{
$type = zmf::val('type', 1);
if (!$type || $type == 'staycheck') {
$status = Posts::STATUS_STAYCHECK;
} else {
$status = Posts::STATUS_PASSED;
}
$sql = "SELECT c.id,c.uid,c.content,c.cTime,p.title,c.logid,c.status FROM {{comments}} c,{{posts}} p WHERE c.status={$status} AND c.logid=p.id ORDER BY c.cTime DESC";
Posts::getAll(array('sql' => $sql), $pager, $items);
if (!empty($items)) {
$uids = array_filter(array_keys(CHtml::listData($items, 'uid', '')));
$uidsStr = join(',', $uids);
if ($uidsStr != '') {
$usernames = Yii::app()->db->createCommand("SELECT id,truename FROM {{users}} WHERE id IN({$uidsStr})")->queryAll();
if (!empty($usernames)) {
foreach ($items as $k => $val) {
foreach ($usernames as $val2) {
if ($val['uid'] > 0 && $val['uid'] == $val2['id']) {
$items[$k]['loginUsername'] = $val2['truename'];
}
}
}
}
}
}
$this->render('index', array('pages' => $pager, 'posts' => $items));
}
示例5: init
public function init()
{
parent::init();
$passwdErrorTimes = zmf::getCookie('checkWithCaptcha');
$time = zmf::config('adminErrorTimes');
if ($time > 0) {
if ($passwdErrorTimes >= $time) {
header('Content-Type: text/html; charset=utf-8');
echo '您暂时已被禁止访问';
Yii::app()->end();
}
}
$uid = zmf::uid();
if ($uid) {
// $randKey_cookie = zmf::getCookie('adminRandKey' . $uid);
// $randKey_cache = zmf::getFCache('adminRandKey' . $uid);
// if (!$randKey_cookie || ($randKey_cache != $randKey_cookie)) {
// Yii::app()->user->logout();
// $this->message(0, '登录已过期,请重新登录', Yii::app()->createUrl('admin/site/login'));
// }
$this->userInfo = Users::getOne($uid);
$this->uid = $uid;
} else {
$currentUrl = Yii::app()->request->url;
if (strpos($currentUrl, '/site/') === false) {
$this->message(0, '请先登录', Yii::app()->createUrl('/site/login'));
}
}
}
示例6: actionExrates
/**
* 获取汇率
* 雅虎YQL https://developer.yahoo.com/yql/console/
* 请求语句 select * from yahoo.finance.xchange where pair="CNYUSD,CNYHKD"
* 示例 https://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20yahoo.finance.xchange%20where%20pair%3D%22CNYUSD%2CCNYHKD%22%0A%09%09&format=json&env=http%3A%2F%2Fdatatables.org%2Falltables.env&callback=
*/
public function actionExrates()
{
$units = tools::getUnits();
unset($units['CNY']);
$arr = array();
foreach ($units as $k => $v) {
$arr[] = 'CNY' . $k;
}
$str = join(',', $arr);
$url = "https://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20yahoo.finance.xchange%20where%20pair%3D%22{$str}%22%0A%09%09&format=json&env=http%3A%2F%2Fdatatables.org%2Falltables.env&callback=";
$output = zmf::curlget($url);
if (!$output) {
exit('Failed');
}
$rateArr = CJSON::decode($output);
$rateArr = $rateArr['query']['results']['rate'];
foreach ($rateArr as $val) {
$_key = str_replace('CNY', '', $val['id']);
$rates[$_key] = array('rate' => $val['Rate'], 'title' => tools::getUnits($_key));
}
$detailDir = Yii::app()->basePath . '/runtime/rates/';
zmf::createUploadDir($detailDir);
$dir = $detailDir . 'detail.log';
file_put_contents($dir, CJSON::encode($rates));
exit('well done');
}
示例7: add
public static function add($params = array())
{
$uid = zmf::uid();
$data = array('uid' => $params['uid'], 'authorid' => $uid, 'content' => $params['content'], 'new' => 1, 'type' => $params['type'], 'cTime' => zmf::now(), 'from_id' => $params['from_id'], 'from_idtype' => $params['from_idtype'], 'from_num' => 1);
if ($uid == $params['uid']) {
return false;
}
$model = new Notification();
$info = $model->find("uid=:uid AND authorid=:authorid AND from_id=:from AND type=:type", array(':uid' => $params['uid'], ':authorid' => $uid, ':from' => $params['from_id'], ':type' => $params['type']));
if ($info) {
//存在则更新最新操作时间
if ($model->updateByPk($info['id'], array('cTime' => time(), 'new' => 1, 'from_num' => $info['from_num'] + 1))) {
return true;
} else {
return false;
}
} else {
//不存在则新增
$model->attributes = $data;
if ($model->save()) {
return true;
} else {
return false;
}
}
}
示例8: loadCssJs
public function loadCssJs($type = 'web')
{
$_staticUrl = zmf::config('cssJsStaticUrl');
$staticUrl = $_staticUrl ? $_staticUrl : zmf::config('baseurl');
$cs = Yii::app()->clientScript;
if ($type == 'wedding') {
$cs->registerCssFile($staticUrl . 'common/css/bootstrap.min.css');
$cs->registerCssFile($staticUrl . 'common/css/font-awesome.min.css');
$cs->registerCssFile($staticUrl . 'common/css/wedding.css');
$cs->registerCoreScript('jquery');
$cs->registerScriptFile($staticUrl . "common/js/bootstrap.min.js", CClientScript::POS_END);
$cs->registerScriptFile($staticUrl . "common/js/wedding.js", CClientScript::POS_END);
} elseif ($type == 'user') {
$cs->registerCssFile($staticUrl . 'common/css/bootstrap.min.css');
$cs->registerCssFile($staticUrl . 'common/css/font-awesome.min.css');
$cs->registerCssFile($staticUrl . 'common/css/user.css');
$cs->registerCoreScript('jquery');
$cs->registerScriptFile($staticUrl . "common/js/bootstrap.min.js", CClientScript::POS_END);
$cs->registerScriptFile($staticUrl . "common/js/wedding.js", CClientScript::POS_END);
} elseif ($type == 'group') {
$cs->registerCssFile($staticUrl . 'common/css/bootstrap.min.css');
$cs->registerCssFile($staticUrl . 'common/css/font-awesome.min.css');
$cs->registerCssFile($staticUrl . 'common/css/group.css');
$cs->registerCoreScript('jquery');
$cs->registerScriptFile($staticUrl . "common/js/bootstrap.min.js", CClientScript::POS_END);
$cs->registerScriptFile($staticUrl . "common/js/wedding.js", CClientScript::POS_END);
}
}
示例9: init
public function init()
{
parent::init();
if (zmf::config('closeSite')) {
header("Content-type: text/html; charset=utf-8");
exit(zmf::config('closeSiteReason'));
}
$this->layout = '//layouts/wedding';
$this->currentModule = 'wedding';
// Yii::app()->theme = 'web';
// if (isset($_GET['lang']) && in_array($_GET['lang'], array('zh_cn', 'zh_tw', 'en'))) {
// Yii::app()->language = $_GET['lang'];
// zmf::delCookie('lang');
// zmf::setCookie('lang', $_GET['lang']);
// }
// $lang = zmf::getCookie('lang');
// if ($lang != '') {
// Yii::app()->language = $lang;
// } else {
// $countryCode = zmf::getCountryByIp();
// $countryCode = strtoupper($countryCode);
// if ($countryCode == 'CN') {
// Yii::app()->language = 'zh_cn';
// } elseif (in_array($countryCode, array('HK', 'MO', 'TW'))) {
// Yii::app()->language = 'zh_tw';
// } elseif ($countryCode == 'IANA') {
// Yii::app()->language = 'zh_cn';
// } else {
// Yii::app()->language = 'en';
// }
// zmf::setCookie('lang', Yii::app()->language);
// }
}
示例10: init
public function init()
{
if (!zmf::uid()) {
$this->redirect(zmf::config('baseurl'));
}
Users::checkPower('admin');
Yii::app()->language = 'zh_cn';
}
示例11: rules
public function rules()
{
$rules = array(array('email, password', 'required'), array('rememberMe', 'boolean'), array('password', 'authenticate'));
$cookieInfo = zmf::getCookie('checkWithCaptcha');
if ($cookieInfo == '1') {
$rules[] = array('verifyCode', 'captcha', 'allowEmpty' => !CCaptcha::checkRequirements());
}
return $rules;
}
示例12: init
public function init()
{
if (zmf::config('mobile')) {
if (tools::checkmobile($this->platform)) {
Yii::app()->theme = 'mobile';
$this->isMobile = 'yes';
}
}
}
示例13: getAvatar
public static function getAvatar($aid, $size = 170)
{
$info = Attachments::getOne($aid);
$url = '';
if ($info) {
$url = zmf::uploadDirs($info['cTime'], 'site', $info['classify'], $size) . $info['filePath'];
}
return $url;
}
示例14: actionNotice
public function actionNotice()
{
$sql = "SELECT * FROM {{notification}} WHERE uid='{$this->uid}' ORDER BY cTime DESC";
Posts::getAll(array('sql' => $sql), $pages, $comLists);
Notification::model()->updateAll(array('new' => 0), 'uid=:uid', array(':uid' => $this->uid));
$data = array('posts' => $comLists, 'pages' => $pages);
$this->pageTitle = $this->userInfo['truename'] . '的提醒 - ' . zmf::config('sitename');
$this->render('notice', $data);
}
示例15: init
public function init()
{
//zh_tw\en_us
Yii::app()->language = 'zh_cn';
if (zmf::config('mobile')) {
if (tools::checkmobile($this->platform)) {
$this->isMobile = 'yes';
}
}
}