本文整理汇总了PHP中isUrl函数的典型用法代码示例。如果您正苦于以下问题:PHP isUrl函数的具体用法?PHP isUrl怎么用?PHP isUrl使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了isUrl函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getPreview
/**
* Gets the preview for a video
* @param string $id YouTube ID or url
* @return string
* @uses getId()
*/
public static function getPreview($id)
{
if (isUrl($id)) {
$id = self::getId($id);
}
return sprintf('http://img.youtube.com/vi/%s/0.jpg', $id);
}
示例2: cleanVar
function cleanVar($var)
{
if (!isUrl($var)) {
$var = "NONE";
}
return $var;
}
示例3: setUrl
private function setUrl()
{
if (!isUrl($this->input['url'])) {
$this->errorOutput(strtoupper('illegal_url'));
}
$this->url = trim($this->input['url']);
}
示例4: setUrl
private function setUrl()
{
if (!isUrl("http://" . $this->input['url']) && !isUrl("https://" . $this->input['url'])) {
$this->errorOutput(strtoupper('illegal_url'));
}
$this->url = trim($this->input['url']);
$this->ip = gethostbyname($this->input['url']);
}
示例5: url
public function url(string $url = '') : Ajax
{
// Veri bir url içermiyorsa siteUrl yöntemi ile url'ye dönüştürülür.
if (!isUrl($url)) {
$url = siteUrl($url);
}
$this->sets['url'] = "\turl:\"{$url}\"," . EOL;
return $this;
}
示例6: _render
/**
* Internal function to render a thumbnail
* @param string $target Target file
* @return \Cake\Network\Response|null|void
*/
protected function _render($target)
{
if (isUrl($target)) {
return $this->redirect($target);
}
$this->autoRender = false;
//Renders the thumbnail
header(sprintf('Content-type: %s', mime_content_type($target)));
readfile($target);
exit;
}
示例7: url
public function url($url = '')
{
if (!is_string($url)) {
Error::set(lang('Error', 'stringParameter', '1.(url)'));
return $this;
}
// Veri bir url içermiyorsa siteUrl yöntemi ile url'ye dönüştürülür.
if (!isUrl($url)) {
$url = siteUrl($url);
}
$this->sets['url'] = "\turl:\"{$url}\"," . eol();
return $this;
}
示例8: smarty_function_include_file
/**
* Includes a file in template. Handy for adding html files to tpl files
*
* @param array $Params The parameters passed into the function.
* The parameters that can be passed to this function are as follows.
* - <b>name</b>: The name of the file.
* @param Smarty $Smarty The smarty object rendering the template.
* @return string The rendered asset.
*/
function smarty_function_include_file($Params, &$Smarty)
{
$Name = ltrim(val('name', $Params), '/');
if (strpos($Name, '..') !== false) {
return '<!-- Error, moving up directory path not allowed -->';
}
if (isUrl($Name)) {
return '<!-- Error, urls are not allowed -->';
}
$filename = rtrim($Smarty->template_dir, '/') . '/' . $Name;
if (!file_exists($filename)) {
return '<!-- Error, file does not exist -->';
}
return file_get_contents($filename);
}
示例9: do
public function do(string $email = NULL, string $returnLinkPath = NULL) : bool
{
$email = Properties::$parameters['email'] ?? $email;
$returnLinkPath = Properties::$parameters['returnLink'] ?? $returnLinkPath;
Properties::$parameters = [];
// ------------------------------------------------------------------------------
// Settings
// ------------------------------------------------------------------------------
$tableName = INDIVIDUALSTRUCTURES_USER_CONFIG['matching']['table'];
$senderInfo = INDIVIDUALSTRUCTURES_USER_CONFIG['emailSenderInfo'];
$getColumns = INDIVIDUALSTRUCTURES_USER_CONFIG['matching']['columns'];
$usernameColumn = $getColumns['username'];
$passwordColumn = $getColumns['password'];
$emailColumn = $getColumns['email'];
// ------------------------------------------------------------------------------
if (!empty($emailColumn)) {
DB::where($emailColumn, $email);
} else {
DB::where($usernameColumn, $email);
}
$row = DB::get($tableName)->row();
if (isset($row->{$usernameColumn})) {
if (!isUrl($returnLinkPath)) {
$returnLinkPath = siteUrl($returnLinkPath);
}
$encodeType = INDIVIDUALSTRUCTURES_USER_CONFIG['encode'];
$newPassword = Encode::create(10);
$encodePassword = !empty($encodeType) ? Encode::type($newPassword, $encodeType) : $newPassword;
$templateData = array('usernameColumn' => $row->{$usernameColumn}, 'newPassword' => $newPassword, 'returnLinkPath' => $returnLinkPath);
$message = Import::template('UserEmail/ForgotPassword', $templateData, true);
Email::sender($senderInfo['mail'], $senderInfo['name'])->receiver($email, $email)->subject(lang('IndividualStructures', 'user:newYourPassword'))->content($message);
if (Email::send()) {
if (!empty($emailColumn)) {
DB::where($emailColumn, $email);
} else {
DB::where($usernameColumn, $email);
}
if (DB::update($tableName, [$passwordColumn => $encodePassword])) {
return $this->success = lang('IndividualStructures', 'user:forgotPasswordSuccess');
}
return !($this->error = lang('Database', 'updateError'));
} else {
return !($this->error = lang('IndividualStructures', 'user:emailError'));
}
} else {
return !($this->error = lang('IndividualStructures', 'user:forgotPasswordError'));
}
}
示例10: _getPreview
/**
* Gets the image preview (virtual field)
* @return string|null
* @uses MeTools\Utility\Youtube::getId()
* @uses MeTools\Utility\Youtube::getPreview()
*/
protected function _getPreview()
{
if (empty($this->_properties['text'])) {
return null;
}
//Checks for the first image in the text
preg_match('#<\\s*img [^\\>]*src\\s*=\\s*(["\'])(.*?)\\1#im', $this->_properties['text'], $matches);
if (!empty($matches[2])) {
return Router::url($matches[2], true);
}
//Checks for a YouTube video and its preview
preg_match('/\\[youtube](.+?)\\[\\/youtube]/', $this->_properties['text'], $matches);
if (!empty($matches[1])) {
return Youtube::getPreview(isUrl($matches[1]) ? Youtube::getId($matches[1]) : $matches[1]);
}
return null;
}
示例11: redirect
function redirect(string $url, int $time = 0, array $data = [], bool $exit = true)
{
if (!isUrl($url)) {
$url = siteUrl($url);
}
if (!empty($data)) {
foreach ($data as $k => $v) {
Session::insert('redirect:' . $k, $v);
}
}
if ($time > 0) {
sleep($time);
}
header("Location: {$url}", true);
if ($exit === true) {
exit;
}
}
示例12: __construct
/**
* Construct.
* It sets the origin file.
*
* If the origin is relative, it will be relative to `APP/webroot/img`.
* @param string $origin Origin file
* @return \Thumbs\Utility\ThumbCreator
* @throws InternalErrorException
* @uses $height
* @uses $origin
* @uses $width
* @uses _downloadTemporary()
*/
public function __construct($origin)
{
//If the origin is a remote file, downloads as temporary file
if (isUrl($origin)) {
$origin = $this->_downloadTemporary($origin);
//If it's a local file, can be relative to `APP/webroot/img/`
} elseif (!Folder::isAbsolute($origin)) {
$origin = WWW_ROOT . 'img' . DS . $origin;
}
//Checks if is readable
if (!is_readable($origin)) {
throw new NotFoundException(__d('thumbs', 'File or directory {0} not readable', $origin));
}
//Checks if has a valid extension
if (!in_array(extension($origin), ['gif', 'jpg', 'jpeg', 'png'])) {
throw new InternalErrorException(__d('thumbs', 'The file {0} is not an image', $origin));
}
//Sets path, width and height of the origin file
$this->origin = $origin;
$this->width = getimagesize($origin)[0];
$this->height = getimagesize($origin)[1];
return $this;
}
示例13: use
public function use(...$styles)
{
$str = '';
$eol = EOL;
$args = $this->_parameters($styles, 'styles');
$lastParam = $args->lastParam;
$arguments = $args->arguments;
$links = $args->cdnLinks;
foreach ($arguments as $style) {
if (is_array($style)) {
$style = '';
}
$styleFile = STYLES_DIR . suffix($style, ".css");
if (!is_file($styleFile)) {
$styleFile = EXTERNAL_STYLES_DIR . suffix($style, ".css");
}
if (!in_array("style_" . $style, Properties::$isImport)) {
if (is_file($styleFile)) {
$str .= '<link href="' . baseUrl($styleFile) . '" rel="stylesheet" type="text/css" />' . $eol;
} elseif (isUrl($style) && extension($style) === 'css') {
$str .= '<link href="' . $style . '" rel="stylesheet" type="text/css" />' . $eol;
} elseif (isset($links[strtolower($style)])) {
$str .= '<link href="' . $links[strtolower($style)] . '" rel="stylesheet" type="text/css" />' . $eol;
}
Properties::$isImport[] = "style_" . $style;
}
}
if (!empty($str)) {
if ($lastParam === true) {
return $str;
} else {
echo $str;
}
} else {
return false;
}
}
示例14: use
public function use(...$scripts)
{
$str = '';
$eol = EOL;
$args = $this->_parameters($scripts, 'scripts');
$lastParam = $args->lastParam;
$arguments = $args->arguments;
$links = $args->cdnLinks;
foreach ($arguments as $script) {
if (is_array($script)) {
$script = '';
}
$scriptFile = SCRIPTS_DIR . suffix($script, ".js");
if (!is_file($scriptFile)) {
$scriptFile = EXTERNAL_SCRIPTS_DIR . suffix($script, ".js");
}
if (!in_array("script_" . $script, Properties::$isImport)) {
if (is_file($scriptFile)) {
$str .= '<script type="text/javascript" src="' . baseUrl($scriptFile) . '"></script>' . $eol;
} elseif (isUrl($script) && extension($script) === 'js') {
$str .= '<script type="text/javascript" src="' . $script . '"></script>' . $eol;
} elseif (isset($links[strtolower($script)])) {
$str .= '<script type="text/javascript" src="' . $links[strtolower($script)] . '"></script>' . $eol;
}
Properties::$isImport[] = "script_" . $script;
}
}
if (!empty($str)) {
if ($lastParam === true) {
return $str;
} else {
echo $str;
}
} else {
return false;
}
}
示例15: renderMaster
/**
*
*/
public function renderMaster()
{
// Build the master view if necessary
if (in_array($this->_DeliveryType, array(DELIVERY_TYPE_ALL))) {
$this->MasterView = $this->masterView();
// Only get css & ui components if this is NOT a syndication request
if ($this->SyndicationMethod == SYNDICATION_NONE && is_object($this->Head)) {
$CssAnchors = AssetModel::getAnchors();
$this->EventArguments['CssFiles'] =& $this->_CssFiles;
$this->fireEvent('BeforeAddCss');
$ETag = AssetModel::eTag();
$CombineAssets = c('Garden.CombineAssets');
$ThemeType = isMobile() ? 'mobile' : 'desktop';
// And now search for/add all css files.
foreach ($this->_CssFiles as $CssInfo) {
$CssFile = $CssInfo['FileName'];
if (!array_key_exists('Options', $CssInfo) || !is_array($CssInfo['Options'])) {
$CssInfo['Options'] = array();
}
$Options =& $CssInfo['Options'];
// style.css and admin.css deserve some custom processing.
if (in_array($CssFile, $CssAnchors)) {
if (!$CombineAssets) {
// Grab all of the css files from the asset model.
$AssetModel = new AssetModel();
$CssFiles = $AssetModel->getCssFiles($ThemeType, ucfirst(substr($CssFile, 0, -4)), $ETag);
foreach ($CssFiles as $Info) {
$this->Head->addCss($Info[1], 'all', true, $CssInfo);
}
} else {
$Basename = substr($CssFile, 0, -4);
$this->Head->addCss(url("/asset/css/{$ThemeType}/{$Basename}-{$ETag}.css", '//'), 'all', false, $CssInfo['Options']);
}
continue;
}
$AppFolder = $CssInfo['AppFolder'];
$LookupFolder = !empty($AppFolder) ? $AppFolder : $this->ApplicationFolder;
$Search = AssetModel::CssPath($CssFile, $LookupFolder, $ThemeType);
if (!$Search) {
continue;
}
list($Path, $UrlPath) = $Search;
if (isUrl($Path)) {
$this->Head->AddCss($Path, 'all', val('AddVersion', $Options, true), $Options);
continue;
} else {
// Check to see if there is a CSS cacher.
$CssCacher = Gdn::factory('CssCacher');
if (!is_null($CssCacher)) {
$Path = $CssCacher->get($Path, $AppFolder);
}
if ($Path !== false) {
$Path = substr($Path, strlen(PATH_ROOT));
$Path = str_replace(DS, '/', $Path);
$this->Head->addCss($Path, 'all', true, $Options);
}
}
}
// Add a custom js file.
if (arrayHasValue($this->_CssFiles, 'style.css')) {
$this->addJsFile('custom.js');
// only to non-admin pages.
}
$Cdns = array();
if (!c('Garden.Cdns.Disable', false)) {
$Cdns = array('jquery.js' => "//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js");
}
// And now search for/add all JS files.
$this->EventArguments['Cdns'] =& $Cdns;
$this->fireEvent('AfterJsCdns');
$this->Head->addScript('', 'text/javascript', false, array('content' => $this->definitionList(false)));
foreach ($this->_JsFiles as $Index => $JsInfo) {
$JsFile = $JsInfo['FileName'];
if (!is_array($JsInfo['Options'])) {
$JsInfo['Options'] = array();
}
$Options =& $JsInfo['Options'];
if (isset($Cdns[$JsFile])) {
$JsFile = $Cdns[$JsFile];
}
$AppFolder = $JsInfo['AppFolder'];
$LookupFolder = !empty($AppFolder) ? $AppFolder : $this->ApplicationFolder;
$Search = AssetModel::JsPath($JsFile, $LookupFolder, $ThemeType);
if (!$Search) {
continue;
}
list($Path, $UrlPath) = $Search;
if ($Path !== false) {
$AddVersion = true;
if (!isUrl($Path)) {
$Path = substr($Path, strlen(PATH_ROOT));
$Path = str_replace(DS, '/', $Path);
$AddVersion = val('AddVersion', $Options, true);
}
$this->Head->addScript($Path, 'text/javascript', $AddVersion, $Options);
continue;
}
//.........这里部分代码省略.........