Example #1
0
 public function prints($id = 0)
 {
     if (!($uid = use_id())) {
         $this->error('请登录后打印!');
     } elseif (!($book = M('book')->find($id))) {
         $this->error('资源不存在');
     } elseif (!($copies = I('copies'))) {
         $this->error('份数大于0');
     } else {
         $file['pri_id'] = $book['pri_id'];
         $file['use_id'] = $uid;
         $file['status'] = 1;
         $file['ppt_layout'] = 10;
         $file['copies'] = $copies;
         $file['url'] = 'book:' . $book['name'] . '/' . $id;
         $file['name'] = $book['name'] . '【店内书】';
         if ($requirements = I('post.requirements', 0, 'htmlspecialchars')) {
             $file['requirements'] = $requirements;
         }
         if (M('file')->add($file)) {
             $this->success('打印订单设置成功', '/File');
         } else {
             $this->success('打印失败');
         }
     }
 }
Example #2
0
 public function detail($id = 0)
 {
     $pid = use_id();
     if ($id && ($book = M('Book')->field('id,name,price,detail,image')->find($id))) {
         $this->book = $book;
         $this->display();
     } else {
         $this->error('无权访问!');
     }
 }
 public function getPrice()
 {
     $uid = use_id();
     $pid = I('pid', 0, 'int');
     if ($uid && $pid) {
         $Printer = M('Printer');
         $result = $Printer->where('id=' . $pid)->getField('price');
         if ($result) {
             $result = json_decode($result);
             $this->success($result);
         } else {
             $this->error('打印店还没设置价钱');
         }
     } else {
         $this->error('你可能还没登录或者没提供打印店编号');
     }
 }
Example #4
0
 /**
  * 反馈处理
  */
 public function feedback()
 {
     $Form = D('Feedback');
     $msg = I('post.message');
     if (!$msg) {
         $this->error('内容不能为空!');
     }
     $_POST['message'] = $msg . '##FromStudentID:' . use_id();
     if ($Form->create()) {
         $result = $Form->add();
         if ($result) {
             $this->success('操作成功!');
         } else {
             $this->error('操作错误!');
         }
     } else {
         $this->error($Form->getError());
     }
 }
Example #5
0
 /**
  * 	删除文件记录
  * @method delete
  * @author NewFuture[newfuture@yunyin.org]
  */
 public function delete()
 {
     $uid = use_id(U('Index/index'));
     $fid = I('fid', null, 'int');
     if ($uid && $fid) {
         $map['id'] = $fid;
         $map['_string'] = 'status=1 OR status=5';
         $File = M('File');
         $file = $File->where($map)->Field('url,pri_id')->find();
         if ($file) {
             $url = $file['url'];
             /*此处需要修改,将文件和任务拆分后,可删除原文件*/
             // if (delete_file($url))
             // {
             $data['status'] = 0;
             $data['url'] = '';
             $result = $File->where($map)->save($data);
             if ($result) {
                 $this->success($result);
             } else {
                 $this->error('记录更新异常');
             }
             // }
             // $this->error('文件不可删除');
         }
         $this->error('记录已不存在');
     }
     $this->error('当前状态不允许删除!');
 }
Example #6
0
 /**
  * 修改密码
  */
 public function changePwd()
 {
     $uid = use_id(U('Index/index'));
     $user = M('User')->field('student_number,password')->getById($uid);
     $deprecated_password = I('post.deprecated_password');
     $password = I('post.password');
     if ($user && $deprecated_password && $password) {
         $isMD5 = I('isMD5');
         if (!$isMD5) {
             $deprecated_password = md5($deprecated_password);
             $password = md5($password);
         }
         if (encode($deprecated_password, $user['student_number']) == $user['password']) {
             M('User')->where('id=%d', $uid)->setField('password', encode($password, $user['student_number']));
             $this->success('密码修改成功重新登陆!', U('/Auth/logout'));
         } else {
             $this->error('原密码错误');
         }
     }
     $this->error('验证失败!');
 }
Example #7
0
/**
 * 获取用户学校
 * @method sch_id
 * @param  boolean $use_cookie [是否相信cookie信息]
 * @return [type]              [description]
 * @author NewFuture[newfuture@yunyin.org]
 */
function sch_id($use_cookie = false)
{
    $sid = session('sch_id');
    if ($sid) {
        return $sid;
    } elseif ($uid = use_id()) {
        $sid = M('User')->getFieldById($uid, 'sch_id');
        session('sch_id', $sid);
    } elseif ($use_cookie) {
        $sid = I('cookie.sch_id');
    }
    return $sid;
}
Example #8
0
 /**
  * 失主尚未加入平台,或已加入平台但未绑定信息
  * 向微博、人人平台发送消息
  * @param send_msg		要发送的信息
  * @param add_msg                        附加消息
  */
 public function send()
 {
     $uid = use_id('/');
     /*判断是否有接收者*/
     $receiver = session('receiver');
     if (!$receiver) {
         $this->error('禁止乱发信息!!!', '/Card');
     }
     /*判断尝试次数*/
     $cache_name = 'send_' . $uid;
     $times = S($cache_name);
     $User = M('User');
     if ($times > 5) {
         \Think\Log::record('第三方平台发送失败:ip:' . get_client_ip() . ',find_id' . $find_id);
         $this->error('发送次数过多!', '/Card');
     } else {
         S($cache_name, $times + 1, 3600);
     }
     /*添加到丢失记录*/
     $receiver_id = $receiver['uid'] ? $receiver['uid'] : 0;
     $log = array('find_id' => $uid, 'lost_id' => $receiver_id, 'status' => 0);
     $msg_id = M('Cardlog')->add($log);
     $finder = $User->field('sch_id,name')->getById($uid);
     //是否匿名
     $finder_name = I('anonymity') ? '云小印' : $finder['name'];
     //是否公开手机
     $finder_phone = I('add_phone') ? get_phone_by_id($uid) : '';
     $finder_school = M('School')->cache(true)->getFieldById($finder['sch_id'], 'name');
     /*$msg_info = array(
     		'card_number' => $receiver['number'],
     		'card_name' => '[' . $msg_id . ']' . $receiver['name'],
     		'card_school' => $School->cache(true)->getFieldById($receiver['sch_id'], 'name'),
     		'finder_name' => $finder_name,
     		'finder_school' => $School->cache(true)->getFieldById($finder['sch_id'], 'name'),
     		'msg' => I('add_msg'),
     		);
     		$msg = L('CARD_MSG_IN', $msg_info);*/
     /*post数据到API*/
     $url = 'https://newfuturepy.sinaapp.com/broadcast';
     $data = array('key' => C('WEIBO_API_PWD'), 'school' => $receiver['sch_id'], 'card_id' => $receiver['number'], 'name' => $receiver['name'], 'contact_name' => $finder_name . '【' . $msg_id . '】', 'contact_phone' => $finder_phone, 'msg' => I('add_msg'));
     $result = json_decode($this->_post($url, $data));
     if ($result) {
         session('receiver', null);
         $result_info = '人人发送成功(' . $result->renren . ')条;微博发送成功(' . $result->weibo . ')条;BBS发送' . ($result->bbs ? '成功' : '失败');
         $this->success($result_info, '/Card/log');
     } else {
         M('Cardlog')->where('id=%d', $msg_id)->delete();
         $this->error('发送失败,请通过其他方式寻找失主或联系我们');
     }
 }
Example #9
0
 /**
  * 查询标签列表
  * @method getTags
  * @return [type]  [description]
  * @author NewFuture[newfuture@yunyin.org]
  */
 public function getTags()
 {
     if (!use_id()) {
         $this->error('未登录!', '/');
     } else {
         $name = I('tag', null, 'trim');
         if ($name) {
             $tags = M('Tag')->where('name LIKE "%%%s%%"', $name)->order('count desc')->limit(10)->select();
         } else {
             $tags = $this->_getTopTags();
         }
         $this->success($tags);
     }
 }