当前位置: 首页>>代码示例>>PHP>>正文


PHP createFolder函数代码示例

本文整理汇总了PHP中createFolder函数的典型用法代码示例。如果您正苦于以下问题:PHP createFolder函数的具体用法?PHP createFolder怎么用?PHP createFolder使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了createFolder函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: createFolder

function createFolder($path)
{
    if (!file_exists($path)) {
        createFolder(dirname($path));
        mkdir($path, 0777);
    }
}
开发者ID:albertoquijano,项目名称:IdentidadEsMujer,代码行数:7,代码来源:face.php

示例2: createFolder

function createFolder($path)
{
    if (!is_dir($path)) {
        createFolder(dirname($path));
        @mkdir($path);
        @chmod($path, 0777);
    }
}
开发者ID:jechiy,项目名称:PHPWind,代码行数:8,代码来源:core.php

示例3: writetocache

 function writetocache($script, $file, $dir, $folder, $prefix = 'cache_')
 {
     global $authkey;
     if (!is_dir(ROOT_PATH . $folder . "/" . $dir)) {
         createFolder(ROOT_PATH . $folder . "/" . $dir, 0777);
     }
     if ($fp = @fopen(ROOT_PATH . $folder . "/" . $dir . "/{$prefix}{$file}.php", 'wb')) {
         fwrite($fp, "<?php\n//cache file, DO NOT modify me!" . "\n//Created: " . date("M j, Y, G:i") . "\n//Identify: " . md5($prefix . $file . '.php' . $authkey) . "\n\n{$script}?>");
         fclose($fp);
     } else {
         exit("Can not write to cache files, please check directory ./data/{$dir}.");
     }
 }
开发者ID:solarpwx,项目名称:Collector,代码行数:13,代码来源:cls_cache.php

示例4: createLink

function createLink($target, $link)
{
    if (!file_exists($target)) {
        throw new Exception("{$target} does not exists");
    }
    $link = rtrim($link, '/');
    if (file_exists($link)) {
        throw new Exception("{$link} exists but is not link");
    }
    $target = rtrim($target, '/');
    $folder = dirname($link);
    createFolder($folder);
    symlink($target, $link);
}
开发者ID:eridal,项目名称:cadenza,代码行数:14,代码来源:cadenza.php

示例5: pJAccesslist2

 /**
  * @Title: pJAccesslist
  * @Description: todo(任务节点权限生成)
  * @param $id int 任务节点id(以前用于生成数组key值,后改用控制器名称)
  * @param $actionname string 控制器名称
  * @author 谢友志
  * @date 2015-4-7 上午9:59:20
  * @throws
  */
 public function pJAccesslist2($actionname, $id = '')
 {
     //查找任务节点对应模板名称
     $Action = $actionname;
     //查找该模板名称对应记录
     $nodedetails = M("node")->where("name='" . $Action . "'")->find();
     if (!$nodedetails) {
         logs($Action . "---------没有对应模板------------", "taskNodeAccess");
     }
     //$nodeid = getFieldBy($action,"name","id","node");
     //查找该模板的操作节点
     $nodemodel = M("node");
     $list = $nodemodel->where("pid=" . $nodedetails['id'])->select();
     /**
      索引文件以“paaccess_”+任务节点id为key值 已对应模板名称为value值组成数组
     */
     if ($list) {
         //组合一个索引文件的元素 这里直接做成一个数组,后面与索引文件取得的数组进行合并
         $name = "pjaccess_" . $Action;
         //对操作节点数据进行重组$detailes
         $temp = array('GROUPID' => $nodedetails['group_id']);
         foreach ($list as $k => $v) {
             $optionname = strtoupper($v['name']);
             // 				if($optionname=="INDEX"){
             $temp1 = array($optionname => $v['id'] . "-1");
             // 				}else{
             // 					$temp1 = array($optionname=>$v['id']."-4");
             // 				}
             $temp = array_merge($temp, $temp1);
         }
         $detailes = array($Action => $temp);
         //套表 组合表情况下 添加权限详情元素
         $isbinddetailes = $this->pjAccessisbind($Action);
         $detailes = array_merge($detailes, $isbinddetailes);
         //暂时生成文件 其操作节点权限全部为1
         //任务节点权限文件夹
         $pathconf = DConfig_PATH . '/PJAccessList';
         if (!file_exists($pathconf)) {
             createFolder($pathconf);
         }
         //调用lookupobj模型的写入文件方法
         $lookupmodel = D("LookupObj");
         // 每个任务节点生成单独的文件
         $detailesfile = $pathconf . '/' . $name . '.php';
         $detailesnum = $lookupmodel->SetSongleRule($detailesfile, $detailes);
     } else {
         logs($Action . "=======没有对应下级操作========", "taskNodeAccess");
     }
 }
开发者ID:tmlsoft,项目名称:main,代码行数:58,代码来源:MisSystemFlowWorkModel.class.php

示例6: createFolders

function createFolders(&$drive_service, &$client, &$configObj, &$UsersAFSObj)
{
    // Recreate the user's AFS directory structure inside Box
    $afsFilesFolder = createFolder($drive_service, "AFS Migration Files", "Home for migrated files", "root", $configObj);
    $UsersAFSObj->folderList[$UsersAFSObj->afsPath] = $afsFilesFolder->getID();
    ++$UsersAFSObj->numFoldersUploaded;
    $logline = date('Y-m-d H:i:s') . " User's AFS Path: " . $UsersAFSObj->afsPath . "\n";
    $logline = date('Y-m-d H:i:s') . " Our root folder ID: " . $UsersAFSObj->folderList[$UsersAFSObj->afsPath] . "\n";
    fwrite($configObj->logFile, $logline);
    foreach ($UsersAFSObj->folderList as $key => $value) {
        // Avoid creating a folder for the root directory
        if (strcmp($key, $UsersAFSObj->afsPath) == 0) {
            continue;
        }
        // Make sure the folder still exists in AFS
        if (!file_exists($key)) {
            continue;
        }
        $parentFolderID = $UsersAFSObj->folderList[getParentFolder($key)];
        $logline = date('Y-m-d H:i:s') . " Parent folder name: " . getParentFolder($key) . "\n";
        $logline = $logline . date('Y-m-d H:i:s') . " Parent folder ID: " . $parentFolderID . "\n";
        fwrite($configObj->logFile, $logline);
        // See if the access token is about to expire
        if ($client->isAccessTokenExpired()) {
            //Trade access token for refresh token
            if ($client->refreshToken($configObj->refreshToken) == null) {
                $logline = date('Y-m-d H:i:s') . ": Using refresh token, access token granted. \n";
                fwrite($configObj->logFile, $logline);
            } else {
                $logline = date('Y-m-d H:i:s') . ": Unable to obtain access token. \n";
                fwrite($configObj->logFile, $logline);
            }
        }
        //Create folder
        $logline = date('Y-m-d H:i:s') . " The folder name: " . getFileName($key) . "\n";
        $folder = createFolder($drive_service, getFileName($key), "", $parentFolderID, $configObj);
        if ($folder) {
            //If creation worked, store folder ID for the file uploads
            ++$UsersAFSObj->numFoldersUploaded;
            $UsersAFSObj->folderList[$key] = $folder->getID();
            $logline = $logline . date('Y-m-d H:i:s') . " Success! The ID of this new folder is: " . $folder->getID() . "\n";
            fwrite($configObj->logFile, $logline);
        } else {
            $logline = $logline . date('Y-m-d H:i:s') . " The following folder could not be created: " . $folder->getID() . "\n";
            fwrite($configObj->logFile, $logline);
        }
    }
}
开发者ID:rakochi,项目名称:afs-migration-tool,代码行数:48,代码来源:GoogleDriveFuncs.php

示例7: createFolder

 function createFolder($dir, $recursive = true)
 {
     global $REX;
     if (is_dir($dir)) {
         return true;
     }
     $parent = dirname($dir);
     if (!is_dir($parent) && (!$recursive || !createFolder($parent))) {
         return false;
     }
     if (mkdir($dir, $REX['DIRPERM'])) {
         @chmod($dir, $REX['DIRPERM']);
         return true;
     }
     return false;
 }
开发者ID:Barnhiac,项目名称:MTW_REDAXO,代码行数:16,代码来源:function_folder.inc.php

示例8: copysubdir

function copysubdir($srcdir, $destdir)
{
    $dir = opendir($srcdir);
    while ($file = readdir($dir)) {
        if (!($file != ".") && !($file != "..")) {
            $dircontent = $srcdir . "/" . $file;
            if (is_dir($dircontent)) {
                if (!file_exists($destdir . "/" . $file)) {
                    createFolder($destdir . "/" . $file);
                }
                copyfiles($dircontent, $destdir . "/" . $file);
            }
        }
    }
    closedir($_dirrun);
}
开发者ID:TheProjecter,项目名称:webfmt,代码行数:16,代码来源:base.php

示例9: saveBrowseList

 static function saveBrowseList($authId = null)
 {
     if (null === $authId) {
         $authId = $_SESSION[C('USER_AUTH_KEY')];
     }
     // 如果使用普通权限模式,保存当前用户的访问权限列表
     // 管理员不生成浏览权限
     if (C('USER_AUTH_TYPE') != 2 && !$_SESSION[C('ADMIN_AUTH_KEY')]) {
         // 把权限写入文件通过文件判断
         //$file = DConfig_PATH . "/BrowsecList/borwse_" . $_SESSION [C ( 'USER_AUTH_KEY' )] . ".php"; ---xyz
         $file = DConfig_PATH . "/BrowsecList/borwse_" . $authId . ".php";
         //---xyz
         if (!file_exists($file)) {
             $browselist = Browse::getBrowseList($authId);
             if (!file_exists(DConfig_PATH . "/BrowsecList")) {
                 createFolder(dirname(DConfig_PATH . "/BrowsecList"));
                 mkdir(DConfig_PATH . "/BrowsecList", 0777);
             }
             Browse::writeover($file, "return " . Browse::pw_var_export($browselist) . ";\n", true);
         }
     }
     return;
 }
开发者ID:tmlsoft,项目名称:main,代码行数:23,代码来源:Browse.class.php

示例10: getMatrixFolderId

/**
* This function will get the the corresponding matrix id for a folder
* If the matrix is equal to zero it will make sure create the folder
* it will also make sure that all the parent folders are created in matrix
*
* @param string	$folder_path	folder's path
* @param array	&$matrix_ids	array containing all the matrix ids
*
* @return int
* @access private
*/
function getMatrixFolderId($folder_path, &$matrix_ids)
{
    if (empty($matrix_ids[$folder_path])) {
        $folder_to_create = array();
        array_push($folder_to_create, $folder_path);
        while (!empty($folder_to_create)) {
            // take current folder and get its parent
            // if the parent folder has a matrix id then create the folder
            // if the parent folder doesnt add the parent folder to the $folder_to_create list
            $current_folder = array_pop($folder_to_create);
            // if the current folder is empty means that we went too far
            if (empty($current_folder)) {
                trigger_error("We could not found the asset id for the folder {$folder_path}", E_USER_ERROR);
            }
            $parent_folder = dirname($current_folder);
            if (!empty($matrix_ids[$parent_folder])) {
                $matrix_ids[$current_folder] = createFolder($matrix_ids[$parent_folder], basename($current_folder));
            } else {
                array_push($folder_to_create, $parent_folder);
            }
        }
    }
    return $matrix_ids[$folder_path];
}
开发者ID:joshgillies,项目名称:mysource-matrix,代码行数:35,代码来源:import_files.php

示例11: insert

 public function insert()
 {
     global $CONFIG;
     $post = $_POST;
     $message = '';
     $tbl_locn = 'locn';
     $tbl_indiv = 'indiv';
     $tbl_obs = 'obs';
     $tbl_img = 'img';
     $data[$tbl_locn] = array('locality' => $post['locality']);
     $data[$tbl_indiv] = array('personID' => $post['personID']);
     $data[$tbl_obs] = array('personID' => $post['personID'], 'localname' => $post['localname']);
     $data[$tbl_img] = array();
     $insertLocn = $this->mspecimen->insertTransaction($tbl_locn, $data[$tbl_locn]);
     $locn_id = $insertLocn['lastid'];
     $data[$tbl_indiv]['locnID'] = $locn_id;
     $insertIndiv = $this->mspecimen->insertTransaction('indiv', $data[$tbl_indiv]);
     $indiv_id = $insertIndiv['lastid'];
     $data[$tbl_obs]['indivID'] = $indiv_id;
     $data[$tbl_img]['indivID'] = $indiv_id;
     $data[$tbl_img]['personID'] = $post['personID'];
     $insertObs = $this->mspecimen->insertTransaction('obs', $data[$tbl_obs]);
     $name = 'image';
     $path = '';
     $uploaded_file = uploadFile($name, $path, 'image');
     //if uploaded
     if ($uploaded_file['status'] != '0') {
         logFile('Upload Success');
         if (extension_loaded('gd') && function_exists('gd_info')) {
             logFile('GD2 is installed. Checking image data.');
             $tmp_name = $uploaded_file['full_name'];
             $entry = str_replace(array('\'', '"'), '', $uploaded_file['real_name']);
             $image_name_encrypt = md5(str_shuffle($CONFIG['default']['salt'] . $entry));
             //check filename
             //$dataExist = $this->mspecimen->imageExist($personID, $entry);
             $path_entry = $CONFIG['default']['upload_path'];
             $src_tmp = $path_entry . "/" . $tmp_name;
             logFile('Prepare to cropping image');
             $path_data = 'public_assets/';
             //$path_user = $path_data.$username;
             $path_img = $path_data . '/img';
             $path_img_1000px = $path_img . '/1000px';
             $path_img_500px = $path_img . '/500px';
             $path_img_100px = $path_img . '/100px';
             $fileinfo = getimagesize($path_entry . '/' . $tmp_name);
             $toCreate = array($path_img, $path_img_1000px, $path_img_500px, $path_img_100px);
             createFolder($toCreate, 0755);
             copy($path_entry . "/" . $tmp_name, $path_img_1000px . '/' . $image_name_encrypt . '.1000px.jpg');
             if (!@copy($path_entry . "/" . $tmp_name, $path_img_1000px . '/' . $image_name_encrypt . '.1000px.jpg')) {
                 logFile('Copy file failed');
                 $status = "error";
                 $msg = error_get_last();
             } else {
                 logFile('Copy file success');
                 $dest_1000px = $CONFIG['default']['root_path'] . '/' . $path_img_1000px . '/' . $image_name_encrypt . '.1000px.jpg';
                 $dest_500px = $CONFIG['default']['root_path'] . '/' . $path_img_500px . '/' . $image_name_encrypt . '.500px.jpg';
                 $dest_100px = $CONFIG['default']['root_path'] . '/' . $path_img_100px . '/' . $image_name_encrypt . '.100px.jpg';
                 if ($fileinfo[0] >= 1000 || $fileinfo[1] >= 1000) {
                     if ($fileinfo[0] > $fileinfo[1]) {
                         $percentage = 1000 / $fileinfo[0];
                         $config['width'] = $percentage * $fileinfo[0];
                         $config['height'] = $percentage * $fileinfo[1];
                     } else {
                         $percentage = 1000 / $fileinfo[1];
                         $config['width'] = $percentage * $fileinfo[0];
                         $config['height'] = $percentage * $fileinfo[1];
                     }
                     $this->resize_pic($src_tmp, $dest_1000px, $config);
                     unset($config);
                 }
                 logFile('Cropping to 1000px image');
                 //Set cropping for y or x axis, depending on image orientation
                 if ($fileinfo[0] > $fileinfo[1]) {
                     $config['width'] = $fileinfo[1];
                     $config['height'] = $fileinfo[1];
                     $config['x_axis'] = $fileinfo[0] / 2 - $config['width'] / 2;
                     $config['y_axis'] = 0;
                 } else {
                     $config['width'] = $fileinfo[0];
                     $config['height'] = $fileinfo[0];
                     $config['x_axis'] = 0;
                     $config['y_axis'] = $fileinfo[1] / 2 - $config['height'] / 2;
                 }
                 $this->cropToSquare($src_tmp, $dest_500px, $config);
                 unset($config);
                 logFile('Cropping to square image');
                 //set new config
                 $config['width'] = 500;
                 $config['height'] = 500;
                 $this->resize_pic($dest_500px, $dest_500px, $config);
                 unset($config);
                 logFile('Cropping to 500px image');
                 $config['width'] = 100;
                 $config['height'] = 100;
                 $this->resize_pic($dest_500px, $dest_100px, $config);
                 unset($config);
                 logFile('Cropping to 100px image');
                 //add file information to array
                 /*$fileToInsert = array('filename' => $entry,'md5sum' => $image_name_encrypt, 'directory' => '', 'mimetype' => $fileinfo['mime']);
                   
//.........这里部分代码省略.........
开发者ID:Gunadarma-Codecamp,项目名称:peer-website,代码行数:101,代码来源:specimen.php

示例12: makeDatabase


//.........这里部分代码省略.........
				$state = mysql_escape_string($details[9]);
				$postcode = mysql_escape_string($details[10]);
				$interests = mysql_escape_string($details[11]);
			}

			//	 todo: code location of upload directory into sysIdentification, remove from edit form (should not be changed)
			//	 todo: might wish to control ownership rather than leaving it to the O/S, although this works well at present

			$warnings = 0;

			// Create a default upload directory for uploaded files eg multimedia, images etc.
			$uploadPath = HEURIST_UPLOAD_ROOT.$newDBName;//TODO: This locks us into upload path. This is teh place for DB override.
			$cmdline = "mkdir -p -m a=rwx ".$uploadPath;
			$output2 = exec($cmdline . ' 2>&1', $output, $res2);
			if ($res2 != 0 ) { // TODO: need to properly trap the error and distiguish different versions.
				// Old uplaod directories hanging around could cause problems if upload file IDs are duplicated,
				// so should probably NOT allow their re-use
				echo ("<h3>Warning:</h3> Unable to create $uploadPath directory for database $newDBName<br>&nbsp;<br>");
				echo ("This may be because the directory already exists or the parent folder is not writable<br>");
				echo ("Please check/create directory by hand. Consult Heurist helpdesk if needed<br>");
				echo($output2);
				$warnings = 1;
			}

			// copy icon and thumbnail directories from default set in the program code (sync. with H3CoreDefinitions)
			$cmdline = "cp -R rectype-icons $uploadPath"; // creates directories and copies icons and thumbnails
			$output2 = exec($cmdline . ' 2>&1', $output, $res2);
			if ($res2 != 0 ) {
				echo ("<h3>Warning:</h3> Unable to create/copy record type icons folder rectype-icons to $uploadPath<br>");
				echo ("If upload directory was created OK, this is probably due to incorrect file permissions on new folders<br>");
				echo($output2);
				$warnings = 1;
			}
			// copy smarty template directory from default set in the program code
			$cmdline = "cp -R smarty-templates $uploadPath";
			$output2 = exec($cmdline . ' 2>&1', $output, $res2);
			if ($res2 != 0 ) {
				echo ("<h3>Warning:</h3> Unable to create/copy smarty-templates folder to $uploadPath<br>");
				echo($output2);
				$warnings = 1;
			}

			if($isExtended){
				// copy xsl template directories from default set in the program code
				$cmdline = "cp -R xsl-templates $uploadPath";
				$output2 = exec($cmdline . ' 2>&1', $output, $res2);
				if ($res2 != 0 ) {
					echo ("<h3>Warning:</h3> Unable to create/copy xsl-templates folder to $uploadPath<br>");
					echo($output2);
					$warnings = 1;
				}
			}

			$warnings =+ createFolder("settings","used to store import mappings and the like");
			$warnings =+ createFolder("scratch","used to store temporary files");
			$warnings =+ createFolder("hml-output","used to write published records as hml files");
			$warnings =+ createFolder("html-output","used to write published records as generic html files");
			$warnings =+ createFolder("generated-reports","used to write generated reports");

			if ($warnings > 0) {
				echo "<h2>Please take note of warnings above</h2>";
				echo "You must create the folders indicated or uploads, icons and templates will not work<br>";
				echo "If upload folder is created but icons and template forlders are not, look at file permissions on new folder creation";
			}

			// Prepare to write to the newly created database
			mysql_connection_insert($newname);

			// Update file locations
			$query='update sysIdentification
			    set sys_hmlOutputDirectory = "'.$uploadPath.'/hml-output",
			    sys_htmlOutputDirectory = "'.$uploadPath.'/html-output"';
  			mysql_query($query);
			if (mysql_error()) {
				echo "<h3>Warning: </h3> Unable to update sysIdentification table - please go to DBAdmin > Databases > Properties &".
				" Advanced Properties, and check the path to the upload, hml and html directories. (".mysql_error().")";
			}

			// Make the current user the owner and admin of the new database
			mysql_query('UPDATE sysUGrps SET ugr_LongName="'.$longName.'", ugr_FirstName="'.$firstName.'",
			ugr_LastName="'.$lastName.'", ugr_eMail="'.$eMail.'", ugr_Name="'.$name.'",
			ugr_Password="'.$password.'", ugr_Department="'.$department.'", ugr_Organisation="'.$organisation.'",
			ugr_City="'.$city.'", ugr_State="'.$state.'", ugr_Postcode="'.$postcode.'",
			ugr_interests="'.$interests.'" WHERE ugr_ID=2');
			// TODO: error check, although this is unlikely to fail

			echo "<h2>New database '$newDBName' created successfully</h2>";

			echo "<p><strong>Admin username:</strong> ".$name."<br />";
			echo "<strong>Admin password:</strong> &#60;<i>same as account currently logged in to</i>&#62;</p>";

			echo "<p>You may wish to bookmark the database home page (search page): <a href=\"".HEURIST_BASE_URL."?db=".$newDBName."\" title=\"\" target=\"_new\">".HEURIST_BASE_URL."?db=".$newDBName."</a>.</p>";
			echo "<p><a href='".HEURIST_BASE_URL."admin/adminMenu.php?db=".$newDBName."' title='' target=\"_new\" style='font-size:1.2em;font-weight:bold'>Go to Administration page</a>, to configure your new database</p>";

			// TODO: automatically redirect to the new database, maybe, in a new window

			return false;
		} // isset

	} //makedatabase
开发者ID:beoutsports,项目名称:heurist-v3-1,代码行数:101,代码来源:createNewDB.php

示例13: strJSON

    }
    // 对象转换为JSON字符串
    $sFilesInfo = strJSON($filesInfo);
    $jsonFile = json_decode($sFilesInfo);
    // 拼装接口消息体
    $oMsg = new message(true, "OK", $jsonFile);
    echo $oMsg;
} elseif ('mkdir_dir' === $act) {
    if ('' === $dir) {
        $oMsg = new message(false, "file_dir_name操作参数错误。");
        echo $oMsg;
        exit;
    }
    $dir = ltrim($dir, HOME_FILE);
    $dir = HOME_PRO . HOME_FILE . DS . $dir;
    $msg = createFolder($dir);
    if ("文件夹创建成功" === $msg) {
        // 文件夹创建成功
        $oMsg = new message(true, $msg);
        echo $oMsg;
    } else {
        // 文件夹创建出现异常
        $oMsg = new message(false, $msg);
        echo $oMsg;
    }
} elseif ('mkdir_file' === $act) {
    if ('' === $dir) {
        $oMsg = new message(false, "file_dir_name操作参数错误。");
        echo $oMsg;
        exit;
    }
开发者ID:001-pace,项目名称:fileManagerWeb,代码行数:31,代码来源:doAction.php

示例14: elseif

\t</form>
EOF;
    echo $str;
} elseif ($act == "doRename") {
    //实现重命名的操做
    $newname = $_REQUEST['newname'];
    $mes = renameFile($filename, $newname);
    alertMes($mes, $redirect);
} elseif ($act == "delFile") {
    $mes = delFile($filename);
    alertMes($mes, $redirect);
} elseif ($act == "downFile") {
    //完成下载的操作
    $mes = downFile($filename);
} elseif ($act == "创建文件夹") {
    $mes = createFolder($path . "/" . $dirname);
    alertMes($mes, $redirect);
} elseif ($act == "renameFolder") {
    $str = <<<EOF
\t\t\t<form action="index.php?act=doRenameFolder" method="post"> 
\t请填写新文件夹名称:<input type="text" name="newname" placeholder="重命名"/>
\t<input type="hidden" name="path" value="{$path}" />
\t<input type='hidden' name='dirname' value='{$dirname}' />
\t<input type="submit" value="重命名"/>
\t</form>
EOF;
    echo $str;
} elseif ($act == "doRenameFolder") {
    $newname = $_REQUEST['newname'];
    //echo $newname,"-",$dirname,"-",$path;
    $mes = renameFolder($dirname, $path . "/" . $newname);
开发者ID:vipmorgana,项目名称:PHP,代码行数:31,代码来源:index.php

示例15: fetch_folder

 /**
  * @todo fetch folder function basedomain/zip/extract
  * 
  * @see createFolder Function
  * @see getContents Function
  * @see resize & crop Function
  * @see validateUsername Function
  * @see imagezip class
  * 
  * */
 function fetch_folder($status = NULL, $msg = NULL, $data = NULL)
 {
     global $CONFIG;
     $name = $_POST['imagezip'];
     $path = '';
     $path_folder = $CONFIG['default']['root_data'];
     //get data user from session
     $session = new Session();
     $sess_data = $session->get_session();
     $username = $sess_data['login']['username'];
     $personID = $sess_data['login']['id'];
     $password = $sess_data['login']['password'];
     if (empty($username) || empty($personID) || empty($password)) {
         $status = "error";
         $msg = "Kesalahan terjadi saat validasi data pengguna, silakan logout kemudian login kembali";
         echo json_encode(array('status' => $status, 'message' => $msg));
         exit;
     }
     if (!empty($name)) {
         $file = $path_folder . $name;
         //check file zip exist
         if (!is_dir($file)) {
             $status = "error";
             $msg = "Sistem tidak dapat menemukan folder yang ditentukan";
             echo json_encode(array('status' => $status, 'message' => $msg));
             exit;
         }
         $path_data = 'public_assets/';
         //$path_user = $path_data.$username;
         $path_img = $path_data . '/img';
         $path_img_ori = $path_img . '/ori';
         $path_img_1000px = $path_img . '/1000px';
         $path_img_500px = $path_img . '/500px';
         $path_img_100px = $path_img . '/100px';
         $toCreate = array($path_img, $path_img_ori, $path_img_1000px, $path_img_500px, $path_img_100px);
         $permissions = 0755;
         if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
             createFolder($toCreate, $permissions);
         } else {
             shell_createFolder($toCreate);
         }
         $images = $this->GetContents($file);
         $list = count($images);
         $dataNotExist = array();
         foreach ($images as $image) {
             $entry = $image['filename'];
             $path_entry = $image['path'];
             $len = strlen($file);
             $folder = substr($path_entry, $len);
             if (preg_match('#\\.(jpg|jpeg|JPG|JPEG)$#i', $entry)) {
                 $image_name_encrypt = md5(str_shuffle($CONFIG['default']['salt'] . $entry));
                 $fileinfo = getimagesize($path_entry . '/' . $entry);
                 if (!$fileinfo) {
                     $status = "error";
                     $msg = "Tidak ada informasi jenis berkas";
                 } else {
                     $valid_types = array(IMAGETYPE_JPEG);
                     $valid_mime = array('image/jpeg');
                     if (in_array($fileinfo[2], $valid_types) || in_array($fileinfo['mime'], $valid_mime)) {
                         $mime = true;
                     } else {
                         $mime = false;
                     }
                     if ($mime) {
                         //check file exist here
                         //$dataExist = $this->imagezip->dataExist($entry);
                         $dataExist = $this->imagezip->imageExist($entry);
                         //add file information to array
                         $fileToInsert = array('filename' => $entry, 'md5sum' => $image_name_encrypt, 'directory' => $folder, 'mimetype' => $fileinfo['mime']);
                         if ($dataExist) {
                             //get detail image
                             $detail_image = $this->imagezip->get_image_by_name($entry);
                             if ($detail_image['md5sum']) {
                                 $delete_image = array($path_img_ori . '/' . $detail_image['md5sum'] . '.ori.jpg', $path_img_1000px . '/' . $detail_image['md5sum'] . '.1000px.jpg', $path_img_500px . '/' . $detail_image['md5sum'] . '.500px.jpg', $path_img_100px . '/' . $detail_image['md5sum'] . '.100px.jpg');
                                 //delete old image
                                 $this->delete_img($delete_image);
                             }
                             copy($path_entry . "/" . $entry, $path_img_ori . '/' . $image_name_encrypt . '.ori.jpg');
                             copy($path_entry . "/" . $entry, $path_img_1000px . '/' . $image_name_encrypt . '.1000px.jpg');
                             if (!@copy($path_entry . "/" . $entry, $path_img_1000px . '/' . $image_name_encrypt . '.1000px.jpg')) {
                                 $status = "error";
                                 $msg = error_get_last();
                             } else {
                                 $src_tmp = $path_entry . "/" . $entry;
                                 $dest_1000px = $CONFIG['default']['root_path'] . '/' . $path_img_1000px . '/' . $image_name_encrypt . '.1000px.jpg';
                                 $dest_500px = $CONFIG['default']['root_path'] . '/' . $path_img_500px . '/' . $image_name_encrypt . '.500px.jpg';
                                 $dest_100px = $CONFIG['default']['root_path'] . '/' . $path_img_100px . '/' . $image_name_encrypt . '.100px.jpg';
                                 if ($fileinfo[0] >= 1000 || $fileinfo[1] >= 1000) {
                                     if ($fileinfo[0] > $fileinfo[1]) {
                                         $percentage = 1000 / $fileinfo[0];
//.........这里部分代码省略.........
开发者ID:Gunadarma-Codecamp,项目名称:peer-website,代码行数:101,代码来源:zip.php


注:本文中的createFolder函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。