function notifyBackupFile($user, $fileName) { $fileUrl = File::url($fileName); $body = sprintf(_m("The backup file you requested is ready for download.\n\n" . "%s\n" . "Thanks for your time,\n", "%s\n"), $fileUrl, common_config('site', 'name')); $headers = _mail_prepare_headers('offlinebackup', $user->nickname, $user->nickname); mail_to_user($user, _('Backup file ready for download'), $body, $headers); }
public function testURLConstruction() { $root = new Root(); $root->setScheme('s://'); $root->addDirectory($dir = new Directory('dir')); $dir->addDirectory($dir = new Directory('dir')); $dir->addFile($file = new File('file')); $this->assertEquals('s://dir/dir/file', $file->url()); }
public static function url($path_origin) { $config = Config::get(); $path = self::path($path_origin); $url = File::url($path); if (strpos($path, ROOT) === false) { return strpos($url, '://') !== false ? Filter::apply('asset:url', $url . ($config->resource_versioning && strpos($url, $config->url) === 0 ? '?' . sprintf(ASSET_VERSION_FORMAT, filemtime($path)) : ""), $path_origin) : false; } return file_exists($path) ? Filter::apply('asset:url', $url . ($config->resource_versioning ? '?' . sprintf(ASSET_VERSION_FORMAT, filemtime($path)) : ""), $path_origin) : false; }
public static function url($source) { $config = Config::get(); $source = Filter::colon('asset:source', $source); $path = Filter::colon('asset:path', self::path($source, false)); $url = File::url($path); if ($path && strpos($path, ROOT) === false) { return strpos($url, '://') !== false || strpos($url, '//') === 0 ? Filter::colon('asset:url', $url, $source) : false; } return $path && file_exists($path) ? Filter::colon('asset:url', $url, $source) : false; }
function storeFile() { $file = new File(); $file->filename = $this->filename; $file->url = File::url($this->filename); $filepath = File::path($this->filename); $file->size = filesize($filepath); $file->date = time(); $file->mimetype = $this->mimetype; $file_id = $file->insert(); if (!$file_id) { common_log_db_error($file, "INSERT", __FILE__); throw new ClientException(_('There was a database error while saving your file. Please try again.')); } return $file; }
/** * Handle the request * * @return void */ protected function handle() { parent::handle(); $profile = $this->user->getProfile(); $base64img = $this->img; if (stristr($base64img, 'image/jpeg')) { $base64img_mime = 'image/jpeg'; } elseif (stristr($base64img, 'image/png')) { // should convert to jpg here!! $base64img_mime = 'image/png'; } $base64img = str_replace('data:image/jpeg;base64,', '', $base64img); $base64img = str_replace('data:image/png;base64,', '', $base64img); $base64img = str_replace(' ', '+', $base64img); $base64img_hash = md5($base64img); $base64img = base64_decode($base64img); $base64img_basename = basename('bg'); $base64img_filename = File::filename($profile, $base64img_basename, $base64img_mime); $base64img_path = File::path($base64img_filename); $base64img_success = file_put_contents($base64img_path, $base64img); $base64img_mimetype = MediaFile::getUploadedMimeType($base64img_path, $base64img_filename); $mediafile = new MediaFile($profile, $base64img_filename, $base64img_mimetype); $imagefile = new ImageFile($mediafile->fileRecord->id, File::path($mediafile->filename)); $imagefile->resizeTo(File::path($mediafile->filename), array('width' => 1280, 'height' => 1280, 'x' => $this->cropX, 'y' => $this->cropY, 'w' => $this->cropW, 'h' => $this->cropH)); $result['url'] = File::url($mediafile->filename); Profile_prefs::setData($profile, 'qvitter', 'background_image', $result['url']); $this->initDocument('json'); $this->showJsonObjects($result); $this->endDocument('json'); }
/** * Generate and store a thumbnail image for the uploaded file, if applicable. * * @return File_thumbnail or null */ function storeThumbnail() { if (substr($this->mimetype, 0, strlen('image/')) != 'image/') { // @fixme video thumbs would be nice! return null; } try { $image = new ImageFile($this->fileRecord->id, File::path($this->filename)); } catch (Exception $e) { // Unsupported image type. return null; } $outname = File::filename($this->user->getProfile(), 'thumb-' . $this->filename, $this->mimetype); $outpath = File::path($outname); $maxWidth = common_config('attachments', 'thumb_width'); $maxHeight = common_config('attachments', 'thumb_height'); list($width, $height) = $this->scaleToFit($image->width, $image->height, $maxWidth, $maxHeight); $image->resizeTo($outpath, $width, $height); File_thumbnail::saveThumbnail($this->fileRecord->id, File::url($outname), $width, $height); }
/** * Format the attachment placeholder img with the final version. * * @param DOMElement $img * @param MediaFile $media */ private function formatAttachment($img, $media) { $parent = $img->parentNode; $dom = $img->ownerDocument; $link = $dom->createElement('a'); $link->setAttribute('href', $media->fileurl); $link->setAttribute('title', File::url($media->filename)); if ($this->isEmbeddable($media)) { // Fix the the <img> attributes and wrap the link around it... $this->insertImage($img, $media); $parent->replaceChild($link, $img); //it dies in here?! $link->appendChild($img); } else { // Not an image? Replace it with a text link. $link->setAttribute('rel', 'external'); $link->setAttribute('class', 'attachment'); $link->setAttribute('id', 'attachment-' . $media->fileRecord->id); $text = $dom->createTextNode($media->shortUrl()); $link->appendChild($text); $parent->replaceChild($link, $img); } }
/** * ============================================================ * URL REDIRECTION * ============================================================ * * -- CODE: --------------------------------------------------- * * Guardian::kick('manager/login'); * * ------------------------------------------------------------ * */ public static function kick($path = "") { $path = Converter::url(File::url($path)); $path = Filter::apply('guardian:kick', $path); $G = array('data' => array('url' => $path)); Session::set('url_origin', Config::get('url_current')); Weapon::fire('before_kick', array($G, $G)); header('Location: ' . $path); exit; }
/** * Handle the request * * @return void */ protected function handle() { parent::handle(); $profile = $this->user->getProfile(); // see if we have regular uploaded image data try { $mediafile = MediaFile::fromUpload('banner', $profile); } catch (NoUploadedMediaException $e) { // if not we may have base64 data $img = $this->img; if (stristr($img, 'image/jpeg')) { $img_mime = 'image/jpeg'; } elseif (stristr($img, 'image/png')) { // should convert to jpg here!! $img_mime = 'image/png'; } // i don't remember why we had to do this $img = str_replace('data:image/jpeg;base64,', '', $img); $img = str_replace('data:image/png;base64,', '', $img); $img = str_replace(' ', '+', $img); $img = base64_decode($img, true); try { $img_filename = File::filename($profile, 'cover', $img_mime); $img_path = File::path($img_filename); $img_success = file_put_contents($img_path, $img); $img_mimetype = MediaFile::getUploadedMimeType($img_path, $img_filename); $mediafile = new MediaFile($profile, $img_filename, $img_mimetype); } catch (Exception $e) { $this->clientError($e, 400); } } if (!$mediafile instanceof MediaFile) { $this->clientError(_('Could not process image data.'), 400); } // maybe resize $width = $this->cropW; $height = $this->cropH; $scale = 1; if ($width > 1200) { $scale = 1200 / $width; } elseif ($height > 600) { $scale = 600 / $height; } $width = round($width * $scale); $height = round($height * $scale); // crop try { $imagefile = new ImageFile($mediafile->fileRecord->id, File::path($mediafile->filename)); $imagefile->resizeTo(File::path($mediafile->filename), array('width' => $width, 'height' => $height, 'x' => $this->cropX, 'y' => $this->cropY, 'w' => $this->cropW, 'h' => $this->cropH)); $result['url'] = File::url($mediafile->filename); } catch (Exception $e) { $this->clientError(_('The image could not be resized and cropped. ' . $e), 422); } // save in profile_prefs try { Profile_prefs::setData($profile, 'qvitter', 'cover_photo', $result['url']); } catch (ServerException $e) { $this->clientError(_('The image could not be resized and cropped. ' . $e), 422); } // return json $this->initDocument('json'); $this->showJsonObjects($result); $this->endDocument('json'); }
/** * Show configured logo. * * @return nothing */ function showLogo() { $this->elementStart('address', array('id' => 'site_contact', 'class' => 'vcard')); if (Event::handle('StartAddressData', array($this))) { if (common_config('singleuser', 'enabled')) { $user = User::singleUser(); $url = common_local_url('showstream', array('nickname' => $user->nickname)); } else { $url = common_local_url('public'); } $this->elementStart('a', array('class' => 'url home bookmark', 'href' => $url)); if (StatusNet::isHTTPS()) { $logoUrl = common_config('site', 'ssllogo'); if (empty($logoUrl)) { // if logo is an uploaded file, try to fall back to HTTPS file URL $httpUrl = common_config('site', 'logo'); if (!empty($httpUrl)) { $f = File::staticGet('url', $httpUrl); if (!empty($f) && !empty($f->filename)) { // this will handle the HTTPS case $logoUrl = File::url($f->filename); } } } } else { $logoUrl = common_config('site', 'logo'); } if (empty($logoUrl) && file_exists(Theme::file('logo.png'))) { // This should handle the HTTPS case internally $logoUrl = Theme::path('logo.png'); } if (!empty($logoUrl)) { $this->element('img', array('class' => 'logo photo', 'src' => $logoUrl, 'alt' => common_config('site', 'name'))); } $this->text(' '); $this->element('span', array('class' => 'fn org'), common_config('site', 'name')); $this->elementEnd('a'); Event::handle('EndAddressData', array($this)); } $this->elementEnd('address'); }
<div class="grid col-9"> <div class="row"> <form action="" method="post" enctype="multipart/form-data" > <p><?php if (isset($confirm) && $confirm > 0) { echo "Modificación exitosa"; } ?> </p> <h3>Ingrese la imagen de fondo</h3> <input type="file" name="background" accept="image/*"> <br> <br> <input type="submit" value="Enviar" class="btn"> <input type="hidden" name="add" val=""> </form> <h3>Preview</h3> <img src="<?php echo File::url(Config::option('bgtestimonios')); ?> " alt="Preview imagen testimonios"> </div> </div> </div> </div> <?php require "template/footer.php";
</p> <?php } ?> <p> <?php if ($e === 'cache') { ?> <?php echo Form::hidden('name', File::url($the_name)); ?> <?php } else { ?> <?php echo Form::text('name', Guardian::wayback('name', File::url($the_name)), $speak->manager->placeholder_file_name); ?> <?php } ?> <?php if (strpos($config->url_path, '/repair/file:') === false) { ?> <?php echo Jot::button('construct', $speak->create); ?> <?php } else { ?> <?php echo Jot::button('action', $is_text ? $speak->update : $speak->rename);
protected function storeFile() { $filepath = File::path($this->filename); if (!empty($this->filename) && $this->filehash === null) { // Calculate if we have an older upload method somewhere (Qvitter) that // doesn't do this before calling new MediaFile on its local files... $this->filehash = hash_file(File::FILEHASH_ALG, $filepath); if ($this->filehash === false) { throw new ServerException('Could not read file for hashing'); } } try { $file = File::getByHash($this->filehash); // We're done here. Yes. Already. We assume sha256 won't collide on us anytime soon. return $file; } catch (NoResultException $e) { // Well, let's just continue below. } $fileurl = File::url($this->filename); $file = new File(); $file->filename = $this->filename; $file->urlhash = File::hashurl($fileurl); $file->url = $fileurl; $file->filehash = $this->filehash; $file->size = filesize($filepath); if ($file->size === false) { throw new ServerException('Could not read file to get its size'); } $file->date = time(); $file->mimetype = $this->mimetype; $file_id = $file->insert(); if ($file_id === false) { common_log_db_error($file, "INSERT", __FILE__); // TRANS: Client exception thrown when a database error was thrown during a file upload operation. throw new ClientException(_('There was a database error while saving your file. Please try again.')); } // Set file geometrical properties if available try { $image = ImageFile::fromFileObject($file); $orig = clone $file; $file->width = $image->width; $file->height = $image->height; $file->update($orig); // We have to cleanup after ImageFile, since it // may have generated a temporary file from a // video support plugin or something. // FIXME: Do this more automagically. if ($image->getPath() != $file->getPath()) { $image->unlink(); } } catch (ServerException $e) { // We just couldn't make out an image from the file. This // does not have to be UnsupportedMediaException, as we can // also get ServerException from files not existing etc. } return $file; }
static function url($filename) { // TODO: Store thumbnails in their own directory and don't use File::url here return File::url($filename); }
?> <div class="media<?php if (!$c) { ?> no-capture<?php } ?> " id="shield:<?php echo $folder; ?> "> <?php if ($c) { ?> <div class="media-capture" style="background-image:url('<?php echo File::url($c); ?> ?v=<?php echo filemtime($c); ?> ');" role="image"></div> <?php } ?> <h4 class="media-title"><?php echo Jot::icon('shield') . ' ' . $page->title; ?> </h4> <div class="media-content"> <?php if (preg_match('#<blockquote(>| .*?>)\\s*([\\s\\S]*?)\\s*<\\/blockquote>#', $page->content, $matches)) {
<table class="table-bordered table-full-width"> <tbody> <?php if ($files) { ?> <?php foreach ($files as $file) { ?> <?php $url = File::url(str_replace($c_path, "", $file->path)); ?> <tr<?php echo Session::get('recent_file_update') === File::B($file->path) ? ' class="active"' : ""; ?> > <td><?php echo strpos($url, '/') !== false ? Jot::span('fade', File::D($url) . '/') . File::B($url) : $url; ?> </td> <td class="td-icon"> <?php echo isset($c_url_repair) && $c_url_repair !== false ? Jot::a('construct', $c_url_repair . $url, Jot::icon('pencil'), array('title' => $speak->edit)) : Jot::icon('pencil'); ?> </td> <td class="td-icon"> <?php echo isset($c_url_kill) && $c_url_kill !== false ? Jot::a('destruct', $c_url_kill . $url, Jot::icon('times'), array('title' => $speak->delete)) : Jot::icon('times'); ?> </td> </tr> <?php
$G = array('data' => array('path' => $file)); Config::set(array('page_title' => $speak->editing . ': ' . File::B($path) . $config->title_separator . $config->manager->title, 'cargo' => 'repair.cache.php')); if ($request = Request::post()) { $request = Filter::apply('request:__cache', $request, $file); Guardian::checkToken($request['token']); $P = array('data' => $request); File::open($file)->write($request['content'])->save(0600); Notify::success(Config::speak('notify_file_updated', '<code>' . $path . '</code>')); Session::set('recent_item_update', explode(DS, $path)); $name = File::path($request['name']); if ($name !== $path) { File::open($file)->moveTo(CACHE . DS . $name); Guardian::kick($config->manager->slug . '/cache/1'); } Weapon::fire(array('on_cache_update', 'on_cache_repair'), array($G, $P)); Guardian::kick($config->manager->slug . '/cache/repair/file:' . File::url($request['name'])); } Shield::lot(array('segment' => 'cache', 'path' => $path, 'content' => File::open($file)->read()))->attach('manager'); }); /** * Cache Killer * ------------ */ Route::accept($config->manager->slug . '/cache/kill/(file|files):(:all)', function ($prefix = "", $file = "") use($config, $speak) { if (!Guardian::happy(1)) { Shield::abort(); } $path = File::path($file); if (strpos($path, ';') !== false) { $deletes = explode(';', $path); } else {
if (trim($request['name']) === "") { $request['name'] = $id . '.txt'; // empty file name } $_path = Text::parse(sprintf($request['name'], $id), '->safe_path_name'); $e = File::E($_path, false); if ($e !== 'txt' && $e !== 'php') { $e = 'txt'; $_path .= '.txt'; } $_path_ = File::path($_path); $file = ASSET . DS . '__snippet' . DS . $e . DS . $_path; if (File::exist($file)) { // file already exists Notify::error(Config::speak('notify_file_exist', '<code>' . $_path_ . '</code>')); } if (trim($request['content']) === "") { // empty file content Notify::error($speak->notify_error_content_empty); } if (!Notify::errors()) { $recent = array_slice(File::open(CACHE . DS . 'plugin.snippet.cache')->unserialize(), 0, $config->per_page); File::serialize(array_merge(array($_path), $recent))->saveTo(CACHE . DS . 'plugin.snippet.cache', 0600); $url = $config->manager->slug . '/asset/repair/file:__snippet/' . $e . '/' . File::url($_path) . '?path=' . urlencode(rtrim('__snippet/' . $e . '/' . File::D(File::url($_path)), '/')); File::write($request['content'])->saveTo($file, 0600); Notify::success(Config::speak('notify_file_created', '<code>' . $_path_ . '</code>' . (!isset($request['redirect']) ? ' <a class="pull-right" href="' . $config->url . '/' . $url . '" target="_blank">' . Jot::icon('pencil') . ' ' . $speak->edit . '</a>' : ""))); Notify::info('<strong>' . $speak->shortcode . ':</strong> <code>{{' . ($e === 'php' ? 'include' : 'print') . ':' . str_replace('.' . $e . X, "", File::url($_path) . X) . '}}</code>'); Guardian::kick(isset($request['redirect']) ? $url : File::D($config->url_current)); } Guardian::kick(File::D($config->url_current)); });
</p> <p><?php echo Form::checkbox('redirect', 1, Request::method('get') ? false : Guardian::wayback('redirect', false), Config::speak('manager.description_redirect_to_', $speak->file)); ?> </p> </form> </div> <div class="tab-content hidden" id="tab-content-2"> <?php $_files = array(); foreach (File::open(CACHE . DS . 'plugin.snippet.cache')->unserialize() as $_file) { $e = File::E($_file); if (!file_exists(ASSET . DS . '__snippet' . DS . $e . DS . $_file)) { continue; } $_files[] = File::url($_file); } ?> <?php if (!empty($_files)) { ?> <table class="table-bordered table-full-width"> <tbody> <?php foreach ($_files as $_file) { ?> <?php $e = File::E($_file); ?> <tr> <td><a href="javascript:do_snippet('<?php
$P = array('data' => $request); if (!Notify::errors()) { $s = $_file !== false ? $_file : $_folder . DS . $name; File::write($request['content'])->saveTo($s); if ($path !== false && $path !== $name) { File::open($s)->moveTo($_folder . DS . $name); } // Remove empty folder(s) $f = glob(File::D($s) . DS . '*', GLOB_NOSORT); if (empty($f)) { File::open(File::D($s))->delete(); } Notify::success(Config::speak('notify_file_' . ($file === false ? 'created' : 'updated'), '<code>' . File::B($name) . '</code>')); Session::set('recent_item_update', File::B($name)); Weapon::fire(array('on_shield_update', 'on_shield_repair'), array($G, $P)); Guardian::kick($config->manager->slug . '/shield/' . $folder . ($file !== false ? '/repair/file:' . File::url($name) : "")); } } Shield::lot(array('segment' => 'shield', 'folder' => $folder, 'path' => $path, 'content' => $content))->attach('manager'); }); /** * Shield Killer * ------------- */ Route::accept(array($config->manager->slug . '/shield/kill/id:(:any)', $config->manager->slug . '/shield/(:any)/kill/file:(:all)'), function ($folder = false, $file = false) use($config, $speak) { if (!Guardian::happy(1) || $folder === "") { Shield::abort(); } $info = Shield::info($folder); $path = $file !== false ? File::path($file) : false; if ($file !== false) {
} } else { // Missing file extension Notify::error($speak->notify_error_file_extension_missing); } } $P = array('data' => $request); if (!Notify::errors()) { File::open($file)->write($request['content'])->save(); if ($path !== $name) { File::open($file)->moveTo(SHIELD . DS . $folder . DS . $name); } Notify::success(Config::speak('notify_file_updated', '<code>' . File::B($path) . '</code>')); Weapon::fire('on_shield_update', array($G, $P)); Weapon::fire('on_shield_repair', array($G, $P)); Guardian::kick($config->manager->slug . '/shield/' . $folder . '/repair/file:' . File::url($name)); } } Shield::lot(array('segment' => 'shield', 'the_shield' => $folder, 'the_name' => $path, 'the_content' => $content))->attach('manager', false); }); /** * Shield Killer * ------------- */ Route::accept(array($config->manager->slug . '/shield/kill/id:(:any)', $config->manager->slug . '/shield/(:any)/kill/file:(:all)'), function ($folder = "", $path = false) use($config, $speak) { if (Guardian::get('status') !== 'pilot' || $folder === "") { Shield::abort(); } $info = Shield::info($folder, true); if ($path) { $path = File::path($path);
if (File::exist($d . DS . $folder)) { Notify::error(Config::speak('notify_folder_exist', '<code>' . $folder . '</code>')); } } else { Notify::error(Config::speak('notify_error_empty_field', $speak->folder)); } if (!Notify::errors()) { File::pocket($d . DS . $folder); Notify::success(Config::speak('notify_folder_created', '<code>' . $folder . '</code>')); $fo = explode(DS, $folder); Session::set('recent_file_update', $fo[0]); $P = array('data' => $request); Weapon::fire('on_asset_update', array($P, $P)); Weapon::fire('on_asset_construct', array($P, $P)); if (isset($request['redirect'])) { $folder = File::url($folder); Guardian::kick($config->manager->slug . '/asset/' . $offset . '?path=' . urlencode($p ? $p . '/' . $folder : $folder)); } Guardian::kick($config->manager->slug . '/asset/' . $offset); } else { Weapon::add('SHIPMENT_REGION_BOTTOM', function () { echo '<script> (function($) { $(\'.tab-area .tab[href$="#tab-content-2"]\').trigger("click"); })(window.Zepto || window.jQuery); </script>'; }, 11); } // New file } else { if (isset($_FILES) && !empty($_FILES)) {
* ============================================================= * * -- CODE: ---------------------------------------------------- * * Config::load(); * * ------------------------------------------------------------- * */ Config::plug('load', function () { // Extract the configuration file $config = Get::state_config(); // Define some default variable(s) $config['protocol'] = $config['url_protocol'] = !empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off' || $_SERVER['SERVER_PORT'] === 443 ? 'https://' : 'http://'; $config['host'] = $config['url_host'] = $_SERVER['HTTP_HOST']; $config['base'] = $config['url_base'] = trim(File::url(File::D($_SERVER['SCRIPT_NAME'])), '/'); $config['url'] = rtrim($config['protocol'] . $config['host'] . '/' . $config['base'], '/'); $config['url_path'] = trim(str_replace('/?', '?', $_SERVER['REQUEST_URI']), '/') === $config['base'] . '?' . trim('?' . $_SERVER['QUERY_STRING'], '/?') ? "" : preg_replace('#[?&].*$#', "", trim('?' . $_SERVER['QUERY_STRING'], '/?')); $config['url_current'] = rtrim($config['url'] . '/' . $config['url_path'], '/'); $config['page_title'] = $config['title']; $config['index_query'] = $config['tag_query'] = $config['archive_query'] = $config['search_query'] = ""; $config['articles'] = $config['article'] = $config['pages'] = $config['page'] = $config['responses'] = $config['response'] = $config['files'] = $config['file'] = $config['pagination'] = $config['cargo'] = false; $config['total_articles'] = count(glob(ARTICLE . DS . '*.txt', GLOB_NOSORT)); $config['total_pages'] = count(glob(PAGE . DS . '*.txt', GLOB_NOSORT)); $config['total_comments'] = count(glob(RESPONSE . DS . '*.txt', GLOB_NOSORT)); $config['total_articles_backend'] = count(glob(ARTICLE . DS . '*.{txt,draft,archive}', GLOB_NOSORT | GLOB_BRACE)); $config['total_pages_backend'] = count(glob(PAGE . DS . '*.{txt,draft,archive}', GLOB_NOSORT | GLOB_BRACE)); $config['total_comments_backend'] = count(glob(RESPONSE . DS . '*.{txt,hold}', GLOB_NOSORT | GLOB_BRACE)); $page = '404'; $path = $config['url_path']; $s = explode('/', $path);
<?php $hooks = array($page, $segment); echo $messages; ?> <form class="form-repair form-cache" id="form-repair" action="<?php echo $config->url_current . $config->url_query; ?> " method="post"> <?php echo Form::hidden('token', $token); ?> <?php $e = File::E($path !== false ? $path : ""); $is_text = $path === false || strpos(',' . SCRIPT_EXT . ',', ',' . $e . ',') !== false; $path = File::url($path); ?> <?php if ($is_text && $content !== false) { ?> <p> <?php echo Form::textarea('content', Request::get('content', Guardian::wayback('content', $content)), $speak->manager->placeholder_content, array('class' => array('textarea-block', 'textarea-expand', 'code'))); ?> </p> <?php } ?> <p> <?php echo Form::hidden('name', $path);
/** * Returns the srcset attribute value for a given Kirby file * Generates thumbnails on the fly * * @param File $file * @uses kirby_get_sources_array * @uses thumb * * @return string */ function kirby_get_srcset($file) { $srcset = $file->url() . ' ' . $file->width() . 'w'; $sources_arr = kirby_get_sources_array($file); foreach ($sources_arr as $source) { $thumb = thumb($file, $source); $srcset .= ', ' . $thumb->url() . ' ' . $thumb->width() . 'w'; } return $srcset; }
<?php // First installation ... if ($installer = File::exist(ROOT . DS . 'install.php')) { Config::load(); Guardian::kick(File::url($installer)); }
<a class="tab-button ajax-post" href="#tab-content-preview" data-action-url="<?php echo $config->url . '/' . $config->manager->slug . '/ajax/preview:' . File::url(str_replace(ROOT . DS, "", File::D(__DIR__, 3))) . '/' . (is_array($segment) ? $segment[0] : $segment); ?> " data-text-progress="<p><?php echo $speak->previewing; ?> …</p>" data-text-error="<p><?php echo $speak->error; ?> .</p>" data-scope="#form-<?php echo $page->id ? 'repair' : 'ignite'; ?> " data-target="#form-<?php echo $page->id ? 'repair' : 'ignite'; ?> -preview"><?php echo Jot::icon('eye', 'fw') . ' ' . $speak->preview; ?> </a>
/** * Store the full-length scrubbed HTML of a remote notice to an attachment * file on our server. We'll link to this at the end of the cropped version. * * @param string $title plaintext for HTML page's title * @param string $rendered HTML fragment for HTML page's body * @return File */ function saveHTMLFile($title, $rendered) { $final = sprintf("<!DOCTYPE html>\n" . '<html><head>' . '<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">' . '<title>%s</title>' . '</head>' . '<body>%s</body></html>', htmlspecialchars($title), $rendered); $filename = File::filename($this->localProfile(), 'ostatus', 'text/html'); $filepath = File::path($filename); $fileurl = File::url($filename); file_put_contents($filepath, $final); $file = new File(); $file->filename = $filename; $file->urlhash = File::hashurl($fileurl); $file->url = $fileurl; $file->size = filesize($filepath); $file->date = time(); $file->mimetype = 'text/html'; $file_id = $file->insert(); if ($file_id === false) { common_log_db_error($file, "INSERT", __FILE__); // TRANS: Server exception. throw new ServerException(_m('Could not store HTML content of long post as file.')); } return $file; }
<table class="table-bordered table-full-width"> <tbody> <?php $origins = array(Jot::icon('database', 'fw') . ' ' . $speak->site => '.', Jot::icon('file-text', 'fw') . ' ' . $speak->article => str_replace(CARGO . DS, "", ARTICLE), Jot::icon('file', 'fw') . ' ' . $speak->page => str_replace(CARGO . DS, "", PAGE), Jot::icon('magnet', 'fw') . ' ' . $speak->extend => str_replace(CARGO . DS, "", EXTEND), Jot::icon('comments', 'fw') . ' ' . $speak->comment => str_replace(CARGO . DS, "", COMMENT), Jot::icon('cogs', 'fw') . ' ' . $speak->config => str_replace(CARGO . DS, "", STATE), Jot::icon('briefcase', 'fw') . ' ' . $speak->asset => str_replace(CARGO . DS, "", ASSET), Jot::icon('shield', 'fw') . ' ' . $speak->shield => str_replace(CARGO . DS, "", SHIELD), Jot::icon('plug', 'fw') . ' ' . $speak->plugin => str_replace(CARGO . DS, "", PLUGIN)); ?> <?php foreach ($origins as $title => $origin) { ?> <tr> <td><?php echo $title; ?> </td> <td class="td-icon"> <?php echo Cell::a($config->url_current . '/origin:' . File::url($origin), Jot::icon('download'), null, array('title' => $speak->download)); ?> </td> </tr> <?php } ?> </tbody> </table> </div> <div class="tab-content hidden" id="tab-content-2"> <h3><?php echo $speak->restore; ?> </h3> <?php