<?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.')));
} $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'])) {
<?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);