/**
  * 生成随机头像identicon
  * @param $str 字符串
  * @param int $size 大小
  * @return string uri
  */
 function get_identicon($str, $size = 64)
 {
     require_once APPPATH . 'third_party/identicon/autoload.php';
     $identicon = new \Identicon\Identicon();
     $imageDataUri = $identicon->getImageDataUri($str, $size);
     return $imageDataUri;
 }
Beispiel #2
0
 public function getAvater()
 {
     // 说明: Gravatar 随机头像太丑了 所以使用 Identicon 随机头像
     // TODO 保存头像图片 加缓存
     // return $this->getGravatar();
     $identicon = new \Identicon\Identicon();
     return $identicon->getImageDataUri($this->email, $this->size);
 }
Beispiel #3
0
 /**
  * 添加内容
  */
 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);
 }
Beispiel #4
0
 /**
  * 注册帐号
  */
 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'));
 }
Beispiel #5
0
 /**
  * 导入数据库
  */
 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('安装完成!');
 }
Beispiel #6
0
 public function getIdenticon($size = 30)
 {
     $identicon = new \Identicon\Identicon();
     return $identicon->getImageDataUri($this->email . $this->name, $size);
 }
Beispiel #7
0
 /**
  * use a default icon in case of errors while processing uploaded files
  */
 public function useDefaultImage()
 {
     $identicon = new \Identicon\Identicon();
     $this->avatar = $identicon->getImageDataUri($this->user->email);
 }
Beispiel #8
0
 /**
  * 生成头像图标
  * @param $size
  * @return string
  */
 protected function getIdenticon($size)
 {
     $identicon = new \Identicon\Identicon();
     return $identicon->getImageDataUri($this->email, $size);
 }
 public function getIdenticonImageDataUri($size = 32)
 {
     $identicon = new \Identicon\Identicon();
     return $identicon->getImageDataUri($this->getSecretHash(), $size);
 }