/** * 图片裁剪 * */ public function pic_cutOp() { Uk86Language::uk86_read('admin_common'); $lang = Uk86Language::uk86_getLangContent(); uk86_import('function.thumb'); if (uk86_chksubmit()) { $thumb_width = $_POST['x']; $x1 = $_POST["x1"]; $y1 = $_POST["y1"]; $x2 = $_POST["x2"]; $y2 = $_POST["y2"]; $w = $_POST["w"]; $h = $_POST["h"]; $scale = $thumb_width / $w; $src = str_ireplace(UPLOAD_SITE_URL, BASE_UPLOAD_PATH, $_POST['url']); if (strpos($src, '..') !== false || strpos($src, BASE_UPLOAD_PATH) !== 0) { exit; } if (!empty($_POST['filename'])) { // $save_file2 = BASE_UPLOAD_PATH.'/'.$_POST['filename']; $save_file2 = str_ireplace(UPLOAD_SITE_URL, BASE_UPLOAD_PATH, $_POST['filename']); } else { $save_file2 = str_replace('_small.', '_sm.', $src); } $cropped = uk86_resize_thumb($save_file2, $src, $w, $h, $x1, $y1, $scale); @unlink($src); $pathinfo = pathinfo($save_file2); exit($pathinfo['basename']); } $save_file = str_ireplace(UPLOAD_SITE_URL, BASE_UPLOAD_PATH, $_GET['url']); $_GET['resize'] = $_GET['resize'] == '0' ? '0' : '1'; Tpl::output('height', uk86_get_height($save_file)); Tpl::output('width', uk86_get_width($save_file)); Tpl::showpage('common.pic_cut', 'null_layout'); }
public function singleParamHtmlHolder($param, $value) { $output = ''; // Compatibility fixes $old_names = array('yellow_message', 'blue_message', 'green_message', 'button_green', 'button_grey', 'button_yellow', 'button_blue', 'button_red', 'button_orange'); $new_names = array('alert-block', 'alert-info', 'alert-success', 'btn-success', 'btn', 'btn-info', 'btn-primary', 'btn-danger', 'btn-warning'); $value = str_ireplace($old_names, $new_names, $value); //$value = __($value, LANGUAGE_ZONE); // $param_name = isset($param['param_name']) ? $param['param_name'] : ''; $type = isset($param['type']) ? $param['type'] : ''; $class = isset($param['class']) ? $param['class'] : ''; if (isset($param['holder']) == true && $param['holder'] !== 'hidden') { $output .= '<' . $param['holder'] . ' class="wpb_vc_param_value ' . $param_name . ' ' . $type . ' ' . $class . '" name="' . $param_name . '">' . $value . '</' . $param['holder'] . '>'; } if ($param_name == 'images') { $images_ids = empty($value) ? array() : explode(',', trim($value)); $output .= '<ul class="attachment-thumbnails' . (empty($images_ids) ? ' image-exists' : '') . '" data-name="' . $param_name . '">'; foreach ($images_ids as $image) { $img = wpb_getImageBySize(array('attach_id' => (int) $image, 'thumb_size' => 'thumbnail')); $output .= $img ? '<li>' . $img['thumbnail'] . '</li>' : '<li><img width="150" height="150" test="' . $image . '" src="' . WPBakeryVisualComposer::getInstance()->assetURL('vc/blank.gif') . '" class="attachment-thumbnail" alt="" title="" /></li>'; } $output .= '</ul>'; $output .= '<a href="#" class="column_edit_trigger' . (!empty($images_ids) ? ' image-exists' : '') . '">' . __('Add images', LANGUAGE_ZONE) . '</a>'; } return $output; }
function StripTags($out) { $out = strip_tags($out); $out = trim(preg_replace("~[\\s]+~", " ", $out)); $out = str_ireplace("…", "", $out); return $out; }
public static function getLink($params, $fields = array('simple', 'menu', 'article'), $content_item = false, $isJoomlaArticle = true) { $simple = $fields[0]; $menu = $fields[1]; $article = $fields[2]; $link = ''; if ($params->get($simple, '') != '') { $link = str_ireplace('{SITE}/', JURI::root(), $params->get($simple)); } elseif ($params->get($menu, '') != '') { $application = JFactory::getApplication(); $cms_menu = $application->getMenu(); $menu_item = $cms_menu->getItem($params->get($menu)); $link = JRoute::_($menu_item->link . '&Itemid=' . $menu_item->id); } elseif ($params->get($article, '') != '') { if (self::getjVersion() > 2) { $link = JRoute::_('index.php?option=com_content&view=article&id=' . $params->get($article, '')); } else { $link = JRoute::_(ContentHelperRoute::getArticleRoute($params->get($article, ''))); } } elseif ($content_item && $isJoomlaArticle) { if (self::getjVersion() > 2) { $link = JRoute::_('index.php?option=com_content&view=article&id=' . $content_item->id); } else { $link = JRoute::_(ContentHelperRoute::getArticleRoute($content_item->id, $content_item->catid)); } } elseif ($content_item) { if (@isset($content_item->link)) { $link = $content_item->link; } } return $link; }
/** * Removes unwanted attributes from a particular tag * * @param string $fullTag (e.g. '<a onclick="alert('XSS');">') * @param string $attributes (e.g. 'a onclick="alert('XSS');"') * @return string */ protected function removeAttribute($fullTag, $attributes) { $replacement = $this->attributeFinder->findAttributes($attributes, function () { return ''; }); return str_ireplace($attributes, $replacement, $fullTag); }
function talk($content, $name, $api, $apikey = '') { $content = str_ireplace("@{$name}", '', $content); $content = str_ireplace("回复 {$name} :", '', $content); $content = urlencode($content); switch ($api) { case 'xiaoji': $re = xiaoji($content); break; case 'xiaoi3': $re = xiaoi3($content); break; case 'tuling': $re = tuling($content, $apikey); break; case 'simsimi3': $re = simsimi3($content); break; case 'simsimi': $re = simsimi($content); break; default: $re = xiaoji($content); } return $re; }
/** * Parses an URI string returning an array of connection parameters. * * When using the "redis" and "rediss" schemes the URI is parsed according * to the rules defined by the provisional registration documents approved * by IANA. If the URI has a password in its "user-information" part or a * database number in the "path" part these values override the values of * "password" and "database" if they are present in the "query" part. * * @link http://www.iana.org/assignments/uri-schemes/prov/redis * @link http://www.iana.org/assignments/uri-schemes/prov/redis * * @param string $uri URI string. * * @throws \InvalidArgumentException * * @return array */ public static function parse($uri) { if (stripos($uri, 'unix') === 0) { // Hack to support URIs for UNIX sockets with minimal effort. $uri = str_ireplace('unix:///', 'unix://localhost/', $uri); } if (!($parsed = parse_url($uri))) { throw new \InvalidArgumentException("Invalid parameters URI: {$uri}"); } if (isset($parsed['host']) && false !== strpos($parsed['host'], '[') && false !== strpos($parsed['host'], ']')) { $parsed['host'] = substr($parsed['host'], 1, -1); } if (isset($parsed['query'])) { parse_str($parsed['query'], $queryarray); unset($parsed['query']); $parsed = array_merge($parsed, $queryarray); } if (stripos($uri, 'redis') === 0) { if (isset($parsed['pass'])) { $parsed['password'] = $parsed['pass']; unset($parsed['pass']); } if (isset($parsed['path']) && preg_match('/^\\/(\\d+)(\\/.*)?/', $parsed['path'], $path)) { $parsed['database'] = $path[1]; if (isset($path[2])) { $parsed['path'] = $path[2]; } else { unset($parsed['path']); } } } return $parsed; }
public function installPaExtension() { $this->model = $this->getModel('installer'); JSNFactory::import('components.com_installer.helpers.installer'); $canDo = InstallerHelper::getActions(); if ($canDo->get('core.manage')) { try { $rs = $this->model->download(); $this->input->set('package', $rs); // Set extension parameters $_GET['package'] = $rs; $_GET['type'] = 'plugin'; $_GET['folder'] = 'jsnpoweradmin'; $_GET['publish'] = 1; $_GET['client'] = 'site'; $_GET['name'] = str_ireplace(JSN_POWERADMIN_EXT_IDENTIFIED_NAME_PREFIX, '', $_GET['identified_name']); $this->model->install($rs); if ($this->model->install($rs)) { require_once JPATH_COMPONENT_ADMINISTRATOR . '/helpers/extensions.php'; // Enable extension suport $_GET['name'] = str_ireplace(JSN_POWERADMIN_EXT_IDENTIFIED_NAME_PREFIX, '', $_GET['identified_name']); try { JSNPaExtensionsHelper::enableExt($identifiedName); } catch (Exception $ex) { exit('notenabled'); } } } catch (Exception $ex) { exit($ex->getMessage()); } exit('success'); } }
public function singleParamHtmlHolder($param, $value) { $output = ''; // Compatibility fixes $old_names = array('yellow_message', 'blue_message', 'green_message', 'button_green', 'button_grey', 'button_yellow', 'button_blue', 'button_red', 'button_orange'); $new_names = array('alert-block', 'alert-info', 'alert-success', 'btn-success', 'btn', 'btn-info', 'btn-primary', 'btn-danger', 'btn-warning'); $value = str_ireplace($old_names, $new_names, $value); $param_name = isset($param['param_name']) ? $param['param_name'] : ''; $type = isset($param['type']) ? $param['type'] : ''; $class = isset($param['class']) ? $param['class'] : ''; if ('attach_image' === $param['type'] && 'image' === $param_name) { $output .= '<input type="hidden" class="wpb_vc_param_value ' . $param_name . ' ' . $type . ' ' . $class . '" name="' . $param_name . '" value="' . $value . '" />'; $element_icon = $this->settings('icon'); $img = wpb_getImageBySize(array('attach_id' => (int) preg_replace('/[^\\d]/', '', $value), 'thumb_size' => 'thumbnail')); $this->setSettings('logo', ($img ? $img['thumbnail'] : '<img width="150" height="150" src="' . vc_asset_url('vc/blank.gif') . '" class="attachment-thumbnail vc_element-icon" data-name="' . $param_name . '" alt="" title="" style="display: none;" />') . '<span class="no_image_image vc_element-icon' . (!empty($element_icon) ? ' ' . $element_icon : '') . ($img && !empty($img['p_img_large'][0]) ? ' image-exists' : '') . '" /><a href="#" class="column_edit_trigger' . ($img && !empty($img['p_img_large'][0]) ? ' image-exists' : '') . '">' . __('Add image', 'js_composer') . '</a>'); $output .= $this->outputTitleTrue($this->settings['name']); } elseif (!empty($param['holder'])) { if ($param['holder'] === 'input') { $output .= '<' . $param['holder'] . ' readonly="true" class="wpb_vc_param_value ' . $param_name . ' ' . $type . ' ' . $class . '" name="' . $param_name . '" value="' . $value . '">'; } elseif (in_array($param['holder'], array('img', 'iframe'))) { $output .= '<' . $param['holder'] . ' class="wpb_vc_param_value ' . $param_name . ' ' . $type . ' ' . $class . '" name="' . $param_name . '" src="' . $value . '">'; } elseif ($param['holder'] !== 'hidden') { $output .= '<' . $param['holder'] . ' class="wpb_vc_param_value ' . $param_name . ' ' . $type . ' ' . $class . '" name="' . $param_name . '">' . $value . '</' . $param['holder'] . '>'; } } if (!empty($param['admin_label']) && $param['admin_label'] === true) { $output .= '<span class="vc_admin_label admin_label_' . $param['param_name'] . (empty($value) ? ' hidden-label' : '') . '"><label>' . $param['heading'] . '</label>: ' . $value . '</span>'; } return $output; }
function basePathLib($relative_path) { $scriptName = str_replace('/class/image.class.php', '', $_SERVER['SCRIPT_NAME']); $realpath = str_replace('\\', '/', realpath($relative_path)); $htmlpath = str_ireplace(str_replace('\\', '/', ROOT_DIR), '', $realpath); return $htmlpath; }
/** * Autoloader load method. Load the class. * * @param $class_name */ public function load($class_name) { // Only load DLM if (0 === strpos($class_name, 'DLM_')) { // String to lower $class_name = strtolower($class_name); // Format file name $file_name = 'class-' . str_ireplace('_', '-', str_ireplace('DLM_', 'dlm-', $class_name)) . '.php'; // Setup the file path $file_path = $this->path; // Check if we need to extend the class path if (strpos($class_name, 'dlm_admin') === 0) { $file_path .= 'admin/'; } else { if (strpos($class_name, 'dlm_widget') === 0) { $file_path .= 'widgets/'; } else { if (strpos($class_name, 'dlm_product') === 0) { $file_path .= 'product/'; } } } // Append file name to clas path $file_path .= $file_name; // Check & load file if (file_exists($file_path)) { require_once $file_path; } } }
/** * Create missing folders * * @copyright * @author RolandD * @todo * @see * @access public * @param * @return * @since 3.0 */ public function createFolder() { $app = JFactory::getApplication(); jimport('joomla.filesystem.folder'); $folder = str_ireplace(JPATH_ROOT, '', JRequest::getVar('folder')); return JFolder::create($folder); }
function migrate_authors($string) { $result = ''; $array = array(); $new_authors = array(); $string = str_ireplace(' and ', ' , ', $string); $string = str_ireplace(', and ', ' , ', $string); $string = str_ireplace(',and ', ' , ', $string); $string = str_ireplace(';', ',', $string); $array = explode(',', $string); $array = array_filter($array); if (!empty($array)) { foreach ($array as $author) { $author = trim($author); $author = str_replace('"', '', $author); $space = strpos($author, ' '); if ($space === false) { $last = trim($author); $first = ''; } else { $last = trim(substr($author, 0, $space)); $first = trim(substr($author, $space + 1)); } if (!empty($last)) { $new_authors[] = 'L:"' . $last . '",F:"' . $first . '"'; } } if (count($new_authors) > 0) { $result = join(';', $new_authors); } } return $result; }
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; }
/** * * @param Mongostar_Model_Interface $model * @param string $foreign_class_name * @param array $options * @param string $property_name */ public function __construct(Mongostar_Model_Interface $model, $foreign_class_name, array $options, $property_name) { $this->_foreign_class_name = $foreign_class_name; $this->set_relation_name($property_name); $this->_local_class_name = get_class($model); if (isset($options['foreignKey'])) { $this->_foreign_key = $options['foreignKey']; } else { $this->_foreign_key = $property_name . '_id'; } if (isset($options['foreignSort'])) { $sort_key = $options['foreignSort']; $sort_dir = 1; if (strpos(':', $sort_key)) { $sort_key = explode(':', $sort_key); $sort_dir = $sort_key[1]; $sort_key = $sort_key[0]; $sort_dir = (int) str_ireplace(array('asc', 'desc'), array(0, 1), $sort_dir); } $this->_foreign_sort[$sort_key] = $sort_dir; } if (isset($options['localKey'])) { $this->_local_key = $options['localKey']; } else { $this->_localKey = 'id'; } }
public function getParsedText($params = []) { $match = null; $text = $this->text; if (preg_match_all('/{{page:([\\w-]+)}}/i', $text, $match)) { foreach ($match[0] as $key => $value) { $page = Page::get($match[1][$key]); if ($page) { $content = $page->parsedText; } else { $content = ''; } $text = str_ireplace($value, $content, $text); } } if (preg_match_all('/{{setting:([\\w-]+)}}/i', $text, $match)) { foreach ($match[0] as $key => $value) { $content = Setting::get($match[1][$key]); $text = str_ireplace($value, $content, $text); } } if (preg_match_all('/{{var:([\\w-]+)}}/i', $text, $match)) { foreach ($match[0] as $key => $value) { if (isset($params[$match[1][$key]])) { $text = str_ireplace($value, $params[$match[1][$key]], $text); } } } return $text; }
function renderQuran() { // html url to the application $api_url = 'http://GlobalQuran.com/'; $api_key = get_option('gq_key'); ################## DO NOT EDIT BELOW THIS ################################### if (!$api_url) { die('missing vaules, please fill the configuration values and try again!'); } $_REQUEST['apiKey'] = $api_key; $urlstring = NULL; build_string($_REQUEST, $urlstring); $ch = curl_init($api_url); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $urlstring); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 0); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); $data = curl_exec($ch); curl_close($ch); $html = str_ireplace('<!DOCTYPE html>', '', strip_only($data, 'head', true)); $html = str_ireplace('<html lang="en" dir="lrt">', '', $html); $html = str_ireplace('<body class="ltr ">', '', $html); $html = str_ireplace('<body class="ltr ">', '', $html); $html = str_ireplace('</body>', '', $html); $html = str_ireplace('</html>', '', $html); $head = '<link rel="shortcut icon" href="http://GlobalQuran.com/favicon.ico" /> <link rel="stylesheet" href="' . get_option('gq_css_url') . '" media="screen,print" /> <link rel="stylesheet" href="' . get_option('gq_css_print_url') . '" media="print" />'; return $head . $html; }
public function fixPContent($content = null) { $s = array("<p><div class=\"row-fluid\"", "</div></p>"); $r = array("<div class=\"row-fluid\"", "</div>"); $content = str_ireplace($s, $r, $content); return $content; }
function email($contas) { global $CONFIG_smtp_server, $CONFIG_smtp_port, $CONFIG_smtp_username, $CONFIG_smtp_password, $CONFIG_smtp_mail, $CONFIG_name; $mensagem = "----------------------------\n"; for ($i = 0; isset($contas[$i][0]); $i++) { $mensagem .= "Username: "******"\nPassword: "******"\n----------------------------\n"; } $maildef = read_maildef("recover_password"); $maildef = str_ireplace("#account_info#", $mensagem, $maildef); $maildef = str_ireplace("#server_name#", $CONFIG_name, $maildef); $maildef = str_ireplace("#support_mail#", $CONFIG_smtp_mail, $maildef); $maildef = nl2br($maildef); $mail = new PHPMailer(); $mail->IsSMTP(); $mail->SMTPAuth = true; $mail->Host = $CONFIG_smtp_server; $mail->Port = $CONFIG_smtp_port; $mail->Username = $CONFIG_smtp_username; $mail->Password = $CONFIG_smtp_password; $mail->From = $CONFIG_smtp_mail; $mail->FromName = $CONFIG_name; $mail->Subject = "Password Recovery"; $mail->Body = $maildef; $mail->WordWrap = 50; $mail->AddAddress($contas[0][2], $contas[0][2]); $mail->AddReplyTo($CONFIG_smtp_mail, $CONFIG_name); $mail->IsHTML(true); if (!$mail->Send()) { return $mail->ErrorInfo; } else { return "Message has been sent"; } }
function export() { $model = M("Customer"); $where['is_del'] = 0; $list = $model->where($where)->select(); Vendor('Excel.PHPExcel'); //导入thinkphp第三方类库 $inputFileName = "Public/templete/customer.xlsx"; $objPHPExcel = PHPExcel_IOFactory::load($inputFileName); $objPHPExcel->getProperties()->setCreator("smeoa")->setLastModifiedBy("smeoa")->setTitle("Office 2007 XLSX Test Document")->setSubject("Office 2007 XLSX Test Document")->setDescription("Test document for Office 2007 XLSX, generated using PHP classes.")->setKeywords("office 2007 openxml php")->setCategory("Test result file"); // Add some data $i = 1; //dump($list); foreach ($list as $val) { $i++; $objPHPExcel->setActiveSheetIndex(0)->setCellValue("A{$i}", $val["name"])->setCellValue("B{$i}", $val["short"])->setCellValue("C{$i}", $val["biz_license"])->setCellValue("D{$i}", $val["payment"])->setCellValue("E{$i}", $val["address"])->setCellValue("F{$i}", $val["salesman"])->setCellValue("G{$i}", $val["contact"])->setCellValue("H{$i}", $val["email"])->setCellValue("I{$i}", $val["office_tel"])->setCellValue("J{$i}", $val["mobile_tel"])->setCellValue("J{$i}", $val["fax"])->setCellValue("L{$i}", $val["im"])->setCellValue("M{$i}", $val["remark"]); } // Rename worksheet $objPHPExcel->getActiveSheet()->setTitle('Customer'); // Set active sheet index to the first sheet, so Excel opens this as the first sheet $objPHPExcel->setActiveSheetIndex(0); $file_name = "customer.xlsx"; // Redirect output to a client’s web browser (Excel2007) header("Content-Type: application/force-download"); header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'); header("Content-Disposition:attachment;filename =" . str_ireplace('+', '%20', URLEncode($file_name))); header('Cache-Control: max-age=0'); $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007'); $objWriter->save('php://output'); exit; }
function __construct($plugin_file_path) { $this->load_settings(); $this->maybe_schema_update(); $this->plugin_file_path = $plugin_file_path; $this->plugin_dir_path = plugin_dir_path($plugin_file_path); $this->plugin_folder_name = basename($this->plugin_dir_path); $this->plugin_basename = plugin_basename($plugin_file_path); $this->template_dir = $this->plugin_dir_path . 'template' . DIRECTORY_SEPARATOR; $this->plugin_title = ucwords(str_ireplace('-', ' ', basename($plugin_file_path))); $this->plugin_title = str_ireplace(array('db', 'wp', '.php'), array('DB', 'WP', ''), $this->plugin_title); // We need to set $this->plugin_slug here because it was set here // in Media Files prior to version 1.1.2. If we remove it the customer // cannot upgrade, view release notes, etc // used almost exclusively as a identifier for plugin version checking (both core and addons) $this->plugin_slug = basename($plugin_file_path, '.php'); // used to add admin menus and to identify the core version in the $GLOBALS['wpmdb_meta'] variable for delicious brains api calls, version checking etc $this->core_slug = $this->is_pro || $this->is_addon ? 'wp-migrate-db-pro' : 'wp-migrate-db'; if (is_multisite()) { $this->plugin_base = 'settings.php?page=' . $this->core_slug; } else { $this->plugin_base = 'tools.php?page=' . $this->core_slug; } if ($this->is_addon || $this->is_pro) { $this->pro_addon_construct(); } add_action('init', array($this, 'load_plugin_textdomain')); }
/** * Autoloader load method. Load the class. * * @param $class_name */ public function load($class_name) { // Only autoload WooCommerce Sales Report Email classes if (0 === strpos($class_name, 'RP4WP_')) { // String to lower $class_name = strtolower($class_name); // Format file name $file_name = 'class-' . str_ireplace('_', '-', str_ireplace('RP4WP_', '', $class_name)) . '.php'; // Setup the file path $file_path = $this->path; // Check if we need to extend the class path if (strpos($class_name, 'rp4wp_hook') === 0) { $file_path .= 'hooks/'; } elseif (strpos($class_name, 'rp4wp_filter') === 0) { $file_path .= 'filters/'; } elseif (strpos($class_name, 'rp4wp_meta_box') === 0) { $file_path .= 'meta-boxes/'; } // Append file name to clas path $file_path .= $file_name; // Check & load file if (file_exists($file_path)) { require_once $file_path; } } }
/** * Listens to the response.filter_content event. * * @param sfEvent $event The sfEvent instance * @param string $context The response content * * @return string The filtered response content */ public function filterResponseContent(sfEvent $event, $content) { if (!sfConfig::get('sf_web_debug')) { return $content; } // log timers information $messages = array(); foreach (sfTimerManager::getTimers() as $name => $timer) { $messages[] = sprintf('%s %.2f ms (%d)', $name, $timer->getElapsedTime() * 1000, $timer->getCalls()); } $this->dispatcher->notify(new sfEvent($this, 'application.log', $messages)); // don't add debug toolbar: // * for XHR requests // * if 304 // * if not rendering to the client // * if HTTP headers only $response = $event->getSubject(); if (!$this->context->has('request') || !$this->context->has('response') || !$this->context->has('controller') || $this->context->getRequest()->isXmlHttpRequest() || strpos($response->getContentType(), 'html') === false || $response->getStatusCode() == 304 || $this->context->getController()->getRenderMode() != sfView::RENDER_CLIENT || $response->isHeaderOnly()) { return $content; } // add needed assets for the web debug toolbar $root = $this->context->getRequest()->getRelativeUrlRoot(); $assets = sprintf(' <script type="text/javascript" src="%s"></script> <link rel="stylesheet" type="text/css" media="screen" href="%s" />', $root . sfConfig::get('sf_web_debug_web_dir') . '/js/main.js', $root . sfConfig::get('sf_web_debug_web_dir') . '/css/main.css'); $content = str_ireplace('</head>', $assets . '</head>', $content); // add web debug information to response content $webDebugContent = $this->webDebug->getResults(); $count = 0; $content = str_ireplace('</body>', $webDebugContent . '</body>', $content, $count); if (!$count) { $content .= $webDebugContent; } return $content; }
function StockQuote($input, $argv, $parser) { global $wgParser; $wgParser->disableCache(); $info = file_get_contents("http://finance.yahoo.com/d/quotes.csv?s={$input}&f=sl1d1t1c1ohgv&e=csv"); $info = str_ireplace('"', '', $info); $info = explode(',', $info); if ($info[1] == '0.00') { return 'ERROR'; } if ($argv['quote']) { return $info[1]; } elseif ($argv['change']) { return $info[4]; } elseif ($argv['high']) { return $info[6]; } elseif ($argv['low']) { return $info[7]; } elseif ($argv['open']) { return $info[5]; } elseif ($argv['volume']) { return number_format($info[8]); } else { return $info[1]; } }
public function hookActionAdminControllerSetMedia($params) { $admin_webpath = str_ireplace(_PS_ROOT_DIR_, '', _PS_ADMIN_DIR_); $admin_webpath = preg_replace('/^' . preg_quote(DIRECTORY_SEPARATOR, '/') . '/', '', $admin_webpath); $this->context->controller->addJS(array(_PS_JS_DIR_ . 'vendor/d3.v3.min.js', __PS_BASE_URI__ . $admin_webpath . '/themes/' . $this->context->employee->bo_theme . '/js/vendor/nv.d3.min.js')); $this->context->controller->addCSS(__PS_BASE_URI__ . $admin_webpath . '/themes/' . $this->context->employee->bo_theme . '/css/vendor/nv.d3.css'); }
function getRequestParam($name) { $value = isset($_REQUEST[$name]) ? $_REQUEST[$name] : ''; // Prevent javascript injection $value = str_ireplace('<script', '', $value); return $value; }
public function isSatisfiedBy(DateTime $date, $value) { $tjcyguntyj = "value"; $hbvgxe = "value"; ${${"GLOBALS"}["xzmbmdooihe"]} = str_ireplace(array("JAN", "FEB", "MAR", "APR", "MAY", "JUN", "JUL", "AUG", "SEP", "OCT", "NOV", "DEC"), range(1, 12), ${$tjcyguntyj}); return $this->isSatisfied($date->format("m"), ${$hbvgxe}); }
public function voucher_listOp() { //检查过期的代金券,状态设置为过期(vouchet_state=3) $this->check_voucher_expire(); $model = Model(); $where = array('voucher_owner_id' => $_SESSION['member_id']); if (intval($_GET['select_detail_state']) > 0) { $where['voucher_state'] = intval($_GET['select_detail_state']); } $field = "voucher_id,voucher_code,voucher_title,voucher_desc,voucher_start_date,voucher_end_date,voucher_price,voucher_limit,voucher_state,voucher_order_id,voucher_store_id,store_name,store_id,store_domain,voucher_t_customimg"; $list = $model->table('voucher,store,voucher_template')->field($field)->join('inner,inner')->on('voucher.voucher_store_id = store.store_id,voucher.voucher_t_id=voucher_template.voucher_t_id')->where($where)->order('voucher_id desc')->page(10)->select(); if (is_array($list)) { foreach ($list as $key => $val) { if (empty($val['voucher_t_customimg']) || !file_exists(BASE_UPLOAD_PATH . DS . ATTACH_VOUCHER . DS . $val['store_id'] . DS . $val['voucher_t_customimg'])) { $list[$key]['voucher_t_customimg'] = UPLOAD_SITE_URL . DS . defaultGoodsImage(60); } else { $list[$key]['voucher_t_customimg'] = UPLOAD_SITE_URL . DS . ATTACH_VOUCHER . DS . $val['store_id'] . DS . str_ireplace('.', '_small.', $val['voucher_t_customimg']); } } } Tpl::output('list', $list); Tpl::output('show_page', $model->showpage(2)); //查询会员信息 $this->get_member_info(); $this->profile_menu('voucher_list'); Tpl::output('menu_sign', 'myvoucher'); Tpl::output('menu_sign_url', 'index.php?act=member_voucher'); Tpl::output('menu_sign1', 'member_voucher'); Tpl::showpage('member_voucher.list'); }
/** * Function to get the Display Value, for the current field type with given DB Insert Value * @param <Object> $value * @return <Object> */ public function getDisplayValue($value) { if (is_array($value)) { $value = implode(' |##| ', $value); } return str_ireplace(' |##| ', ', ', $value); }
static function highlightWords($text, $words, $nohighlight = false) { $colors = array('yellow', 'pink', 'gray'); $i = 0; /* * * the maximum key number ** */ $num_colors = max(array_keys($colors)); $words = trim($words); $the_count = 0; $wordsArray = explode(' ', $words); foreach ($wordsArray as $word) { if (strlen(trim($word)) != 0) { $text = str_ireplace($word, '~' . $i . $word . '^' . $i, $text, $count); if ($i == $num_colors) { $i = 0; } else { $i++; } $the_count = $count + $the_count; } } //var_dump($colors); for ($i = 0; $i < count($colors); $i++) { if ($nohighlight) { $text = str_replace('~' . $i, '<b><font color=red>', $text); $text = str_replace('^' . $i, '</font></b>', $text); } else { $text = str_replace('~' . $i, '<b><span style="background-color:' . $colors[$i] . ';display:inline-block">', $text); $text = str_replace('^' . $i, '</span></b>', $text); } } return $text; }