Example #1
0
 public function update()
 {
     $data = array('id' => intval($this->input['id']), 'name' => trim($this->input['name']));
     if (!$data['id']) {
         $this->errorOutput("ID不能为空");
     }
     if (!$data['name']) {
         $this->errorOutput("运势名不能为空");
     }
     $sql = 'SELECT * FROM ' . DB_PREFIX . 'astro_app_fortuneinfo WHERE id = ' . $data['id'];
     $res = $this->db->query_first($sql);
     $astrofunimg = unserialize($res['astrofunimg']) ? unserialize($res['astrofunimg']) : array();
     $logo['Filedata'] = $_FILES['logo'];
     if ($logo['Filedata']) {
         include_once ROOT_PATH . 'lib/class/material.class.php';
         $material = new material();
         $re = $material->addMaterial($logo);
         $logo = array();
         $logo = array('host' => $re['host'], 'dir' => $re['dir'], 'filepath' => $re['filepath'], 'filename' => $re['filename']);
     } else {
         $logo = $astrofunimg;
     }
     $where = ' WHERE 1 ';
     $where .= ' AND  id = ' . $data['id'];
     $sql = 'UPDATE ' . DB_PREFIX . 'astro_app_fortuneinfo' . ' SET astrofuncn = "' . $data['name'] . '", astrofunimg ="' . addslashes(serialize($logo)) . '"' . $where;
     //$this->errorOutput($sql);
     $this->db->query($sql);
     $this->constellation->updatetime_orerid($data['id'], 'fortuneinfo');
     $data['logo'] = $logo;
     $this->addItem($data);
     $this->output();
 }
Example #2
0
 public function insert_plataccount($picfiles)
 {
     $data = array('type' => urldecode($this->input['plat_type']), 'name' => urldecode($this->input['name']), 'offiaccount' => urldecode($this->input['offiaccount']), 'akey' => urldecode($this->input['apikey']), 'skey' => urldecode($this->input['secretkey']), 'oauthurl' => urldecode($this->input['oauthurl']), 'shareurl' => urldecode($this->input['shareurl']), 'userurl' => urldecode($this->input['userurl']), 'callback' => urldecode($this->input['callback']), 'accessurl' => urldecode($this->input['accessurl']), 'followurl' => urldecode($this->input['followurl']), 'status' => urldecode($this->input['status']), 'addtime' => time());
     $sql = "INSERT INTO " . DB_PREFIX . "plat SET";
     $sql_extra = $space = ' ';
     foreach ($data as $k => $v) {
         $sql_extra .= $space . $k . "='" . $v . "'";
         $space = ',';
     }
     $sql .= $sql_extra;
     $this->db->query($sql);
     $id = $this->db->insert_id();
     /*将图片提交到图片服务器*/
     $files['Filedata'] = $picfiles;
     if ($files['Filedata']) {
         $material_pic = new material();
         $img_info = $material_pic->addMaterial($files, $id, $this->input['module_id'], 'img10');
         $img_thumb_info = $this->get_thumb_pic($img_info['filepath'], $img_info['filename']);
         //去请求一张缩略图
         $data = array('platId' => $id, 'oldname' => $files['Filedata']['name'], 'newname' => $img_info['filename'], 'addtime' => time(), 'path' => $img_info['filepath']);
         //判断是否存在封面 如果不存在则以第一幅图片做为封面
         $sql = 'UPDATE ' . DB_PREFIX . 'plat SET picurl = "' . $data['path'] . $data['newname'] . '" WHERE id = ' . $data['platId'];
         $this->db->query($sql);
         $sql = "INSERT INTO " . DB_PREFIX . "pics SET";
         $sql_extra = $space = ' ';
         foreach ($data as $k => $v) {
             $sql_extra .= $space . $k . "='" . $v . "'";
             $space = ',';
         }
         $sql .= $sql_extra;
         $this->db->query($sql);
     }
     return true;
 }
Example #3
0
 public function update()
 {
     if (!$this->input['id']) {
         $this->errorOutput(NOID);
     }
     $data = array('name' => $this->input['name'], 'description' => $this->input['description'], 'need_update' => intval($this->input['need_update']));
     //处理logo图片
     if ($_FILES['map_marker']) {
         $_FILES['Filedata'] = $_FILES['map_marker'];
         $material_pic = new material();
         $img_info = $material_pic->addMaterial($_FILES);
         if ($img_info) {
             $map_marker = array('host' => $img_info['host'], 'dir' => $img_info['dir'], 'filepath' => $img_info['filepath'], 'filename' => $img_info['filename']);
             $data['map_marker'] = @serialize($map_marker);
         }
     }
     $ret = $this->mode->update($data, $this->input['id']);
     if ($ret) {
         $update_data = array('user_id' => $this->user['user_id'], 'user_name' => $this->user['user_name'], 'update_time' => TIMENOW, 'ip' => hg_getip());
         $pre_data = $this->mode->update($update_data, $this->input['id']);
         $up_data = $data + $update_data;
         $this->addLogs('更新停车场类型', $pre_data, $up_data, $up_data['name']);
     }
     $this->addItem('success');
     $this->output();
 }
Example #4
0
 public function update()
 {
     if (!$this->input['id']) {
         $this->errorOutput(NOID);
     }
     $data = array('name' => $this->input['name'], 'enterprise_nature' => $this->input['enterprise_nature'], 'description' => $this->input['description'], 'tel' => $this->input['tel'], 'parking_num' => $this->input['parking_num'], 'address' => $this->input['address']);
     //处理logo图片
     if ($_FILES['logo']) {
         $_FILES['Filedata'] = $_FILES['logo'];
         $material_pic = new material();
         $img_info = $material_pic->addMaterial($_FILES);
         if ($img_info) {
             $logo = array('host' => $img_info['host'], 'dir' => $img_info['dir'], 'filepath' => $img_info['filepath'], 'filename' => $img_info['filename']);
             $data['logo'] = @serialize($logo);
         }
     }
     $ret = $this->mode->update($data, $this->input['id']);
     if ($ret) {
         $update_data = array('user_id' => $this->user['user_id'], 'user_name' => $this->user['user_name'], 'update_time' => TIMENOW, 'ip' => hg_getip());
         $pre_data = $this->mode->update($update_data, $this->input['id']);
         $up_data = $data + $update_data;
         $this->addLogs('更新物业单位', $pre_data, $up_data, $up_data['name']);
     }
     $this->addItem('success');
     $this->output();
 }
Example #5
0
 public function update()
 {
     if (!$this->input['id']) {
         $this->errorOutput(NOID);
     }
     $name = $this->input['name'];
     $body_html = $this->input['body_html'];
     if (!$name) {
         $this->errorOutput(NO_TPL_NAME);
     }
     if (!$body_html) {
         $this->errorOutput(NO_TPL_HTML);
     }
     $update_data = array('name' => $name, 'body_html' => $body_html, 'type' => intval($this->input['type']), 'update_time' => TIMENOW);
     //更改图片
     if (isset($_FILES['img_info']) && !$_FILES['img_info']['error']) {
         $_FILES['Filedata'] = $_FILES['img_info'];
         $material_pic = new material();
         $img = $material_pic->addMaterial($_FILES);
         if ($img) {
             $img_info = array('host' => $img['host'], 'dir' => $img['dir'], 'filepath' => $img['filepath'], 'filename' => $img['filename'], 'imgwidth' => $img['imgwidth'], 'imgheight' => $img['imgheight']);
             $update_data['img_info'] = @serialize($img_info);
         }
     }
     $ret = $this->mode->update($this->input['id'], $update_data);
     if ($ret) {
         $this->addItem('success');
         $this->output();
     }
 }
Example #6
0
 /**
  * 上传图片
  * 
  */
 public function upload_img()
 {
     $logo['Filedata'] = $_FILES['pic'];
     if ($logo['Filedata']) {
         $material_pic = new material();
         $logo_info = $material_pic->addMaterial($logo);
         $logo = array();
         $logo_pic = array('host' => $logo_info['host'], 'dir' => $logo_info['dir'], 'filepath' => $logo_info['filepath'], 'filename' => $logo_info['filename']);
         $img_info = addslashes(serialize($logo_pic));
     }
     if (!$logo_pic) {
         $this->errorOutput('没有上传的图片信息');
     }
     $logoid = intval($this->input['logoid']);
     if ($logoid) {
         $sql = 'SELECT id FROM ' . DB_PREFIX . "material  WHERE id = " . $logoid;
         $ret = $this->db->query_first($sql);
     }
     if ($logoid && $ret['id']) {
         $sql = " UPDATE " . DB_PREFIX . "material SET img_info = '" . $img_info . "' WHERE id = " . $logoid;
         $query = $this->db->query($sql);
         $data['id'] = $logoid;
     } else {
         $sql = " INSERT INTO " . DB_PREFIX . "material SET img_info = '" . $img_info . "'";
         $query = $this->db->query($sql);
         $vid = $this->db->insert_id();
         $data['id'] = $vid;
     }
     $data['img_info'] = hg_fetchimgurl($logo_pic, 200, 160);
     $this->addItem($data);
     $this->output();
 }
Example #7
0
 public function upload()
 {
     if ($_FILES['Filedata']) {
         if ($_FILES['Filedata']['error']) {
             $this->addItem(array('error' => '图片有误'));
             $this->output();
         } else {
             /*
             $tmp = getimagesize($_FILES['Filedata']['tmp_name']);
             				if($tmp[0]<2100)
             				{
             					$this->addItem(array('error' => '图片宽度必须大于2100'));
             					$this->output();
             				}
             				if($tmp[1]<1400)
             				{
             					$this->addItem(array('error' => '图片高度必须大于1400'));
             					$this->output();
             				}
             */
             include_once ROOT_PATH . '/lib/class/material.class.php';
             $obj_material = new material();
             $ret = $obj_material->addMaterial($_FILES);
             if (!empty($ret)) {
                 $this->addItem($ret);
                 $this->output();
             }
         }
     }
 }
Example #8
0
 public function water_config_list()
 {
     include_once ROOT_PATH . 'lib/class/material.class.php';
     $material = new material();
     $ret = $material->water_config_list();
     $this->addItem($ret);
     $this->output();
 }
Example #9
0
 public function update()
 {
     if (!$this->input['id']) {
         $this->errorOutput(NOID);
     }
     $update_data = array('name' => trim($this->input['name']), 'points_system' => $this->input['points_system'], 'is_login' => intval($this->input['is_login']));
     //数据验证
     $this->data_check($data, $this->input['old_name']);
     //上传索引图
     $cover['Filedata'] = $_FILES['Filedata'];
     $cover2['Filedata'] = $_FILES['Filedata2'];
     include_once ROOT_PATH . 'lib/class/material.class.php';
     $material = new material();
     if ($cover['Filedata']) {
         $re = $material->addMaterial($cover);
         $cover = array();
         $cover = array('host' => $re['host'], 'dir' => $re['dir'], 'filepath' => $re['filepath'], 'filename' => $re['filename']);
         $update_data['index_pic'] = addslashes(serialize($cover));
     }
     //上传默认图
     if ($cover2['Filedata']) {
         $re2 = $material->addMaterial($cover2);
         $cover2 = array();
         $cover2 = array('host' => $re2['host'], 'dir' => $re2['dir'], 'filepath' => $re2['filepath'], 'filename' => $re2['filename']);
         $update_data['default_pic'] = addslashes(serialize($cover2));
     }
     $ret = $this->mode->update($this->input['id'], $update_data);
     if ($ret) {
         //如果内容有更新才更新以下内容
         $update_data['update_user_name'] = $this->user['user_name'];
         $update_data['update_user_id'] = $this->user['user_id'];
         $update_data['update_org_id'] = $this->user['org_id'];
         $update_data['update_time'] = TIMENOW;
         $update_data['update_ip'] = $this->user['ip'];
         $sql = "UPDATE " . DB_PREFIX . "grade_style SET \n\t\t\t\t\tupdate_user_name ='" . $update_data['update_user_name'] . "',\n\t\t\t\t\tupdate_user_id = '" . $update_data['update_user_id'] . "',\n\t\t\t\t\tupdate_org_id = '" . $update_data['update_org_id'] . "',\n\t\t\t\t\tupdate_ip = '" . $update_data['update_ip'] . "', \n\t\t\t\t\tupdate_time = '" . TIMENOW . "' WHERE id=" . $this->input['id'];
         $this->db->query($sql);
         //更新描述
         if ($this->input['is_describe']) {
             $names = $this->input['name'];
             //简述词
             $describes = $this->input['describe'];
             //描述
             if ($names || $describes) {
                 foreach ($names as $k => $v) {
                     $describe_data = array('style_id' => $vid, 'star' => $k, 'name' => trim($v), 'describes' => trim($describes[$k]));
                     $this->mode->update_describe($this->input['id'], $describe_data);
                 }
             }
         }
     }
     //$this->addLogs('更新',$ret,'','更新' . $this->input['id']);此处是日志,自己根据情况加一下
     $this->addItem('success');
     $this->output();
 }
Example #10
0
 public function img_upload($img_file)
 {
     $classfile = ROOT_PATH . 'lib/class/material.class.php';
     if (is_file($classfile)) {
         class_exists('material') or (include $classfile);
         $material_pic = new material();
         $img = array('Filedata' => $img_file);
         if (!$this->settings['App_material']) {
             return '';
         }
         $img_info = $material_pic->addMaterial($img);
         $img_data = array('host' => $img_info['host'], 'dir' => $img_info['dir'], 'filepath' => $img_info['filepath'], 'filename' => $img_info['filename']);
         return maybe_serialize($img_data);
     }
     return '';
 }
Example #11
0
	 * @param Array $data
	 */
    public function count($data)
    {
        $condition = $this->get_condition($data);
        $sql = 'SELECT COUNT(id) AS total FROM ' . DB_PREFIX . 'message WHERE 1';
        if ($condition) {
            $sql .= $condition;
        }
        return $this->db->query_first($sql);
    }
    /**
	 * 获取单个微信信息
	 * @param Int $id
	 */
    public function detail($id)
    {
Example #12
0
 public function events()
 {
     if (!env('student')) {
         redirect('m=login');
     }
     $updisciplineId = val($_REQUEST, 'updisciplineId');
     $learningMode = val($_REQUEST, 'learningMode');
     if (empty($updisciplineId) || empty($learningMode)) {
         throw new Exception('Missed required param', 404);
     }
     $updiscipline = entry_sql('SELECT * FROM updiscipline WHERE updisciplineId=:updisciplineId', array(':updisciplineId' => $updisciplineId));
     if (empty($updiscipline)) {
         throw new Exception('Updiscipline not found', 404);
     }
     $groupPeriod = entry_sql('SELECT gp.* FROM group_history gh INNER JOIN group_period gp USING(groupPeriodId) WHERE gh.studentId=:studentId AND gp.sersemester=:sersemester', array('studentId' => studentId(), 'sersemester' => $updiscipline['sersemester']));
     if (empty($groupPeriod)) {
         throw new Exception('Cannot detect groupPeriod', 404);
     }
     $events = entries_sql('SELECT * FROM event WHERE updisciplineId=:updisciplineId AND groupPeriodId=:groupPeriodId AND learningMode=:learningMode', array('groupPeriodId' => $groupPeriod['groupPeriodId'], 'updisciplineId' => $updiscipline['updisciplineId'], 'learningMode' => $learningMode));
     array_walk($events, function (&$event, $k, $studentId) {
         $event['c'] = material::i($event['instanceType'])->c();
         $event['grade'] = material::i($event['instanceType'])->get_grade($event['instanceId'], $studentId);
     }, studentId());
     env('breadcrumbs', array(array(lng('up:disciplines'), '/?c=up'), array($updiscipline['disciplineName'], '/?c=up&amp;m=events&amp;updisciplineId=' . $updisciplineId . '&amp;learningMode=' . $learningMode), lng('up:events')));
     tpl('up/events', array('updiscipline' => $updiscipline, 'events' => $events, 'result' => entry_sql('SELECT * FROM result WHERE studentId=:studentId AND updisciplineId=:updisciplineId AND learningMode=:learningMode', array('studentId' => studentId(), 'updisciplineId' => $updiscipline['updisciplineId'], 'learningMode' => $learningMode))));
 }
Example #13
0
 public function get_grade($instanceId, $studentId)
 {
     $attempt = entry_sql('SELECT * FROM quiz_attempt WHERE quizId=:quizId AND studentId=:studentId AND status=:status ORDER BY grade DESC LIMIT 1', array('quizId' => $instanceId, 'studentId' => $studentId, 'status' => STATUS_COMPLETE));
     if (!$attempt) {
         return parent::get_grade($instanceId, $studentId);
     }
     return array('time' => $attempt['timeFinish'], 'coef' => $attempt['grade']);
 }
 protected function _up_breadcrumbs($event)
 {
     $updiscipline = entry_sql('SELECT * FROM updiscipline WHERE updisciplineId=:updisciplineId', array(':updisciplineId' => $event['updisciplineId']));
     if (empty($updiscipline)) {
         throw new Exception('Cannot fetch updiscipline "' . $event['updisciplineId'] . '"', 500);
     }
     return array(array(lng('up:disciplines'), '/?c=up'), array($updiscipline['disciplineName'], '/?c=up&amp;m=events&amp;updisciplineId=' . $event['updisciplineId'] . '&amp;learningMode=' . $event['learningMode']), lng('up:events'), array($event['name'], '/?c=' . material::i($event['instanceType'])->c() . '&amp;eventId=' . $event['eventId'] . '&amp;id=' . $event['instanceId']));
 }
Example #15
0
 /**
  * 上传图片
  */
 public function upload()
 {
     if (!$_FILES['Filedata']) {
         $this->errorOutput(PARAM_WRONG);
     }
     $material = new material();
     $result = $material->addMaterial($_FILES, '', '', '', '', 'png');
     if (!$result) {
         $this->errorOutput(FAILED);
     }
     $flag = !!$this->input['flag'];
     if ($flag) {
         $picData = array('material_id' => $result['id'], 'name' => $result['name'], 'mark' => $result['mark'], 'type' => $result['type'], 'filesize' => $result['filesize'], 'imgwidth' => $result['imgwidth'], 'imgheight' => $result['imgheight'], 'host' => $result['host'], 'dir' => $result['dir'], 'filepath' => $result['filepath'], 'filename' => $result['filename'], 'user_id' => $this->user['user_id'], 'user_name' => $this->user['user_name'], 'org_id' => $this->user['org_id'], 'create_time' => $result['create_time'], 'ip' => $result['ip']);
         $result = $this->api->create('app_material', $picData);
     }
     $this->addItem($result);
     $this->output();
 }
Example #16
0
 public function show()
 {
     $dir = TARGET_DIR . 'livesnap/';
     $time = $this->input['time'] ? $this->input['time'] : TIMENOW;
     $material = new material();
     $handle = dir($dir);
     $snaps = array();
     while ($file = $handle->read()) {
         if ($file == '.' || $file == '..' || !intval($file)) {
             continue;
         }
         if (!is_dir($dir . $file . '/')) {
             continue;
         }
         $sdir = $dir . $file . '/';
         $handle1 = dir($sdir);
         $i = 0;
         while ($file1 = $handle1->read()) {
             if (!is_file($sdir . $file1)) {
                 continue;
             }
             $vv = $sdir . $file1;
             $k = $file;
             @copy($vv, $dir . '/live_' . $k . '.png');
             $vv = $dir . '/live_' . $k . '.png';
             if (defined("TARGET_VIDEO_DOMAIN")) {
                 $pic = 'http://' . ltrim(TARGET_VIDEO_DOMAIN, 'http://') . '/' . 'livesnap/live_' . $k . '.png';
             } else {
                 $pic = $this->settings['videouploads']['protocol'] . $this->settings['videouploads']['host'] . '/' . 'livesnap/live_' . $k . '.png';
             }
             $kk = filemtime($vv);
             if (time() - $kk < 2) {
                 $img_info = $material->addMaterialNodb($pic, 1, 'livesnap/img/' . date('Y', $kk) . '/' . date('m', $kk));
                 $this->addItem($img_info[0]);
             } else {
                 @unlink($vv);
             }
             $i++;
         }
     }
     $this->output();
 }
Example #17
0
 public function update()
 {
     $starttime = explode('-', $this->input['astrostart']);
     $astrostart = mktime(0, 0, 0, $starttime[0], $starttime[1], 0);
     unset($starttime);
     $endtime = explode('-', $this->input['astroend']);
     $astroend = mktime(0, 0, 0, $endtime[0], $endtime[1], 0);
     unset($endtime);
     $data = array('id' => intval($this->input['id']), 'name' => trim($this->input['name']), 'astrointroduction' => trim($this->input['astrointroduction']), 'astrostart' => trim($astrostart), 'astroend' => trim($astroend));
     if (!$data['id']) {
         $this->errorOutput("ID不能为空");
     }
     if (!$data['name']) {
         $this->errorOutput("星座名不能为空");
     }
     $sql = 'SELECT astroimg FROM ' . DB_PREFIX . 'astro_app_info WHERE id = ' . $data['id'];
     $res = $this->db->query_first($sql);
     $astroimg = unserialize($res['astroimg']) ? unserialize($res['astroimg']) : array();
     $logo['Filedata'] = $_FILES['logo'];
     if ($logo['Filedata']) {
         include_once ROOT_PATH . 'lib/class/material.class.php';
         $material = new material();
         $re = $material->addMaterial($logo);
         $logo = array();
         $logo = array('host' => $re['host'], 'dir' => $re['dir'], 'filepath' => $re['filepath'], 'filename' => $re['filename']);
     } else {
         $logo = $astroimg;
     }
     $where = ' WHERE 1 ';
     $where .= ' AND  id = ' . $data['id'];
     $sql = 'UPDATE ' . DB_PREFIX . 'astro_app_info' . ' SET astrocn = "' . $data['name'] . '",astrointroduction = "' . $data['astrointroduction'] . '", astroimg ="' . addslashes(serialize($logo)) . '",astrostart = "' . $data['astrostart'] . '",astroend = "' . $data['astroend'] . '"' . $where;
     //$this->errorOutput($sql);
     $this->db->query($sql);
     $this->constellation->updatetime_orerid($data['id'], 'info');
     $data['logo'] = $logo;
     $this->addItem($data);
     $this->output();
 }
Example #18
0
 public function delete($ids)
 {
     if ($ids) {
         $sql = "SELECT logo_id FROM " . DB_PREFIX . "res_sort WHERE id IN(" . $ids . ")";
         $q = $this->db->query($sql);
         $mid = $space = '';
         while ($row = $this->db->fetch_array($q)) {
             $mid .= $space . $row['logo_id'];
             $space = ',';
         }
         $sql = "DELETE FROM " . DB_PREFIX . "res_sort WHERE id IN(" . $ids . ")";
         $this->db->query($sql);
         $sql = "DELETE FROM " . DB_PREFIX . "res WHERE sort_id IN(" . $ids . ")";
         //删除res对应子项目
         $this->db->query($sql);
         if ($mid) {
             include_once ROOT_PATH . 'lib/class/material.class.php';
             $mater = new material();
             $mater->delMaterialById($mid);
         }
         return array('id' => $ids);
     }
 }
Example #19
0
 /**
  * 创建数据
  */
 public function create()
 {
     $category_id = intval($this->input['category_id']);
     $iconFiles = $_FILES['iconFiles'];
     if ($category_id <= 0 || empty($iconFiles)) {
         $this->errorOutput(PARAM_WRONG);
     }
     $_FILES['Filedata'] = $iconFiles;
     unset($_FILES['iconFiles']);
     $imgzip = $iconFiles['type'] == 'application/zip' ? 1 : 0;
     $material = new material();
     $iconInfo = $material->addMaterial($_FILES, '', '', '', $imgzip);
     if (!$iconInfo) {
         $this->errorOutput(FAILED);
     }
     $data = array('cate_id' => $category_id, 'user_id' => $this->user['user_id'], 'user_name' => $this->user['user_name'], 'org_id' => $this->user['org_id']);
     $condition = array('id' => $category_id);
     if ($imgzip) {
         foreach ($iconInfo as $icon) {
             $this->prepareData($data, $icon);
             $result = $this->api->create('app_material', $data);
         }
         //更新分类下图片数
         $pic_count = count($iconInfo);
         $updateData = array('pic_count' => $pic_count);
         $this->api->update('icon_category', $updateData, $condition, true);
     } else {
         $this->prepareData($data, $iconInfo);
         $result = $this->api->create('app_material', $data);
         //更新分类下图片数
         $updateData = array('pic_count' => 1);
         $this->api->update('icon_category', $updateData, $condition, true);
     }
     $this->addItem($result);
     $this->output();
 }
Example #20
0
 public function delete()
 {
     if (empty($this->input['id'])) {
         $this->errorOutput("ID不能为空");
     }
     $ids = urldecode($this->input['id']);
     include_once ROOT_PATH . 'lib/class/material.class.php';
     $material = new material();
     //删除圈子log
     $sql = "SELECT log FROM " . DB_PREFIX . "group WHERE id IN(" . $ids . ")";
     $q = $this->db->query($sql);
     while ($row = $this->db->fetch_array($q)) {
         $row['log'] = json_decode($row['log'], 1);
         if ($row['log']) {
             $material->delMaterialById($row['log'][0]['id'], 2);
         }
     }
     $sql = "DELETE FROM " . DB_PREFIX . "group WHERE id IN(" . $ids . ")";
     $this->db->query($sql);
     $this->addLogs('删除路况分类', '', '', '删除路况分类+' . $ids);
     $this->addItem($ids);
     $this->output();
 }
Example #21
0
 public function insert_lbs($str, $sort_id = '')
 {
     if (!$str) {
         continue;
     }
     //explode:函数把字符串分割为数组。
     if (stripos($str, ' ') !== false) {
         $str = $this->trimall($str);
     }
     $arr = array();
     $arr = explode("\\", trim($str, "\\"));
     if (empty($arr)) {
         continue;
     }
     //file_put_contents('44.txt', var_export($arr,1));exit();
     /*$arr = array(
     		  	0 => '机床1#',//名称
     		  	1 => '机床新村27#旁',//地址
     		  	2 => '120.278897',//经度
     		  	3 => '31.56376533',//纬度
     		  	4 => '120.278897',//百度坐标
     		  	5 => '31.56376533',
     		  	6 => '江苏省',//省
     		  	7 => '无锡市',//城市
     		  	8 => '滨湖区',//区
     		  	9 => '公共设施',//分类
     		  	10 => '客服:025-89809090|售前:025-87898009',//联系电话
     		  	11 => '9:00-18:00',//营业时间
     		  	12 => 'http://g.hiphotos.baidu.com/image/pic/item/08f790529822720eb25fa86479cb0a46f31fab9f.jpg',//索引图
     			13 => '简介',//简介
     			14 => 'HJSWUXBHQ00001',//地点编号
     		);*/
     $data = array();
     if ($arr[14]) {
         $data['local_id'] = $arr[14];
         //判断数据是否导入过
         /*$sql = "SELECT local_id FROM " . DB_PREFIX . "lbs WHERE local_id = '" . $data['local_id'] . "'";
         		$res = $this->db->query_first($sql);
         		
         		if($res['local_id'])
         		{
         			continue;
         		}*/
     }
     if ($arr[0]) {
         $data['title'] = $arr[0];
     }
     if ($arr[1]) {
         $data['address'] = $arr[1];
     }
     if ($arr[2]) {
         $data['GPS_longitude'] = $arr[2];
     }
     if ($arr[3]) {
         $data['GPS_latitude'] = $arr[3];
     }
     if ($arr[4]) {
         $data['baidu_longitude'] = $arr[4];
     }
     if ($arr[5]) {
         $data['baidu_latitude'] = $arr[5];
     }
     //处理省市区
     if ($arr[6]) {
         $sql = "SELECT id FROM " . DB_PREFIX . "province WHERE name LIKE '%" . $arr[6] . "%'";
         $res = $this->db->query_first($sql);
         if ($res['id']) {
             $data['province_id'] = $res['id'];
         }
         if ($data['province_id'] && $arr[7]) {
             $sql = "SELECT id FROM " . DB_PREFIX . "city WHERE province_id = " . $data['province_id'] . " AND city LIKE '%" . $arr[7] . "%'";
             $city_res = $this->db->query_first($sql);
             if ($city_res['id']) {
                 $data['city_id'] = $city_res['id'];
             }
         }
         if ($arr[8] && $data['city_id']) {
             $sql = "SELECT id FROM " . DB_PREFIX . "area WHERE city_id = " . $data['city_id'] . " AND area LIKE '%" . $arr[8] . "%'";
             $area_res = $this->db->query_first($sql);
             if ($area_res['id']) {
                 $data['area_id'] = $area_res['id'];
             }
         }
     }
     //处理分类
     if ($sort_id) {
         $data['sort_id'] = $sort_id;
     } else {
         if ($arr[9]) {
             $sql = "SELECT id FROM " . DB_PREFIX . "sort WHERE name = '" . $arr[9] . "'";
             $sort_res = $this->db->query_first($sql);
             if ($sort_res['id']) {
                 $data['sort_id'] = $sort_res['id'];
             }
         }
     }
     //处理联系电话
     if ($arr[10]) {
         $tel_arr = array();
         if (stripos($arr[10], '|') !== false) {
             $tel = explode('|', trim($arr[10]));
             if (!empty($tel) && is_array($tel)) {
                 foreach ($tel as $key => $val) {
                     if (stripos($val, ':') !== false) {
                         $tmp = explode(':', $val);
                     } else {
                         if (stripos($val, ':') !== false) {
                             $tmp = explode(':', $val);
                         }
                     }
                     if (!empty($tmp)) {
                         $telname = $tmp[0] ? $tmp[0] : '联系电话' . ($key + 1);
                         $tel_arr[] = array('telname' => $telname, 'tel' => $tmp[1]);
                     }
                 }
             }
             $data['tel'] = serialize($tel_arr);
         } else {
             if (stripos($arr[10], ':') !== false) {
                 $tmp = explode(':', $arr[10]);
             } else {
                 if (stripos($arr[10], ':') !== false) {
                     $tmp = explode(':', $arr[10]);
                 }
             }
             if (!empty($tmp)) {
                 $telname = $tmp[0] ? $tmp[0] : '联系电话' . ($key + 1);
                 $tel_arr[] = array('telname' => $telname, 'tel' => $tmp[1]);
             }
             $data['tel'] = serialize($tel_arr);
         }
     }
     //处理经营时间
     if ($arr[11]) {
         if (stripos($arr[11], '-') !== false) {
             $jy_time = explode('-', $arr[11]);
             $ymd = date('Y-m-d', TIMENOW);
             $stime = strtotime($ymd . ' ' . $jy_time[0]);
             $etime = strtotime($ymd . ' ' . $jy_time[1]);
             $data['stime'] = $stime;
             $data['etime'] = $etime;
         }
     }
     //入库
     if (empty($data)) {
         continue;
     }
     //如果百度坐标存在gps不存在的话,就转换为gps坐标也存起来
     if ($data['baidu_longitude'] && $data['baidu_latitude']) {
         $gps = $this->lbs->FromBaiduToGpsXY($data['baidu_longitude'], $data['baidu_latitude']);
         $data['GPS_longitude'] = $gps['GPS_x'];
         $data['GPS_latitude'] = $gps['GPS_y'];
     }
     //如果GPS坐标存在并且百度坐标不存在的话,就转换为百度坐标也存起来
     if (!$data['baidu_longitude'] && !$data['baidu_latitude'] && $data['GPS_longitude'] && $data['GPS_latitude']) {
         $baidu = array();
         //防止网络崩溃,暂时注释
         $baidu = $this->lbs->FromGpsToBaiduXY($data['GPS_longitude'], $data['GPS_latitude']);
         if (!empty($baidu)) {
             $data['baidu_longitude'] = $baidu['x'];
             $data['baidu_latitude'] = $baidu['y'];
         }
     }
     $data['create_time'] = TIMENOW;
     $data['org_id'] = $this->user['org_id'];
     $data['user_id'] = $this->user['user_id'];
     $data['user_name'] = $this->user['user_name'];
     $data['ip'] = $this->user['ip'];
     $lbs = $this->lbs->add_lbs($data);
     $id = $lbs['id'];
     if (!$id) {
         continue;
     }
     if ($arr[12]) {
         //对索引图的处理
         include_once ROOT_PATH . 'lib/class/material.class.php';
         $material_pic = new material();
         $img_info = array();
         $img_info = $material_pic->localMaterial($arr[12]);
         //图片本地化失败,重复请求3次
         /*if(empty($img_info))
         		{
         			for ($i=0;$i<3;$i++)
         			{
         				$img_info = $material_pic->localMaterial($arr[12]);
         				if(!empty($img_info))
         				{
         					break;
         				}
         			}
         		}*/
         if (!empty($img_info)) {
             $img_info = $img_info[0];
             $img_data = array('host' => $img_info['host'], 'dir' => $img_info['dir'], 'filepath' => $img_info['filepath'], 'filename' => $img_info['filename']);
             $img_data['cid'] = $id;
             //lbs的id,直接置零
             $img_data['original_id'] = $img_info['id'];
             $img_data['type'] = $img_info['type'];
             $img_data['mark'] = 'img';
             $img_data['imgwidth'] = $img_info['imgwidth'];
             $img_data['imgheight'] = $img_info['imgheight'];
             $img_data['flag'] = 1;
             $vid = $this->lbs->insert_img($img_data);
         }
         if ($vid) {
             $sql = 'UPDATE ' . DB_PREFIX . 'lbs set indexpic = ' . $vid . ' WHERE id = ' . $id;
             $this->db->query($sql);
         }
     }
     //简介描述
     if ($arr[13]) {
         $this->lbs->add_content($arr[13], $id);
     }
 }
Example #22
0
        $this->output();
    }
    /**
	 * 上传小组标识
	 */
    public function upload()
    {
        include_once ROOT_PATH . 'lib/class/material.class.php';
        $upload = new material();
        $result = $upload->addMaterial($_FILES);
        $ret['data'] = serialize($result);
Example #23
0
 public function testTagCollection()
 {
     $material = new material();
     $this->assertFalse($material->containsTag('t'));
     $material->addTag('t');
     $this->assertTrue($material->containsTag('t'));
     $material->removeTag('t');
     $this->assertFalse($material->containsTag('t'));
     //Repeat Tag
     $this->assertFalse($material->containsTag('t'));
     $material->addTag('t');
     $material->addTag('t');
     $this->assertTrue($material->containsTag('t'));
     $material->removeTag('t');
     $this->assertFalse($material->containsTag('t'));
     $this->assertFalse($material->removeTag('t'));
     //containsAllTag and containsAnyTag
     $material->addTag('t1');
     $material->addTag('t2');
     $material->addTag('t3');
     $this->assertTrue($material->containsAnyTag(array('t0', 't2')));
     $this->assertTrue($material->containsAnyTag(array('t2', 't3')));
     $this->assertFalse($material->containsAnyTag(array('t0', 't4')));
     $this->assertTrue($material->containsAllTags(array('t1', 't2')));
     $this->assertTrue($material->containsAllTags(array('t1')));
     $this->assertFalse($material->containsAllTags(array('t0', 't2')));
     $this->assertFalse($material->containsAllTags(array('t0', 't1', 't2', 't3')));
 }
Example #24
0
 public function callback($video_id = 0)
 {
     if (!$video_id) {
         $video_id = intval($this->input['video_id']);
         if (!$video_id) {
             return false;
         }
     }
     $sql = 'SELECT * FROM ' . DB_PREFIX . 'vod_extend WHERE content_id=' . $video_id;
     $local_video = $this->db->query_first($sql);
     if (!$local_video) {
         return false;
     }
     $this->user_unique = $this->settings['cloud_user'];
     $this->secret_key = $this->settings['cloud_secret_key'];
     $videoinfo = $this->videoGet($video_id);
     $videoinfo = json_decode($videoinfo, 1);
     if ($videoinfo['code'] == 109) {
         $sql = 'DELETE FROM ' . DB_PREFIX . 'vod_extend WHERE content_id=' . $video_id;
         $this->db->query($sql);
         $sql = 'DELETE FROM ' . DB_PREFIX . 'vodinfo WHERE id=' . intval($local_video['vodinfo_id']);
         $this->db->query($sql);
     }
     if (!$videoinfo['code']) {
         $sql = 'SELECT * FROM ' . DB_PREFIX . 'vodinfo WHERE  id=' . intval($local_video['vodinfo_id']);
         $local_video_info = $this->db->query_first($sql);
         $swf = $this->videoGetPlayinterface($this->user_unique, $local_video['extend_data'], 'flash');
         //				exit($swf);
         $data = array('totalsize' => $videoinfo['data']['video_duration'] * 1000, 'duration' => $videoinfo['data']['initial_size'], 'update_time' => time(), 'is_link' => 1, 'swf' => $swf);
         if (!$local_video_info['comment']) {
             $data['comment'] = $videoinfo['data']['video_desc'];
         }
         if (!$local_video_info['keywords']) {
             $data['keywords'] = $videoinfo['data']['tag'];
         }
         if ($videoinfo['data']['status'] == 10) {
             if ($local_video_info['status'] < 1) {
                 $data['status'] = 1;
             }
         } elseif ($videoinfo['data']['status'] == 20) {
             $data['status'] = -1;
         } else {
             if ($local_video_info['status'] == 2) {
                 $data['status'] = 1;
             }
         }
         $img_info = unserialize($local_video_info['img_info']);
         if (!strstr($videoinfo['data']['img'], 'noimg') || !$img_info['filename']) {
             include_once ROOT_PATH . 'lib/class/material.class.php';
             $material = new material();
             $imgurl = pathinfo($videoinfo['data']['img']);
             $imgurl = $imgurl['dirname'] . '/' . $imgurl['filename'] . '_640_360.' . $imgurl['extension'];
             $img_info = $material->localMaterial($imgurl);
             $img_info = $img_info[0];
             $image_info = array('host' => $img_info['host'], 'dir' => $img_info['dir'], 'filepath' => $img_info['filepath'], 'filename' => $img_info['filename'], 'imgwidth' => $img_info['imgwidth'], 'imgheight' => $img_info['imgheight']);
             $data['img_info'] = serialize($image_info);
         }
         if ($data) {
             $update = array();
             foreach ($data as $k => $v) {
                 $update[] = $k . "='" . $v . "'";
             }
             $sql = 'UPDATE ' . DB_PREFIX . 'vodinfo SET ' . implode(',', $update) . ' WHERE  id=' . intval($local_video_info['id']);
             $this->db->query($sql);
             return true;
         }
     }
     echo '<pre>';
     print_r($data);
     print_r($videoinfo);
     print_r($local_video_info);
     return false;
 }
Example #25
0
<?php

trigger_reg('material.graded', function ($codeOrName, $id, $studentId) {
    global $CFG;
    $code = is_numeric($codeOrName) ? $codeOrName : array_search($codeOrName, $CFG->material);
    if (!is_numeric($code)) {
        throw new Exception('Cannot detect meterial type of "' . $codeOrName . '"', 500);
    }
    $updisciplines = entries_sql('SELECT ud.*,e.groupPeriodId,e.learningMode FROM event e, updiscipline ud, group_period gp, group_history gh
								WHERE e.updisciplineId=ud.updisciplineId AND ud.upId=gp.upId AND gp.groupPeriodId=gh.groupPeriodId AND e.instanceType=:type AND  e.instanceId=:id AND gh.studentId=:studentId', array('type' => $code, 'id' => $id, 'studentId' => $studentId));
    foreach ($updisciplines as $upd) {
        $events = entries_sql('SELECT * FROM event WHERE updisciplineId=:updisciplineId AND groupPeriodId=:groupPeriodId AND learningMode=:learningMode', array('groupPeriodId' => $upd['groupPeriodId'], 'updisciplineId' => $upd['updisciplineId'], 'learningMode' => $upd['learningMode']));
        $result = array_reduce($events, function ($r, $e) {
            $r['sum'] += $e['weight'];
            $r['got'] += $e['weight'] * val(material::i($e['instanceType'])->get_grade($e['instanceId'], $r['studentId']), 'coef', 0);
            return $r;
        }, array('studentId' => $studentId, 'sum' => 0, 'got' => 0));
        if (empty($result['sum'])) {
            continue;
        }
        entry_change('result', array('grade' => $result['got'] / $result['sum'] * 100), array('studentId' => $studentId, 'updisciplineId' => $upd['updisciplineId'], 'learningMode' => $upd['learningMode']));
    }
});
Example #26
0
 /**
  * 入素材库
  * Enter description here ...
  * @param unknown_type $file
  * @param unknown_type $id
  */
 public function add_material($file, $id)
 {
     include_once ROOT_PATH . 'lib/class/material.class.php';
     $mMaterial = new material();
     if (!$mMaterial) {
         return false;
     }
     $files['Filedata'] = $file;
     $material = $mMaterial->addMaterial($files, $id);
     $return = array();
     if (!empty($material)) {
         $return['host'] = $material['host'];
         $return['dir'] = $material['dir'];
         $return['filepath'] = $material['filepath'];
         $return['filename'] = $material['filename'];
     }
     return $return;
 }
 public function img_upload($img_file)
 {
     require_once ROOT_PATH . 'lib/class/material.class.php';
     $img['Filedata'] = $img_file;
     if (!$this->settings['App_material']) {
         $this->errorOutput('图片服务器未安装!');
     }
     $material_pic = new material();
     $img_info = $material_pic->addMaterial($img);
     $img_data = array('host' => $img_info['host'], 'dir' => $img_info['dir'], 'filepath' => $img_info['filepath'], 'filename' => $img_info['filename']);
     return maybe_serialize($img_data);
 }
Example #28
0
 private function storage_data($video, $vod_config)
 {
     if ($video['column_id']) {
         $publish_column = new publishconfig();
         $column_id = $video['column_id'];
         $column_id = $publish_column->get_columnname_by_ids('id,name', $column_id);
         $column_id = serialize($column_id);
     }
     $channel_id = $video['channel_id'];
     if ($video['create_time'] != -1) {
         $create_time = strtotime($video['create_time']);
     }
     $pathinfo = pathinfo($video['filepath']);
     //如果不存在分类就默认其分类与类型相同
     $vod_leixing = $video['vod_leixing'] ? $video['vod_leixing'] : 1;
     if (!$video['vod_sort_id'] || intval($video['vod_sort_id']) == -1) {
         $video['vod_sort_id'] = $vod_leixing;
     }
     /************创建视频的权限控制**********/
     if ($this->user['group_type'] > MAX_ADMIN_TYPE) {
         $prms['_action'] = 'create';
         $prms['node'] = $video['vod_sort_id'];
         if (!$this->verify_self_prms($prms)) {
             $this->errorOutput('NO_PRIVILEGE');
             //$this->addItem(array('return' => 'fail'));
             //$this->output();
         }
     }
     foreach ($video as $k => $v) {
         if (is_string($v)) {
             $video[$k] = rawurldecode($v);
         }
     }
     $data = array('cur_clarity' => $vod_config['unique_id'], 'title' => $video['title'] ? $video['title'] : $this->dir_info['original'], 'source' => $video['source'], 'subtitle' => $video['subtitle'], 'keywords' => $video['keywords'], 'weight' => $video['weight'], 'comment' => $video['comment'], 'author' => $video['author'], 'vod_leixing' => $vod_leixing, 'bitrate' => $vod_config['video_bitrate'], 'vod_sort_id' => $video['vod_sort_id'], 'is_allow' => $video['is_mark'], 'starttime' => $video['starttime'] ? strtotime($video['starttime']) : '', 'hostwork' => defined("TARGET_VIDEO_DOMAIN") ? 'http://' . ltrim(TARGET_VIDEO_DOMAIN, 'http://') : $this->settings['videouploads']['protocol'] . $this->settings['videouploads']['host'], 'source_hostwork' => defined("SOURCE_VIDEO_DOMIAN") ? 'http://' . ltrim(SOURCE_VIDEO_DOMIAN, 'http://') : '', 'source_base_path' => UPLOAD_DIR, 'source_path' => rtrim($pathinfo['dirname'], '/') . '/', 'source_filename' => $pathinfo['basename'], 'video_base_path' => TARGET_DIR, 'video_path' => $this->dir_info['target_dir'], 'video_filename' => $this->dir_info['output_filename'] . '.' . $this->dir_info['output_format'], 'channel_id' => $channel_id, 'column_id' => $column_id, 'from_appid' => $this->user['appid'], 'from_appname' => $this->user['display_name'], 'user_id' => $video['_user_id'] ? $video['_user_id'] : ($this->input['user_id'] ? $this->input['user_id'] : $this->user['user_id']), 'addperson' => $video['_user_name'] ? $video['_user_name'] : ($this->input['user_name'] ? $this->input['user_name'] : $this->user['user_name']), 'org_id' => $this->input['org_id'] ? $this->input['org_id'] : $this->user['org_id'], 'create_time' => $create_time ? $create_time : TIMENOW, 'update_time' => TIMENOW, 'ip' => hg_getip(), 'app_uniqueid' => $video['app_uniqueid'] ? $video['app_uniqueid'] : 'livmedia', 'mod_uniqueid' => $video['mod_uniqueid'] ? $video['mod_uniqueid'] : MOD_UNIQUEID, 'morebitrate_config_id' => $video['vod_config_id'], 'template_sign' => $video['template_sign']);
     if ($video['is_time_shift']) {
         $sql = "UPDATE " . DB_PREFIX . "vodinfo SET ";
     } else {
         $sql = " INSERT INTO " . DB_PREFIX . "vodinfo SET ";
     }
     foreach ($data as $k => $v) {
         $sql .= " {$k} = '{$v}',";
     }
     $sql = trim($sql, ',');
     if ($video['is_time_shift']) {
         $sql .= ' WHERE id = ' . $video['id'];
     }
     $this->db->query($sql);
     if ($video['is_time_shift']) {
         $vid = $video['id'];
     } else {
         $vid = $this->db->insert_id();
     }
     //记录发布库栏目分发表
     $this->update_pub_column($vid, $video['column_id']);
     //记录发布库栏目分发表
     if ($video['index_pic']) {
         $material = new material();
         $img_info = $material->localMaterial($video['index_pic'], $vid);
         $img_info = $img_info[0];
     } else {
         //获取一张截图,并且提交到图片服务器
         $img_info = getimage(UPLOAD_DIR . $video['filepath'], TARGET_DIR . $this->dir_info['target_dir'], $vid);
         if (!$img_info || !$img_info['filename']) {
             if ($this->settings['App_live'] && $channel_id) {
                 include_once ROOT_PATH . 'lib/class/live.class.php';
                 $live = new live();
                 $channelinfo = $live->getChannelById($channel_id, 1, 1);
                 if ($channelinfo && $channelinfo[0] && $channelinfo[0]['snap']) {
                     $img_info = $channelinfo[0]['snap'];
                 }
             }
         }
     }
     if ($img_info && is_array($img_info)) {
         $image_info = array('host' => $img_info['host'], 'dir' => $img_info['dir'], 'filepath' => $img_info['filepath'], 'filename' => $img_info['filename'], 'imgwidth' => $img_info['imgwidth'], 'imgheight' => $img_info['imgheight']);
     } else {
         $image_info = array();
     }
     $sql = " UPDATE " . DB_PREFIX . "vodinfo SET video_order_id = {$vid},img_info = '" . serialize($image_info) . "'  WHERE id = {$vid}";
     $this->db->query($sql);
     //存储vod_extend表
     if ($video['content_id']) {
         $extend_data = array('vodinfo_id' => $vid, 'content_id' => $video['content_id'], 'extend_data' => $video['extend_data']);
         $sql = " INSERT INTO " . DB_PREFIX . "vod_extend SET ";
         foreach ($extend_data as $k => $v) {
             $sql .= " {$k} = '{$v}',";
         }
         $sql = trim($sql, ',');
         $this->db->query($sql);
     }
     //加入日志
     $data['id'] = $vid;
     $this->addLogs('创建视频', '', $data, $data['title']);
     return array('vid' => $vid, 'img_info' => $image_info);
 }
Example #29
0
 public function upload_material()
 {
     if (!$_FILES['Filedata']) {
         $this->errorOutput("素材内容不能为空");
     }
     include_once ROOT_PATH . 'lib/class/material.class.php';
     $material_server = new material();
     $responce = $material_server->addMaterial($_FILES);
     if ($responce['ErrorCode'] || $responce['ErrorTexts']) {
         $this->errorOutput($responce['ErrorCode'] . $responce['ErrorTexts']);
     }
     $this->addItem($responce);
     $this->output();
 }
Example #30
0
 /**
  * 上传引导图
  */
 public function upload_guide_pic()
 {
     if (!$_FILES['guide_pic']) {
         $this->errorOutput(PARAM_WRONG);
     }
     $material = new material();
     $_FILES['Filedata'] = $_FILES['guide_pic'];
     unset($_FILES['guide_pic']);
     $pic_info = $material->addMaterial($_FILES, '', '', '', '', 'png');
     if (!$pic_info) {
         $this->errorOutput(FAILED);
     }
     $data = array('info' => serialize($pic_info), 'user_id' => $this->user['user_id'], 'user_name' => $this->user['user_name'], 'org_id' => $this->user['org_id'], 'create_time' => TIMENOW, 'ip' => hg_getip());
     $result = $this->api->create('app_pic', $data);
     if ($result['id']) {
         $this->api->update('app_pic', array('sort_order' => $result['id']), array('id' => $result['id']));
         $ret = array('id' => $result['id'], 'host' => $pic_info['host'], 'dir' => $pic_info['dir'], 'filepath' => $pic_info['filepath'], 'filename' => $pic_info['filename'], 'sort_order' => $result['id']);
         $this->addItem($ret);
     }
     $this->output();
 }