示例#1
2
function move_file($src, $dest, $filename = null)
{
    fileLog(__FUNCTION__, '-', 'ALIAS calling rename_file');
    $status = rename_file($src, $dest, $filename);
    return $status;
}
示例#2
1
      * Изменение смайла
      */
 /**
  * Изменение смайла
  */
 case 'change':
     $uid = !empty($_GET['uid']) ? check($_GET['uid']) : 0;
     $code = isset($_POST['code']) ? check(utf_lower($_POST['code'])) : '';
     $smile = DBM::run()->selectFirst('smiles', array('smiles_id' => $id));
     $checkcode = DBM::run()->selectFirst('smiles', array('smiles_code' => $code, 'smiles_id' => $id));
     $checkcode = DBM::run()->queryFirst("SELECT `smiles_id` FROM `smiles` WHERE `smiles_code`=:code AND `smiles_id`<>:id LIMIT 1;", compact('code', 'id'));
     $validation = new Validation();
     $validation->addRule('equal', array($uid, $_SESSION['token']), 'Неверный идентификатор сессии, повторите действие!')->addRule('not_empty', $smile, 'Не найден смайл для редактирования!')->addRule('empty', $checkcode, 'Смайл с данным кодом уже имеется в списке!')->addRule('string', $code, 'Слишком длинный или короткий код смайла!', true, 1, 20)->addRule('regex', array($code, '|^:+[a-яa-z0-9_\\-/\\(\\)]+$|i'), 'Код смайла должен начинаться с двоеточия. Разрешены буквы, цифры и дефис!', true);
     if ($validation->run()) {
         if (!preg_match('/[А-Яа-яЁё]/u', $code)) {
             $newname = rename_file($smile['smiles_name'], substr($code, 1));
         } else {
             $newname = $smile['smiles_name'];
         }
         if (rename(BASEDIR . '/images/smiles/' . $smile['smiles_name'], BASEDIR . '/images/smiles/' . $newname)) {
             $smile = DBM::run()->update('smiles', array('smiles_name' => $newname, 'smiles_code' => $code), array('smiles_id' => $id));
             clearCache();
             notice('Смайл успешно отредактирован!');
             redirect("smiles.php?start={$start}");
         } else {
             show_error('Ошибка! Не удалось переименовать файл смайла!');
         }
     } else {
         show_error($validation->getErrors());
     }
     render('includes/back', array('link' => 'smiles.php?act=edit&amp;id=' . $id . '&amp;start=' . $start, 'title' => 'Вернуться'));
 public function validate_watermark($wm_id = null, $data = array())
 {
     $return = array("errors" => array(), "data" => array());
     if (isset($data["name"])) {
         $return["data"]["name"] = strip_tags($data["name"]);
         if (empty($return["data"]["name"])) {
             $return["errors"][] = l('error_title_invalid', 'uploads');
         }
     }
     if (isset($data["gid"])) {
         $return["data"]["gid"] = strip_tags($data["gid"]);
         $return["data"]["gid"] = preg_replace("/[\n\t\\s]{1,}/", "-", trim($return["data"]["gid"]));
         if (empty($return["data"]["gid"])) {
             $return["errors"][] = l('error_gid_invalid', 'uploads');
         }
     }
     if (isset($data["position_ver"])) {
         $return["data"]["position_ver"] = $data["position_ver"];
     }
     if (isset($data["position_hor"])) {
         $return["data"]["position_hor"] = $data["position_hor"];
     }
     if (isset($data["alpha"])) {
         $return["data"]["alpha"] = intval($data["alpha"]);
     }
     if (isset($data["wm_type"])) {
         $return["data"]["wm_type"] = $data["wm_type"];
     }
     if (isset($data["img"]) && is_array($data["img"]) && is_uploaded_file($data["img"]["tmp_name"])) {
         $this->CI->load->helper('upload');
         $config = array('allowed_types' => 'gif|jpg|png');
         $img_return = upload_file('img', $this->watermark_path, $config);
         if (!empty($img_return["error"])) {
             foreach ($img_return["error"] as $imgError) {
                 $return["errors"][] = $imgError;
             }
             $img_name = "";
         } else {
             $old_name = $img_return["data"]["file_name"];
             $new_name = "wm_" . $return["data"]["gid"] . $img_return["data"]["file_ext"];
             $rename = rename_file($img_return["data"]["file_path"] . $old_name, $img_return["data"]["file_path"] . $new_name);
             $img_name = $rename ? $new_name : $old_name;
         }
         $return["data"]["img"] = $img_name;
     }
     if (isset($data["font_size"])) {
         $return["data"]["font_size"] = intval($data["font_size"]);
     }
     if (isset($data["shadow_distance"])) {
         $return["data"]["shadow_distance"] = intval($data["shadow_distance"]);
     }
     if (isset($data["font_color"])) {
         $return["data"]["font_color"] = $data["font_color"];
     }
     if (isset($data["shadow_color"])) {
         $return["data"]["shadow_color"] = $data["shadow_color"];
     }
     if (isset($data["font_face"])) {
         $return["data"]["font_face"] = $data["font_face"];
     }
     if (isset($data["font_text"])) {
         $return["data"]["font_text"] = strip_tags($data["font_text"]);
     }
     return $return;
 }
示例#4
1
/**
 * Restore Backup copy of a dataFile to where it belongs
 *
 * @since 3.4
 *
 * @param string $file filepath of data file to restore from backup, locked to GSDATAPATH
 * @param  bool $delete delete the backup
 * @return bool success
 */
function restore_datafile($filepath, $delete = true)
{
    if (!filepath_is_safe($filepath, GSDATAPATH)) {
        return false;
    }
    $bakfilepath = getBackupFilePath($filepath);
    // backup original before restoring
    if (file_exists($filepath)) {
        rename_file($bakfilepath, $bakfilepath . '.tmp');
        move_file($filepath, $bakfilepath);
        $bakfilepath .= '.tmp';
    }
    if (!$delete) {
        return copy_file($bakfilepath, $filepath);
    }
    return move_file($bakfilepath, $filepath);
}
示例#5
1
         $name = fix_filename($name, $transliteration, $convert_spaces, $replace_with);
         if (!empty($name)) {
             if (!rename_file($path, $name, $transliteration)) {
                 response(trans('Rename_existing_file'), 403)->send();
                 exit;
             }
             rename_file($path_thumb, $name, $transliteration);
             if ($fixed_image_creation) {
                 $info = pathinfo($path);
                 foreach ($fixed_path_from_filemanager as $k => $paths) {
                     if ($paths != "" && $paths[strlen($paths) - 1] != "/") {
                         $paths .= "/";
                     }
                     $base_dir = $paths . substr_replace($info['dirname'] . "/", '', 0, strlen($current_path));
                     if (file_exists($base_dir . $fixed_image_creation_name_to_prepend[$k] . $info['filename'] . $fixed_image_creation_to_append[$k] . "." . $info['extension'])) {
                         rename_file($base_dir . $fixed_image_creation_name_to_prepend[$k] . $info['filename'] . $fixed_image_creation_to_append[$k] . "." . $info['extension'], $fixed_image_creation_name_to_prepend[$k] . $name . $fixed_image_creation_to_append[$k], $transliteration);
                     }
                 }
             }
         } else {
             response(trans('Empty_name'), 400)->send();
             exit;
         }
     }
     break;
 case 'duplicate_file':
     if ($duplicate_files) {
         $name = fix_filename($name, $transliteration, $convert_spaces, $replace_with);
         if (!empty($name)) {
             if (!duplicate_file($path, $name)) {
                 response(trans('Rename_existing_file'), 403)->send();
示例#6
0
function rename_file($fromDir, $new_module)
{
    $handle = opendir($fromDir);
    $exceptions = array('.', '..');
    while (false != ($item = readdir($handle))) {
        if (is_dir($fromDir . "/" . $item)) {
            if (!in_array($item, $exceptions)) {
                $new_module_lower = strtolower($new_module);
                $new_item = str_replace("Memday", $new_module, $item);
                $new_item = str_replace("memday", $new_module_lower, $new_item);
                echo "newItem:" . $new_item . "<br>";
                rename($fromDir . "/" . $item, $fromDir . "/" . $new_item);
                rename_file($fromDir . "/" . $new_item, $new_module);
            }
        } else {
            $new_module_lower = strtolower($new_module);
            $new_module_upper = strtoupper($new_module);
            $new_item = str_replace("Memday", $new_module, $item);
            $new_item = str_replace("memday", $new_module_lower, $new_item);
            rename($fromDir . "/" . $item, $fromDir . "/" . $new_item);
            strChangeInThisFile($fromDir . "/" . $new_item, "Memdays", $new_module . "s");
            strChangeInThisFile($fromDir . "/" . $new_item, "Memday", $new_module);
            strChangeInThisFile($fromDir . "/" . $new_item, "memdays", $new_module_lower . "s");
            strChangeInThisFile($fromDir . "/" . $new_item, "memday", $new_module_lower);
            strChangeInThisFile($fromDir . "/" . $new_item, "MEMDAYS", $new_module_upper . "S");
            strChangeInThisFile($fromDir . "/" . $new_item, "MEMDAY", $new_module_upper);
            //strChangeInThisFile($fromDir."/".$new_item,"ec_","vtiger_");
            strChangeInThisFile($fromDir . "/" . $new_item, "纪念日", "客户回访");
        }
    }
    closedir($handle);
}
function rename_file($path, $original)
{
    $ext = explode(".", $original);
    $part1 = time();
    $newName = $part1 . "." . $ext[1];
    if (file_exists($path . $newName)) {
        rename_file($path, $newName);
    } else {
        return $newName;
    }
}
 /**
  * Save image to uploads folder and change the name to something unique
  *
  * @param SettingRequest $request
  * @param $field
  * @return array
  */
 private function storeImage(SettingRequest $request, $field)
 {
     $data = $request->except([$field]);
     if ($request->file($field)) {
         $file = $request->file($field);
         $request->file($field);
         $fileName = rename_file($file->getClientOriginalName(), $file->getClientOriginalExtension());
         $path = '/uploads/' . str_plural($field);
         $move_path = public_path() . $path;
         $file->move($move_path, $fileName);
         $data[$field] = $path . $fileName;
     }
     return $data;
 }
 public function getImage($request)
 {
     if ($request->hasFile('logo')) {
         $file = $request->file('logo');
         $fileName = rename_file('complogo', $file->getClientOriginalExtension());
         $path = '/assets/images/complogo/';
         $move_path = public_path() . $path;
         $file->move($move_path, $fileName);
         Queue::push(ImageResizerJob::class, ['path' => $path, 'filename' => $fileName]);
         $data = $request->except('_method', '_token', 'logo');
         $data['image_path'] = $path;
         $data['image_name'] = $fileName;
         return $data;
     }
     return $request->except('_method', '_token', 'logo');
 }
示例#10
0
            break;
        case 'create_folder':
            create_folder(fix_path($path), fix_path($path_thumb));
            break;
        case 'rename_folder':
            $name = fix_filename($name);
            if (!empty($name)) {
                if (!rename_folder($path, $name)) {
                    die(lang_Rename_existing_folder);
                }
                rename_folder($path_thumb, $name);
            } else {
                die(lang_Empty_name);
            }
            break;
        case 'rename_file':
            $name = fix_filename($name);
            if (!empty($name)) {
                if (!rename_file($path, $name)) {
                    die(lang_Rename_existing_file);
                }
                rename_file($path_thumb, $name);
            } else {
                die(lang_Empty_name);
            }
            break;
        default:
            die('wrong action');
            break;
    }
}
示例#11
0
 /**
  * 文件批量上传
  * @method upload
  * @return [type] [description]
  * @author 孙卓豪[@yunyin.org]
  * @author 修改NewFuture
  */
 public function upload()
 {
     $uid = use_id();
     $files = I('post.files');
     if (!$uid) {
         /*未登录*/
         $this->error(L('UNLOGIN'), __ROOT__);
     } elseif (!$files) {
         /*未登录*/
         $this->error('无文件');
     } else {
         /*批量获取文件名*/
         /*获取文件设置基本信息*/
         $File = D('File');
         $file_data = array();
         $file_data['use_id'] = $uid;
         $file_data = $File->create($file_data);
         /*获取和更新session中的缓存表信息*/
         $upload_list = session('uploads');
         session('uploads', null);
         $result = array();
         foreach ($files as $path) {
             $old_name = $upload_list[$path];
             if ($old_name) {
                 $url = 'upload_' . $path;
                 rename_file('temp_' . $path, $url);
                 $file_data['url'] = $url;
                 $file_data['name'] = $old_name;
                 if ($File->add($file_data)) {
                     $result[] = array('name' => $old_name, 'r' => 1);
                 } else {
                     $result[] = array('name' => $old_name, 'r' => 0);
                 }
             }
         }
         if (empty($result)) {
             $this->error('上传失败');
         } else {
             $this->success($result);
         }
     }
 }
示例#12
0
 }
 $file['info'] = array();
 if ($file['tmp_name']) {
     $file['info'] = @getimagesize($file['tmp_name']);
 }
 if (!$err) {
     $res = validate_img($file);
     if ($res !== true) {
         $err = $res;
     }
 }
 // still no error? we can now try and copy the file from the tmp location to the icon dir
 if (!$err) {
     $newfile = catfile($ps->conf['theme']['icons_dir'], $file['name']);
     $overwrote = file_exists($newfile);
     $ok = @rename_file($file['tmp_name'], $newfile);
     if (!$ok) {
         $err = $cms->trans("Error copying new image to icon directory!");
         //			$err .= is_writable(dirname($newfile)) ? "<br/>" . $cms->trans("Permission Denied") : '';
         //			if (isset($php_errormsg)) $err .= "<br/>\n" . $php_errormsg;
     } else {
         $action_result = $cms->trans("File '%s' uploaded successfully!", $file['name']);
         if ($overwrote) {
             $action_result .= " (" . $cms->trans("Original file was overwritten") . ")";
         }
         $uploaded_icon = $file['name'];
         @chmod(catfile($ps->conf['theme']['icons_dir'], $file['name']), 0644);
     }
 }
 if ($err) {
     $form->error('fatal', $err);
示例#13
0
 public function clearuploadfile()
 {
     echo $root = dirname(dirname(dirname(__FILE__)));
     include $root . "/Servise.php";
     $pathpdf = "";
     $type = $_FILES['file']['type'][0];
     $file = rename_file($_FILES['file']);
     $num_files = count($_FILES['file']['name']);
     $upload_file = array();
     array_push($upload_file, 'http://www.notesgen.com/upload_file/files/uploads/' . $file[0]);
     for ($i = 1; $i < $num_files; $i++) {
         $fulpath = rename_multi_file($_FILES['file'], $i);
         array_push($upload_file, 'http://www.notesgen.com/upload_file/files/uploads/' . $fulpath[0]);
     }
     if (strstr($type, 'image/')) {
         $myImage2Pdf = new Image2PdfConverter();
         $myImage2Pdf->apiKey = "jvj1mkcxabj1l5";
         $myImage2Pdf->inputImageLocation = "upload_file/files/uploads/" . $file[0];
         //please make sure that the dir is writable chmod 777
         $myImage2Pdf->outputPdfLocation = "upload_file/files/converts/" . $file[1] . ".pdf";
         $myImage2Pdf->pdfAuthor = "My php Author";
         $myImage2Pdf->pdfTitle = "My php Title";
         $myImage2Pdf->pdfSubject = "my php subject";
         $myImage2Pdf->pdfKeywords = "my php keywords";
         //$result will be OK or APINOK or Error Message
         $result = $myImage2Pdf->Image2PdfConvert();
         $myImages2Pdf = new ImagesToPdfConverter();
         $myImages2Pdf->inputTextLocation = "upload_file/files/uploads/" . $file[0];
         $myImages2Pdf->inputimagesLocation = $upload_file;
         //please make sure that the dir is writable chmod 777
         $myImages2Pdf->outputPdfLocation = "upload_file/files/converts/" . $file[1] . ".pdf";
         //$result will be OK or APINOK or Error Message
         $result = $myImages2Pdf->ImagesToPdfConvert();
         $url = $result[0];
         $fff = guid();
         $img = "upload_file/files/converts/" . $fff . ".pdf";
         file_put_contents($img, file_get_contents($url));
         include $root . "/mpdf/mpdf.php";
         $userid = $_SESSION['user']['user_id'];
         $mpdf = new mPDF();
         $mpdf->SetImportUse();
         $pagecount = $mpdf->SetSourceFile('upload_file/files/converts/' . $fff . ".pdf");
         $tplId = $mpdf->ImportPage(1);
         $mpdf->UseTemplate($tplId);
         $mpdf->SetDisplayMode('fullpage');
         $mpdf->SetWatermarkText(' ');
         $mpdf->watermark_font = 'DejaVuSansCondensed';
         $mpdf->showWatermarkText = true;
         $md5 = $fff . ".pdf";
         $mpdf->Output('upload_file/files/pdfpreview/' . $md5 . '.pdf', '');
         $mpdf->Thumbnail('upload_file/files/pdfpreview/' . $md5 . '.pdf', 1);
         $mpdf->Output('upload_file/files/pdfpreview/' . $md5 . '.pdf', '');
         //unlink('/upload_file/files/c'.$uploaddatafile1.".pdf");
         $im = new imagick();
         $im->readimage('upload_file/files/pdfpreview/' . $md5 . '.pdf');
         //$im->readimage('/upload_file/files/'.$md5.'.pdf');
         $im->setImageCompressionQuality(0);
         $im->setImageFormat('jpeg');
         $im->writeImage('upload_file/images/' . $md5 . '.jpg');
         $this->db->set('id', $userid);
         $this->db->set('fullpdf', 'upload_file/files/pdfpreview/' . $md5 . '.pdf');
         $this->db->set('pdf', 'upload_file/files/pdfpreview/' . $md5 . '.pdf');
         $this->db->set('image', 'upload_file/images/r' . $md5 . '.jpg');
         $this->db->insert('scribe');
         $im->clear();
         $im->destroy();
         //	echo $path_upload.'|'.serialize($data).'|upload_file/images/r'.$md5.'.jpg|upload_file/files/'.$uploaddatafile1.'.pdf';
         echo "<a href='upload_file/files/converts/" . $fff . ".pdf' target='blank'>PDF File</a>";
     } elseif ($type == 'application/vnd.openxmlformats-officedocument.wordprocessingml.document' || $type == 'application/msword') {
         $returned_content = get_data("http://online.verypdf.com/api/?apikey=456044A5728D76FB34D489DA2BC5504173498EF3&app=doc2any&infile=http://www.notesgen.com/upload_file/files/uploads/" . $file[0] . "&outfile=out.pdf");
         $url = str_replace("[Output] ", "", $returned_content);
         $url = str_replace("<br>", "", $url);
         $fff = guid();
         $word = "upload_file/files/converts/" . $fff . ".pdf";
         file_put_contents($word, file_get_contents($url));
         echo "OK";
         include $root . "/mpdf/mpdf.php";
         $userid = $_SESSION['user']['user_id'];
         $mpdf = new mPDF();
         $mpdf->SetImportUse();
         $pagecount = $mpdf->SetSourceFile('upload_file/files/converts/' . $fff . ".pdf");
         $tplId = $mpdf->ImportPage(1);
         $mpdf->UseTemplate($tplId);
         $mpdf->SetDisplayMode('fullpage');
         $mpdf->SetWatermarkText(' ');
         $mpdf->watermark_font = 'DejaVuSansCondensed';
         $mpdf->showWatermarkText = true;
         $md5 = $fff . ".pdf";
         $mpdf->Output('upload_file/files/pdfpreview/' . $md5 . '.pdf', '');
         $mpdf->Thumbnail('upload_file/files/pdfpreview/' . $md5 . '.pdf', 1);
         $mpdf->Output('upload_file/files/pdfpreview/' . $md5 . '.pdf', '');
         //unlink('/upload_file/files/c'.$uploaddatafile1.".pdf");
         $im = new imagick();
         $im->readimage('upload_file/files/pdfpreview/' . $md5 . '.pdf');
         //$im->readimage('/upload_file/files/'.$md5.'.pdf');
         $im->setImageCompressionQuality(0);
         $im->setImageFormat('jpeg');
         $im->writeImage('upload_file/images/' . $md5 . '.jpg');
         $this->db->set('id', $userid);
         $this->db->set('fullpdf', 'upload_file/files/pdfpreview/' . $md5 . '.pdf');
         $this->db->set('pdf', 'upload_file/files/pdfpreview/' . $md5 . '.pdf');
         $this->db->set('image', 'upload_file/images/r' . $md5 . '.jpg');
         $this->db->insert('scribe');
         $im->clear();
         $im->destroy();
         echo "<a href='upload_file/files/" . $fff . ".pdf' target='blank'>PDF File</a>";
     } elseif ($type == 'text/plain') {
         $returned_content = get_data("http://online.verypdf.com/api/?apikey=456044A5728D76FB34D489DA2BC5504173498EF3&app=doc2any&infile=http://www.notesgen.com/upload_file/files/uploads/" . $file[0] . "&outfile=out.pdf");
         $url = str_replace("[Output] ", "", $returned_content);
         $url = str_replace("<br>", "", $url);
         $fff = guid();
         $word = "upload_file/files/converts/" . $fff . ".pdf";
         file_put_contents($word, file_get_contents($url));
         echo "OK";
         include $root . "/mpdf/mpdf.php";
         $userid = $_SESSION['user']['user_id'];
         $mpdf = new mPDF();
         $mpdf->SetImportUse();
         $pagecount = $mpdf->SetSourceFile('upload_file/files/converts/' . $fff . ".pdf");
         $tplId = $mpdf->ImportPage(1);
         $mpdf->UseTemplate($tplId);
         $mpdf->SetDisplayMode('fullpage');
         $mpdf->SetWatermarkText(' ');
         $mpdf->watermark_font = 'DejaVuSansCondensed';
         $mpdf->showWatermarkText = true;
         $md5 = $fff . ".pdf";
         $mpdf->Output('upload_file/files/pdfpreview/' . $md5 . '.pdf', '');
         $mpdf->Thumbnail('upload_file/files/pdfpreview/' . $md5 . '.pdf', 1);
         $mpdf->Output('upload_file/files/pdfpreview/' . $md5 . '.pdf', '');
         //unlink('/upload_file/files/c'.$uploaddatafile1.".pdf");
         $im = new imagick();
         $im->readimage('upload_file/files/pdfpreview/' . $md5 . '.pdf');
         //$im->readimage('/upload_file/files/'.$md5.'.pdf');
         $im->setImageCompressionQuality(0);
         $im->setImageFormat('jpeg');
         $im->writeImage('upload_file/images/' . $md5 . '.jpg');
         $this->db->set('id', $userid);
         $this->db->set('fullpdf', 'upload_file/files/pdfpreview/' . $md5 . '.pdf');
         $this->db->set('pdf', 'upload_file/files/pdfpreview/' . $md5 . '.pdf');
         $this->db->set('image', 'upload_file/images/r' . $md5 . '.jpg');
         $this->db->insert('scribe');
         $im->clear();
         $im->destroy();
         echo "<a href='upload_file/files/converts/" . $fff . ".pdf' target='blank'>PDF File</a>";
     } elseif ($type == 'application/vnd.openxmlformats-officedocument.presentationml.presentation' || $type == 'application/vnd.ms-powerpointtd>') {
         $returned_content = get_data("http://online.verypdf.com/api/?apikey=456044A5728D76FB34D489DA2BC5504173498EF3&app=doc2any&infile=http://www.notesgen.com/upload_file/files/uploads/" . $file[0] . "&outfile=out.pdf");
         $url = str_replace("[Output] ", "", $returned_content);
         $url = str_replace("<br>", "", $url);
         $fff = guid();
         $word = "upload_file/files/converts/" . $fff . ".pdf";
         file_put_contents($word, file_get_contents($url));
         echo "OK";
         include $root . "/mpdf/mpdf.php";
         $userid = $_SESSION['user']['user_id'];
         $mpdf = new mPDF();
         $mpdf->SetImportUse();
         $pagecount = $mpdf->SetSourceFile('upload_file/files/converts/' . $fff . ".pdf");
         $tplId = $mpdf->ImportPage(1);
         $mpdf->UseTemplate($tplId);
         $mpdf->SetDisplayMode('default');
         $mpdf->SetWatermarkText(' ');
         $mpdf->watermark_font = 'DejaVuSansCondensed';
         $mpdf->showWatermarkText = true;
         $md5 = $fff . ".pdf";
         $mpdf->Output('upload_file/files/pdfpreview/' . $md5 . '.pdf', '');
         $mpdf->Thumbnail('upload_file/files/pdfpreview/' . $md5 . '.pdf', 1);
         $mpdf->Output('upload_file/files/pdfpreview/' . $md5 . '.pdf', '');
         //unlink('/upload_file/files/c'.$uploaddatafile1.".pdf");
         $im = new imagick();
         $im->readimage('upload_file/files/pdfpreview/' . $md5 . '.pdf');
         //$im->readimage('/upload_file/files/'.$md5.'.pdf');
         $im->setImageCompressionQuality(0);
         $im->setImageFormat('jpeg');
         $im->writeImage('upload_file/images/' . $md5 . '.jpg');
         $this->db->set('id', $userid);
         $this->db->set('fullpdf', 'upload_file/files/pdfpreview/' . $md5 . '.pdf');
         $this->db->set('pdf', 'upload_file/files/pdfpreview/' . $md5 . '.pdf');
         $this->db->set('image', 'upload_file/images/r' . $md5 . '.jpg');
         $this->db->insert('scribe');
         $im->clear();
         $im->destroy();
         echo "<a href='upload_file/files/" . $fff . ".pdf' target='blank'>PDF File</a>";
     } else {
         echo $type;
         echo 'The type of file is not correct!';
         //header("location:http://www.notesgen.com/profile-note?emsg=22");
     }
 }
 /**
  * Get data, if image column is passed, upload it
  *
  * @param $request
  * @return mixed
  */
 public function getData($request)
 {
     if (!empty($request->image)) {
         $imageColumn = $request->image;
         $imageCategory = strtolower($this->model);
         if ($imageCategory === 'article') {
             $getImageCategory = Category::find($request->category_id);
             $imageCategory = strtolower($getImageCategory->title);
         }
         $data = $request->except($imageColumn);
         if ($request->file($imageColumn)) {
             $file = $request->file($imageColumn);
             $request->file($imageColumn);
             $fileName = rename_file($imageCategory, $file->getClientOriginalExtension());
             $path = '/assets/images/' . str_slug($imageCategory, '-') . '/';
             $move_path = public_path() . $path;
             $file->move($move_path, $fileName);
             Queue::push(ImageResizerJob::class, ['path' => $path, 'filename' => $fileName]);
             $data['image_path'] = $path;
             $data['image_name'] = $fileName;
         }
         return $data;
     }
     return $request->all();
 }
示例#15
0
}
?>

<table width="600" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <th>Real Name</th>
    <th>New Name</th>
  </tr>
<?php 
define('Path', 'F:/Tutorials/Node/');
$dir = 'F:/Tutorials/Node/';
$files = scandir($dir);
arsort($files);
foreach ($files as $file) {
    ?>
              <tr>
                <td align="left"><?php 
    print $file;
    ?>
</td>
                <td align="left"><?php 
    print rename_file($file);
    ?>
</td>
              </tr>
    <?php 
}
?>
</table>
</body>
</html>
 /**
  * Upload the image and return the data
  *
  * @param $request
  * @param string $field
  * @return mixed
  */
 protected function uploadImage($request, $field)
 {
     $data = $request->except($field);
     if ($file = $request->file($field)) {
         $fileName = rename_file($file->getClientOriginalName(), $file->getClientOriginalExtension());
         $path = $this->getUploadPath($field);
         $file->move(public_path($path), $fileName);
         $data[$field] = $path . $fileName;
     }
     return $data;
 }
示例#17
0
 //check if file have illegal caracter
 $filename = substr($file, 0, '-' . (strlen($file_array['extension']) + 1));
 if ($file != fix_filename($file)) {
     $file1 = fix_filename($file);
     $file_path1 = $current_path . $subfolder . $subdir . $file1;
     if (file_exists($file_path1)) {
         $i = 1;
         $info = pathinfo($file1);
         while (file_exists($current_path . $subfolder . $subdir . $info['filename'] . ".[" . $i . "]." . $info['extension'])) {
             $i++;
         }
         $file1 = $info['filename'] . ".[" . $i . "]." . $info['extension'];
         $file_path1 = $current_path . $subfolder . $subdir . $file1;
     }
     $filename = substr($file1, 0, '-' . (strlen($file_array['extension']) + 1));
     rename_file($file_path, fix_filename($filename));
     $file = $file1;
     $file_array['extension'] = fix_filename($file_array['extension']);
     $file_path = $file_path1;
 }
 $is_img = false;
 $is_video = false;
 $is_audio = false;
 $show_original = false;
 $show_original_mini = false;
 $mini_src = "";
 $src_thumb = "";
 $extension_lower = mb_strtolower($file_array['extension']);
 if (in_array($extension_lower, $ext_img)) {
     $src = $base_url . $cur_dir . $file;
     $mini_src = $src_thumb = $thumbs_path . $subdir . $file;
示例#18
0
 //check if file have illegal caracter
 $filename = substr($file, 0, '-' . (strlen($file_array['extension']) + 1));
 if ($file != fix_filename($file, $transliteration)) {
     $file1 = fix_filename($file, $transliteration);
     $file_path1 = $current_path . $rfm_subfolder . $subdir . $file1;
     if (file_exists($file_path1)) {
         $i = 1;
         $info = pathinfo($file1);
         while (file_exists($current_path . $rfm_subfolder . $subdir . $info['filename'] . ".[" . $i . "]." . $info['extension'])) {
             $i++;
         }
         $file1 = $info['filename'] . ".[" . $i . "]." . $info['extension'];
         $file_path1 = $current_path . $rfm_subfolder . $subdir . $file1;
     }
     $filename = substr($file1, 0, '-' . (strlen($file_array['extension']) + 1));
     rename_file($file_path, fix_filename($filename, $transliteration), $transliteration);
     $file = $file1;
     $file_array['extension'] = fix_filename($file_array['extension'], $transliteration);
     $file_path = $file_path1;
 }
 $is_img = false;
 $is_video = false;
 $is_audio = false;
 $show_original = false;
 $show_original_mini = false;
 $mini_src = "";
 $src_thumb = "";
 $extension_lower = fix_strtolower($file_array['extension']);
 if (in_array($extension_lower, $ext_img)) {
     $src = $base_url . $cur_dir . rawurlencode($file);
     $mini_src = $src_thumb = $thumbs_path . $subdir . $file;
示例#19
0
文件: index.php 项目: Ereaey/Cloud
     $key = $_GET['key'];
     $id_file = $_GET['id_file'];
     $content = $_POST['content'];
     write_file($key, $id_file, $content);
 } else {
     if ($action == "create_cloud") {
         $key = $_GET['key'];
         $name = $_GET['name'];
         $type = $_GET['type'];
         create_cloud($key, $name, $type);
     } else {
         if ($action == "rename_file") {
             $key = $_GET['key'];
             $name = $_GET['name'];
             $id_file = $_GET['id_file'];
             rename_file($key, $id_file, $name);
         } else {
             if ($action == "rename_folder") {
                 $key = $_GET['key'];
                 $name = $_GET['name'];
                 $id_folder = $_GET['id_folder'];
                 rename_folder($key, $id_folder, $name);
             } else {
                 if ($action == "create_min_url") {
                     $url = $_GET['url'];
                     $type = $_GET['type'];
                     create_min_url($url, $type);
                 } else {
                     if ($action == "get_table") {
                         $key = $_GET['key'];
                         $id_cloud = $_GET['id_cloud'];
示例#20
-1
    <th>Real Name</th>
    <th>New Name</th>
  </tr>
<?php 
define('Path', '/rename-file/files/');
//change path with your own
$dir = '/rename-file/files/';
//change path with your own
$files = scandir($dir);
arsort($files);
foreach ($files as $file) {
    $new_name = md5_file(Path . $file);
    $path_info = pathinfo(Path . $file);
    $replace_name = $path_info['filename'];
    ?>
          <tr>
                <td align="left"><?php 
    print $file;
    ?>
</td>             
               <td align="left"><?php 
    print rename_file($replace_name, $new_name, $file);
    ?>
</td> 
              </tr>
    <?php 
}
?>
</table>
</body>
</html>
示例#21
-1
     get_content_file($_POST['name'], rtrim($_POST['from'], "/") . "/");
     break;
 case 'file_put_content':
     put_content_file($_POST['name'], rtrim($_POST['from'], "/") . "/", $_POST["file_content"]);
     break;
 case 'create_folder':
     create_folder($_POST["name"], rtrim($_POST["to"], '/') . '/');
     break;
 case 'copy':
     copy_file($_POST["file_name"], rtrim($_POST["from"], "/") . "/", rtrim($_POST['to'], "/") . "/");
     break;
 case 'multiple_copy':
     copy_multiple_file($_POST["file"], $_POST["folder"], $_POST["folder_name"], rtrim($_POST["from"], "/") . "/", rtrim($_POST['to'], "/") . "/");
     break;
 case 'rename':
     rename_file($_POST["old_name"], $_POST["new_name"], rtrim($_POST["to"], "/") . '/');
     break;
 case 'remove':
     delete_file($_POST["name"], rtrim($_POST["from"], "/") . "/");
     break;
 case 'multiple_remove':
     delete_multiple_file($_POST["file"], $_POST["folder"], rtrim($_POST["from"], "/") . "/");
     break;
 case 'create_archive':
     create_archive($_POST["archive_name"], rtrim($_POST["to"], '/') . '/', $_POST["extension"], $_POST["files"], $_POST["multiple"]);
     break;
 case 'extract_archive':
     extract_archive($_POST["archive_name"], rtrim($_POST["to"], '/') . '/', $_POST["archive_password"]);
     break;
 case 'properties':
     get_stat($_POST["name"], rtrim($_POST["to"], '/') . '/');
示例#22
-1
 $tempconfig = 'temp.' . GSCONFIGFILE;
 $init = GSROOTPATH . GSCONFIGFILE;
 $temp = GSROOTPATH . $tempconfig;
 if (file_exists($init)) {
     // config already exists
     if (file_exists($temp)) {
         delete_file($temp);
     }
     # remove temp file
     if (file_exists($temp)) {
         // failed to remove temp.gsonfig
         $err .= sprintf(i18n_r('REMOVE_TEMPCONFIG_ERROR'), $tempconfig) . '<br />';
     }
 } else {
     // copy temp.gsconfig to gsconfig
     rename_file($temp, $init);
     if (!file_exists($init)) {
         // failed to create gsconfig
         $err .= sprintf(i18n_r('MOVE_TEMPCONFIG_ERROR'), $tempconfig, GSCONFIGFILE) . '<br />';
     }
 }
 # send email to new administrator
 $subject = $site_full_name . ' ' . i18n_r('EMAIL_COMPLETE');
 $message .= '<p>' . i18n_r('EMAIL_USERNAME') . ': <strong>' . stripslashes($_POST['user']) . '</strong>';
 $message .= '<br>' . i18n_r('EMAIL_PASSWORD') . ': <strong>' . $random . '</strong>';
 $message .= '<br>' . i18n_r('EMAIL_LOGIN') . ': <a href="' . $SITEURL . $GSADMIN . '/">' . $SITEURL . $GSADMIN . '/</a></p>';
 $message .= '<p><em>' . i18n_r('EMAIL_THANKYOU') . ' ' . $site_full_name . '!</em></p>';
 $status = sendmail($EMAIL, $subject, $message);
 # activate default plugins
 foreach (explode(',', GSINSTALLPLUGINS) as $actplugin) {
     change_plugin($actplugin, true);
示例#23
-1
        $error .= msgError('Unable to update ' . GSWEBSITEFILE . ' file!');
    } else {
        $message .= msgOK('Created updated ' . GSWEBSITEFILE . ' file');
    }
    # rename old user.xml
    if (!file_exists(GSDATAOTHERPATH . '_legacy_user.xml')) {
        $status = rename_file(GSDATAOTHERPATH . 'user.xml', GSDATAOTHERPATH . '_legacy_user.xml');
        if (!$status) {
            $error .= msgError('Unable to rename user.xml to _legacy_user.xml');
        } else {
            $message .= msgOK('Renamed user.xml to _legacy_user.xml');
        }
    }
    # rename old cp_settings.xml
    if (!file_exists(GSDATAOTHERPATH . '_legacy_cp_settings.xml')) {
        $status = rename_file(GSDATAOTHERPATH . 'cp_settings.xml', GSDATAOTHERPATH . '_legacy_cp_settings.xml');
        if (!$status) {
            $error .= msgError('Unable to rename cp_settings.xml to _legacy_cp_settings.xml');
        } else {
            $message .= msgOK('Renamed cp_settings.xml to _legacy_cp_settings.xml');
        }
    }
    /* end update */
}
// redirect to health check or login and show updated notice
$redirect = cookie_check() ? "health-check.php?updated=1" : "index.php?updated=1";
// If no errors or messages, then we did nothing, just continue automatically
if (!isset($error) && !isset($message)) {
    redirect($redirect);
}
// we already showed a notice, pass updated so it gets deleted, no indication,
示例#24
-1
 public function two($app, $files, $twigArr, $config, $subdir, $filter, $transliteration, $thumbs_path, $get_params, Utility $util, $rfm_subfolder)
 {
     $files_prevent_duplicate = array();
     $html = "";
     foreach ($files as $nu => $file_array) {
         $file = $file_array['file'];
         if ($file == '.' || $file == '..' || is_dir($config['current_path'] . $rfm_subfolder . $subdir . $file) || in_array($file, $config['hidden_files']) || !in_array($util->fix_strtolower($file_array['extension']), $config['ext']) || $filter != '' && $n_files > $file_number_limit_js && stripos($file, $filter) === false) {
             continue;
         }
         $file_path = $config['current_path'] . $rfm_subfolder . $subdir . $file;
         //check if file have illegal caracter
         $filename = substr($file, 0, '-' . (strlen($file_array['extension']) + 1));
         if ($file != $util->fix_filename($file, $transliteration)) {
             $file1 = $util->fix_filename($file, $transliteration);
             $file_path1 = $this->current_path . $rfm_subfolder . $subdir . $file1;
             if (file_exists($file_path1)) {
                 $i = 1;
                 $info = pathinfo($file1);
                 while (file_exists($this->current_path . $rfm_subfolder . $subdir . $info['filename'] . ".[" . $i . "]." . $info['extension'])) {
                     $i++;
                 }
                 $file1 = $info['filename'] . ".[" . $i . "]." . $info['extension'];
                 $file_path1 = $this->current_path . $rfm_subfolder . $subdir . $file1;
             }
             $filename = substr($file1, 0, '-' . (strlen($file_array['extension']) + 1));
             rename_file($file_path, $util->fix_filename($filename, $transliteration), $transliteration);
             $file = $file1;
             $file_array['extension'] = $util->fix_filename($file_array['extension'], $transliteration);
             $file_path = $file_path1;
         }
         $is_img = false;
         $is_video = false;
         $is_audio = false;
         $show_original = false;
         $show_original_mini = false;
         $mini_src = "";
         $src_thumb = "";
         $extension_lower = $util->fix_strtolower($file_array['extension']);
         if ($extension_lower === 'svg') {
             //dont try mking thumb for svg file!
         } else {
             if (in_array($extension_lower, $config['ext_img'])) {
                 $src = $this->base_url . $this->cur_dir . rawurlencode($file);
                 $mini_src = $src_thumb = $thumbs_path . $subdir . $file;
                 //add in thumbs folder if not exist
                 if (!file_exists($src_thumb)) {
                     try {
                         if (!$util->create_img($file_path, $src_thumb, 122, 91)) {
                             $src_thumb = $mini_src = "";
                         } else {
                             $util->new_thumbnails_creation($this->current_path . $rfm_subfolder . $subdir, $file_path, $file, $this->current_path, '', '', '', '', '', '', '', $fixed_image_creation, $fixed_path_from_filemanager, $fixed_image_creation_name_to_prepend, $fixed_image_creation_to_append, $fixed_image_creation_width, $fixed_image_creation_height, $fixed_image_creation_option);
                         }
                     } catch (Exception $e) {
                         $src_thumb = $mini_src = "";
                     }
                 }
             }
             $is_img = true;
             //check if is smaller than thumb
             list($img_width, $img_height, $img_type, $attr) = @getimagesize($file_path);
             if ($img_width < 122 && $img_height < 91) {
                 $src_thumb = $this->cur_dir . $file;
                 //var_dump($src_thumb);
                 $show_original = true;
             }
             if ($img_width < 45 && $img_height < 38) {
                 $mini_src = $this->cur_dir . $rfm_subfolder . $subdir . $file;
                 //var_dump($mini_src);
                 //$mini_src=$this->current_path.$rfm_subfolder.$subdir.$file."sr";
                 $show_original_mini = true;
             }
             $twigArr['img_width'] = $img_width;
             $twigArr['img_height'] = $img_height;
             $twigArr['src'] = $src;
         }
         $is_icon_thumb = false;
         $is_icon_thumb_mini = false;
         $no_thumb = false;
         if ($src_thumb == "") {
             $no_thumb = true;
             if (file_exists('img/' . $config['icon_theme'] . '/' . $extension_lower . ".jpg")) {
                 $src_thumb = 'img/' . $config['icon_theme'] . '/' . $extension_lower . ".jpg";
             } else {
                 $src_thumb = "img/" . $config['icon_theme'] . "/default.jpg";
             }
             $is_icon_thumb = true;
         }
         if ($mini_src == "") {
             $is_icon_thumb_mini = false;
         }
         $class_ext = 0;
         if (in_array($extension_lower, $config['ext_video'])) {
             $class_ext = 4;
             $is_video = true;
         } elseif (in_array($extension_lower, $config['ext_img'])) {
             $class_ext = 2;
         } elseif (in_array($extension_lower, $config['ext_music'])) {
             $class_ext = 5;
             $is_audio = true;
         } elseif (in_array($extension_lower, $config['ext_misc'])) {
             $class_ext = 3;
         } else {
             $class_ext = 1;
         }
         $twigArr['class_ext'] = $class_ext;
         $twigArr['is_img'] = $is_img;
         $twigArr['is_audio'] = $is_audio;
         $twigArr['is_video'] = $is_video;
         $twigArr['is_icon_thumb'] = $is_icon_thumb;
         $twigArr['show_original'] = $show_original;
         $twigArr['src_thumb'] = $src_thumb;
         $twigArr['extension_lower'] = $extension_lower;
         $twigArr['mini_src'] = $mini_src;
         $twigArr['show_original_mini'] = $show_original_mini;
         $twigArr['is_icon_thumb_mini'] = $is_icon_thumb_mini;
         $twigArr['filename'] = $filename;
         $twigArr['nu'] = $nu;
         $file_prevent_rename = false;
         $file_prevent_delete = false;
         if (isset($filePermissions[$file])) {
             if (isset($filePermissions[$file]['prevent_duplicate']) && $filePermissions[$file]['prevent_duplicate']) {
                 $files_prevent_duplicate[] = $file;
             }
             $file_prevent_rename = isset($filePermissions[$file]['prevent_rename']) && $filePermissions[$file]['prevent_rename'];
             $file_prevent_delete = isset($filePermissions[$file]['prevent_delete']) && $filePermissions[$file]['prevent_delete'];
         }
         $twigArr['files_prevent_duplicate'][] = $file;
         $this->files_prevent_duplicate = $twigArr['files_prevent_duplicate'];
         $twigArr['file_prevent_delete'] = $file_prevent_delete;
         $twigArr['file_prevent_rename'] = $file_prevent_rename;
         $twigArr['file_array'] = $file_array;
         $twigArr['file'] = $file;
         //var_dump($twigArr['subdir']);
         $twigArr['file_array']['makeSize'] = $util->makeSize($file_array['size']);
         if (!($_GET['type'] == 1 && !$is_img) && !($_GET['type'] == 3 && !$is_video && ($_GET['type'] == 3 && !$is_audio)) && $class_ext > 0) {
             $template = 'FileManager/two/two.html.twig';
             $html = $html . $app['twig']->render($template, $twigArr);
             //template!
         }
     }
     return $html;
 }