Ejemplo n.º 1
0
 public function profile()
 {
     // Amango_Addons_Import('Xitedu.php','Xitedu');//导入
     // $demo = new \Xitedu();
     Amango_Addons_Import('Xitlibrary.php', 'Xitedu');
     //导入
     $demo = new \Xitlibrary();
     //$demo->paraxinfo();die;
     if (IS_POST) {
         //$a     = $demo->postLogin(I('username'),I('password'),I('val'));
         $pwd = I('password');
         $oldinfo = $demo->library_login(I('username'), $pwd);
         foreach ($oldinfo as $key => $value) {
             $oldinfo[$key] = str_replace(array("\n", "\r"), "", $value);
         }
         //判断是否登陆成功
         if (!empty($oldinfo[1])) {
             $sysinfo = session('P');
             $userinfo = array();
             //获取个人信息
             $userinfo = $demo->getUserinfo();
             if (empty($userinfo)) {
                 $this->error('亲!服务器不给力,无法获取相关信息,请再登陆一次');
             }
             //获取个人照片
             //$headimg  = $demo->getUserpic($userinfo[0]);
             //获取个人考证成绩 序列化
             //$allexam  = serialize($demo->getUserexam());
             //获取个人学年成绩 序列化
             $allscore = serialize($demo->getclass());
             //获取个人课表
             $classlist = $demo->getscore();
             $data = array('fromusername' => $sysinfo['fromusername'], 'name' => $userinfo[1], 'headimg' => $pwd, 'xuehao' => $userinfo[0], 'sex' => $userinfo[3], 'cardid' => $userinfo[5], 'birthday' => $userinfo[4], 'zhuanye' => $userinfo[10], 'xueyuan' => $userinfo[9], 'address' => $userinfo[12], 'mingzu' => $userinfo[6], 'shengfen' => $userinfo[8], 'grade' => $userinfo[11], 'type' => $userinfo[7], 'youbian' => $userinfo[13]);
             // if(!empty($allexam)){
             //     $data['allexam'] = $allexam;
             // }
             if (!empty($allscore)) {
                 $data['allscore'] = $allscore;
             }
             $Addonseduinfo = M('Addonseduinfo');
             $has_user = $Addonseduinfo->where(array('fromusername' => $sysinfo['fromusername']))->count();
             if ($has_user == 1) {
                 $Addonseduinfo->where(array('fromusername' => $sysinfo['fromusername']))->save($data);
             } else {
                 $Addonseduinfo->add($data);
             }
             //插入个人课表
             if (!empty($classlist)) {
                 $classdata = array('xuehao' => $userinfo[0], 'itemname' => $classlist['name'][0], 'classname' => $classlist['name'][1], 'week1' => serialize($classlist['class'][1]), 'week2' => serialize($classlist['class'][2]), 'week3' => serialize($classlist['class'][3]), 'week4' => serialize($classlist['class'][4]), 'week5' => serialize($classlist['class'][5]), 'week6' => serialize($classlist['class'][6]), 'week0' => serialize($classlist['class'][7]));
                 $Addonsclass = M('Addonsclass');
                 $has_class = $Addonsclass->where(array('xuehao' => $userinfo[0]))->count();
                 if ($has_class == 0) {
                     $Addonsclass->add($classdata);
                 } else {
                     $Addonsclass->where(array('xuehao' => $userinfo[0]))->save($classdata);
                 }
                 $this->success('恭喜您绑定学号密码成功!');
             }
         } else {
             $this->error('亲!请确保账号·密码·验证码是否填写正确');
         }
     } else {
         $userinfo = session('P');
         if (empty($userinfo)) {
             $this->display();
         } else {
             $edumodel = M('Addonseduinfo');
             $eduinfo = $edumodel->where(array('fromusername' => $userinfo['fromusername']))->field('allscore,name,id,xuehao,birthday,shengfen,xueyuan')->find();
             if (empty($eduinfo)) {
                 $this->display();
             } else {
                 //TODO  可以新增缓存
                 $allscore = unserialize($eduinfo['allscore']);
                 $allteach = 0;
                 $unteach = 0;
                 foreach ($allscore as $key => $value) {
                     //计算总科目
                     $allteach = count($value) + $allteach;
                     foreach ($value as $k => $v) {
                         if (is_string($v[8]) && $v[8] == '不合格') {
                             $unteach = $unteach + 1;
                         }
                         if (is_numeric($v[8]) && $v[8] < 60) {
                             $unteach = $unteach + 1;
                         }
                     }
                 }
                 $edytese = array();
                 $teseper = array();
                 //总人数
                 $edytese['count'] = $edumodel->count();
                 //同名
                 $edytese['name'] = $edumodel->where(array('name' => array('like', $eduinfo['name'])))->count();
                 $teseper['name'] = $edytese['name'] / $edytese['count'] * 100;
                 //生日
                 $edytese['birthday'] = $edumodel->where(array('birthday' => array('like', $eduinfo['birthday'])))->count();
                 $teseper['birthday'] = $edytese['birthday'] / $edytese['count'] * 100;
                 //老乡
                 $edytese['shengfen'] = $edumodel->where(array('shengfen' => array('like', $eduinfo['shengfen'])))->count();
                 $teseper['shengfen'] = $edytese['shengfen'] / $edytese['count'] * 100;
                 //同学院
                 $edytese['xueyuan'] = $edumodel->where(array('xueyuan' => array('like', $eduinfo['xueyuan'])))->count();
                 $teseper['xueyuan'] = $edytese['xueyuan'] / $edytese['count'] * 100;
                 //同专业
                 $edytese['zhuanye'] = $edumodel->where(array('zhuanye' => array('like', $eduinfo['zhuanye'])))->count();
                 $teseper['zhuanye'] = $edytese['zhuanye'] / $edytese['count'] * 100;
                 //挂科相关
                 $edytese['guake'] = $unteach;
                 $edytese['allke'] = $allteach;
                 $teseper['guake'] = $unteach / $allteach * 100;
                 $this->assign('eduinfo', $eduinfo);
                 $this->assign('edutese', $edytese);
                 $this->assign('teseper', $teseper);
                 $this->display('index');
             }
         }
     }
 }
    public function index()
    {
        //提交的配置
        $config = $_POST['config'];
        $filePath = AMANGO_FILE_ROOT . $config['excel_path'];
        $currentid = $config['excel_readxls'] >= 1 ? $config['excel_readxls'] - 1 : 0;
        $startid = $config['excel_currentrow'] >= 2 ? $config['excel_currentrow'] : 2;
        if ($filePath == AMANGO_FILE_ROOT) {
            $this->error('请选择文件');
        }
        $xlsparam = parse_config($_POST['config']['excel_param']);
        //导入第三方插件
        Amango_Addons_Import('PHPExcel.php', 'Excelimport');
        Amango_Addons_Import('PHPExcel/Reader/Excel2007.php', 'Excelimport');
        //自动生成唯一数据表名
        $table_name = 'addonsexcel' . str_replace('_', '', strtolower($config['excel_tablename']));
        $tablename = C('DB_PREFIX') . $table_name;
        $sql = <<<sql
\t\t\t\tSHOW TABLES LIKE '{$tablename}';
sql;
        $res = M()->query($sql);
        //判断表唯一  以便生成新表
        if (count($res) > 0) {
            $this->error('该表名已存在,请换个数据表名');
        } else {
            if (strpos($_POST['config']['excel_param'], ':') === false) {
                $this->error('生成数据表时,请务必填写字段读取配置,格式:字段名:读取列标识');
            } else {
                $fields = '';
                $field = array();
                foreach ($xlsparam as $key => $value) {
                    if (!empty($key)) {
                        $fields .= "`{$key}` text,";
                        $field[] = $key;
                    }
                }
                //生成数据表
                $sql = <<<sql
\t\t\t\tCREATE TABLE IF NOT EXISTS `{$tablename}` (
\t\t\t\t`id`  int(10) UNSIGNED NOT NULL AUTO_INCREMENT COMMENT '主键' ,
\t\t\t\t{$fields}
\t\t\t\tPRIMARY KEY (`id`)
\t\t\t\t)
\t\t\t\tENGINE=MyISAM
\t\t\t\tDEFAULT CHARACTER SET=utf8 COLLATE=utf8_general_ci
\t\t\t\tCHECKSUM=0
\t\t\t\tROW_FORMAT=DYNAMIC
\t\t\t\tDELAY_KEY_WRITE=0
\t\t\t\t;
sql;
                $res = M()->execute($sql);
                if ($res === false) {
                    $this->error('建立数据表出错,请重新建表');
                }
            }
        }
        //导入数据表名 存入总表
        D('addonsexcel')->add(array('fileds' => implode(',', $field), 'tablename' => $tablename));
        $PHPExcel = new \PHPExcel();
        /**默认用excel2007读取excel,若格式不对,则用之前的版本进行读取*/
        $PHPReader = new \PHPExcel_Reader_Excel2007();
        if (!$PHPReader->canRead($filePath)) {
            $PHPReader = new \PHPExcel_Reader_Excel5();
            if (!$PHPReader->canRead($filePath)) {
                $this->error('无法在' . $filePath . '路径下找到该文件');
            }
        }
        $PHPExcel = $PHPReader->load($filePath);
        /**读取excel文件中的第一个工作表*/
        $currentSheet = $PHPExcel->getSheet($currentid);
        /**取得最大的列号*/
        $allColumn = $currentSheet->getHighestColumn();
        /**取得一共有多少行*/
        $allRow = $currentSheet->getHighestRow();
        //初始化
        $rows = array();
        foreach ($xlsparam as $key => $value) {
            for ($currentRow = $startid; $currentRow <= $allRow; $currentRow++) {
                $rowinfo = $currentSheet->getCell(strtoupper($value) . $currentRow)->getValue();
                $rows[$currentRow][$key] = $config['excel_parxhtml'] == 1 ? strip_tags($rowinfo) : $rowinfo;
            }
        }
        //读取出总记录
        foreach ($rows as $key => $value) {
            M($table_name)->add($value);
        }
        M('addonsexcel')->where(array('tablename' => $tablename))->save(array('rows' => count($rows)));
        $this->success('新增成功', U('Addons/adminList', array('name' => 'Excelimport')));
    }
Ejemplo n.º 3
0
 public function ykt_jieyue()
 {
     global $_P;
     $info = $this->has_xuehao($_P['fromusername']);
     Amango_Addons_Import('Xitlibrary.php', 'Xitedu');
     //导入
     $demo = new \Xitlibrary();
     $oldinfo = $demo->library_login($info['xuehao'], $info['headimg']);
     foreach ($oldinfo as $key => $value) {
         $oldinfo[$key] = str_replace(array("\n", "\r"), "", $value);
     }
     //判断是否登陆成功
     if (empty($oldinfo[1])) {
         $autolink = $this->create_loginurl('profile');
         $errmsg = "❶.未绑定通行证?点击本图文进入绑定";
         $errurl = array($autolink, '出错');
         $this->error($errmsg, $errurl, 'dantw', '未绑定学号!点击绑定');
     }
     //读取图书借阅情况
     $booklist = $demo->getovertime();
     if (empty($booklist)) {
         $str = "\n--------------------\n您暂未借阅任何书籍";
     } else {
         $str = '';
         foreach ($booklist as $key => $value) {
             $str .= "\n--------------------\n【" . ($key + 1) . "】《:" . $value[2] . "》\n应还日期:" . $value[1] . "\n借阅日期:" . $value[6];
         }
     }
     $article[0] = array('Title' => $info['name'] . " 图书借阅记录", 'Description' => "-", 'PicUrl' => ADDON_PUBLIC . 'img/logo.jpg', 'Url' => $this->create_loginurl('borrow'));
     $article[1] = array('Title' => "已借图书:" . count($booklist) . "册" . $str, 'Description' => "-222-", 'PicUrl' => "", 'Url' => $this->create_loginurl('borrow'));
     $this->assign('Duotw', $article);
     $this->display();
 }
Ejemplo n.º 4
0
 public function add_questionall()
 {
     if (IS_POST) {
         //提交的配置
         $groupid = $_POST['group'];
         $filePath = $_POST['excelpath'];
         //提取有效path
         $filePathparam = explode('Uploads', $filePath);
         $filePath = './Uploads' . $filePathparam[1];
         if (!file_exists($filePath)) {
             $this->error('请选择文件');
         }
         //导入第三方插件
         Amango_Addons_Import('PHPExcel.php', 'Exam');
         Amango_Addons_Import('PHPExcel/Reader/Excel2007.php', 'Exam');
         $PHPExcel = new \PHPExcel();
         /**默认用excel2007读取excel,若格式不对,则用之前的版本进行读取*/
         $PHPReader = new \PHPExcel_Reader_Excel2007();
         if (!$PHPReader->canRead($filePath)) {
             $PHPReader = new \PHPExcel_Reader_Excel5();
             if (!$PHPReader->canRead($filePath)) {
                 $this->error('无法在' . $filePath . '路径下找到该文件');
             }
         }
         $startid = 1;
         $PHPExcel = $PHPReader->load($filePath);
         /**读取excel文件中的第一个 0 工作表*/
         $currentSheet = $PHPExcel->getSheet(0);
         /**取得最大的列号*/
         $allColumn = $currentSheet->getHighestColumn();
         /**取得一共有多少行*/
         $allRow = $currentSheet->getHighestRow();
         $xlsparam = array('A', 'B', 'C');
         foreach ($xlsparam as $key => $value) {
             for ($currentRow = $startid; $currentRow <= $allRow; $currentRow++) {
                 if ($currentRow % 3 != 0) {
                     $rowinfo = $currentSheet->getCell(strtoupper($value) . $currentRow)->getValue();
                     $rows[$currentRow][$key] = $rowinfo;
                 }
             }
         }
         require_once ONETHINK_ADDON_PATH . 'Exam/functions.php';
         $new_group = array_chunk($rows, 2);
         $total = count($new_group);
         $newrows = array();
         $i = 0;
         //答案类型
         $a_typearr = array_flip($this->a_typearr);
         //题目类型
         $q_typearr = array('文字' => 'text', '图片' => 'image', '音频' => 'audio', '视频' => 'video');
         foreach ($new_group as $key => $value) {
             $num = $i++;
             $newrows[] = array('paixu' => $total - $num, 'q_title' => set_kb($value[0][1]), 'q_titletype' => set_kb($q_typearr[$value[0][0]]), 'a_typedata' => set_kb($value[0][2]), 'a_type' => set_kb($a_typearr[$value[1][0]]), 'a_choices' => set_kb($value[1][2]), 'q_right' => set_kb($value[1][1]));
         }
         $status = D('Addons://Exam/Addonsques')->check_questions($newrows);
         $Addonsques = M('Addonsques');
         if ($status[0] == '0') {
             $this->error('考题格式错误!错误位置:' . implode(',', $status[1][1]));
         }
         foreach ($status[1] as $key => $value) {
             $value['group'] = $groupid;
             $Addonsques->add($value);
         }
         $this->success('Excel批量导入考题成功!', addons_url('Exam://Exam/list_question', array('id' => $groupid)));
     } else {
         $group = I('get.group');
         $model = M('Addonsexam');
         $testlist = $model->field('title,id')->select();
         $this->assign('list', $testlist);
         $this->assign('info', $this->test_info($group));
         $this->assign('group', $group);
         $this->display();
     }
 }
Ejemplo n.º 5
0
 public function index()
 {
     //获取该插件配置参数
     $config = Amango_Addons_Config();
     //查看缓存是否存在
     $article = S('ADDONS_SnatchTieba');
     if (empty($article)) {
         Amango_Addons_Import('phpQuery/phpQuery.php');
         \phpQuery::$defaultCharset = 'GBK';
         \phpQuery::newDocumentFile('http://tieba.baidu.com/f?kw=' . urlencode($config['tieba_name']) . '&fr=ala0');
         $articlecontent = array();
         $artlist = \pq(".j_thread_list");
         foreach ($artlist as $li) {
             //获取评论数
             $tz_commont = iconv('GBK', 'UTF-8', \pq($li)->find('.threadlist_rep_num')->html());
             //获取标题
             $tz_title = iconv('GBK', 'UTF-8', \pq($li)->find('a.j_th_tit')->html());
             //获取内容
             $tz_content = iconv('GBK', 'UTF-8', \pq($li)->find('.threadlist_abs_onlyline')->html());
             $tz_content = preg_replace('/s/', '', $tz_content);
             $tz_content = str_replace('<!---->', '', $tz_content);
             //获取链接
             $tz_link = 'http://tieba.baidu.com' . iconv('GBK', 'UTF-8', \pq($li)->find('a.j_th_tit')->attr('href'));
             //获取作者
             $tz_author = strip_tags(iconv('GBK', 'UTF-8', \pq($li)->find('span.tb_icon_author a')->html()));
             $tz_author = preg_replace('/s/', '', $tz_author);
             //获取回复者
             $tz_reply = iconv('GBK', 'UTF-8', \pq($li)->find('span.tb_icon_author_rely a')->html());
             //获取回复时间
             $tz_replytime = \pq($li)->find('span.j_reply_data')->text();
             $tz_replytime = preg_replace('/s/', '', $tz_replytime);
             //获取图片
             $tz_pic = iconv('GBK', 'UTF-8', \pq($li)->find('img')->attr('original'));
             if (!in_array($tz_title, $toptitle)) {
                 $articlecontent['other'][] = array('Title' => 1 == $config['tieba_extra'] ? "[" . $tz_commont . "]" . $tz_title . "\n" . $tz_content . "\n作者:" . $tz_author . "|回复:" . $tz_reply . "-" . $tz_replytime : $tz_title . "\n" . $tz_content, 'Description' => '', 'PicUrl' => empty($tz_pic) ? '' : $tz_pic, 'Url' => $tz_link);
             }
         }
         $allownums = $config['tieba_nums'] > 8 ? 8 : $config['tieba_nums'];
         $allownums = $allownums >= 1 ? $allownums : 1;
         if ($config['tieba_jinghua'] == 1) {
             $arttoplist = \pq(".thread_top");
             foreach ($arttoplist as $li) {
                 //获取评论数
                 $tz_commont = iconv('GBK', 'UTF-8', \pq($li)->find('.threadlist_rep_num')->html());
                 //获取标题
                 $tz_title = iconv('GBK', 'UTF-8', \pq($li)->find('a.j_th_tit')->html());
                 //获取链接
                 $tz_link = 'http://tieba.baidu.com' . iconv('GBK', 'UTF-8', \pq($li)->find('a.j_th_tit')->attr('href'));
                 //获取作者
                 $tz_author = strip_tags(iconv('GBK', 'UTF-8', \pq($li)->find('span.tb_icon_author a')->html()));
                 $toptitle[] = $tz_title;
                 $tz_author = preg_replace('/s/', '', $tz_author);
                 $articlecontent['top'][] = array('Title' => "[" . $tz_commont . "]" . $tz_title, 'Description' => '', 'PicUrl' => empty($tz_pic) ? '' : $tz_pic, 'Url' => $tz_link);
             }
             $article = self::havejinghua($articlecontent['top'], $articlecontent['other'], $allownums);
         } else {
             $article = self::deljinghua($articlecontent['other'], $allownums);
         }
         \phpQuery::unloadDocuments();
         if ($config['tieba_cache'] > 0 && !empty($article)) {
             S('ADDONS_SnatchTieba', $article, $config['tieba_cache']);
         }
     }
     $this->assign('Duotw', $article);
     $this->display();
 }