本文整理汇总了PHP中FileManager::verify_file方法的典型用法代码示例。如果您正苦于以下问题:PHP FileManager::verify_file方法的具体用法?PHP FileManager::verify_file怎么用?PHP FileManager::verify_file使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FileManager
的用法示例。
在下文中一共展示了FileManager::verify_file方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: header
<?php
/**
* Save the changes from Aviary for an image.
*/
$this->require_admin();
$page->layout = false;
header('Content-Type: application/json');
if (!isset($_GET['file'])) {
echo json_encode(array('success' => false, 'error' => __('No file specified.')));
return;
}
if (!FileManager::verify_file($_GET['file'])) {
echo json_encode(array('success' => false, 'error' => __('Invalid file.')));
return;
}
if (!isset($_GET['url'])) {
echo json_encode(array('success' => false, 'error' => __('No image url specified.')));
return;
}
$res = fetch_url($_GET['url']);
if (!$res) {
echo json_encode(array('success' => false, 'error' => __('Updated image not found.')));
return;
}
if (!file_put_contents(conf('Paths', 'filemanager_path') . '/' . $_GET['file'], $res)) {
echo json_encode(array('success' => false, 'error' => __('Unable to write to the file. Please check your folder permissions and try again.')));
return;
}
echo json_encode(array('success' => true, 'data' => __('File saved.')));
示例2: isset
}
$data['width'] = isset($data['width']) && is_numeric($data['width']) ? $data['width'] : 300;
$data['height'] = isset($data['height']) && is_numeric($data['height']) ? $data['height'] : 200;
$data['alt'] = isset($data['alt']) ? $data['alt'] : '';
$data['class'] = isset($data['class']) ? $data['class'] : false;
if (!isset($data['key'])) {
echo '<!-- Error: Missing key value -->';
return;
}
if (!$this->internal) {
if (isset($data['photo'])) {
if (!preg_match('|^/files/|', $data['photo'])) {
$data['photo'] = null;
} else {
$photo = preg_replace('|^/files/|', '', $data['photo']);
if (!FileManager::verify_file($photo)) {
$data['photo'] = null;
}
}
} else {
$data['photo'] = null;
}
}
$data['photo'] = Image::for_key($data['key'], $data['photo']);
if ((!isset($data['link']) || !$data['link'] || $data['link'] === '') && $data['photo'] !== null) {
$photo = preg_replace('|^/files/|', '', $data['photo']);
$data['link'] = FileManager::prop($photo, 'link');
}
if ($data['photo']) {
$data['src'] = '/' . Image::resize($data['photo'], $data['width'], $data['height'], 'cover', 'ext');
} elseif (isset($data['default'])) {
示例3: preg_replace
<?php
if (!$this->internal) {
return;
}
if (!isset($data['mp4'])) {
return;
}
if (!preg_match('|^/files/|', $data['mp4'])) {
return;
}
$mp4 = preg_replace('|^/files/|', '', $data['mp4']);
if (!FileManager::verify_file($mp4)) {
return;
}
$data['width'] = isset($data['width']) ? $data['width'] : 952;
$data['height'] = isset($data['height']) ? $data['height'] : 536;
$page->add_style('//vjs.zencdn.net/4.12/video-js.css');
$page->add_script('//vjs.zencdn.net/4.12/video.js');
echo $tpl->render('videojs/embed', $data);