本文整理汇总了PHP中XUtils类的典型用法代码示例。如果您正苦于以下问题:PHP XUtils类的具体用法?PHP XUtils怎么用?PHP XUtils使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了XUtils类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: actionLogin
/**
* 会员登录
*/
public function actionLogin()
{
$model = new Admin('login');
if (XUtils::method() == 'POST') {
$model->attributes = $_POST['Admin'];
if ($model->validate()) {
$data = $model->find('username=:username', array('username' => $model->username));
if ($data === null) {
$model->addError('username', '用户不存在');
AdminLogger::_create(array('catalog' => 'login', 'intro' => '登录失败,用户不存在:' . CHtml::encode($model->username), 'user_id' => 0));
} elseif (!$model->validatePassword($data->password)) {
$model->addError('password', '密码不正确');
AdminLogger::_create(array('catalog' => 'login', 'intro' => '登录失败,密码不正确:' . CHtml::encode($model->username) . ',使用密码:' . CHtml::encode($model->password), 'user_id' => 0));
} elseif ($data->group_id == 2) {
$model->addError('username', '用户被锁定,请联系网站管理');
} else {
parent::_stateWrite(array('userId' => $data->id, 'userName' => $data->username, 'groupId' => $data->group_id, 'super' => $data->group_id == 1 ? 1 : 0), array('prefix' => '_admini'));
$data->last_login_ip = XUtils::getClientIP();
$data->last_login_time = time();
$data->login_count = $data->login_count + 1;
$data->save();
AdminLogger::_create(array('catalog' => 'login', 'intro' => '用户登录成功:' . CHtml::encode($model->username)));
$this->redirect(array('default/index'));
}
}
}
$this->render('login', array('model' => $model));
}
示例2: actionBasicExecute
/**
* 上传
*/
public function actionBasicExecute()
{
if (XUtils::method() == 'POST') {
$adminiUserId = self::_sessionGet('adminiUserId');
$file = XUpload::upload($_FILES['imgFile']);
if (is_array($file)) {
$model = new Upload();
$model->user_id = intval($accountUserId);
$model->file_name = $file['pathname'];
$model->thumb_name = $file['paththumbname'];
$model->real_name = $file['name'];
$model->file_ext = $file['extension'];
$model->file_mime = $file['type'];
$model->file_size = $file['size'];
$model->save_path = $file['savepath'];
$model->hash = $file['hash'];
$model->save_name = $file['savename'];
$model->create_time = time();
if ($model->save()) {
exit(CJSON::encode(array('state' => 'success', 'fileId' => $model->id, 'realFile' => $model->real_name, 'message' => '上传成功', 'file' => $file['pathname'])));
} else {
@unlink($file['pathname']);
exit(CJSON::encode(array('state' => 'error', 'message' => '数据写入失败,上传错误')));
}
} else {
exit(CJSON::encode(array('error' => 1, 'message' => '上传错误')));
}
}
}
示例3: _catalogList
/**
* 获取栏目内容数据
*
* @param array $params
* @return array 数组
*/
protected function _catalogList($params = array())
{
$postModel = new Post();
$postCriteria = new CDbCriteria();
$condition = '1';
if ($params['catalog']) {
$condition .= ' AND t.catalog_id=:catalogId';
$criteriaParams[':catalogId'] = intval($params['catalog']);
}
if ($params['keyword']) {
$condition .= ' AND t.title=:title';
$criteriaParams[':title'] = CHtml::encode(strip_tags($params['keyword']));
}
$condition .= " AND t.status_is='Y'";
$postCriteria->condition = $condition;
$postCriteria->params = $criteriaParams;
$postCriteria->order = 't.id DESC';
$postCriteria->with = 'catalog';
$count = $postModel->count($postCriteria);
$postPages = new CPagination($count);
$postPages->pageSize = $params['pageSize'] > 0 ? $params['pageSize'] : 20;
$pageParams = XUtils::buildCondition($_GET, array('catalog', 'keyword'));
$postPages->params = is_array($pageParams) ? $pageParams : array();
$postCriteria->limit = $postPages->pageSize;
$postCriteria->offset = $postPages->currentPage * $postPages->pageSize;
$bagecmsDataList = $postModel->findAll($postCriteria);
$catalogArr = Catalog::item($params['catalog'], $this->_catalog);
if ($catalogArr) {
$this->_seoTitle = empty($catalogArr['catalog_name']) ? $this->_seoTitle : $catalogArr['catalog_name'];
$bagecmsCatalogData = $catalogArr;
$this->_seoKeywords = empty($catalogArr['seo_keywords']) ? $this->_seoKeywords : $catalogArr['seo_keywords'];
$this->_seoDescription = empty($catalogArr['seo_description']) ? $this->_seoDescription : $catalogArr['seo_description'];
}
return array('bagecmsDataList' => $bagecmsDataList, 'bagecmsPagebar' => $postPages, 'bagecmsCatalogData' => $bagecmsCatalogData);
}
示例4: actionLogin
/**
* 会员登录
*/
public function actionLogin()
{
try {
$model = new EnergyAdmin('login');
if (XUtils::method() == 'POST') {
$model->id = $_POST['id'];
$model->password = $_POST['password'];
$data = $model->find('id=:id', array('id' => $model->id));
if ($data === null) {
$model->addError('id', '用户不存在');
AdminLogger::_create(array('catalog' => 'login', 'intro' => '登录失败,用户不存在:' . CHtml::encode($model->id), 'user_id' => 0));
} elseif (!$model->validatePassword($data->password)) {
$model->addError('password', '密码不正确');
AdminLogger::_create(array('catalog' => 'login', 'intro' => '登录失败,密码不正确:' . CHtml::encode($model->id) . ',使用密码:' . CHtml::encode($model->password), 'user_id' => 0));
} else {
parent::_stateWrite(array('userId' => $data->id, 'userName' => $data->name), array('prefix' => '_admini'));
// $data->save();
AdminLogger::_create(array('catalog' => 'login', 'intro' => '用户登录成功:' . CHtml::encode($model->id)));
$this->redirect(array('energy/index'));
}
}
$this->render('login', array('model' => $model));
} catch (Exception $e) {
echo var_dump($e);
}
}
示例5: actionBatch
/**
* 批量操作
*
*/
public function actionBatch()
{
if (XUtils::method() == 'GET') {
$command = trim($_GET['command']);
$ids = intval($_GET['id']);
} elseif (XUtils::method() == 'POST') {
$command = trim($_POST['command']);
$ids = $_POST['id'];
is_array($ids) && ($ids = implode(',', $ids));
} else {
XUtils::message('errorBack', '只支持POST,GET数据');
}
empty($ids) && XUtils::message('error', '未选择记录');
switch ($command) {
case 'delete':
parent::_acl('position_delete');
$cityModel = new Position();
$cityModel->deleteAll('id IN(' . $ids . ')');
AdminLogger::_create(array('catalog' => 'delete', 'intro' => '删除内容,ID:' . $ids));
parent::_delete(new Position(), $ids, array('index'));
break;
default:
throw new CHttpException(404, '错误的操作类型:' . $command);
break;
}
}
示例6: actionLogin
public function actionLogin()
{
$model = new Admin('login');
if (XUtils::method() == 'POST') {
$model->attributes = $_POST['Admin'];
if ($model->validate()) {
$data = $model->find('username=:username', array('username' => $model->username));
if ($data === null) {
$model->addError('username', '用户不存在');
parent::_backendLogger(array('catalog' => 'login', 'intro' => '登录失败,用户不存在:' . CHtml::encode($model->username), 'user_id' => 0));
} elseif (!$model->validatePassword($data->password)) {
$model->addError('password', '密码不正确');
parent::_backendLogger(array('catalog' => 'login', 'intro' => '登录失败,密码不正确:' . CHtml::encode($model->username) . ',使用密码:' . CHtml::encode($model->password), 'user_id' => 0));
} elseif ($data->group_id == 2) {
$model->addError('username', '用户已经锁定,请联系管理');
} else {
$this->_sessionSet('_backendGroupId', $data->group_id);
if (isset($data->group_id) && $data->group_id == 1) {
$this->_sessionSet('_backendPermission', 'backendstrator');
}
$data->last_login_ip = XUtils::getClientIP();
$data->last_login_time = time();
$data->login_count = $data->login_count + 1;
$data->save();
parent::_sessionSet('uid', $data->id);
parent::_sessionSet('uname', $data->username);
parent::_backendLogger(array('catalog' => 'login', 'intro' => '用户登录成功:' . $data->username));
$this->redirect(array('default/index'));
XUtils::message('success', '登录成功', $this->createUrl('default/index'), 2);
}
}
}
$this->render('login', array('model' => $model));
}
示例7: actionBatch
/**
* 批量操作
*/
public function actionBatch()
{
if (XUtils::method() == 'GET') {
$command = trim($this->_gets->getParam('command'));
$ids = intval($this->_gets->getParam('id'));
} elseif (XUtils::method() == 'POST') {
$command = $this->_gets->getPost('command');
$ids = $this->_gets->getPost('id');
is_array($ids) && ($ids = implode(',', $ids));
} else {
throw new CHttpException(404, '只支持POST,GET数据');
}
empty($ids) && XUtils::message('error', '未选择记录');
switch ($command) {
case 'attachDelete':
parent::_acl('attach_delete');
AdminLogger::_create(array('catalog' => 'delete', 'intro' => '删除附件,ID:' . $ids));
//日志
parent::_delete(new Upload(), $ids, array('attach'), array('file_name'));
break;
default:
throw new CHttpException(404, '错误的操作类型:' . $command);
break;
}
}
示例8: actionUpload
/**
* 编辑器文件上传
*/
public function actionUpload()
{
if (XUtils::method() == 'POST') {
$file = XUpload::upload($_FILES['imgFile']);
if (is_array($file)) {
$model = new Upload();
$model->user_id = intval($admini['userId']);
$model->file_name = CHtml::encode($file['pathname']);
$model->thumb_name = CHtml::encode($file['paththumbname']);
$model->real_name = CHtml::encode($file['name']);
$model->file_ext = $file['extension'];
$model->file_mime = $file['type'];
$model->file_size = $file['size'];
$model->save_path = $file['savepath'];
$model->hash = $file['hash'];
$model->save_name = $file['savename'];
$model->create_time = time();
if ($model->save()) {
exit(CJSON::encode(array('error' => 0, 'url' => Yii::app()->baseUrl . '/' . $file['pathname'])));
} else {
@unlink($file['pathname']);
@unlink($file['paththumbname']);
exit(CJSON::encode(array('error' => 1, 'message' => '上传错误')));
}
} else {
exit(CJSON::encode(array('error' => 1, 'message' => '上传错误:' . $file)));
}
}
}
示例9: actionView
public function actionView($id)
{
$lesson = $this->loadModel($id);
$userId = $this->_cookiesGet('userId');
$userType = $this->_cookiesGet('userType');
$this->_seoTitle = '课程 - ' . $lesson->name;
//取报名人数
$actual_students_criteria = new CDbCriteria();
$actual_students = StudentLesson::model()->count($actual_students_criteria->addCondition("lesson_id =" . $id));
$lesson->actual_students = $actual_students;
$teacher = Teacher::model()->findByPk($lesson->teacher_id);
$place = Place::model()->findByPk($lesson->place_id);
//教学环境图片显示
$imageList = $this->_gets->getParam('imageList');
$imageListSerialize = XUtils::imageListSerialize($imageList);
//判断学员已收藏的课程
if ($userType === 'student') {
$is_focus = StudentLesson::model()->findByAttributes(array('student_id' => $userId, 'lesson_id' => $id, 'is_collection' => 1));
}
if ($imageList) {
$imageList = $imageListSerialize['data'];
} elseif ($place->pic_other) {
$imageList = unserialize($place->pic_other);
}
$this->render('view', array('is_focus' => $is_focus, 'isJoin' => $this->isJoin($userId, $id, 1), 'userType' => $userType, 'lesson' => $lesson, 'place' => $place, 'teacher' => $teacher, 'imageList' => $imageList));
}
示例10: actionUpdatePlace
public function actionUpdatePlace()
{
$model = Place::model()->findByPk($_GET['id']);
$imageList = $this->_gets->getParam('imageList');
$imageListSerialize = XUtils::imageListSerialize($imageList);
if (isset($_POST['Place'])) {
$model->attributes = $_POST['Place'];
$model->pic_other = $imageListSerialize['dataSerialize'];
$file = XUpload::upload($_FILES['attach'], array('thumb' => true, 'thumbSize' => array(192, 470)));
$adr = XUpload::upload($_FILES['pic_adr'], array('thumb' => true, 'thumbSize' => array(498, 364)));
if (is_array($file)) {
$model->pic = $file['paththumbname'];
@unlink($_POST['oAttach']);
@unlink($_POST['oThumb']);
}
if (is_array($adr)) {
$model->pic_adr = $adr['paththumbname'];
@unlink($_POST['oAttach']);
@unlink($_POST['oThumb']);
}
if ($model->validate() && $model->save()) {
$this->redirect(array('/host/default/myplace'));
}
}
if ($imageList) {
$imageList = $imageListSerialize['data'];
} elseif ($model->pic_other) {
$imageList = unserialize($model->pic_other);
}
$this->render('addplace', array('model' => $model, 'imageList' => $imageList));
}
示例11: actionShow
/**
* 查看专题
*/
public function actionShow($name)
{
$specialModel = Special::model()->find('title_alias=:titleAlias', array('titleAlias' => CHtml::encode(strip_tags($name))));
if (false == $specialModel) {
throw new CHttpException(404, '专题不存在');
}
//更新浏览次数
$specialModel->updateCounters(array('view_count' => 1), 'id=:id', array('id' => $specialModel->id));
$specialPostModel = new Post();
$criteria = new CDbCriteria();
$criteria->addCondition('t.status_is=:status AND special_id=:specialId');
$criteria->params = array('status' => 'Y', 'specialId' => $specialModel->id);
$criteria->order = 't.id DESC';
$bagecmsSpecialCount = $specialPostModel->count($criteria);
$postPage = new CPagination($bagecmsSpecialCount);
$postPage->pageSize = 10;
$postPageParams = XUtils::buildCondition($_GET, array());
$postPageParams['#'] = 'list';
$postPage->params = is_array($postPageParams) ? $postPageParams : array();
$criteria->limit = $postPage->pageSize;
$criteria->offset = $postPage->currentPage * $postPage->pageSize;
$specialPostList = $specialPostModel->findAll($criteria);
$this->_seoTitle = empty($specialModel->seo_title) ? $specialModel->title . ' - ' . $this->_conf['site_name'] : $specialModel->seo_title;
$tpl = empty($specialModel->tpl) ? 'show' : $specialModel->tpl;
$data = array('specialShow' => $specialModel, 'specialPostList' => $specialPostList, 'bagecmsPagebar' => $postPage);
$this->render($tpl, $data);
}
示例12: actionHome
/**
* 主界面
*/
public function actionHome()
{
$data['soft'] = 'bagecms';
$data['softVersion'] = $this->_bagecms;
$data['softRelease'] = $this->_bagecmsRelease;
$data['serverSoft'] = $_SERVER['SERVER_SOFTWARE'];
$data['serverOs'] = PHP_OS;
$data['phpVersion'] = PHP_VERSION;
$data['fileupload'] = ini_get('file_uploads') ? ini_get('upload_max_filesize') : '禁止上传';
$data['serverUri'] = $_SERVER['SERVER_NAME'];
$data['maxExcuteTime'] = ini_get('max_execution_time') . ' 秒';
$data['maxExcuteMemory'] = ini_get('memory_limit');
$data['magic_quote_gpc'] = MAGIC_QUOTE_GPC ? '开启' : '关闭';
$data['allow_url_fopen'] = ini_get('allow_url_fopen') ? '开启' : '关闭';
$data['excuteUseMemory'] = function_exists('memory_get_usage') ? XUtils::byteFormat(memory_get_usage()) : '未知';
$dbsize = 0;
$connection = Yii::app()->db;
$sql = 'SHOW TABLE STATUS LIKE \'' . $connection->tablePrefix . '%\'';
$command = $connection->createCommand($sql)->queryAll();
foreach ($command as $table) {
$dbsize += $table['Data_length'] + $table['Index_length'];
}
$mysqlVersion = $connection->createCommand("SELECT version() AS version")->queryAll();
$data['mysqlVersion'] = $mysqlVersion[0]['version'];
$data['dbsize'] = $dbsize ? XUtils::byteFormat($dbsize) : '未知';
$notebook = Admin::model()->findByPk($this->_admini['userId']);
$env = XUtils::b64encode(serialize($data));
$this->render('home', array('notebook' => $notebook, 'env' => $env, 'server' => $data));
}
示例13: beforeSave
/**
* 自动化初始值/处理数据
*
* @return unknown
*/
public function beforeSave()
{
if ($this->isNewRecord) {
isset($this->create_time) && ($this->create_time = time());
}
$this->sort_order = intval($this->sort_order);
$this->site_url = XUtils::convertHttp($this->site_url);
return true;
}
示例14: _create
/**
* 后台日志记录
* @param $intro
*/
public static function _create(array $arr = array())
{
$session = new XSession();
$admini = $session->get('_admini');
$model = new AdminLogger();
$model->attributes = $arr;
!isset($arr['user_id']) && ($model->user_id = intval($admini['userId']));
$model->url = Yii::app()->request->getRequestUri();
$model->ip = XUtils::getClientIP();
$model->save();
}
示例15: sendMail
function sendMail($email, $subject, $message, $name)
{
global $app;
$headers = "To: " . XUtils::strToBase($name, 'utf-8', 'windows-1251') . " <{$email}>\n";
$headers .= "From: " . XUtils::strToBase($app->Dictionary->getWord("MailFrom"), 'utf-8', 'windows-1251') . "<" . $app->getVar("mailsender") . ">\n";
$headers .= "X-Sender: " . XUtils::strToBase($app->Dictionary->getWord("XSender"), 'utf-8', 'windows-1251') . "\n";
$headers .= "Content-Type: text/plain; charset=windows-1251\n";
$headers .= "Content-Transfer-Encoding: 8bit\n";
$headers .= "MIME-Version: 1.0\n";
$headers = iconv("utf-8", "windows-1251", $headers);
$subject = XUtils::strToBase($subject, 'utf-8', 'windows-1251');
$message = iconv("utf-8", "windows-1251", $message);
mail($email, $subject, $message, $headers);
}