本文整理汇总了PHP中strrchr函数的典型用法代码示例。如果您正苦于以下问题:PHP strrchr函数的具体用法?PHP strrchr怎么用?PHP strrchr使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了strrchr函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: attach
function attach($message,$name,$ctype = '') {
// type de contenu non defini
if(empty($ctype)){
// on essaie de reconnaitre l'extension
switch(strrchr(basename($name), ".")){
case ".gz": $ctype = "application/x-gzip"; break;
case ".tgz": $ctype = "application/x-gzip"; break;
case ".zip": $ctype = "application/zip"; break;
case ".pdf": $ctype = "application/pdf"; break;
case ".png": $ctype = "image/png"; break;
case ".gif": $ctype = "image/gif"; break;
case ".jpg": $ctype = "image/jpeg"; break;
case ".txt": $ctype = "text/plain"; break;
case ".htm": $ctype = "text/html"; break;
case ".html": $ctype = "text/html"; break;
default: $ctype = "application/octet-stream"; break;
}
}
$this->parts[] =
array (
"ctype" => $ctype,
"message" => $message,
"encode" => "",
"name" => $name
);
// fin de fonction
}
示例2: add
/**
* Add a file
* @param string
* @param string
* @param string
*/
public function add($strFile, $strVersion = null, $strMedia = 'screen')
{
$strType = strrchr($strFile, '.');
// Check the file type
if ($strType != self::CSS && $strType != self::JS) {
throw new Exception("Invalid file {$strFile}");
}
// Set the operation mode
if (!$this->strMode) {
$this->strMode = $strType;
} elseif ($this->strMode != $strType) {
throw new Exception('You cannot mix different file types. Create another Combiner object instead.');
}
// Prevent duplicates
if (isset($this->arrFiles[$strFile])) {
return;
}
// Check the source file
if (!file_exists(TL_ROOT . '/' . $strFile)) {
$this->import('StyleSheets');
$this->StyleSheets->updateStyleSheets();
// Retry
if (!file_exists(TL_ROOT . '/' . $strFile)) {
throw new Exception("File {$strFile} does not exist");
}
}
// Default version
if ($strVersion === null) {
$strVersion = VERSION . '.' . BUILD;
}
// Store the file
$arrFile = array('name' => $strFile, 'version' => $strVersion, 'media' => $strMedia);
$this->arrFiles[$strFile] = $arrFile;
$this->strKey .= '-f' . $strFile . '-v' . $strVersion . '-m' . $strMedia;
}
示例3: format
public function format($source)
{
$this->tkns = token_get_all($source);
$this->code = '';
while (list($index, $token) = each($this->tkns)) {
list($id, $text) = $this->getToken($token);
$this->ptr = $index;
switch ($id) {
case T_TRAIT:
case T_CLASS:
if ($this->leftUsefulTokenIs(T_DOUBLE_COLON)) {
$this->appendCode($text);
break;
}
$this->appendCode($text);
$this->printUntil(ST_CURLY_OPEN);
list(, $text) = $this->printAndStopAt(T_WHITESPACE);
if ($this->hasLn($text)) {
$text = substr(strrchr($text, 10), 0);
}
$this->appendCode($text);
break;
default:
$this->appendCode($text);
break;
}
}
return $this->code;
}
示例4: save
public static function save($path, UploadedFile $file)
{
$ext = substr(strrchr($file->getClientOriginalName(), '.'), 1);
$new_name = md5(time() . rand()) . '.' . $ext;
$file->move($path, $new_name);
return $new_name;
}
示例5: saveFile
public function saveFile($data)
{
$post = (object) $data;
self::setMapping();
// recupera variáveis
$fileData = $_FILES["filedata"];
$fileName = $fileData["name"];
$fileType = $fileData["type"];
$tempName = $fileData["tmp_name"];
$dataType = self::$mapping[$fileType];
if (!is_uploaded_file($tempName)) {
self::$response->success = false;
self::$response->text = "O arquivo não foi enviado com sucesso. Erro de sistema: {$fileData['error']}.";
return json_encode(self::$response);
}
if (!array_key_exists($fileType, self::$mapping)) {
return '{"success":false,"records":0,"error":2,"root":[],"text":"Tipo de arquivo não mapeado para esta operação!"}';
}
// comprime arquivo temporário
if ($dataType === true) {
self::sizeFile();
self::workSize($tempName);
}
$tempData = base64_encode(file_get_contents($tempName));
// recupera extensão do arquivo
$fileExtension = strtoupper(strrchr($fileName, "."));
$fileExtension = str_replace(".", "", $fileExtension);
$fileInfo = array("fileType" => $fileType, "fileExtension" => $fileExtension, "dataType" => $dataType, "fileName" => $fileName);
$fileInfo = stripslashes(json_encode($fileInfo));
$affectedRows = $this->exec("update {$post->tableName} set filedata = '{$tempData}', fileinfo = '{$fileInfo}' where id = {$post->id}");
unlink($tempName);
return $affectedRows;
}
示例6: carbon_preprocess_page
/**
* Implements hook_preprocess_page().
*/
function carbon_preprocess_page(&$variables) {
$is_front = $variables['is_front'];
// Adjust the html element that wraps the site name. h1 on front page, p on other pages
$variables['wrapper_site_name_prefix'] = ($is_front ? '<h1' : '<p');
$variables['wrapper_site_name_prefix'] .= ' id="site-name"';
$variables['wrapper_site_name_prefix'] .= ' class="site-name'.($is_front ? ' site-name-front' : '').'"';
$variables['wrapper_site_name_prefix'] .= '>';
$variables['wrapper_site_name_suffix'] = ($is_front ? '</h1>' : '</p>');
// If the theme's info file contains the custom theme setting
// default_logo_path, set the $logo variable to that path.
$default_logo_path = theme_get_setting('default_logo_path');
if (!empty($default_logo_path) && theme_get_setting('default_logo')) {
$variables['logo'] = file_create_url(path_to_theme() . '/' . $default_logo_path);
}
else {
$variables['logo'] = null;
}
//Arrange the elements of the main content area (content and sidebars) based on the layout class
$layoutClass = _carbon_get_layout();
$layout = substr(strrchr($layoutClass, '-'), 1); //Get the last bit of the layout class, the 'abc' string
$contentPos = strpos($layout, 'c');
$sidebarsLeft = substr($layout,0,$contentPos);
$sidebarsRight = strrev(substr($layout,($contentPos+1))); // Reverse the string so that the floats are correct.
$sidebarsHidden = ''; // Create a string of sidebars that are hidden to render and then display:none
if(stripos($layout, 'a') === false) { $sidebarsHidden .= 'a'; }
if(stripos($layout, 'b') === false) { $sidebarsHidden .= 'b'; }
$variables['sidebars']['left'] = str_split($sidebarsLeft);
$variables['sidebars']['right'] = str_split($sidebarsRight);
$variables['sidebars']['hidden'] = str_split($sidebarsHidden);
}
示例7: _getParentContentData
private function _getParentContentData()
{
$data = $this->getData();
$ids = array();
while ($data && !$data->inherits) {
$ids[] = strrchr($data->componentId, '-');
$data = $data->parent;
}
while ($data) {
if ($data->inherits) {
$d = $data;
foreach (array_reverse($ids) as $id) {
$d = $d->getChildComponent($id);
}
if (!$d) {
break;
}
if ($d->componentClass != $this->getData()->componentClass) {
return $d;
}
}
$data = $data->parent;
}
return null;
}
示例8: wpui_slide_shortcode
function wpui_slide_shortcode($atts, $content = null)
{
extract(shortcode_atts(array('image' => false, 'image_title' => false), $atts));
if ($image_title) {
$imagea = wpui_get_media_item($image_title);
}
$image = $imagea['image'];
if (!$image || !function_exists('getimagesize')) {
return false;
}
if (is_array($imagea)) {
$img_title = $imagea['title'];
} else {
$filename = substr(strrchr($image, '/'), 1);
$filename = str_ireplace(strrchr($filename, '.'), '', $filename);
$img_title = $filename;
}
$samp = getimagesize($image);
if (!is_array($samp)) {
return "Not a valid image.";
}
$output = '';
$output .= '<h3 class="wp-tab-title">' . $imagea['title'] . '</h3>';
$output .= '<div class="wpui-slide wp-tab-content">';
$output .= '<img src="' . $image . '" />';
$output .= '<div class="wpui_image_description">' . $content . '</div>';
$output .= '</div><!-- end .wpui-slide -->';
return $output;
}
示例9: getName
/**
* 名称
* @return string
*/
function getName()
{
if (is_null($this->name)) {
$this->name = strrchr(get_class($this), '\\');
}
return $this->name;
}
示例10: output_html
/**
* Modify the output of the field on the fronted profile.
*
* @since 1.2.0
* @param string $value the value of the field.
* @param object $field field details.
* @return string the formatted field value.
*/
public static function output_html($value, $field)
{
$files = $value;
$output = '';
// Display files if they're images.
if (wpaam_is_multi_array($files)) {
foreach ($files as $key => $file) {
$extension = !empty($extension) ? $extension : substr(strrchr($file['url'], '.'), 1);
if (3 !== strlen($extension) || in_array($extension, array('jpg', 'gif', 'png', 'jpeg', 'jpe'))) {
$output .= '<span class="wpaam-uploaded-file-preview"><img src="' . esc_url($file['url']) . '" /></span>';
} else {
$output .= ' <span class="wpaam-uploaded-file-name"><code>' . esc_html(basename($file['url'])) . '</code></span>';
}
}
// We have a single file.
} else {
$extension = !empty($extension) ? $extension : substr(strrchr($files['url'], '.'), 1);
if (3 !== strlen($extension) || in_array($extension, array('jpg', 'gif', 'png', 'jpeg', 'jpe'))) {
$output .= '<span class="wpaam-uploaded-file-preview"><img src="' . esc_url($files['url']) . '" /></span>';
} else {
$output .= ' <span class="wpaam-uploaded-file-name"><code>' . esc_html(basename($files['url'])) . '</code></span>';
}
}
return $output;
}
示例11: save_images
function save_images($image_url, $post_id, $i)
{
//set_time_limit(180); //每个图片最长允许下载时间,秒
$file = file_get_contents($image_url);
$fileext = substr(strrchr($image_url, '.'), 1);
$fileext = strtolower($fileext);
if ($fileext == "" || strlen($fileext) > 4) {
$fileext = "jpg";
}
$savefiletype = array('jpg', 'gif', 'png', 'bmp');
if (!in_array($fileext, $savefiletype)) {
$fileext = "jpg";
}
$im_name = date('YmdHis', time()) . $i . mt_rand(10, 20) . '.' . $fileext;
$res = wp_upload_bits($im_name, '', $file);
if (isset($res['file'])) {
$attach_id = insert_attachment($res['file'], $post_id);
} else {
return;
}
if (ot_get_option('auto_save_image_thumb') == 'on' && $i == 1) {
set_post_thumbnail($post_id, $attach_id);
}
return $res;
}
示例12: set_fromhost
function set_fromhost()
{
global $proxyIPs;
global $fullfromhost;
global $fromhost;
@($fullfromhost = $_SERVER["HTTP_X_FORWARDED_FOR"]);
if ($fullfromhost == "") {
@($fullfromhost = $_SERVER["REMOTE_ADDR"]);
$fromhost = $fullfromhost;
} else {
$ips = explode(",", $fullfromhost);
$c = count($ips);
if ($c > 1) {
$fromhost = trim($ips[$c - 1]);
if (isset($proxyIPs) && in_array($fromhost, $proxyIPs)) {
$fromhost = $ips[$c - 2];
}
} else {
$fromhost = $fullfromhost;
}
}
if ($fromhost == "") {
$fromhost = "127.0.0.1";
$fullfromhost = "127.0.0.1";
}
if (defined("IPV6_LEGACY_IPV4_DISPLAY")) {
if (strchr($fromhost, '.') && ($p = strrchr($fromhost, ':'))) {
$fromhost = substr($p, 1);
}
}
//sometimes,fromhost has strang space
bbs_setfromhost(trim($fromhost), trim($fullfromhost));
}
示例13: onMove
public function onMove($typeProgress, $module, $name, $copy = FALSE)
{
$imgs = $this->getConfig('img');
foreach ($imgs as $img) {
$oldPath = $img['name'];
$imagePath = substr(strstr($oldPath, '/files/'), 7);
$newPath = $module . '/files/' . $imagePath;
if ($oldPath !== $newPath) {
if (stream_resolve_include_path($newPath) !== FALSE) {
/* check if an image with this path already exists in profile */
$fileInfo = pathinfo($imagePath);
$extension = strtolower($fileInfo['extension']);
$filename = $fileInfo['filename'];
/* allow to not overload filename with name_0_3_2_0 ... */
$generatedPart = strrchr($filename, '_');
if ($generatedPart !== FALSE && is_numeric(substr($generatedPart, 1))) {
$filename = substr($fileInfo['filename'], 0, -strlen($generatedPart));
}
$nbn = 0;
while (stream_resolve_include_path($newPath)) {
$imagePath = $filename . '_' . $nbn . '.' . $extension;
$newPath = $module . '/files/' . $imagePath;
$nbn++;
}
}
$this->setConfig('imgPath', $newPath);
\tools::file_put_contents(PROFILE_PATH . $newPath, file_get_contents($oldPath, FILE_USE_INCLUDE_PATH));
}
}
}
示例14: importImages
/**
* import images
*
* @access public
* @param $product, $image, $sku
* @return void
*
*/
private function importImages($product, $image, $sku)
{
$image_url = $image['img'];
$image_url = str_replace("https://", "http://", $image_url);
$image_type = substr(strrchr($image_url, "."), 1);
$split = explode("?", $image_type);
$image_type = $split[0];
$imgName = basename($image_url);
$imgName = str_replace('.' . $image_type, "", $imgName);
$filename = md5($imgName . $sku) . '.' . $image_type;
$dirPath = Mage::getBaseDir('media') . DS . 'import';
if (!file_exists($dirPath)) {
mkdir($dirPath, 0777, true);
}
$filepath = $dirPath . DS . $filename;
$curl_handle = curl_init();
curl_setopt($curl_handle, CURLOPT_URL, $image_url);
curl_setopt($curl_handle, CURLOPT_CONNECTTIMEOUT, 2);
curl_setopt($curl_handle, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl_handle, CURLOPT_USERAGENT, 'Cirkel');
$query = curl_exec($curl_handle);
curl_close($curl_handle);
file_put_contents($filepath, $query);
if (file_exists($filepath)) {
$attrIMG = array();
if (array_key_exists('main', $image)) {
if ($image['main'] == true) {
$attrIMG = array('image', 'thumbnail', 'small_image');
}
}
$productMG = Mage::getModel('catalog/product')->loadByAttribute('sku', $product->getSku());
$productMG->addImageToMediaGallery($filepath, $attrIMG, false, false);
$productMG->save();
}
}
示例15: convert
/**
* Convert the token
*
* @param Zend_Markup_Token $token
* @param string $text
*
* @return string
*/
public function convert(Zend_Markup_Token $token, $text)
{
$uri = $text;
if (!preg_match('/^([a-z][a-z+\\-.]*):/i', $uri)) {
$uri = 'http://' . $uri;
}
// check if the URL is valid
if (!Zend_Markup_Renderer_Html::isValidUri($uri)) {
return $text;
}
if ($token->hasAttribute('alt')) {
$alt = $token->getAttribute('alt');
} else {
// try to get the alternative from the URL
$alt = rtrim($text, '/');
$alt = strrchr($alt, '/');
if (false !== strpos($alt, '.')) {
$alt = substr($alt, 1, strpos($alt, '.') - 1);
}
}
// run the URI and alt through htmlentities
$uri = htmlentities($uri, ENT_QUOTES, Zend_Markup_Renderer_Html::getEncoding());
$alt = htmlentities($alt, ENT_QUOTES, Zend_Markup_Renderer_Html::getEncoding());
return "<img src=\"{$uri}\" alt=\"{$alt}\"" . Zend_Markup_Renderer_Html::renderAttributes($token) . " />";
}