コード例 #1
0
ファイル: User.class.php プロジェクト: tarscoding/PESCMS-TEAM
 /**
  * 添加内容
  */
 public static function add()
 {
     $data = self::baseFrom();
     //自动生成头像
     \Core\Func\CoreFunc::$defaultPath = false;
     require PES_PATH . '/Expand/Identicon/autoload.php';
     $identicon = new \Identicon\Identicon();
     $data['mes']['user_head'] = $identicon->getImageDataUri($_POST['user_mail']);
     if ($data['status'] == false) {
         return self::error($data['mes']);
     }
     $addResult = self::db('user')->insert($data['mes']);
     if (empty($addResult)) {
         return self::error($GLOBALS['_LANG']['USER']['ADD_CONTENT_FAIL']);
     }
     return self::success($addResult);
 }
コード例 #2
0
 public function index()
 {
     $id = $this->isG('id', '请选择要下载的文件');
     $model = strtolower($this->isG('model', '请选择下载的模块'));
     //要下载文件的字段,缺省值为file
     $field = empty($_GET['field']) ? "{$model}_file" : $model . "_" . $this->g('field');
     /**
      * 多个文件下载的判断,如果存放文件的字段有多个文件存在时
      * 则根据提交过来的num参数,进行获取文件。
      * 由于拆分的文件,数组键值是从0开始的。所以需要减1
      */
     $num = $this->isG('num', '请选择要下载的文件序号');
     $res = \Model\Content::findContent($model, $id, "{$model}_id");
     if (empty($res)) {
         echo '<script>alert("文件已丢失或者地址不正确")</script>';
         exit;
     }
     $arrayFile = explode(',', $res[$field]);
     //确保下载的文件次序在范围内。
     if ($num > count($arrayFile)) {
         echo '<script>alert("文件已丢失或者地址不正确")</script>';
         exit;
     }
     $file = PES_PATH . $arrayFile[$num];
     $path_parts = pathinfo($file);
     \Core\Func\CoreFunc::$defaultPath = false;
     if (class_exists('\\finfo')) {
         $finfo = new \finfo(FILEINFO_MIME);
         $array = explode(';', $finfo->file($file));
         $mimetypes = $array[0];
     } elseif (function_exists('mime_content_type')) {
         $mimetypes = mime_content_type($file);
     } else {
         $mimetypes = $this->mimetypes[$path_parts['extension']];
         if (empty($mimetypes)) {
             echo '<script>alert("系统无法获知文件类型")</script>';
             exit;
         }
     }
     $name = empty($res["{$model}_title"]) ? '附件' : $res["{$model}_title"];
     header("Content-type: {$mimetypes}");
     header('Content-Disposition: attachment; filename="' . $name . "_{$num}" . '.' . $path_parts['extension'] . '"');
     readfile($file);
     exit;
 }
コード例 #3
0
ファイル: Login.class.php プロジェクト: hurricanetx/PESCMS2
 /**
  * 注册帐号
  */
 public function signup()
 {
     if (\Model\Option::findOption('signup')['value'] == '0') {
         $this->error('本系统没有开启注册。');
     }
     $data['user_account'] = $this->isP('account', '请填写帐号');
     $existAccount = \Model\Content::findContent('user', $data['user_account'], 'user_account');
     if (!empty($existAccount)) {
         $this->error('帐号已存在');
     }
     $data['user_password'] = \Core\Func\CoreFunc::generatePwd($data['user_account'] . $this->isP('password', '请填写密码'), 'PRIVATE_KEY');
     $repwd = \Core\Func\CoreFunc::generatePwd($data['user_account'] . $this->isP('repassword', '请填写密码'), 'PRIVATE_KEY');
     if ($data['user_password'] != $repwd) {
         $this->error('两次密码不一致');
     }
     $data['user_mail'] = $this->isP('mail', '请填写帐号');
     $existEmail = \Model\Content::findContent('user', $data['user_mail'], 'user_mail');
     if (!empty($existEmail)) {
         $this->error('邮箱地址已存在');
     }
     \Core\Func\CoreFunc::$defaultPath = false;
     require PES_PATH . '/Expand/Identicon/autoload.php';
     $identicon = new \Identicon\Identicon();
     $imageDataUri = $identicon->getImageDataUri($data['user_mail']);
     $data['user_name'] = $this->isP('name', '请填写帐号');
     $data['user_status'] = '1';
     $data['user_createtime'] = time();
     $data['user_department_id'] = '2';
     //人事部
     $data['user_group_id'] = '2';
     //普通用户
     $data['user_head'] = $imageDataUri;
     $addResult = $this->db('user')->insert($data);
     if (empty($addResult)) {
         $this->error('注册失败');
     }
     unset($data['user_password']);
     $data['user_id'] = $addResult;
     $this->setLogin($data);
     $this->success('注册成功!', $this->url(GROUP . '-Index-index'));
 }
コード例 #4
0
ファイル: Index.class.php プロジェクト: jvlstudio/PESCMS-TEAM
 /**
  * 导入数据库
  */
 public function import()
 {
     $title = $this->isP('title', '请填写系统的标题');
     $urlModel = $this->isP('urlModel', '请选择URL模式', FALSE);
     $data['user_account'] = $this->isP('account', '请填写管理员帐号');
     $data['user_password'] = \Core\Func\CoreFunc::generatePwd($data['user_account'] . $this->isP('passwd', '请填写管理员密码'), 'PRIVATE_KEY');
     $data['user_name'] = $this->isP('name', '请填写管理员名称');
     $data['user_mail'] = $this->isP('mail', '请填写管理员邮箱');
     //读取数据库文件
     $sqlFile = file_get_contents(PES_PATH . '/Install/InstallDb/team.sql');
     if (empty($sqlFile)) {
         $this->error('无法读取安装SQL文件');
     }
     //配置PDO信息
     $config = \Core\Func\CoreFunc::loadConfig();
     try {
         $db = new \PDO("mysql:host={$config['DB_HOST']};port={$config['DB_PORT']};dbname={$config['DB_NAME']}", $config['DB_USER'], $config['DB_PWD']);
     } catch (\PDOException $e) {
         $this->error($e->getMessage());
     }
     //安装数据库文件
     $db->exec($sqlFile);
     \Core\Func\CoreFunc::$defaultPath = false;
     require PES_PATH . '/Expand/Identicon/autoload.php';
     $identicon = new \Identicon\Identicon();
     $imageDataUri = $identicon->getImageDataUri($data['user_mail']);
     $data['user_head'] = $imageDataUri;
     $data['user_department_id'] = $data['user_status'] = $data['user_group_id'] = '1';
     //写入管理员帐号
     $this->db('user')->insert($data);
     //更新系统配置
     \Model\Option::update('sitetitle', $title);
     \Model\Option::update('urlModel', $urlModel);
     //更新根目录的index.php
     $readWriteFile = file_get_contents(PES_PATH . '/Install/Write/index.php');
     $fopen = fopen(PES_PATH . '/index.php', 'w+');
     fwrite($fopen, $readWriteFile);
     fclose($fopen);
     //标记程序已安装和移除安装数据库文件
     unlink(PES_PATH . '/Install/index.php');
     unlink(PES_PATH . '/Install/InstallDb/team.sql');
     fclose(fopen(PES_PATH . '/Install/install.txt', 'w+'));
     fclose(fopen(PES_PATH . '/Install/index.html', 'w+'));
     $this->success('安装完成!');
 }
コード例 #5
0
<?php

/**
 * PESCMS for PHP 5.4+
 *
 * Copyright (c) 2014 PESCMS (http://www.pescms.com)
 *
 * For the full copyright and license information, please view
 * the file LICENSE.md that was distributed with this source code.
 */
namespace Expand\Excel;

\Core\Func\CoreFunc::$defaultPath = false;
require_once PES_PATH . '/Expand/Excel/Classes/PHPExcel.php';
/**
 * Excel文件导入和导出
 */
class Excel
{
    /**
     * 暴露EXCEL对象
     * 注意:不需要声明头部文件
     */
    public static function api()
    {
        $objPHPExcel = new \PHPExcel();
        $objPHPExcel->getProperties()->setCreator("Maarten Balliauw")->setLastModifiedBy("Maarten Balliauw")->setTitle("Office 2007 XLSX Test Document")->setSubject("Office 2007 XLSX Test Document")->setDescription("Test document for Office 2007 XLSX, generated using PHP classes.")->setKeywords("office 2007 openxml php")->setCategory("Test result file");
        return $objPHPExcel;
    }
    public static function save($obj, $fileName)
    {
コード例 #6
0
ファイル: Controller.class.php プロジェクト: Myazure/PESCMS2
 /**
  * 模板变量赋值
  */
 protected function assign($name, $value = '')
 {
     if (is_array($name)) {
         \Core\Func\CoreFunc::$param = array_merge(\Core\Func\CoreFunc::$param, $name);
     } elseif (is_object($name)) {
         foreach ($name as $key => $val) {
             \Core\Func\CoreFunc::$param[$key] = $val;
         }
     } else {
         \Core\Func\CoreFunc::$param[$name] = $value;
     }
 }