コード例 #1
0
ファイル: filemanage.php プロジェクト: qiuai/esp_cms
 function onupfilesave()
 {
     require_once admin_ROOT . '/public/class_upload.php';
     $temppath = $this->fun->accept('path', 'P');
     $temppath = empty($temppath) ? $this->CON['upfile_dir'] : $temppath;
     $path = admin_ROOT . $temppath;
     if (!$this->fun->filemode($path)) {
         exit($this->lng['filemanage_js_upfile_no']);
     }
     $amid = $this->fun->accept('amid', 'P');
     $isamid = $this->fun->accept('isamid', 'P');
     $title = $this->fun->accept('title', 'P');
     $lng = $this->fun->accept('lng', 'P');
     if ($isamid) {
         if (empty($title)) {
             exit($this->lng['download_mess_size_err6']);
         }
         $db_table = db_prefix . 'album_images';
         $date = time();
         $db_field = 'pid,lng,title,content,pic,addtime,isclass,istop';
         $db_values = "50,'{$lng}','{$title}','{$title}','',{$date},1,0";
         $this->db->query('INSERT INTO ' . $db_table . ' (' . $db_field . ') VALUES (' . $db_values . ')');
         $amid = $this->db->insert_id();
     }
     $upfilepath = $this->fun->accept('upfilepath', 'P');
     $img_issmallpic = $this->fun->accept('img_issmallpic', 'P');
     $img_issmallpic = empty($img_issmallpic) ? 0 : $img_issmallpic;
     $img_width = $this->fun->accept('img_width', 'P');
     $img_width = empty($img_width) ? 0 : ceil($img_width);
     $img_height = $this->fun->accept('img_height', 'P');
     $img_height = empty($img_height) ? 0 : ceil($img_height);
     $img_issmallpic = $img_width < 1 || $img_height < 1 ? 0 : $img_issmallpic;
     $img_iswater = $this->fun->accept('img_iswater', 'P');
     $img_iswater = empty($img_iswater) ? 0 : $img_iswater;
     $type = $this->fun->accept('filetype', 'P');
     $type = empty($type) ? 'img' : $type;
     $isgetback = intval($this->fun->accept('isgetback', 'P'));
     $isgetback = empty($isgetback) ? 0 : $isgetback;
     $dirdate = $this->fun->accept('dirdate', 'P');
     if ($isgetback == 1) {
         $dirdate = 'list';
     } else {
         $dirdate = empty($dirdate) ? $this->CON['img_dirtype'] : $dirdate;
     }
     $filenametype = $this->fun->accept('filenametype', 'P');
     $filenametype = empty($filenametype) ? $this->CON['img_cfiletype'] : $filenametype;
     $iszoom = $this->fun->accept('iszoom', 'P');
     $iszoom = empty($iszoom) ? $this->CON['img_iszoom'] : $iszoom;
     $filename = $_FILES['upfilepath']['name'];
     $filesize = intval($_FILES['upfilepath']['size']);
     $filetmpname = $_FILES['upfilepath']['tmp_name'];
     $fileerror = $_FILES['upfilepath']['error'];
     $filetype = $_FILES['upfilepath']['type'];
     if ($filesize <= 0 || $filesize > intval($this->CON['upfile_maxsize'])) {
         exit($this->lng['download_mess_size_err2']);
     }
     $upfile = new uploadFile();
     $filename = $upfile->upfilebase($img_width, $img_height, $img_issmallpic, $img_iswater, $path, $filename, $filesize, $filetmpname, $fileerror, $filetype, $type, $dirdate, $filenametype, $iszoom);
     if ($filename) {
         $db_table = db_prefix . 'filename';
         $date = time();
         $filename = str_replace(admin_ROOT, '', $filename);
         list($uploadfile, $toImagesFile, $outfiletype, $filepath, $iswidth, $extension) = explode('|', $filename);
         if (!empty($uploadfile)) {
             $pathnow_array = preg_split('(\\\\|/)', $filepath);
             $pathnow = is_array($pathnow_array) ? count($pathnow_array) - 2 : 0;
             unset($pathnow_array[0]);
             $db_field = 'username,filetitle,filename,filetype,filepath,addtime,iswidth,extension,pathnow';
             for ($index = 0; $index < count($pathnow_array) - 1; $index++) {
                 $keyid = $index + 1;
                 $updirname = $pathnow_array[$index];
                 $filename = $pathnow_array[$keyid];
                 $dirname_len .= !empty($updirname) ? $pathnow_array[$index] . '/' : null;
                 $dirfilepath = empty($updirname) ? $this->CON['upfile_dir'] : $this->CON['upfile_dir'] . $dirname_len;
                 $db_where = " WHERE pathnow={$index} AND filename='{$filename}' AND filepath='{$dirfilepath}'";
                 $countnum = $this->db_numrows($db_table, $db_where);
                 if ($countnum <= 0) {
                     $db_values = "'{$this->esp_username}','','{$filename}','dir','{$dirfilepath}',{$date},0,'dir',{$index}";
                     $this->db->query('INSERT INTO ' . $db_table . ' (' . $db_field . ') VALUES (' . $db_values . ')');
                 }
             }
             $db_values = "('{$this->esp_username}','','{$uploadfile}','{$outfiletype}','{$filepath}',{$date},{$iswidth},'{$extension}',{$pathnow})";
             if ($toImagesFile) {
                 $db_values .= ",('{$this->esp_username}','','{$toImagesFile}','{$outfiletype}','{$filepath}',{$date},{$iswidth},'{$extension}',{$pathnow})";
             }
             $this->db->query('INSERT INTO ' . $db_table . ' (' . $db_field . ') VALUES ' . $db_values . '');
             if ($amid && $outfiletype == 'img') {
                 $insert_id = $this->db->insert_id();
                 $db_table = db_prefix . 'album_file';
                 $db_field = 'amid,fiid,filetitle,filedes,filename,filepath,iswidth,addtime';
                 $db_values = "({$amid},{$insert_id},'{$uploadfile}','','{$uploadfile}','{$filepath}',{$iswidth},{$date})";
                 if ($toImagesFile) {
                     $db_values .= ",({$amid},{$insert_id},'{$toImagesFile}','','{$toImagesFile}','{$filepath}',{$iswidth},{$date})";
                 }
                 $this->db->query('INSERT INTO ' . $db_table . ' (' . $db_field . ') VALUES ' . $db_values . '');
             }
         }
     }
     if ($uploadfile) {
         if ($toImagesFile) {
             exit($filepath . $uploadfile . '|' . $outfiletype . '|' . $iswidth . '|' . $filepath . $toImagesFile);
         } else {
             exit($filepath . $uploadfile . '|' . $outfiletype . '|' . $iswidth . '|');
         }
     } else {
         exit('false');
     }
 }
コード例 #2
0
ファイル: filemanage.php プロジェクト: huangs0928/zzlangshi
 function onupfilesave()
 {
     require_once admin_ROOT . '/public/class_upload.php';
     $temppath = $this->fun->accept('path', 'P');
     $path = admin_ROOT . $temppath;
     if (!$this->fun->filemode($path)) {
         exit($this->lng['filemanage_js_upfile_no']);
     }
     $amid = $this->fun->accept('amid', 'P');
     $isamid = $this->fun->accept('isamid', 'P');
     $title = $this->fun->accept('title', 'P');
     $lng = $this->fun->accept('lng', 'P');
     if ($isamid) {
         if (empty($title)) {
             exit($this->lng['download_mess_size_err6']);
         }
         $db_table = db_prefix . 'album_images';
         $date = time();
         $db_field = 'pid,lng,title,content,pic,addtime,isclass,istop';
         $db_values = "50,'{$lng}','{$title}','{$title}','',{$date},1,0";
         $this->db->query('INSERT INTO ' . $db_table . ' (' . $db_field . ') VALUES (' . $db_values . ')');
         $amid = $this->db->insert_id();
     }
     $upfilepath = $this->fun->accept('upfilepath', 'P');
     $img_issmallpic = $this->fun->accept('img_issmallpic', 'P');
     $img_issmallpic = empty($img_issmallpic) ? 0 : $img_issmallpic;
     $img_width = $this->fun->accept('img_width', 'P');
     $img_width = empty($img_width) ? 0 : ceil($img_width);
     $img_height = $this->fun->accept('img_height', 'P');
     $img_height = empty($img_height) ? 0 : ceil($img_height);
     $img_issmallpic = $img_width < 1 || $img_height < 1 ? 0 : $img_issmallpic;
     $img_iswater = $this->fun->accept('img_iswater', 'P');
     $img_iswater = empty($img_iswater) ? 0 : $img_iswater;
     $type = $this->fun->accept('filetype', 'P');
     $type = empty($type) ? 'img' : $type;
     $dirdate = $this->fun->accept('dirdate', 'P');
     $dirdate = empty($dirdate) ? $this->CON['img_dirtype'] : $dirdate;
     $filenametype = $this->fun->accept('filenametype', 'P');
     $filenametype = empty($filenametype) ? $this->CON['img_cfiletype'] : $filenametype;
     $iszoom = $this->fun->accept('iszoom', 'P');
     $iszoom = empty($iszoom) ? $this->CON['img_iszoom'] : $iszoom;
     $filename = $_FILES['upfilepath']['name'];
     $filesize = intval($_FILES['upfilepath']['size']);
     $filetmpname = $_FILES['upfilepath']['tmp_name'];
     $fileerror = $_FILES['upfilepath']['error'];
     $filetype = $_FILES['upfilepath']['type'];
     if ($filesize <= 0 || $filesize > intval($this->CON['upfile_maxsize'])) {
         exit($this->lng['download_mess_size_err2']);
     }
     $upfile = new uploadFile();
     $filename = $upfile->upfilebase($img_width, $img_height, $img_issmallpic, $img_iswater, $path, $filename, $filesize, $filetmpname, $fileerror, $filetype, $type, $dirdate, $filenametype, $iszoom);
     if ($filename) {
         $db_table = db_prefix . 'filename';
         $date = time();
         $filename = str_replace(admin_ROOT, '', $filename);
         list($uploadfile, $toImagesFile, $outfiletype, $filepath, $iswidth) = explode('|', $filename);
         if (!empty($uploadfile)) {
             $db_field = 'username,filetitle,filename,filetype,filepath,addtime,iswidth';
             $db_values = "('{$this->esp_username}','','{$uploadfile}','{$outfiletype}','{$filepath}',{$date},{$iswidth})";
             if ($toImagesFile) {
                 $db_values .= ",('{$this->esp_username}','','{$toImagesFile}','{$outfiletype}','{$filepath}',{$date},{$iswidth})";
             }
             $this->db->query('INSERT INTO ' . $db_table . ' (' . $db_field . ') VALUES ' . $db_values . '');
             if ($amid && $outfiletype == 'img') {
                 $insert_id = $this->db->insert_id();
                 $db_table = db_prefix . 'album_file';
                 $db_field = 'amid,fiid,filetitle,filedes,filename,filepath,iswidth,addtime';
                 $db_values = "({$amid},{$insert_id},'{$uploadfile}','','{$uploadfile}','{$filepath}',{$iswidth},{$date})";
                 if ($toImagesFile) {
                     $db_values .= ",({$amid},{$insert_id},'{$toImagesFile}','','{$toImagesFile}','{$filepath}',{$iswidth},{$date})";
                 }
                 $this->db->query('INSERT INTO ' . $db_table . ' (' . $db_field . ') VALUES ' . $db_values . '');
             }
         }
     }
     if ($uploadfile) {
         if ($toImagesFile) {
             exit($filepath . $uploadfile . '|' . $outfiletype . '|' . $iswidth . '|' . $filepath . $toImagesFile);
         } else {
             exit($filepath . $uploadfile . '|' . $outfiletype . '|' . $iswidth . '|');
         }
     } else {
         exit('false');
     }
 }