本文整理汇总了PHP中zmf::now方法的典型用法代码示例。如果您正苦于以下问题:PHP zmf::now方法的具体用法?PHP zmf::now怎么用?PHP zmf::now使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类zmf
的用法示例。
在下文中一共展示了zmf::now方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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;
}
}
}
示例2: formatTime
public static function formatTime($date)
{
$thisyear = intval(zmf::time(NULL, 'Y'));
$dateyear = intval(zmf::time($date, 'Y'));
if ($thisyear - $dateyear > 0) {
return zmf::time($date, 'Y-m-d H:i');
}
$thismo = intval(zmf::time(NULL, 'm'));
$datemo = intval(zmf::time($date, 'm'));
if ($thisyear == $dateyear && $thismo != $datemo) {
return zmf::time($date, 'm-d H:i');
}
$timer = $date;
$diff = zmf::now() - $timer;
$thisto = intval(zmf::time(NULL, 'd'));
$dateto = intval(zmf::time($date, 'd'));
$day = $thisto - $dateto;
$free = $diff % 86400;
if ($day > 0) {
if ($day > 7) {
return zmf::time($date, 'n-j H:i');
} elseif ($day == 1) {
return "昨天 " . zmf::time($date, 'H:i');
} elseif ($day == 2) {
return "前天 " . zmf::time($date, 'H:i');
} else {
return $day . "天前";
}
} else {
if ($free > 0) {
$hour = floor($free / 3600);
$free = $free % 3600;
if ($hour > 0) {
return $hour . "小时前";
} else {
if ($free > 0) {
$min = floor($free / 60);
$free = $free % 60;
if ($min > 0) {
return $min . "分钟前";
} else {
if ($free > 0) {
return $free . "秒前";
} else {
return '刚刚';
}
}
} else {
return '刚刚';
}
}
} else {
return '刚刚';
}
}
}
示例3: add
public static function add($params = array())
{
$data = array('uid' => $params['uid'], 'authorid' => $params['authorid'], '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 ($params['uid'] == $params['authorid']) {
return false;
}
$model = new Notification();
//2016修改为不计条数
$model->attributes = $data;
return $model->save();
}
示例4: calScore
/**
* 计算回答的得分
* @param type $info
* @return double
*/
public static function calScore($info)
{
//距离回答发表的时间
$Qage = (zmf::now() - $info['cTime']) / 3600;
$Qage = round($Qage, 1);
//距离最后一个回答的时间
$Qupdated = (zmf::now() - $info['lastupdate']) / 3600;
$Qupdated = round($Qupdated, 1);
//todo,是否考虑回答的评论数
$dividend = log10($info['hits']) * 4 + $info['comments'] * ($info['favor'] - $info['nouse']) / 5;
$divisor = pow($Qage + 1 - ($Qage - $Qupdated) / 2, 1.5);
return round($dividend / $divisor * 100000, 9);
}
示例5: actionLogin
function actionLogin()
{
$this->layout = 'common';
if (!Yii::app()->user->isGuest) {
$this->message(0, '您已登录,请勿重复操作', Yii::app()->createUrl('admin/index/index'));
}
$model = new LoginForm();
if (isset($_POST['ajax']) && $_POST['ajax'] === 'login-form') {
echo CActiveForm::validate($model);
Yii::app()->end();
}
if (isset($_POST['LoginForm'])) {
$model->attributes = $_POST['LoginForm'];
if ($model->validate() && $model->login()) {
$arr = array('latestLoginTime' => zmf::now());
$uid = Yii::app()->user->id;
if (!$this->checkPower('user', $uid, true)) {
Yii::app()->user->logout();
$model->addError('username', '您不是管理员');
} else {
//User::model()->updateByPk($uid, $arr);
zmf::delCookie('checkWithCaptcha');
//只允许单点登录
$randKey = zmf::randMykeys(8);
zmf::setCookie('adminRandKey' . $uid, $randKey, 86400);
zmf::setFCache('adminRandKey' . $uid, $randKey, 86400);
//记录操作
//UserLog::add($uid, '登录后台'.Yii::app()->request->userHostAddress);
$uuid = zmf::uuid();
zmf::setCookie('userCheckedLogin' . $uid, $uuid, 86400);
$this->redirect(array('index/index'));
}
} else {
$times = zmf::getCookie('checkWithCaptcha');
zmf::setCookie('checkWithCaptcha', intval($times) + 1, 86400);
}
}
$data = array('model' => $model);
$this->render('login', $data);
}
示例6: actionLogin
public function actionLogin()
{
$this->onlyOnPc();
$this->layout = 'common';
if (!Yii::app()->user->isGuest) {
$this->message(0, '您已登录,请勿重复操作');
}
$canLogin = true;
$ip = Yii::app()->request->getUserHostAddress();
$cacheKey = 'loginErrors-' . $ip;
$errorTimes = zmf::getFCache($cacheKey);
if ($errorTimes >= 5) {
$canLogin = false;
}
if ($canLogin) {
$model = new FrontLogin();
if (isset($_POST['FrontLogin'])) {
$model->attributes = $_POST['FrontLogin'];
if ($model->validate() && $model->login()) {
$arr = array('latestLoginTime' => zmf::now());
$uid = Yii::app()->user->id;
// User::model()->updateByPk($uid, $arr);
zmf::delCookie('checkWithCaptcha');
zmf::delFCache($cacheKey);
if ($this->referer) {
$this->redirect($this->referer);
} else {
$this->redirect(zmf::config('baseurl'));
}
} else {
zmf::updateFCacheCounter($cacheKey, 1, 3600);
zmf::setCookie('checkWithCaptcha', 1, 86400);
}
}
}
$this->pageTitle = '登录';
$this->render('login', array('model' => $model));
}
示例7: actionLogin
public function actionLogin($from = '')
{
if (!Yii::app()->user->isGuest) {
$this->message(0, '您已登录,请勿重复操作');
}
$model = new LoginForm();
//登录
if (isset($_POST['ajax']) && $_POST['ajax'] === 'login-form') {
echo CActiveForm::validate($model);
Yii::app()->end();
}
if (isset($_POST['ajax']) && $_POST['ajax'] === 'users-addUser-form') {
echo CActiveForm::validate($modelUser);
Yii::app()->end();
}
//登录
if (isset($_POST['LoginForm'])) {
$from = 'login';
$model->attributes = $_POST['LoginForm'];
if ($model->validate()) {
if ($model->login()) {
$arr = array('last_login_ip' => ip2long(Yii::app()->request->userHostAddress), 'last_login_time' => zmf::now());
Users::model()->updateByPk(Yii::app()->user->id, $arr);
Users::model()->updateCounters(array('login_count' => 1), ':id=id', array(':id' => Yii::app()->user->id));
if ($this->referer == '') {
$this->referer = array('users/index');
}
zmf::delCookie('checkWithCaptcha');
$this->redirect($this->referer);
}
} else {
zmf::setCookie('checkWithCaptcha', 1, 86400);
}
}
$this->pageTitle = '登录 - ' . zmf::config('sitename');
$this->render('login', array('model' => $model));
}
示例8: array
?>
<?php
$this->widget('zii.widgets.jui.CJuiDatePicker', array('model' => $model, 'attribute' => 'startTime', 'language' => 'zh-cn', 'value' => date('Y/m/d', $model->startTime), 'options' => array('showAnim' => 'fadeIn'), 'htmlOptions' => array('readonly' => 'readonly', 'class' => 'form-control', 'value' => date('Y/m/d', $model->startTime ? $model->startTime : zmf::now()))));
?>
<?php
echo $form->error($model, 'startTime');
?>
</div>
</div>
<div class="col-sm-6 col-xs-6">
<div class="form-group">
<?php
echo $form->labelEx($model, 'endTime');
?>
<?php
$this->widget('zii.widgets.jui.CJuiDatePicker', array('model' => $model, 'attribute' => 'endTime', 'language' => 'zh-cn', 'value' => date('Y/m/d', $model->endTime), 'options' => array('showAnim' => 'fadeIn'), 'htmlOptions' => array('readonly' => 'readonly', 'class' => 'form-control', 'value' => date('Y/m/d', $model->endTime ? $model->endTime : zmf::now()))));
?>
<?php
echo $form->error($model, 'endTime');
?>
</div>
</div>
</div>
<div class="row">
<div class="col-sm-6 col-xs-6">
<div class="form-group">
<?php
echo $form->labelEx($model, 'areaid');
?>
<?php
$areaTitle = '';
示例9: add
private function add($type = '')
{
$uid = zmf::filterInput(Yii::app()->request->getParam('uid'), 't', 1);
if (!$uid) {
$uid = zmf::uid();
}
if (zmf::config('fbLoginOnly')) {
if (!$uid) {
$this->jsonOutPut(0, Yii::t('default', 'fbLoginOnly'));
}
}
$url = zmf::filterInput(Yii::app()->request->getParam('url'), 't', 1);
$email = zmf::filterInput(Yii::app()->request->getParam('email'), 't', 1);
$content = zmf::filterInput(Yii::app()->request->getParam('content'), 't', 1);
$ip = zmf::filterInput(Yii::app()->request->getParam('ip'), 't', 1);
$appversion = zmf::filterInput(Yii::app()->request->getParam('appversion'), 't', 1);
$os = zmf::filterInput(Yii::app()->request->getParam('os'), 't', 1);
$platform = zmf::filterInput(Yii::app()->request->getParam('platform'), 't', 1);
$time = zmf::filterInput(Yii::app()->request->getParam('time'), 't', 1);
if (!$ip) {
$ip = ip2long(Yii::app()->request->userHostAddress);
}
if (!$platform) {
$platform = Yii::app()->request->getUserAgent();
}
if ($type == '' || !in_array($type, array('pc', 'mobile', 'ios', 'android'))) {
$type = 'pc';
}
if (!$time) {
$time = zmf::now();
}
$cacheKey = 'feedback_' . $ip;
if ($content == '') {
$this->jsonOutPut(0, Yii::t('default', 'fbNoEmpty'));
}
if (zmf::config('fbTimesLimit')) {
$times = intval(zmf::getFCache($cacheKey));
$_time = $times + 1;
//fbLimitTimes
zmf::setFCache($cacheKey, $_time, 60);
if ($_time >= zmf::config('fbLimitTimes')) {
$this->jsonOutPut(0, Yii::t('default', 'fbTimesLimit'));
}
}
$data = array('uid' => $uid, 'url' => $url, 'email' => $email, 'content' => $content, 'ip' => $ip, 'cTime' => $time, 'status' => Posts::STATUS_STAYCHECK, 'classify' => $type, 'appversion' => $appversion, 'os' => $os, 'platform' => $platform);
$model = new Feedback();
$model->attributes = $data;
if ($model->validate()) {
if ($model->save()) {
if (zmf::config("defaultNoticeUid")) {
$_data = array('uid' => zmf::config("defaultNoticeUid"), 'content' => ($email != '' ? $email . '反馈:' : '新反馈:') . $content, 'type' => 'feedback', 'from_id' => rand(1, 100000), 'from_idtype' => 'feedback');
Notification::add($_data);
}
$this->jsonOutPut(1, Yii::t('default', 'fbThanking'));
} else {
$this->jsonOutPut(0, Yii::t('default', 'fbThanking'));
}
} else {
$this->jsonOutPut(0, Yii::t('default', 'notvalidate'));
}
}
示例10: favorite
public static function favorite($code, $type, $from = 'web', $uid = '')
{
if (!$code || !$type) {
return array('status' => 0, 'msg' => '数据不全,请核实');
}
if (!in_array($type, array('post'))) {
return array('status' => 0, 'msg' => '暂不允许的分类');
}
if (is_numeric($code)) {
$id = $code;
} else {
$codeArr = Posts::decode($code);
if ($codeArr['type'] != $type || !is_numeric($codeArr['id']) || $codeArr['id'] < 1) {
$this->jsonOutPut(0, '您所查看的内容不存在');
}
$id = $codeArr['id'];
}
if (!$uid) {
$uid = zmf::uid();
}
if ($uid) {
if (zmf::actionLimit('favorite-' . $type, $id)) {
return array('status' => 0, 'msg' => '操作太频繁,请稍后再试');
}
} else {
//没有登录的访客点收藏时判断是否已收藏过
if (zmf::actionLimit('favorite-' . $type, $id, 1, 86400, true)) {
return array('status' => 1, 'msg' => '已点赞', 'state' => 1);
}
$uid = 0;
}
$postInfo = Posts::model()->findByPk($id);
if (!$postInfo || $postInfo['status'] != Posts::STATUS_PASSED) {
return array('status' => 0, 'msg' => '文章不存在');
}
$attr = array('uid' => $uid, 'logid' => $id, 'classify' => $type);
$info = false;
if ($uid) {
$info = Favorites::model()->findByAttributes($attr);
}
if ($info) {
if (Favorites::model()->deleteByPk($info['id'])) {
if ($type == 'post') {
Posts::updateCount($id, 'Posts', -1, 'favorite');
}
return array('status' => 1, 'msg' => '取消点赞', 'state' => 3);
} else {
return array('status' => 0, 'msg' => '取消点赞失败', 'state' => 4);
}
} else {
$attr['cTime'] = zmf::now();
$model = new Favorites();
$model->attributes = $attr;
if ($model->save()) {
if ($type == 'post') {
Posts::updateCount($id, 'Posts', 1, 'favorite');
}
//点赞后给对方发提醒
$_noticedata = array('uid' => $postInfo['uid'], 'authorid' => $uid, 'content' => "您的文章【{$postInfo['title']}】有了新的赞", 'new' => 1, 'type' => 'favorite', 'cTime' => zmf::now(), 'from_id' => $model->id, 'from_num' => 1);
Notification::add($_noticedata);
return array('status' => 1, 'msg' => '点赞成功', 'state' => 1);
} else {
return array('status' => 0, 'msg' => '点赞失败', 'state' => 2);
}
}
}
示例11: rules
public function rules()
{
return array(array('uid', 'default', 'setOnEmpty' => true, 'value' => zmf::uid()), array('open', 'default', 'setOnEmpty' => true, 'value' => 1), array('cTime', 'default', 'setOnEmpty' => true, 'value' => zmf::now()), array('open', 'numerical', 'integerOnly' => true), array('uid, logid, cTime', 'length', 'max' => 11), array('classify', 'length', 'max' => 32), array('uid, logid, classify', 'safe', 'on' => 'search'));
}
示例12: rules
/**
* @return array validation rules for model attributes.
*/
public function rules()
{
// NOTE: you should only define rules for those attributes that
// will receive user inputs.
return array(array('uid', 'default', 'setOnEmpty' => true, 'value' => zmf::uid()), array('cTime', 'default', 'setOnEmpty' => true, 'value' => zmf::now()), array('status', 'default', 'setOnEmpty' => true, 'value' => Posts::STATUS_STAYCHECK), array('uid, title,avatar', 'required'), array('members, status,avatar,creditStatus,areaid', 'numerical', 'integerOnly' => true), array('uid,createAt, cTime,avatar,areaid', 'length', 'max' => 10), array('qq,weixin', 'length', 'max' => 25), array('title,address, slogan, phone,content,tagids,contact,openTime,email,weibo,website', 'length', 'max' => 255));
}
示例13: rules
public function rules()
{
return array(array('title,content', 'required'), array('cTime', 'default', 'setOnEmpty' => true, 'value' => zmf::now()), array('status', 'default', 'setOnEmpty' => true, 'value' => Posts::STATUS_PASSED), array('uid', 'default', 'setOnEmpty' => true, 'value' => zmf::uid()), array('status, top', 'numerical', 'integerOnly' => true), array('uid, attachid, hits, comments, favors, cTime', 'length', 'max' => 10), array('title, source, sourceurl', 'length', 'max' => 255), array('classify', 'length', 'max' => 16), array('uid, title, classify, content', 'safe', 'on' => 'search'));
}
示例14: time
/**
* 格式化时间戳
* @param type $time
* @param type $format
* @return type
*/
public static function time($time = '', $format = 'Y-m-d H:i:s')
{
if (!$time) {
$time = zmf::now();
}
$timeset = date_default_timezone_get();
if (!in_array($timeset, array('Etc/GMT-8', 'PRC', 'Asia/Shanghai', 'Asia/Shanghai', 'Asia/Chongqing'))) {
date_default_timezone_set('Etc/GMT-8');
}
return date($format, $time);
}
示例15: actionUpload
public function actionUpload()
{
$uptype = zmf::filterInput($_GET['type'], 't', 1);
$logid = zmf::filterInput($_GET['id']);
//所属对象
$reImgsize = zmf::filterInput($_GET['imgsize']);
//返回图片的尺寸
$fileholder = zmf::filterInput($_GET['fileholder'], 't', 1);
//上传控件的ID
//将ads替换为flash
if (!isset($uptype) or !in_array($uptype, array('siteinfo', 'post'))) {
$this->jsonOutPut(0, '请设置上传所属类型' . $uptype);
}
if (Yii::app()->request->getParam('PHPSESSID')) {
Yii::app()->session->close();
$res = Yii::app()->session->setSessionID(Yii::app()->request->getParam('PHPSESSID'));
Yii::app()->session->open();
}
if (Yii::app()->user->isGuest) {
$this->jsonOutPut(0, Yii::t('default', 'loginfirst'));
}
if (!$fileholder) {
$fileholder = 'filedata';
}
if (!isset($_FILES[$fileholder]) || !is_uploaded_file($_FILES[$fileholder]["tmp_name"]) || $_FILES[$fileholder]["error"] != 0) {
$this->jsonOutPut(0, '无效上传,请重试');
}
$model = new Attachments();
$img = CUploadedFile::getInstanceByName($fileholder);
$ext = $img->getExtensionName();
$size = $img->getSize();
if ($size > zmf::config('imgMaxSize')) {
$this->jsonOutPut(0, '上传文件最大尺寸为:' . tools::formatBytes(zmf::config('imgMaxSize')));
}
$upExt = zmf::config("imgAllowTypes");
if (!preg_match('/^(' . str_replace('*.', '|', str_replace(';', '', $upExt)) . ')$/i', $ext)) {
$this->jsonOutPut(0, '上传文件扩展名必需为:' . $upExt);
}
$sizeinfo = getimagesize($_FILES[$fileholder]["tmp_name"]);
if ($sizeinfo['0'] < zmf::config('imgMinWidth') or $sizeinfo[1] < zmf::config('imgMinHeight')) {
$this->jsonOutPut(0, "要求上传的图片尺寸,宽不能不小于" . zmf::config('imgMinWidth') . "px,高不能小于" . zmf::config('imgMinHeight') . "px.");
}
$ctime = zmf::now();
$dirs = zmf::uploadDirs($ctime, 'app', $uptype, null, true);
$fileName = uniqid() . '.' . $ext;
$origin = $dirs['origin'];
unset($dirs['origin']);
$uploadedFiles = array();
$uploadedFiles[] = array('from' => $origin . $fileName, 'to' => zmf::ftpPath($ctime, $uptype, 'origin') . $fileName);
if (move_uploaded_file($_FILES[$fileholder]["tmp_name"], $origin . $fileName)) {
$data = array();
$status = Posts::STATUS_PASSED;
$data['uid'] = Yii::app()->user->id;
$data['logid'] = $logid;
$data['filePath'] = $fileName;
$data['fileDesc'] = $fileName;
$data['classify'] = $uptype;
$data['covered'] = '0';
$data['cTime'] = time();
$data['status'] = $status;
$data['width'] = $sizeinfo[0];
$data['height'] = $sizeinfo[1];
$data['size'] = $size;
$model->attributes = $data;
if ($model->validate()) {
if ($model->save()) {
$image = Yii::app()->image->load($origin . $fileName);
$_quality = zmf::config('imgQuality');
$quality = isset($quality) ? $quality : 100;
foreach ($dirs as $dk => $_dir) {
if ($dk < 600) {
$image->smart_resize($dk, $dk * 0.75)->quality($quality);
} else {
$image->resize($dk, $dk)->quality($quality);
}
$image->save($_dir . $fileName);
$_todir = zmf::ftpPath($ctime, $uptype, $dk);
$uploadedFiles[] = array('id' => $model->id, 'from' => $_dir . $fileName, 'to' => $_todir . $fileName);
}
$imgsize = $reImgsize > 0 ? $reImgsize : 170;
$returnimg = zmf::uploadDirs($ctime, 'site', $uptype, $imgsize) . $fileName;
$outPutData = array('status' => 1, 'attachid' => $model->id, 'imgsrc' => $returnimg);
$json = CJSON::encode($outPutData);
echo $json;
} else {
$this->jsonOutPut(0, '写入数据库错误');
}
} else {
$this->jsonOutPut(0, '数据验证错误');
}
}
}