fn_set_notification('N', __('notice'), __('cache_cleared')); if (empty($_REQUEST['redirect_url'])) { $_REQUEST['redirect_url'] = 'index.index'; } return array(CONTROLLER_STATUS_REDIRECT); } elseif ($mode == 'clear_thumbnails') { Storage::instance('images')->deleteDir('thumbnails'); fn_set_notification('N', __('notice'), __('thumbnails_removed')); if (empty($_REQUEST['redirect_url'])) { $_REQUEST['redirect_url'] = 'index.index'; } return array(CONTROLLER_STATUS_REDIRECT); } elseif ($mode == 'cdn') { $stored_cdn_data = fn_restore_post_data('cdn_data'); if (Cdn::instance()->getOption('is_active') === false && Cdn::instance()->isActive()) { Cdn::instance()->save(array('is_active' => true)); fn_set_notification('N', __('notice'), __('text_cdn_setup')); } if (Cdn::instance()->getHost()) { Registry::get('view')->assign('cdn_test_url', 'http://' . Cdn::instance()->getHost() . '/js/tygh/core.js'); } if (!empty($stored_cdn_data)) { Registry::get('view')->assign('cdn_data', $stored_cdn_data); } else { Registry::get('view')->assign('cdn_data', Cdn::instance()->getOptions()); } } function fn_get_amazon_regions() { return array('s3.amazonaws.com' => 'US Standard', 's3-us-west-2.amazonaws.com' => 'Oregon', 's3-us-west-1.amazonaws.com' => 'Northern California', 's3-eu-west-1.amazonaws.com' => 'Ireland', 's3-ap-southeast-1.amazonaws.com' => 'Singapore', 's3-sa-east-1.amazonaws.com' => 'Sao Paulo', 's3-ap-northeast-1.amazonaws.com' => 'Tokyo', 's3-ap-southeast-2.amazonaws.com' => 'Sydney'); }
/** * Get file URL * * @param string $file file to get URL * @return string file URL */ public function getUrl($file = '', $protocol = '') { if (strpos($file, '://') !== false) { return $file; } if ($this->getOption('cdn') && Cdn::instance()->getOption('is_enabled')) { if ($protocol == 'http') { $prefix = 'http:'; } elseif ($protocol == 'https') { $prefix = 'https:'; } elseif ($protocol == 'short') { $prefix = ''; } else { $prefix = defined('HTTPS') ? 'https:' : 'http:'; } $prefix .= '//' . Cdn::instance()->getHost('host'); } else { if ($protocol == 'http') { $prefix = Registry::get('config.http_location'); } elseif ($protocol == 'https') { $prefix = Registry::get('config.https_location'); } elseif ($protocol == 'short') { $prefix = '//' . Registry::get('config.http_host') . Registry::get('config.http_path'); // FIXME } else { $prefix = Registry::get('config.current_location'); } } $path = str_replace(Registry::get('config.dir.root'), '', $this->prefix($file)); return $prefix . $path; }
/** * Get file URL * * @param string $file file to get URL * @return string file URL */ public function getUrl($file = '', $protocol = '') { if (strpos($file, '://') !== false) { return $file; } $is_cdn = $this->getOption('cdn') && Cdn::instance()->getOption('is_enabled'); if ($is_cdn) { if ($protocol == 'http') { $prefix = 'http:'; } elseif ($protocol == 'https') { $prefix = 'https:'; } elseif ($protocol == 'short') { $prefix = ''; } else { $prefix = defined('HTTPS') ? 'https:' : 'http:'; } $prefix .= '//' . Cdn::instance()->getHost('host'); } else { if ($protocol == 'http') { $prefix = Registry::get('config.http_location'); } elseif ($protocol == 'https') { $prefix = Registry::get('config.https_location'); } elseif ($protocol == 'short') { $prefix = '//' . Registry::get('config.http_host') . Registry::get('config.http_path'); // FIXME } else { $prefix = Registry::get('config.current_location'); } } if ($is_cdn) { $real_file = $this->getAbsolutePath($file); if (is_file($real_file)) { // add timestamp to files only, skip dirs $file .= '?t=' . filemtime($real_file); } } $path = str_replace(Registry::get('config.dir.root'), '', $this->prefix($file)); return $prefix . $path; }
fn_set_notification('N', __('notice'), __('cache_cleared')); if (empty($_REQUEST['redirect_url'])) { $_REQUEST['redirect_url'] = 'index.index'; } return array(CONTROLLER_STATUS_REDIRECT); } elseif ($mode == 'clear_thumbnails') { Storage::instance('images')->deleteDir('thumbnails'); fn_set_notification('N', __('notice'), __('thumbnails_removed')); if (empty($_REQUEST['redirect_url'])) { $_REQUEST['redirect_url'] = 'index.index'; } return array(CONTROLLER_STATUS_REDIRECT); } elseif ($mode == 'cdn') { $stored_cdn_data = fn_restore_post_data('cdn_data'); if (Cdn::instance()->getOption('is_active') === false && Cdn::instance()->isActive()) { Cdn::instance()->save(array('is_active' => true)); fn_set_notification('N', __('notice'), __('text_cdn_setup')); } if (Cdn::instance()->getHost()) { Tygh::$app['view']->assign('cdn_test_url', 'http://' . Cdn::instance()->getHost() . '/js/tygh/core.js'); } if (!empty($stored_cdn_data)) { Tygh::$app['view']->assign('cdn_data', $stored_cdn_data); } else { Tygh::$app['view']->assign('cdn_data', Cdn::instance()->getOptions()); } } function fn_get_amazon_regions() { return array('s3.amazonaws.com' => 'US Standard', 's3-us-west-2.amazonaws.com' => 'Oregon', 's3-us-west-1.amazonaws.com' => 'Northern California', 's3-eu-west-1.amazonaws.com' => 'Ireland', 's3-ap-southeast-1.amazonaws.com' => 'Singapore', 's3-sa-east-1.amazonaws.com' => 'Sao Paulo', 's3-ap-northeast-1.amazonaws.com' => 'Tokyo', 's3-ap-southeast-2.amazonaws.com' => 'Sydney'); }