本文整理汇总了PHP中PerchUtil::set_file_permissions方法的典型用法代码示例。如果您正苦于以下问题:PHP PerchUtil::set_file_permissions方法的具体用法?PHP PerchUtil::set_file_permissions怎么用?PHP PerchUtil::set_file_permissions使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PerchUtil
的用法示例。
在下文中一共展示了PerchUtil::set_file_permissions方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: move_uploaded_file
public static function move_uploaded_file($filename, $destination)
{
$r = move_uploaded_file($filename, $destination);
PerchUtil::set_file_permissions($destination);
return $r;
}
示例2: resize_image
//.........这里部分代码省略.........
if ($image_w / $target_w > $image_h / $target_h) {
$new_w = $target_w;
$new_h = $target_w / $image_ratio;
} else {
$new_h = $target_h;
$new_w = $target_h * $image_ratio;
}
} else {
if ($image_w > $image_h) {
$new_w = $target_w;
$new_h = $target_w / $image_ratio;
}
if ($image_h > $image_w) {
$new_h = $target_h;
$new_w = $target_h * $image_ratio;
}
}
}
// Default
if (!isset($new_w)) {
$new_w = $image_w;
$new_h = $image_h;
}
// Prepare returned array
$out = array();
$out['w'] = (int) $new_w;
$out['h'] = (int) $new_h;
$out['file_path'] = $save_as;
$parts = explode(DIRECTORY_SEPARATOR, $save_as);
$out['file_name'] = array_pop($parts);
$out['web_path'] = str_replace(PERCH_RESFILEPATH . DIRECTORY_SEPARATOR, PERCH_RESPATH . '/', $save_as);
$out['density'] = $this->density;
// If SVG, we can return at this point.
if ($svg) {
$out['mime'] = $svg;
return $out;
}
if ($crop) {
if ($crop_w) {
$out['w'] = (int) $crop_w;
}
if ($crop_h) {
$out['h'] = (int) $crop_h;
}
}
// Check we're not upsizing
if ($crop) {
if ($crop_w > $image_w || $crop_h > $image_h) {
$bail = true;
}
} else {
if ($new_w > $image_w || $new_h > $image_h) {
$bail = true;
}
}
// Check we're not resizing to the same exact size, as this just kills quality
if ($crop) {
if ($crop_w == $image_w && $crop_h == $image_h) {
$bail = true;
}
} else {
if ($new_w == $image_w && $new_h == $image_h) {
$bail = true;
}
}
// Bail?
if ($bail) {
copy($image_path, $save_as);
PerchUtil::set_file_permissions($save_as);
// reset sizes
$out['w'] = (int) $image_w;
$out['h'] = (int) $image_h;
$Perch->event('assets.create_image', new PerchAssetFile($out));
return $out;
}
// Density
$new_w = floor($new_w * $this->density);
$new_h = floor($new_h * $this->density);
$crop_w = floor($crop_w * $this->density);
$crop_h = floor($crop_h * $this->density);
$crop_x = floor($crop_x * $this->density);
$crop_y = floor($crop_y * $this->density);
//PerchUtil::debug('Density: '.$this->density);
$r = false;
if ($this->mode == 'gd') {
$r = $this->resize_with_gd($image_path, $save_as, $new_w, $new_h, $crop_w, $crop_h, $crop_x, $crop_y);
}
if ($this->mode == 'imagick') {
$r = $this->resize_with_imagick($image_path, $save_as, $new_w, $new_h, $crop_w, $crop_h, $crop_x, $crop_y);
}
if ($r) {
$out['mime'] = $r;
}
PerchUtil::set_file_permissions($save_as);
$Perch->event('assets.create_image', new PerchAssetFile($out));
if ($r) {
return $out;
}
return false;
}
示例3: die
}
} else {
die('{"jsonrpc" : "2.0", "error" : {"code": 101, "message": "Failed to open input stream."}, "id" : "id"}');
}
fclose($in);
fclose($out);
} else {
die('{"jsonrpc" : "2.0", "error" : {"code": 102, "message": "Failed to open output stream."}, "id" : "id"}');
}
}
// If it's the last chunk
if ($chunks == 0 || $chunk == $chunks - 1) {
$newFileName = str_replace('_uploading_', '', $fileName);
rename($targetDir . DIRECTORY_SEPARATOR . $fileName, $targetDir . DIRECTORY_SEPARATOR . $newFileName);
$albumID = (int) $_REQUEST["albumID"];
$API = new PerchAPI(1.0, 'perch_gallery');
$Images = new PerchGallery_Images($API);
$Template = $API->get('Template');
$Template->set('gallery/image.html', 'gallery');
$data = array();
$data['imageAlt'] = PerchUtil::strip_file_extension($newFileName);
$data['albumID'] = $albumID;
$Image = $Images->create($data);
if (is_object($Image)) {
$Image->process_versions($newFileName, $Template);
}
PerchUtil::set_file_permissions($targetDir . DIRECTORY_SEPARATOR . $newFileName);
//file_put_contents(__DIR__.'/log.txt', strip_tags(PerchUtil::output_debug(true)));
}
// Return JSON-RPC response
die('{"jsonrpc" : "2.0", "result" : null, "id" : "id"}');