コード例 #1
0
ファイル: company_update.php プロジェクト: h3len/Project
 public function create()
 {
     if (!$this->user['user_id']) {
         $this->errorOutput(NO_LOGIN);
     }
     if ($this->user['group_type'] == 1) {
         $tmp_bool = $this->obj->checkRight($this->user['org_id']);
         if (isset($tmp_bool['error']) && $tmp_bool['error']) {
             $this->errorOutput($tmp_bool['error']);
             //COMPANY_HAVE_ONLY_ONE);
         }
     }
     if (empty($this->input['name'])) {
         $this->errorOutput(NO_NAME);
     }
     $data = array('name' => trim($this->input['name']) ? trim($this->input['name']) : '', 'tel' => trim($this->input['tel']) ? trim($this->input['tel']) : '', 'address' => trim($this->input['address']) ? trim($this->input['address']) : '', 'legal' => trim($this->input['legal']) ? trim($this->input['legal']) : '', 'token' => hg_generate_user_salt(8), 'create_time' => TIMENOW, 'update_time' => TIMENOW, 'ip' => hg_getip());
     $ret = $this->obj->create($data);
     if ($ret['id']) {
         include_once ROOT_PATH . 'lib/class/auth.class.php';
         $auth = new auth();
         $auth_info = array('name' => $ret['name'], 'fid' => 0);
         $auth_ret = $auth->create_org($auth_info);
         $org_id = $auth_ret['id'];
         if ($org_id) {
             $this->obj->update_org($org_id, $ret['id']);
         }
         $ret['org_id'] = $org_id;
     }
     $this->addItem($ret);
     $this->output();
 }
コード例 #2
0
ファイル: create.php プロジェクト: h3len/Project
 /**
  * 插入1000邀请码
  */
 public function create_code()
 {
     $num = 1000;
     $sql = "INSERT INTO";
     for ($num = 1000; $num > 0; $num--) {
         $arr[] = hg_generate_user_salt(8);
     }
     $sql = "INSERT INTO " . DB_PREFIX . "invite_code(code) VALUES";
     $con = "";
     $space = "";
     foreach ($arr as $key => $value) {
         $con .= $space . "('" . $value . "')";
         $space = ", ";
     }
     $sql = $sql . $con;
     $this->db->query($sql);
 }
コード例 #3
0
ファイル: functions.php プロジェクト: h3len/Project
/**
 * 编译一段字符串中的img标签的src
 * @param string $str 字符串
 * @return array $arr img的集合
 */
function hg_encode_img($str, $filepath)
{
    if (empty($str)) {
        return false;
    }
    $pregfind = array('#<img[^>]+src=(\'|")(.+)(\\1).*>#siU');
    $pregreplace = array('[img]\\2[/img]');
    $text = preg_replace($pregfind, $pregreplace, $str);
    preg_match_all('#\\[img\\](.+)\\[\\/img\\]#siU', $text, $out);
    $arr = array('content' => $text, 'oImg' => $out[1]);
    if (!empty($out[1])) {
        $imgs = $imgtype = $nName = array();
        foreach ($out[1] as $k => $v) {
            $imgType[$k] = "." . end(explode('.', end(explode('/', $v))));
            $nName[$k] = md5(hg_generate_user_salt(5)) . $imgType[$k];
            $imgs[$k] = $filepath . $nName[$k];
        }
        $arr['nImg'] = $imgs;
        $arr['imgType'] = $imgType;
        $arr['nName'] = $nName;
        $arr['content'] = str_replace($out[1], $imgs, $text);
    }
    return $arr;
}
コード例 #4
0
ファイル: article.class.php プロジェクト: h3len/Project
 public function upload()
 {
     if ($_FILES['Filedata']) {
         $material = $this->mater->addMaterial($_FILES, 0, 0, intval($this->input['water_config_id']));
         //图片信息返回后,更新内容标签
         if (!empty($material)) {
             $sql = "REPLACE INTO " . DB_PREFIX . "material SET ";
             $material['material_id'] = $material['id'];
             //unset($material['bundle_id'], $material['mid'], $material['id'], $material['url'],$material['code']);
             $sql_extra = $space = '';
             $data = array('material_id' => $material['id'], 'name' => $material['name'], 'host' => $material['host'], 'dir' => $material['dir'], 'filepath' => $material['filepath'], 'filename' => $material['filename'], 'type' => $material['type'], 'mark' => $material['mark'], 'imgwidth' => $material['imgwidth'], 'imgheight' => $material['imgheight'], 'filesize' => $material['filesize'], 'create_time' => $material['create_time'], 'ip' => $material['ip']);
             foreach ($data as $k => $v) {
                 $sql_extra .= $space . $k . "='" . $v . "'";
                 $space = ',';
             }
             $sql = $sql . $sql_extra;
             $this->db->query($sql);
             $material['filesize'] = hg_bytes_to_size($material['filesize']);
             $return = array('success' => true, 'id' => $material['material_id'], 'filename' => $material['filename'] . '?' . hg_generate_user_salt(4), 'name' => $material['name'], 'mark' => $material['mark'], 'type' => $material['type'], 'filesize' => $material['filesize'], 'path' => $material['host'] . $material['dir'], 'dir' => $material['filepath']);
         } else {
             $return = array('success' => false, 'error' => '文件上传失败');
         }
         return $return;
     }
 }
コード例 #5
0
ファイル: news.php プロジェクト: h3len/Project
 function detail_history()
 {
     if (empty($this->input['id'])) {
         $this->errorOutput('未传入版本ID');
     }
     $id = intval($this->input['id']);
     $sql = "SELECT * FROM " . DB_PREFIX . "article_history WHERE id=" . $id;
     $f = $this->db->query_first($sql);
     if (empty($f)) {
         return FALSE;
     }
     $info = unserialize($f['content']);
     $info['history_id'] = $f['id'];
     $info['create_time'] = date('Y-m-d H:i:s', $info['create_time']);
     $info['newcontent'] = $info['content'];
     //分页
     $info['allpages'] = $info['content'];
     if (!empty($info['indexpic'])) {
         //查找索引图
         $info['indexpic_url'] = $this->getThumbById($info['indexpic'], $this->settings['default_index']);
     } else {
         $info['indexpic_url'] = '';
     }
     $ret = $this->getMaterialByMaterialId($info['material_id']);
     if (!empty($ret)) {
         foreach ($ret as $k => $v) {
             //				if(in_array($v['material_id'],$out['id'])) //去除文章中包含的素材图片
             //				{
             //					unset($ret[$k]);
             //					continue;
             //				}
             switch ($v['mark']) {
                 case 'img':
                     //将缩略图信息加入info数组
                     $info['material'][$v['id']] = $v;
                     $info['material'][$v['id']]['filename'] = $v['filename'];
                     $info['material'][$v['id']]['path'] = $v['host'] . $v['dir'];
                     $info['material'][$v['id']]['dir'] = $v['filepath'];
                     $info['material'][$v['id']]['type'] = $v['type'];
                     $info['material'][$v['id']]['url'] = hg_material_link($v['host'], $v['dir'], $v['filepath'], $v['filename'], $this->settings['default_index']['label'] . '/');
                     $info['material'][$v['id']]['small_url'] = hg_material_link($v['host'], $v['dir'], $v['filepath'], $v['filename'], $this->settings['default_size']['label'] . '/');
                     $other_img .= '[img id="' . $v['id'] . '" width="' . $v['imgwidth'] . '" height="' . $v['imgheight'] . '"]' . $info['material'][$v['id']]['ori_url'] . '[/img]';
                     break;
                 case 'doc':
                     $info['material'][$v['id']] = $v;
                     $info['material'][$v['id']]['url'] = MATERIAL_TYPE_THUMB . "doc.png?" . hg_generate_user_salt(5);
                     //返回小图
                     $other_doc .= '[doc id="' . $v['id'] . '" width="' . $v['imgwidth'] . '" height="' . $v['imgheight'] . '"]' . $info['material'][$v['id']]['ori_url'] . '[/doc]';
                     break;
                 case 'real':
                     $info['material'][$v['id']] = $v;
                     $info['material'][$v['id']]['url'] = MATERIAL_TYPE_THUMB . "real.png?" . hg_generate_user_salt(5);
                     //返回小图
                     $other_real .= '[real id="' . $v['id'] . '" width="' . $v['imgwidth'] . '" height="' . $v['imgheight'] . '"]' . $info['material'][$v['id']]['ori_url'] . '[/real]';
                     break;
                 default:
                     break;
             }
         }
     }
     $info['pubstatus'] = $info['state'];
     $info['status'] = $info['state'] ? 2 : 0;
     $encode = array('user_name', 'content', 'newcontent', 'allpages');
     foreach ($encode as $v) {
         $info[$v] = rawurlencode($info[$v]);
     }
     $this->addItem($info);
     $this->output();
 }
コード例 #6
0
ファイル: update_video.php プロジェクト: h3len/Project
 /**
  *修改视频图片 
  */
 public function update_schematic()
 {
     $userinfo = $this->mUser->verify_credentials();
     if (!$userinfo['id']) {
         $this->errorOutput(USENAME_NOLOGIN);
     }
     $video_id = intval(trim($this->input['video_id']));
     $file_name = urldecode($this->input['schematic']);
     if (!$video_id) {
         $this->errorOutput(OBJECT_NULL);
     }
     $files = $_FILES['files'];
     include_once ROOT_DIR . 'lib/class/gdimage.php';
     //源文件
     $uploadedfile = $files['tmp_name'];
     $image = getimagesize($uploadedfile);
     $width = $image[0];
     $height = $image[1];
     $size = array("big" => array('t' => "b_", 'width' => VIDEO_IMG_WIDTH * VIDEO_IMG_MULTIPLE, 'height' => VIDEO_IMG_HEIGHT * VIDEO_IMG_MULTIPLE), "normal" => array('t' => "n_", 'width' => VIDEO_IMG_WIDTH, 'height' => VIDEO_IMG_HEIGHT));
     //文件名
     if (!$file_name) {
         $file_name = hg_generate_user_salt(16) . ".jpg";
     } else {
         str_replace(DOMAIN, "", $file_name, $cnt);
         if ($cnt) {
             $file_name = hg_generate_user_salt(16) . ".jpg";
         } else {
             $arr = explode("/", $file_name);
             $file_name = substr($arr[count($arr) - 1], 2);
             if (!trim($file_name)) {
                 $file_name = hg_generate_user_salt(16) . ".jpg";
             }
         }
     }
     //目录
     $file_dir = UPLOAD_DIR . VIDEO_DIR . ceil($video_id / NUM_IMG) . "/";
     //文件路径
     $file_path = $file_dir . $file_name;
     if (!hg_mkdir($file_dir)) {
         $this->errorOutput(UPLOAD_ERR_NO_FILE);
     }
     if (!copy($uploadedfile, $file_path)) {
         $this->errorOutput(UPLOAD_ERR_NO_FILE);
     }
     $img = new GDImage($file_path, $file_path, '');
     $info = array();
     foreach ($size as $key => $value) {
         $new_name = $value['t'] . $file_name;
         $save_file_path = $file_dir . $new_name;
         $img->init_setting($file_path, $save_file_path, '');
         $img->maxWidth = $value['width'];
         $img->maxHeight = $value['height'];
         $img->makeThumb(3, false);
         $info[$key] = UPLOAD_URL . VIDEO_DIR . ceil($video_id / NUM_IMG) . "/" . $new_name . "?" . hg_generate_user_salt(5);
     }
     $sql = "UPDATE " . DB_PREFIX . "video SET bschematic = '" . $file_name . "' , schematic = '" . $file_name . "' WHERE id = " . $video_id;
     $info['ori'] = $file_name;
     $info['id'] = $video_id;
     $this->db->query($sql);
     $this->setXmlNode('media', 'info');
     $this->addItem($info);
     return $this->output();
 }
コード例 #7
0
ファイル: upload.php プロジェクト: h3len/Project
 private function handle($uploadedfile)
 {
     include_once ROOT_DIR . 'lib/class/gdimage.php';
     //源文件
     if (filesize($uploadedfile) / 1024 / 1024 >= IMG_SIZE) {
         $this->errorOutput(IMG_SIZE_ERROR);
     }
     $image = getimagesize($uploadedfile);
     $width = $image[0];
     $height = $image[1];
     if (strpos(strtolower($image['mime']), 'jpeg')) {
         $type = '.jpg';
     } else {
         if (strpos(strtolower($image['mime']), 'png')) {
             $type = '.png';
         } else {
             if (strpos(strtolower($image['mime']), 'gif')) {
                 $type = '.gif';
             }
         }
     }
     //文件名
     $file_name = hg_generate_user_salt(16) . ".jpg";
     $size = array("larger" => array('t' => "l_", 'size' => IMG_SIZE_LARGER), "middle" => array('t' => "m_", 'size' => IMG_SIZE_MIDDLE), "small" => array('t' => "s_", 'size' => IMG_SIZE_SMALL));
     //目录
     $file_dir = UPLOAD_DIR . IMG_DIR . ceil($userinfo['id'] / NUM_IMG) . "/";
     //文件路径
     $file_path = $file_dir . $file_name;
     if (!hg_mkdir($file_dir)) {
         $this->errorOutput(UPLOAD_ERR_NO_FILE);
     }
     if (!copy($uploadedfile, $file_path)) {
         $this->errorOutput(UPLOAD_ERR_NO_FILE);
     }
     $img = new GDImage($file_path, $file_path, '');
     $info = array();
     foreach ($size as $key => $value) {
         $new_name = $value['t'] . $file_name;
         $save_file_path = $file_dir . $new_name;
         $img->init_setting($file_path, $save_file_path, '');
         if ($key == "larger") {
             $img->maxWidth = $width > $value['size'] ? $value['size'] : $width;
             $img->maxHeight = $height * ($img->maxWidth / $width);
             $img->makeThumb(1, false, true);
         } else {
             if ($width > $height) {
                 $img->maxWidth = $width > $value['size'] ? $value['size'] : $width;
                 $img->maxHeight = $height * ($img->maxWidth / $width);
             } else {
                 $img->maxHeight = $height > $value['size'] ? $value['size'] : $height;
                 $img->maxWidth = $width * ($img->maxHeight / $height);
             }
             $img->makeThumb(3);
         }
         $info[$key] = UPLOAD_URL . IMG_DIR . ceil($userinfo['id'] / NUM_IMG) . "/" . $new_name;
         if (defined('WATER_MARK_DONE') && WATER_MARK_DONE == true) {
             $img->create_watermark($save_file_path, $type, 4, WATER_MARK_IMG);
         }
     }
     $ip = hg_getip();
     $create_at = time();
     $sql = "INSERT " . DB_PREFIX . "media(status_id,dir,url,ip,create_at) VALUES(0,'" . IMG_DIR . ceil($userinfo['id'] / NUM_IMG) . "/" . "','" . $file_name . "','" . $ip . "'," . $create_at . ")";
     $this->db->query($sql);
     $id = $this->db->insert_id();
     $info['id'] = $id;
     $info['url'] = $file_name;
     $info['ip'] = $ip;
     $info['create_at'] = $create_at;
     $info['type'] = 0;
     return $info;
 }
コード例 #8
0
ファイル: share.class.php プロジェクト: h3len/Project
 function get_thumb_pic($filepath, $filename, $sizelabel = "100x100")
 {
     return UPLOAD_ABSOLUTE_URL . $sizelabel . '/' . $filepath . $filename . "?" . hg_generate_user_salt(5);
 }
コード例 #9
0
ファイル: member.class.php プロジェクト: h3len/Project
 /**
  * 头像编辑
  * Enter description here ...
  * @param unknown_type $member_id
  * @param unknown_type $files
  * @return boolean
  */
 public function avatarEdit($member_id, $files, $type = '')
 {
     if (!$member_id) {
         return false;
     }
     if ($type == 1) {
         $avatar = $files;
     } else {
         $avatar['Filedata'] = $files;
     }
     $type = $type ? $type : 2;
     //$material = $this->mMaterial->addMaterial($avatar, $member_id);
     $sql = "SELECT * FROM " . DB_PREFIX . "member WHERE id=" . $member_id;
     $f = $this->db->query_first($sql);
     //头像传两分
     $sql = "SELECT * FROM " . DB_PREFIX . "member_avatar WHERE member_id=" . $member_id . " ORDER BY orderid DESC";
     $sen = $this->db->query_first($sql);
     $data = array();
     if (!$f['dir']) {
         $data['dir'] = app_to_dir('avatars', 'img');
         $data['filepath'] = '0000/' . (intval($member_id / 10000) < 10 ? '0' . intval($member_id / 10000) : intval($member_id / 10000)) . '/';
         $data['name_prefix'] = hg_generate_user_salt(4) . $member_id . hg_generate_user_salt(2);
         $data['orderid'] = 1;
         $data['filename'] = $data['name_prefix'] . '0000.jpg';
     } else {
         $data['dir'] = $f['dir'];
         $data['filepath'] = $f['filepath'];
         $data['name_prefix'] = $sen['name_prefix'];
         $data['orderid'] = $sen['orderid'] + 1;
         //	$data['filename'] = $f['filename'];
         $data['filename'] = $sen['name_prefix'] . hg_order_num($data['orderid']) . '.jpg';
     }
     $material_nodb = $this->mMaterial->addMaterialNodb($avatar, $type, $data['dir'] . $data['filepath'], $data['filename']);
     //覆盖一份
     if (empty($material_nodb)) {
         return false;
     }
     $material = array();
     if (!empty($sen)) {
         $data['orderid'] = $sen['orderid'] + 1;
         $data['name_prefix'] = $sen['name_prefix'];
     }
     $material = array('member_id' => $member_id, 'member_name' => $f['member_name'], 'host' => $material_nodb['host'], 'dir' => $data['dir'], 'filepath' => $data['filepath'], 'filename' => $data['name_prefix'] . hg_order_num($data['orderid']) . '.jpg', 'name_prefix' => $data['name_prefix'], 'orderid' => $data['orderid'], 'create_time' => TIMENOW, 'update_time' => TIMENOW, 'ip' => hg_getip());
     $material_tmp_nodb = $this->mMaterial->addMaterialNodb($avatar, $type, $material['dir'] . $material['filepath'], $material['filename']);
     //保存一份
     if (empty($material_tmp_nodb)) {
         return false;
     } else {
         $sql_avatar = "INSERT INTO " . DB_PREFIX . "member_avatar SET ";
         $space = "";
         foreach ($material as $key => $value) {
             $sql_avatar .= $space . $key . "='" . $value . "'";
             $space = ',';
         }
         $this->db->query($sql_avatar);
     }
     if (!empty($material) && $material['host']) {
         /*
         			$albums_info = array(
         				'id' => $material['id'],
         				'host' => $material['host'] . $material['dir'],
         				'filepath' => $material['filepath'] . $material['filename'],
         			);
         			include_once(ROOT_PATH . 'lib/class/albums.class.php');
         			$this->albums = new albums();
         			$ret = $this->albums->add_sys_albums(3, serialize($albums_info));
         */
         $sql = "UPDATE " . DB_PREFIX . "member SET avatar=1, host='" . $material['host'] . "', dir='" . $data['dir'] . "',filepath='" . $data['filepath'] . "', filename='" . $data['filename'] . "' WHERE id = " . $member_id;
         $this->db->query($sql);
     }
     $avatar = array('host' => $material['host'], 'dir' => $data['dir'], 'filepath' => $data['filepath'], 'filename' => $data['filename']);
     return $avatar;
     //return false;
 }
コード例 #10
0
ファイル: station.php プロジェクト: h3len/Project
 function logo()
 {
     $mInfo = $this->mUser->verify_credentials();
     if (!$mInfo) {
         $this->errorOutput(USENAME_NOLOGIN);
     }
     $logo = urldecode($this->input['logo']) ? urldecode($this->input['logo']) : '';
     $files = $_FILES['files'];
     $uploadedfile = $files['tmp_name'];
     $image = getimagesize($uploadedfile);
     $width = $image[0];
     $height = $image[1];
     if ($width < LOGO_SIZE_SMALL && $height < LOGO_SIZE_SMALL) {
         $this->setXmlNode('station', 'info');
         $this->addItem("");
         $this->output();
     }
     if ($logo) {
         $size = array("logo_o" => array('t' => "", 'size' => LOGO_SIZE_SMALL), "small" => array('t' => "s_", 'size' => LOGO_SIZE_SMALL));
         $infos = array();
         foreach ($size as $key => $value) {
             $new_name = $value['t'] . $logo;
             $infos[$key] = UPLOAD_DIR . LOGO_DIR . ceil($mInfo['id'] / NUM_IMG) . "/" . $new_name;
             if (is_file($infos[$key])) {
                 unlink($infos[$key]);
             }
         }
     }
     $sql = 'SELECT * FROM ' . DB_PREFIX . 'network_station WHERE user_id = ' . $mInfo['id'];
     $q = $this->db->query_first($sql);
     if ($q) {
         $sta_id = $q['id'];
     } else {
         $sta_id = 0;
     }
     include_once ROOT_DIR . 'lib/class/gdimage.php';
     //源文件
     //文件名
     $file_name = hg_generate_user_salt(5) . ".jpg";
     $size = array("small" => array('t' => "s_", 'size' => LOGO_SIZE_SMALL));
     //目录
     $file_dir = UPLOAD_DIR . LOGO_DIR . ceil($mInfo['id'] / NUM_IMG) . "/";
     //文件路径
     $file_path = $file_dir . $file_name;
     if (!hg_mkdir($file_dir)) {
         $this->errorOutput(UPLOAD_ERR_NO_FILE);
     }
     if (!copy($uploadedfile, $file_path)) {
         $this->errorOutput(UPLOAD_ERR_NO_FILE);
     }
     $img = new GDImage($file_path, $file_path, '');
     $info = array();
     foreach ($size as $key => $value) {
         $new_name = $value['t'] . $file_name;
         $save_file_path = $file_dir . $new_name;
         $img->init_setting($file_path, $save_file_path, '');
         $img->maxWidth = $value['size'];
         $img->maxHeight = $value['size'];
         $img->makeThumb(3, false);
         $info[$key] = UPLOAD_URL . LOGO_DIR . ceil($mInfo['id'] / NUM_IMG) . "/" . $new_name . "?" . hg_rand_num(7);
     }
     if ($sta_id) {
         $sql = "UPDATE " . DB_PREFIX . "network_station SET \r\n\t\t\tlogo='" . $file_name . "' \r\n\t\t\tWHERE id = " . $sta_id . " AND user_id = " . $mInfo['id'];
         $this->db->query($sql);
         $info['id'] = 0;
     } else {
         $sql = "INSERT INTO " . DB_PREFIX . "network_station(user_id,logo,create_time) VALUES(" . $mInfo['id'] . ",'" . $file_name . "'," . time() . ")";
         $this->db->query($sql);
         $info['id'] = $this->db->insert_id();
         include_once ROOT_PATH . 'lib/user/user.class.php';
         $this->mUser = new user();
         $this->mUser->update_type($mInfo['id']);
     }
     $info['logo'] = $file_name;
     $this->setXmlNode('station', 'info');
     $this->addItem($info);
     $this->output();
 }
コード例 #11
0
ファイル: water.class.php プロジェクト: h3len/Project
 public function water_upload()
 {
     $typetmp = explode('.', $_FILES['Filedata']['name']);
     $filetype = strtolower($typetmp[count($typetmp) - 1]);
     //验证文印图片格式
     include_once CUR_CONF_PATH . 'lib/cache.class.php';
     $this->cache = new cache();
     $material_type = $this->cache->check_cache('material_type.cache.php');
     $type = '';
     if (!empty($material_type)) {
         foreach ($material_type as $k => $v) {
             if (in_array($filetype, array_keys($v))) {
                 $type = $k;
             }
         }
     }
     if ($type != 'img') {
         return false;
     }
     $filename = date('YmdHis') . hg_generate_user_salt(4) . '.' . $filetype;
     //上传到临时目录
     $path = hg_getimg_default_dir() . MATERIAL_TMP_PATH;
     if (!hg_mkdir($path)) {
         return false;
     } else {
         if (!move_uploaded_file($_FILES["Filedata"]["tmp_name"], $path . $filename)) {
             return false;
         } else {
             $info['filename'] = $filename;
             $info['path'] = MATERIAL_TMP_PATH;
             $info['url'] = hg_material_link(hg_getimg_default_host(), MATERIAL_TMP_PATH, '', $filename);
             return $info;
         }
     }
 }
コード例 #12
0
ファイル: material_update.php プロジェクト: h3len/Project
 /**
  * 将附件打包提供下载
  * 
  * @param material_path string 图片上传返回的路径信息(取出host)
  * @return string 包得地址 
  */
 function zip_material()
 {
     $material_path = $this->input['material_path'];
     if (empty($material_path)) {
         $this->errorOutput(NO_MATERIAL);
     }
     if (!is_array($material_path)) {
         $material_path = explode(',', $material_path);
     }
     foreach ((array) $material_path as $k => $v) {
         //$v = preg_replace('/(.*?)(\?.*)?/i', '\\1', $v);
         $pos = strpos($v, '?');
         if ($pos !== false) {
             $v = substr($v, 0, $pos);
         }
         if ($domain == $v) {
             $domain = '';
         }
         $material_path[$k] = hg_getimg_dir($domain, "host") . str_replace($domain, '', $v);
     }
     $material_path = implode(' ', $material_path);
     $path = 'ziptmp/' . date('Ym', TIMENOW) . '/';
     $zip_path = hg_getimg_dir() . $path;
     if (!hg_mkdir($zip_path) || !is_writeable($zip_path)) {
         $this->errorOutput('压缩文件存放临时目录不可写');
     }
     $zip_name = TIMENOW . hg_generate_user_salt() . '.zip';
     $zipcmd = ' zip -j ' . $zip_path . $zip_name . ' ' . $material_path;
     exec($zipcmd);
     $url = hg_getimg_host() . $path . $zip_name;
     $this->addItem($url);
     $this->output();
 }
コード例 #13
0
 public function upload()
 {
     $material = $this->material->addMaterial($_FILES);
     if ($material) {
         $material['pic'] = array('host' => $material['host'], 'dir' => $material['dir'], 'filepath' => $material['filepath'], 'filename' => $material['filename']);
         $material['pic'] = serialize($material['pic']);
         $spe_mater = array('material_id' => $material['id'], 'material' => $material['pic'], 'name' => $material['name'], 'mark' => $material['mark'], 'type' => $material['type'], 'filesize' => $material['filesize'], 'ip' => $this->user['ip'], 'create_time' => TIMENOW);
         $this->obj->insert_data($spe_mater, "special_material");
         $material['filesize'] = hg_bytes_to_size($material['filesize']);
         $return = array('success' => true, 'id' => $material['id'], 'filename' => $material['filename'] . '?' . hg_generate_user_salt(4), 'name' => $material['name'], 'mark' => $material['mark'], 'type' => $material['type'], 'filesize' => $material['filesize'], 'path' => $material['host'] . $material['dir'], 'dir' => $material['filepath'], 'pic' => $material['pic']);
     } else {
         $return = array('error' => '文件上传失败');
     }
     $this->addItem($return);
     $this->output();
 }
コード例 #14
0
ファイル: material.class.php プロジェクト: h3len/Project
 public function addMaterial()
 {
     if ($_FILES['Filedata']) {
         if ($_FILES['Filedata']['error']) {
             return false;
         } else {
             /*验证格式*/
             include_once CUR_CONF_PATH . 'lib/cache.class.php';
             $this->cache = new cache();
             $gMaterialTpye = $this->cache->check_cache('material_type.cache.php');
             $info = array();
             $typetmp = explode('.', $_FILES['Filedata']['name']);
             $filetype = strtolower($typetmp[count($typetmp) - 1]);
             $info['type'] = $filetype;
             $type = '';
             foreach ($gMaterialTpye as $k => $v) {
                 if (in_array($filetype, array_keys($v))) {
                     $type = $k;
                     break;
                 }
             }
             if (empty($type)) {
                 return false;
             }
             /*验证大小*/
             $max_size = UPLOAD_FILE_LIMIT * 1024 * 1024;
             if ($_FILES['Filedata']['size'] > $max_size) {
                 return false;
             }
             $info['cid'] = intval($this->input['cid']);
             $info['catid'] = intval($this->input['catid']);
             $info['bundle_id'] = urldecode($this->input['app_bundle']);
             $info['mid'] = urldecode($this->input['module_bundle']);
             $info['user_id'] = intval($this->input['user_id']);
             $info['user_name'] = urldecode($this->input['user_name']);
             $info['client_id'] = intval($this->input['client_id']);
             $info['client_name'] = urldecode($this->input['client_name']);
             //存放的路径
             $info['filepath'] = date('Y') . '/' . date('m') . '/';
             $info['name'] = urldecode($_FILES['Filedata']['name']);
             $tmp_filename = date('YmdHis') . hg_generate_user_salt(4);
             $info['filename'] = $tmp_filename . '.' . $info['type'];
             $path = hg_getimg_dir() . app_to_dir($info['bundle_id'], $type) . $info['filepath'];
             $info['mark'] = $type;
             //如果附件为img图片类型的则 获取水印设置
             if ($info['mark'] == 'img') {
                 $water_id = intval($this->input['water_id']);
                 if (!intval($water_id)) {
                     $water_id = $this->get_water_id(urldecode($this->input['app_bundle']), urldecode($this->input['module_bundle']), urldecode($this->input['catid']));
                 }
                 if ($water_id == -1) {
                     $water_id = 0;
                 }
                 $info['water_id'] = $water_id;
             }
             if (!hg_mkdir($path)) {
                 return false;
             } else {
                 if (!move_uploaded_file($_FILES["Filedata"]["tmp_name"], $path . $info['filename'])) {
                     return false;
                 } else {
                     $imginfo = getimagesize($path . $info['filename']);
                     if ($this->input['trans_format'] && $this->input['trans_format'] != $info['type']) {
                         $tmp_img = '';
                         switch ($imginfo[2]) {
                             case 1:
                                 //gif
                                 $tmp_img = imagecreatefromgif($path . $info['filename']);
                                 break;
                             case 2:
                                 //jpg
                                 $tmp_img = imagecreatefromjpeg($path . $info['filename']);
                                 break;
                             case 3:
                                 //png
                                 $tmp_img = imagecreatefrompng($path . $info['filename']);
                                 break;
                             default:
                                 break;
                         }
                         if ($tmp_img) {
                             switch ($this->input['trans_format']) {
                                 case 'png':
                                     $info['type'] = 'png';
                                     imagepng($tmp_img, $path . $tmp_filename . '.' . $info['type']);
                                     break;
                                 case 'jpg':
                                     $info['type'] = 'jpg';
                                     imagejpeg($tmp_img, $path . $tmp_filename . '.' . $info['type']);
                                     break;
                                 case 'gif':
                                     $info['type'] = 'gif';
                                     imagegif($tmp_img, $path . $tmp_filename . '.' . $info['type']);
                                     break;
                                 default:
                                     $info['type'] = 'png';
                                     imagepng($tmp_img, $path . $tmp_filename . '.' . $info['type']);
                                     break;
                             }
                             @unlink($path . $info['filename']);
                             $info['filename'] = $tmp_filename . '.' . $info['type'];
                             imagedestroy($tmp_img);
                         }
                     }
                     $info['imgwidth'] = $imginfo[0];
                     $info['imgheight'] = $imginfo[1];
                     $info['filesize'] = $_FILES["Filedata"]["size"];
                     $info['create_time'] = TIMENOW;
                     $info['ip'] = hg_getip();
                     $info['nums'] = 1;
                     $info['bs'] = hg_getimg_bs();
                     $info['id'] = $this->insert_data($info);
                     //如果有水印则创建json文件记录水印信息,并记录水印关系表
                     if (!empty($info['water_id'])) {
                         $this->createFile($info['water_id'], $info['bundle_id'], $info['filepath'], $info['filename'], hg_getimg_bs());
                     }
                     $imgurl = hg_getimg_host();
                     $info['url'] = hg_material_link($imgurl, app_to_dir($info['bundle_id'], $type), $info['filepath'], $info['filename']);
                     //unset 防止返回错误
                     $info['host'] = $imgurl;
                     $info['dir'] = app_to_dir($info['bundle_id'], $info['mark']);
                     $info['code'] = str_replace(array('{filename}', '{name}'), array($info['url'], $info['name']), $gMaterialTpye[$info['mark']][$info['type']]['code']);
                     unset($info["bs"], $info['user_id'], $info['user_name'], $info['client_id'], $info['client_name'], $info['water_id'], $info['catid'], $info['nums']);
                     return $info;
                 }
             }
         }
     }
 }
コード例 #15
0
ファイル: article_mode.php プロジェクト: h3len/Project
 public function detail($id = '')
 {
     if (!$id) {
         return false;
     }
     $sql = "SELECT a.*,c.content FROM " . DB_PREFIX . "article a \n\t\t\t\tLEFT JOIN " . DB_PREFIX . "article_content c \n\t\t\t\t\tON a.id = c.articleid \n\t\t\t\tWHERE a.id = " . $id;
     $info = $this->db->query_first($sql);
     $ret = $this->getMaterialById($id);
     if (!empty($ret)) {
         foreach ($ret as $k => $v) {
             $v['filesize'] = hg_bytes_to_size($v['filesize']);
             switch ($v['mark']) {
                 case 'img':
                     //将缩略图信息加入info数组
                     $info['material'][$v['id']] = $v;
                     $info['material'][$v['id']]['path'] = $v['host'] . $v['dir'];
                     $info['material'][$v['id']]['dir'] = $v['filepath'];
                     $info['material'][$v['id']]['filename'] = $v['filename'] . '?' . hg_generate_user_salt(4);
                     break;
                 case 'doc':
                     $info['material'][$v['id']] = $v;
                     $info['material'][$v['id']]['path'] = $v['host'] . $v['dir'];
                     $info['material'][$v['id']]['dir'] = $v['filepath'];
                     $info['material'][$v['id']]['filename'] = $v['filename'] . '?' . hg_generate_user_salt(4);
                     break;
                 case 'real':
                     $info['material'][$v['id']] = $v;
                     break;
                 default:
                     break;
             }
         }
     }
     /*$period_id = $info['period_id'];
     		$stack_id = $info['stack_id'];
     		$page_id = $info['page_id'];
     		
     		
     		if($period_id && $page_id && $stack_id)
     		{
     			$info['stack'] = $this->settings['stack_set'][$stack_id];
     			$sql = "SELECT id FROM ".DB_PREFIX."page WHERE period_id = ".$period_id;
     			$q = $this->db->query($sql);
     			$page_num = 1;
     			while ($r = $this->db->fetch_array($q))
     			{
     				if($r['id'] == $page_id)
     				{
     					$info['page_num'] = $this->settings['stack_set'][$stack_id].$page_num;
     					break;
     				}
     				$page_num = $page_num + 1;
     			}
     		}*/
     return $info;
 }
コード例 #16
0
ファイル: news.class.php プロジェクト: h3len/Project
 public function process_draft($draft)
 {
     if (!empty($draft['content']['indexpic'])) {
         //查找索引图
         $draft['content']['indexpic_url'] = $this->getIndexpic($draft['content']['indexpic']);
     } else {
         $draft['content']['indexpic_url'] = '';
     }
     if (!empty($draft['content']['material_id'])) {
         $material_id = implode(',', $draft['content']['material_id']);
         $ret = $this->getMaterialByMid($material_id);
         if (!empty($ret)) {
             foreach ($ret as $k => $v) {
                 $v['filesize'] = hg_bytes_to_size($v['filesize']);
                 switch ($v['mark']) {
                     case 'img':
                         //将缩略图信息加入info数组
                         $draft['content']['material'][$v['id']] = $v;
                         $draft['content']['material'][$v['id']]['path'] = $v['host'] . $v['dir'];
                         $draft['content']['material'][$v['id']]['dir'] = $v['filepath'];
                         $draft['content']['material'][$v['id']]['filename'] = $v['filename'] . '?' . hg_generate_user_salt(4);
                         break;
                     case 'doc':
                         $draft['content']['material'][$v['id']] = $v;
                         $draft['content']['material'][$v['id']]['path'] = $v['host'] . $v['dir'];
                         $draft['content']['material'][$v['id']]['dir'] = $v['filepath'];
                         $draft['content']['material'][$v['id']]['filename'] = $v['filename'] . '?' . hg_generate_user_salt(4);
                         break;
                     case 'real':
                         $draft['content']['material'][$v['id']] = $v;
                         break;
                     default:
                         break;
                 }
                 //$url = $v['host'] . $v['dir'] . $v['filepath'] . $v['filename'];
                 //$draft['content']['material'][$v['id']]['code'] = str_replace(array('{filename}','{name}'), array($url, $v['name']), $support_type[$v['mark']][$v['type']]['code']);
             }
         }
     }
     return $draft;
 }
コード例 #17
0
ファイル: tables_update.php プロジェクト: h3len/Project
 public function update()
 {
     $id = intval($this->input['id']) ? intval($this->input['id']) : 0;
     if (empty($id)) {
         $this->errorOutput('NO ID');
     }
     if (empty($this->input['name'])) {
         $this->errorOutput('NO NAME');
     }
     if (empty($this->input['table_name'])) {
         $this->errorOutput('NO TABLE_NAME');
     }
     $is_column = intval($this->input['is_column']) ? 1 : 0;
     $tmp_bool = $this->obj->checkTableName($this->input['table_name'], $id);
     if ($tmp_bool) {
         $this->errorOutput(TABLES_IS_EXISTS);
     }
     $field_info = array('field_name' => $this->input['field_name'], 'field_type' => $this->input['field_type'], 'field_length' => $this->input['field_length'], 'field_auto' => $this->input['field_auto'], 'field_index' => $this->input['field_index'], 'field_mark' => $this->input['field_mark'], 'field_key' => $this->input['field_key']);
     if ($is_column) {
         foreach ($field_info['field_name'] as $k => $v) {
             if (in_array($v, array('column_id', 'column_name'))) {
                 $this->errorOutput(CAN_NOT_FORAMT_COLUMN);
             }
         }
         $single = $this->obj->detail($id);
         $single_key = array();
         if (isset($single['table_format'])) {
             foreach ($single['table_format'] as $k => $v) {
                 if (in_array($v['field_name'], array('column_id', 'column_name'))) {
                     $single_key[$v['field_name']] = $k;
                 }
             }
         }
         $key = count($field_info['field_name']);
         $field_info['field_name'][$key] = 'column_id';
         $field_info['field_type'][$key] = 'varchar';
         $field_info['field_length'][$key] = 200;
         $field_info['field_index'][$key] = 'default';
         $field_info['field_mark'][$key] = '栏目ID';
         $field_info['field_key'][$key] = $single_key['column_id'] ? $single_key['column_id'] : hg_generate_user_salt(5);
         $field_info['field_name'][$key + 1] = 'column_name';
         $field_info['field_type'][$key + 1] = 'varchar';
         $field_info['field_length'][$key + 1] = 500;
         $field_info['field_index'][$key + 1] = 'default';
         $field_info['field_mark'][$key + 1] = '栏目名称';
         $field_info['field_key'][$key + 1] = $single_key['column_name'] ? $single_key['column_name'] : hg_generate_user_salt(5);
     }
     $data = array('name' => trim($this->input['name']) ? trim($this->input['name']) : '', 'table_name' => trim($this->input['table_name']) ? trim($this->input['table_name']) : '', 'sort_id' => intval($this->input['sort_id']) ? intval($this->input['sort_id']) : '', 'table_format' => $field_info, 'is_column' => $is_column, 'update_time' => TIMENOW);
     $ret = $this->obj->update($data, $id);
     if ($ret['error']) {
         $this->errorOutput($ret['error']);
     }
     $this->addItem($ret);
     $this->output();
 }
コード例 #18
0
ファイル: news_update.php プロジェクト: h3len/Project
 public function upload()
 {
     $material = $this->mater->addMaterial($_FILES, 0, 0, intval($this->input['water_config_id']));
     if (!empty($material) && is_array($material)) {
         $material['pic'] = array('host' => $material['host'], 'dir' => $material['dir'], 'filepath' => $material['filepath'], 'filename' => $material['filename']);
         $code = $material['code'];
         $data = array('material_id' => $material['id'], 'name' => $material['name'], 'pic' => serialize($material['pic']), 'host' => $material['host'], 'dir' => $material['dir'], 'filepath' => $material['filepath'], 'filename' => $material['filename'], 'type' => $material['type'], 'mark' => $material['mark'], 'imgwidth' => $material['imgwidth'], 'imgheight' => $material['imgheight'], 'filesize' => $material['filesize'], 'create_time' => $material['create_time'], 'ip' => $material['ip'], 'remote_url' => $material['remote_url']);
         $this->obj->insert_data($data, "material");
         $material['filesize'] = hg_bytes_to_size($material['filesize']);
         $return = array('success' => true, 'id' => $material['id'], 'filename' => $material['filename'] . '?' . hg_generate_user_salt(4), 'name' => $material['name'], 'mark' => $material['mark'], 'type' => $material['type'], 'filesize' => $material['filesize'], 'path' => $material['host'] . $material['dir'], 'dir' => $material['filepath'], 'code' => $code, '_host' => $material['host'], '_dir' => $material['dir'], '_filepath' => $material['filepath'], '_filename' => $material['filename'], 'imgwidth' => $material['imgwidth'], 'imgheight' => $material['imgheight']);
     } else {
         $return = array('error' => '文件上传失败');
     }
     $this->addLogs('上传图片', '', '', $return['name']);
     $this->addItem($return);
     $this->output();
 }
コード例 #19
0
ファイル: magic_update.php プロジェクト: h3len/Project
 /**
  * 上传图标
  */
 public function uploadIcon()
 {
     if ($_FILES['Filedata']) {
         if (!$_FILES['Filedata']['error']) {
             $info = array();
             $typetmp = explode('.', $_FILES['Filedata']['name']);
             $filetype = strtolower($typetmp[count($typetmp) - 1]);
             $info['type'] = $filetype;
             if (!in_array($info['type'], array('jpg', 'gif', 'png', 'jpeg', 'bmp'))) {
                 $this->errorOutput('文件格式不正确');
             }
             $info['user_id'] = intval($this->user['user_id']);
             $info['user_name'] = urldecode($this->user['user_name']);
             $info['filepath'] = date('Ym') . '/';
             $info['name'] = urldecode($_FILES['Filedata']['name']);
             $tmp_filename = date('YmdHis') . hg_generate_user_salt(4);
             $info['filename'] = $tmp_filename . '.' . $info['type'];
             $path = CUR_CONF_PATH . 'data/icon/' . $info['filepath'];
             if (!hg_mkdir($path)) {
                 $this->errorOutput('目录创建失败');
             }
             if (!move_uploaded_file($_FILES["Filedata"]["tmp_name"], $path . $info['filename'])) {
                 $this->errorOutput('移动文件失败');
             } else {
                 $imginfo = getimagesize($path . $info['filename']);
                 $info['imgwidth'] = $imginfo[0];
                 $info['imgheight'] = $imginfo[1];
                 $info['filesize'] = $_FILES["Filedata"]["size"];
                 $info['create_time'] = TIMENOW;
                 $info['ip'] = hg_getip();
                 $this->db->insert_data($info, 'icons');
                 $info['real_url'] = ICON_URL . $info['filepath'] . $info['filename'];
                 $info['url'] = '<MATEURL>' . $info['filepath'] . $info['filename'];
                 $info['id'] = $this->db->insert_id();
                 $this->addItem($info);
                 $this->output();
             }
         } else {
             $this->errorOutput('上传失败');
         }
     }
 }
コード例 #20
0
ファイル: layout.php プロジェクト: h3len/Project
 /**
  *  copy一份布局并返回布局的信息
  */
 public function get_layout_preview()
 {
     if (!$this->input['layout_id']) {
         $this->errorOutput('LAYOUT OR TEMPLATE ID IS EMPTY');
     }
     $layout_id = intval($this->input['layout_id']);
     $template_id = intval($this->input['template_id']);
     //copy一份此布局里的单元
     $sql = "SELECT * FROM " . DB_PREFIX . "layout_cell WHERE layout_id = " . $layout_id;
     $q = $this->db->query($sql);
     $new_cell_ids = array();
     while ($row = $this->db->fetch_array($q)) {
         $new_cell_name = date('YmdHis') . hg_generate_user_salt(6);
         $find[] = $row['cell_name'];
         $replace[] = $new_cell_name;
         $row['cell_name'] = $new_cell_name;
         $row['cell_code'] = str_replace($row['cell_name'], $new_cell_name, $row['cell_code']);
         $row['original_id'] = $row['id'];
         $row['param_asso'] = addslashes($row['param_asso']);
         unset($row['id'], $row['layout_id']);
         //unset掉layout_id防止更新操作不成功对原始布局产生有影响
         $new_cell_ids[] = $row['id'] = $this->db->insert_data($row, 'layout_cell');
         $row['param_asso'] = unserialize(stripslashes($row['param_asso']));
         $layout_cell[] = $row;
     }
     //布局详细信息
     $condition = ' AND id = ' . $layout_id;
     $layout_info = $this->layout->detail($condition);
     $layout_info['content'] = html_entity_decode($layout_info['content']);
     $layout_info['css'] = html_entity_decode($layout_info['css']);
     //重新生成一份布局
     $layout_info['content'] = str_replace($find, $replace, $layout_info['content']);
     $layout_info['original_id'] = $layout_info['id'];
     unset($layout_info['id']);
     $layout_info['id'] = $this->db->insert_data($layout_info, 'layout');
     if ($new_cell_ids) {
         $this->db->update_data('layout_id=' . $layout_info['id'], 'layout_cell', ' id IN(' . implode(',', $new_cell_ids) . ')');
     }
     $layout_info['content'] = str_replace($find, $replace, $layout_info['content']);
     //布局命名空间和头部处理
     $layout_info = $this->layout->layout_namespace_and_header_process($layout_info);
     $ret = array();
     //处理布局中单元的信息、生成html
     $return_cell = isset($this->input['return_cell']) ? $this->input['return_cell'] : true;
     if ($return_cell) {
         if (!class_exists('Magic')) {
             include CUR_CONF_PATH . 'lib/magic.class.php';
         }
         $objMagic = new Magic();
         foreach ($layout_cell as $k => $v) {
             $layout_cell[$k] = $objMagic->cellProcess($v);
         }
         $ret['cells'] = $layout_cell;
         $ret = array_merge($ret, $layout_info);
     }
     $this->addItem($ret);
     $this->output();
 }
コード例 #21
0
ファイル: news.php プロジェクト: h3len/Project
 public function details()
 {
     $ids = trim($this->input['ids']);
     foreach ($ids as $id) {
         if ($id) {
             $data_limit = ' AND a.id=' . $id;
         } else {
             $this->output(NOID);
         }
         $info = $this->obj->get_content($data_limit);
         if ($info) {
             $info['create_time_show'] = date("Y-m-d H:i", $info['create_time']);
             $info['update_time_show'] = date("Y-m-d H:i", $info['update_time']);
             $info['pub_time'] = $info['pub_time'] ? date("Y-m-d H:i", $info['pub_time']) : '';
             $info['column_id'] = unserialize($info['column_id']);
             $info['other_settings'] = $info['other_settings'] ? unserialize($info['other_settings']) : '';
             if (is_array($info['column_id'])) {
                 $column_id = array();
                 foreach ($info['column_id'] as $k => $v) {
                     $column_id[] = $k;
                 }
                 $column_id = implode(',', $column_id);
                 $info['column_id'] = $column_id;
             }
             if ($info['outlink'] == '请填写超链接!') {
                 $info['outlink'] = '';
             }
             $info['newcontent'] = $info['content'];
             $info['allpages'] = $info['content'];
             if ($info['indexpic']) {
                 $info['indexpic_url'] = unserialize($info['pic']);
             }
             $ret = $this->obj->getMaterialById($info['id']);
             if (!empty($ret)) {
                 foreach ($ret as $k => $v) {
                     $v['filesize'] = hg_bytes_to_size($v['filesize']);
                     switch ($v['mark']) {
                         case 'img':
                             //将缩略图信息加入info数组
                             $info['material'][$v['id']] = $v;
                             $info['material'][$v['id']]['path'] = $v['host'] . $v['dir'];
                             $info['material'][$v['id']]['dir'] = $v['filepath'];
                             $info['material'][$v['id']]['filename'] = $v['filename'] . '?' . hg_generate_user_salt(4);
                             break;
                         case 'doc':
                             $info['material'][$v['id']] = $v;
                             $info['material'][$v['id']]['path'] = $v['host'] . $v['dir'];
                             $info['material'][$v['id']]['dir'] = $v['filepath'];
                             $info['material'][$v['id']]['filename'] = $v['filename'] . '?' . hg_generate_user_salt(4);
                             break;
                         case 'real':
                             $info['material'][$v['id']] = $v;
                             break;
                         default:
                             break;
                     }
                 }
             }
             $info['newcontent'] = $info['newcontent'];
             $info['pubstatus'] = $info['state'];
             $info['status'] = $info['state'] ? 2 : 0;
             if ($this->input['need_process']) {
                 $info['content'] = htmlspecialchars_decode($info['content']);
                 $info['content'] = strip_tags($info['content'], '<p><br><a><img><div>');
                 $info['content'] = preg_replace('#<p[^>]*>#i', '<p>', $info['content']);
             }
             $support_type = $this->mater->get_allow_type();
             $info['attach_support'] = implode(',', array_keys($support_type['doc']));
             $info['img_support'] = implode(',', array_keys($support_type['img']));
         }
         $newsinfo[] = $info;
         file_put_contents('2.txt', var_export($newsinfo, 1));
     }
     $this->addItem($newsinfo);
     $this->output();
 }
コード例 #22
0
ファイル: auth_emailcode.php プロジェクト: h3len/Project
 private function mkAuthCode()
 {
     $this->code = hg_generate_user_salt(6);
 }
コード例 #23
0
ファイル: message.class.php プロジェクト: h3len/Project
 public function upload_audio(&$file)
 {
     $audit = array();
     if ($file['audiofile']) {
         if (!$file['audiofile']['error']) {
             //                //验证是否是音频
             //                if(strpos($file['audiofile']['type'], 'audio') === FALSE)
             //                {
             //                    return array('error' => 'Not audit file');
             //                }
             //验证文件格式
             if (isset($this->settings['allow_audio_type'])) {
                 $allow_type = $this->settings['allow_audio_type'];
             } else {
                 $allow_type = array('mp3', 'aac');
             }
             $ext = explode('.', $file['audiofile']['name']);
             $ext = $ext[1];
             if (!in_array($ext, $allow_type)) {
                 return array('error' => 'Not allow type');
             }
             //验证文件大小
             if (!defined(UPLOAD_FILE_LIMIT)) {
                 define('UPLOAD_FILE_LIMIT', 5);
             }
             $max_size = UPLOAD_FILE_LIMIT * 1024 * 1024;
             if ($file['audiofile']['size'] > $max_size) {
                 return array('error' => 'max size ' . UPLOAD_FILE_LIMIT . 'M');
             }
             $file_name_ext = $ext;
             $ext == 'aac' && ($file_name_ext = 'mp4');
             $info = array('host' => AUDIO_DOMAIN, 'filepath' => date('Y') . '/' . date('m') . '/' . date('d') . '/', 'filename' => date('YmdHis') . hg_generate_user_salt(4) . '.' . $file_name_ext, 'name' => urldecode($file['audiofile']['name']), 'type' => $ext);
             $des_path = DATA_DIR . $info['filepath'];
             if (!hg_mkdir($des_path)) {
                 return array('error' => 'Directory cannot write');
             }
             if (!move_uploaded_file($file["audiofile"]["tmp_name"], $des_path . $info['filename'])) {
                 return array('error' => 'Directory cannot write');
             }
             $info['user_id'] = $this->user['user_id'];
             $info['user_name'] = $this->user['user_name'];
             $info['filesize'] = $file["audiofile"]["size"];
             $info['create_time'] = TIMENOW;
             $info['ip'] = hg_getip();
             $info['id'] = $this->db->insert_data($info, 'audios');
             $audit[] = array('id' => $info['id'], 'host' => $info['host'], 'filepath' => $info['filepath'], 'filename' => $info['filename'], 'type' => $info['type'], 'audio_duration' => $this->input['audio_duration']);
         } else {
             if ($file['audiofile']['error'] == 1) {
                 return array('error' => 'max upload size in ini');
             } else {
                 return array('error' => 'upload false');
             }
         }
         unset($file['auditfile']);
     }
     return $audit;
 }
コード例 #24
0
ファイル: goods_update.php プロジェクト: h3len/Project
 public function upload()
 {
     $this->verify_content_prms(array('_action' => 'create'));
     include_once ROOT_PATH . 'lib/class/material.class.php';
     $this->mater = new material();
     $material = $this->mater->addMaterial($_FILES);
     if (!empty($material) && is_array($material)) {
         $material['pic'] = array('host' => $material['host'], 'dir' => $material['dir'], 'filepath' => $material['filepath'], 'filename' => $material['filename']);
         $data = array('material_id' => $material['id'], 'pic' => addslashes(json_encode($material['pic'])));
         $insert_id = $this->material_mode->insert($data);
         $return = array('id' => $insert_id, 'filename' => $material['filename'] . '?' . hg_generate_user_salt(4), 'name' => $material['name'], 'mark' => $material['mark'], 'type' => $material['type'], 'filesize' => $material['filesize'], 'path' => $material['host'] . $material['dir'], 'dir' => $material['filepath']);
     } else {
         $return = array('error' => '文件上传失败');
     }
     $this->addLogs('上传图片', '', '', $return['name']);
     $this->addItem($return);
     $this->output();
 }
コード例 #25
0
ファイル: affix.class.php プロジェクト: h3len/Project
 public function upload_affix()
 {
     if ($_FILES['Filedata']) {
         if ($_FILES['Filedata']['error']) {
             return false;
         } else {
             $typetmp = explode('.', $_FILES['Filedata']['name']);
             $filetype = strtolower($typetmp[count($typetmp) - 1]);
             $filepath = date('Y') . '/' . date('m') . '/';
             $tmp_filename = date('YmdHis') . hg_generate_user_salt(4);
             $filename = $tmp_filename . '.' . $filetype;
             include_once CUR_CONF_PATH . 'lib/cache.class.php';
             $this->material_type = new cache();
             $gMaterialType = $this->material_type->check_cache('material_type.cache.php');
             $type = '';
             foreach ($gMaterialType as $k => $v) {
                 if ($k == 'img') {
                     if (in_array($filetype, array_keys($v))) {
                         $path = hg_getimg_dir() . MATERIAL_TMP_PATH . $filepath;
                         hg_mkdir($path);
                         if (!move_uploaded_file($_FILES["Filedata"]["tmp_name"], $path . $filename)) {
                             return false;
                         } else {
                             $ret = array('tmpurl' => hg_material_link(hg_getimg_host(), MATERIAL_TMP_PATH, $filepath, $filename), 'url' => hg_material_link(hg_getimg_host(), MATERIAL_TMP_PATH, $filepath, $filename, $this->settings['default_size']['label'] . '/'));
                         }
                     }
                 }
             }
             return $ret;
         }
     }
 }