/** * Register the application services. * * @return void */ public function register() { $this->app->bind('laravel-monopond-fax', function () { $environment = config('monopond.environment'); return new MonopondSOAPClientV2(config('monopond.username'), config('monopond.password'), constant("MPENV::{$environment}")); }); }
/** * Implement permissions checks in a template. * * Available attributes: * - component (string) The component to be tested, e.g., 'ModuleName::' * - instance (string) The instance to be tested, e.g., 'name::1' * - level (int) The level of access required, e.g., ACCESS_READ * * Example: * <pre> * {secauthaction_block component='News::' instance='1::' level=ACCESS_COMMENT} * do some stuff now that we have permission * {/secauthaction_block} * </pre>. * * @param array $params All attributes passed to this function from the template. * @param string $content The content between the block tags. * @param Smarty &$smarty Reference to the {@link Zikula_View} object. * * @return mixed The content of the block, if the user has the specified * access level for the component and instance, otherwise null; * false on an error. * * @deprecated See {@link smarty_block_securityutil_checkpermission_block}. */ function smarty_block_secauthaction_block($params, $content, &$smarty) { LogUtil::log(__f('Warning! Template block {%1$s} is deprecated, please use {%2$s} instead.', array('secauthaction_block', 'checkpermissionblock')), E_USER_DEPRECATED); if (is_null($content)) { return; } // check our input if (!isset($params['component'])) { $smarty->trigger_error(__f('Error! in %1$s: the %2$s parameter must be specified.', array('smarty_block_secauthaction_block', 'component'))); return false; } if (!isset($params['instance'])) { $smarty->trigger_error(__f('Error! in %1$s: the %2$s parameter must be specified.', array('smarty_block_secauthaction_block', 'instance'))); return false; } if (!isset($params['level'])) { $smarty->trigger_error(__f('Error! in %1$s: the %2$s parameter must be specified.', array('smarty_block_secauthaction_block', 'level'))); return false; } if (!SecurityUtil::checkPermission($params['component'], $params['instance'], constant($params['level']))) { return; } return $content; }
/** * Tests invalid data. */ public function testInvalidDates() { $composer = new Composer(); // Invalid date/time parts $units = array('second' => array(-1, 61, '-1', '61'), 'minute' => array(-1, 61, '-1', '61'), 'hour' => array(-1, 24, '-1', '24'), 'day' => array(0, 32, '0', '32'), 'month' => array(0, 13, '0', '13'), 'year' => array(1901, 2038, '1901', '2038')); foreach ($units as $unit => $tests) { foreach ($tests as $test) { try { $composer->{'set' . ucfirst($unit)}($test); } catch (\Exception $e) { $this->assertInstanceOf('\\Jyxo\\Time\\ComposerException', $e); $this->assertSame(constant('\\Jyxo\\Time\\ComposerException::' . strtoupper($unit)), $e->getCode(), sprintf('Failed test for unit %s and value %s.', $unit, $test)); } } } // Incomplete date try { $date = $composer->getTime(); } catch (\Exception $e) { $this->assertInstanceOf('\\Jyxo\\Time\\ComposerException', $e); $this->assertSame(ComposerException::NOT_COMPLETE, $e->getCode()); } // Invalid dates $tests = array('2002-04-31', '2003-02-29', '2004-02-30', '2005-06-31', '2006-09-31', '2007-11-31'); foreach ($tests as $test) { try { list($year, $month, $day) = explode('-', $test); $composer->setDay($day)->setMonth($month)->setYear($year); $time = $composer->getTime(); } catch (\Exception $e) { $this->assertInstanceOf('\\Jyxo\\Time\\ComposerException', $e); $this->assertSame(ComposerException::INVALID, $e->getCode(), sprintf('Failed test for %s.', $test)); } } }
function dispatch(Lisphp_Form $name) { if ($name instanceof Lisphp_Symbol) { $phpname = $name = $name->symbol; } else { $phpname = $name[0]->symbol; $name = $name[1]->symbol; } $phpname = str_replace('-', '_', $phpname); try { if (preg_match('|^(?:([^/]+/)+)?<(.+?)>$|', $phpname, $matches)) { $phpname = str_replace('/', '_', $matches[1] . $matches[2]); $class = new Lisphp_Runtime_PHPClass($phpname); foreach ($class->getStaticMethods() as $methodName => $method) { $objs["{$name}/{$methodName}"] = $method; } $objs[$name] = $class; return $objs; } if (preg_match('|^(?:([^/]+/)+)?\\+(.+?)\\+$|', $phpname, $matches)) { $phpname = str_replace('/', '_', $matches[1] . $matches[2]); $objs[$name] = constant($phpname); return $objs; } return array($name => new Lisphp_Runtime_PHPFunction($phpname)); } catch (UnexpectedValueException $e) { throw new InvalidArgumentException($e); } }
function sendMemberDaytimeToAdmin($member_id, $service_id, $daytime_id) { define("BodyMemberDaytimeToAdmin", "<h1>Nouvelle inscription à une tranche horaire</h1><p>Un bénévole s'est inscrit à un secteur / tranche horaire.</p><p><strong>Nom :</strong> %s <br /><strong>Secteur :</strong> %s<br /><strong>Date :</strong> %s<br /><strong>Tranche horaire :</strong> %s</p><p><a href=\"" . JURI::root() . "/administrator/index.php?option=com_estivole&view=member&layout=edit&member_id=%s\">Cliquez ici</a> pour valider l'inscription et/ou recontacter le bénévole.</p>"); define("SubjectMemberDaytimeToAdmin", "Nouvelle inscription à une tranche horaire"); $db = JFactory::getDBO(); $query = $db->getQuery(TRUE); $this->user = JFactory::getUser(); // Get the dispatcher and load the user's plugins. $dispatcher = JEventDispatcher::getInstance(); JPluginHelper::importPlugin('user'); $data = new JObject(); $data->id = $this->user->id; // Trigger the data preparation event. $dispatcher->trigger('onContentPrepareData', array('com_users.profilestivole', &$data)); $userProfilEstivole = $data; $userName = $userProfilEstivole->profilestivole['firstname'] . ' ' . $userProfilEstivole->profilestivole['lastname']; $query->select('*'); $query->from('#__estivole_members as b, #__estivole_services as s, #__estivole_daytimes as d'); $query->where('b.member_id = ' . (int) $member_id); $query->where('s.service_id = ' . (int) $service_id); $query->where('d.daytime_id = ' . (int) $daytime_id); $db->setQuery($query); $mailModel = $db->loadObject(); $mail = JFactory::getMailer(); $mail->setBody(sprintf(constant("BodyMemberDaytimeToAdmin"), $userName, $mailModel->service_name, date('d-m-Y', strtotime($mailModel->daytime_day)), date('H:i', strtotime($mailModel->daytime_hour_start)) . ' - ' . date('H:i', strtotime($mailModel->daytime_hour_end)), $mailModel->member_id)); $mail->setSubject(constant("SubjectMemberDaytimeToAdmin")); $mail->isHtml(); $recipient = array('*****@*****.**', $mailModel->email_responsable); $mail->addRecipient($recipient); $mail->Send('*****@*****.**'); }
public function configsAction() { // config classes $check_classes = array('MysqlConfig', 'MongoConfig'); // check classes foreach ($check_classes as $class) { if (!class_exists($class)) { die("Error : bad config class {$define}.\n"); } echo "Check Config class : {$class}\n"; } echo "Check all config classes ok.\n"; // config defines $check_defines = array('__APP_NAME', '__COMM_LIB_DIR', '__HUSH_LIB_DIR', '__MAP_INI_FILE', '__MSG_INI_FILE', '__LIB_PATH_PAGE', '__TPL_SMARTY_PATH', '__FILECACHE_DIR'); // check frontend defines $this->_loadConfig('fe'); foreach ($check_defines as $define) { if (!defined($define) || !constant($define)) { die("Error : bad define constant {$define}.\n"); } echo "Check Frontend Define : {$define} > " . constant($define) . "\n"; } echo "Check frontend defines ok.\n"; // check backend defines $this->_loadConfig('be'); foreach ($check_defines as $define) { if (!defined($define) || !constant($define)) { die("Error : bad define constant {$define}.\n"); } echo "Check Backend Define : {$define} > " . constant($define) . "\n"; } echo "Check backend defines ok.\n"; }
/** * @see TypeDescription::parseTypeName() */ function parseTypeName($typeName) { // Configure the parent class type description // with the expected meta-data class. parent::parseTypeName('lib.pkp.classes.metadata.MetadataDescription'); // Split the type name into class name and assoc type. $typeNameParts = explode('(', $typeName); if (!count($typeNameParts) == 2) { return false; } // The meta-data schema class must be // a fully qualified class name. $splitMetadataSchemaClass = $this->splitClassName($typeNameParts[0]); if ($splitMetadataSchemaClass === false) { return false; } list($this->_metadataSchemaPackageName, $this->_metadataSchemaClassName) = $splitMetadataSchemaClass; // Identify the assoc type. $assocTypeString = trim($typeNameParts[1], ')'); if ($assocTypeString == '*') { $this->_assocType = ASSOC_TYPE_ANY; } else { // Make sure that the given assoc type exists. $assocTypeString = 'ASSOC_TYPE_' . $assocTypeString; if (!defined($assocTypeString)) { return false; } $this->_assocType = constant($assocTypeString); } return true; }
/** * Returns the choices associated to the model. * * @return array An array of choices */ public function getChoices() { $choices = array(); if (false !== $this->getOption('add_empty')) { $choices[''] = true === $this->getOption('add_empty') ? '' : $this->translate($this->getOption('add_empty')); } $class = constant($this->getOption('model') . '::PEER'); $criteria = null === $this->getOption('criteria') ? new Criteria() : clone $this->getOption('criteria'); if ($order = $this->getOption('order_by')) { $method = sprintf('add%sOrderByColumn', 0 === strpos(strtoupper($order[1]), 'ASC') ? 'Ascending' : 'Descending'); $criteria->{$method}(call_user_func(array($class, 'translateFieldName'), $order[0], BasePeer::TYPE_PHPNAME, BasePeer::TYPE_COLNAME)); } $objects = call_user_func(array($class, $this->getOption('peer_method')), $criteria, $this->getOption('connection')); $methodKey = $this->getOption('key_method'); if (!method_exists($this->getOption('model'), $methodKey)) { throw new RuntimeException(sprintf('Class "%s" must implement a "%s" method to be rendered in a "%s" widget', $this->getOption('model'), $methodKey, __CLASS__)); } $methodValue = $this->getOption('method'); if (!method_exists($this->getOption('model'), $methodValue)) { throw new RuntimeException(sprintf('Class "%s" must implement a "%s" method to be rendered in a "%s" widget', $this->getOption('model'), $methodValue, __CLASS__)); } foreach ($objects as $object) { $choices[$object->{$methodKey}()] = $object->{$methodValue}(); } return $choices; }
protected static function setOptions($ch, $method, &$url, &$data) { // Set default options foreach (static::$options as $option => $value) { curl_setopt($ch, constant(strtoupper($option)), $value); } $headers = array(); foreach (static::$headers as $key => $value) { $headers[] = $key . ': ' . $value; } curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); if (is_array($data)) { $data = http_build_query($data); } switch (strtoupper($method)) { case 'HEAD': curl_setopt($ch, CURLOPT_NOBODY, true); break; case 'GET': curl_setopt($ch, CURLOPT_HTTPGET, true); $url .= '?' . $data; $data = ''; break; case 'POST': curl_setopt($ch, CURLOPT_POST, true); break; default: curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $method); } curl_setopt($ch, CURLOPT_URL, $url); if (!empty($data)) { curl_setopt($ch, CURLOPT_POSTFIELDS, $data); } curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); }
protected function prepareSidebar() { if (!JCck::on()) { return; } $buttons = array(); if (JCck::getUIX() == 'compact') { $core = array(array('val' => '2', 'pre' => '', 'key' => 'COM_CCK_')); } else { $core = array(array('val' => '0', 'pre' => '', 'key' => 'COM_CCK_', 'img' => 'cck-application'), array('val' => '2', 'pre' => '- ', 'key' => 'COM_CCK_', 'img' => 'cck-form'), array('val' => '3', 'pre' => '- ', 'key' => '', 'img' => 'cck-plugin'), array('val' => '4', 'pre' => '- ', 'key' => 'COM_CCK_', 'img' => 'cck-search'), array('val' => '1', 'pre' => '- ', 'key' => '', 'img' => 'cck-template'), array('val' => '5', 'pre' => '', 'key' => '', 'img' => 'cck-multisite')); } $components = JCckDatabase::loadObjectList('SELECT a.title, a.link, b.element' . ' FROM #__menu AS a LEFT JOIN #__extensions AS b ON b.extension_id = a.component_id' . ' WHERE a.link LIKE "index.php?option=com_cck\\_%"' . ' AND a.link NOT IN ("index.php?option=com_cck_toolbox&view=processing","index.php?option=com_cck_webservices&view=api")' . ' ORDER BY a.title ASC'); $groupedButtons = array(); $more = array('ADDON' => 16, 'PLUGIN_FIELD' => 19, 'PLUGIN_LINK' => 20, 'PLUGIN_LIVE' => 21, 'PLUGIN_RESTRICTION' => 112, 'PLUGIN_TYPOGRAPHY' => 24, 'PLUGIN_VALIDATION' => 25, 'TEMPLATE' => 27); foreach ($core as $k => $v) { $buttons[] = array('access' => array('core.manage', 'com_cck'), 'group' => 'COM_CCK_CORE', 'image' => $v['img'], 'link' => JRoute::_(constant('_C' . $v['val'] . '_LINK')), 'target' => '_self', 'text' => $v['pre'] . JText::_($v['key'] . constant('_C' . $v['val'] . '_TEXT') . 'S')); } foreach ($components as $k => $v) { $buttons[] = array('access' => array('core.manage', $v->element), 'group' => 'COM_CCK_SEBLOD_MORE', 'image' => 'cck-addon', 'link' => JRoute::_($v->link), 'target' => '_self', 'text' => $v->title); } foreach ($more as $k => $v) { $buttons[] = array('access' => array('core.manage', 'com_cck'), 'group' => 'COM_CCK_SEBLOD_COM', 'image' => 'download', 'link' => JRoute::_('http://www.seblod.com/products?seb_item_category=' . $v), 'target' => '_blank', 'text' => JText::_('COM_CCK_PANE_MORE_' . $k)); } foreach ($buttons as $button) { $groupedButtons[$button['group']][] = $button; } $this->sidebar = '<div class="sidebar-nav quick-icons">' . JHtml::_('links.linksgroups', $groupedButtons) . '</div>'; }
/** * Initializes the backend to perform the search * Connects to the LDAP server using the values from the configuration * * * @access public * @return * @throws StatusException */ public function BackendSearchLDAP() { if (!function_exists("ldap_connect")) { throw new StatusException("BackendSearchLDAP(): php-ldap is not installed. Search aborted.", SYNC_SEARCHSTATUS_STORE_SERVERERROR, null, LOGLEVEL_FATAL); } // connect to LDAP $this->connection = @ldap_connect(LDAP_HOST, LDAP_PORT); @ldap_set_option($this->connection, LDAP_OPT_PROTOCOL_VERSION, 3); // Authenticate if (constant('ANONYMOUS_BIND') === true) { if (!@ldap_bind($this->connection)) { $this->connection = false; throw new StatusException("BackendSearchLDAP(): Could not bind anonymously to server! Search aborted.", SYNC_SEARCHSTATUS_STORE_CONNECTIONFAILED, null, LOGLEVEL_ERROR); } } else { if (constant('LDAP_BIND_USER') != "") { if (!@ldap_bind($this->connection, LDAP_BIND_USER, LDAP_BIND_PASSWORD)) { $this->connection = false; throw new StatusException(sprintf("BackendSearchLDAP(): Could not bind to server with user '%s' and specified password! Search aborted.", LDAP_BIND_USER), SYNC_SEARCHSTATUS_STORE_ACCESSDENIED, null, LOGLEVEL_ERROR); } } else { // it would be possible to use the users login and password to authenticate on the LDAP server // the main $backend has to keep these values so they could be used here $this->connection = false; throw new StatusException("BackendSearchLDAP(): neither anonymous nor default bind enabled. Other options not implemented.", SYNC_SEARCHSTATUS_STORE_CONNECTIONFAILED, null, LOGLEVEL_ERROR); } } }
public function __construct() { $this->name = 'nqgatewayneteven'; $tab_name = 'Tools'; if (constant('_PS_VERSION_') >= 1.4) { $tab_name = 'market_place'; } $this->tab = $tab_name; $this->version = '2.8'; $this->author = 'NetEven'; parent::__construct(); $this->displayName = $this->l('NetEven'); $this->description = $this->l('Vendez sur toutes les marketplaces depuis votre PrestaShop'); $this->ps_versions_compliancy = array('min' => '1.4', 'max' => _PS_VERSION_); $this->feature_url = '/script/set-neteven-categories.php?token=' . Tools::encrypt(Configuration::get('PS_SHOP_NAME')); $this->order_url = '/script/import-order.php?token=' . Tools::encrypt(Configuration::get('PS_SHOP_NAME')) . '&active=1'; $this->product_url = '/script/update-product.php?token=' . Tools::encrypt(Configuration::get('PS_SHOP_NAME')) . '&active=1'; if (!$this->getSOAP()) { $this->warning = $this->l('SOAP should be installed for this module'); } if (version_compare(_PS_VERSION_, '1.5', '<')) { require _PS_MODULE_DIR_ . $this->name . '/backward_compatibility/backward.php'; } if (Module::isInstalled($this->name)) { $this->unInstallHookByVersion(); $this->installHookByVersion(); $this->installCarrier(); } }
public function createThumbnail() { $args = array_merge($this->defaults, func_get_args()[0]); $args = ArrayHash::from($args); $storage = $this->media->getStorage($args->storage); if (isset($args->namespace)) { $storage->setNamespace($args->namespace); } $image = $storage->load($args->file); $width = $args->width; $height = $args->height; if ($image !== NULL) { if ($width && $width != $image->width) { $name = $this->createThumbnailName($image, $width, $height); $thumb = $storage->absolutePath . '/' . $name; $src = NULL; if (!file_exists($thumb)) { $image = Image::fromFile($image->absolutePath); if (empty($height)) { $height = $width; } $image->resize($width, $height, constant('Nette\\Image::' . strtoupper($args->flag))); $image->save($thumb); } $image = $storage->load($name); } $src = $storage->getBaseUrl() . '/' . $image->filename; return $src; } }
public function load_config() { if (defined('MPESA_ORDER_ID')) { $this->data['ORDER_ID'] = constant('MPESA_ORDER_ID'); } if (defined('MPESA_INVOCE')) { $this->data['INVOCE'] = constant('MPESA_INVOCE'); } if (defined('MPESA_TOTAL')) { $this->data['TOTAL'] = constant('MPESA_TOTAL'); } if (defined('MPESA_PHONE_1')) { $this->data['PHONE_1'] = constant('MPESA_PHONE_1'); } if (defined('MPESA_PHONE_2')) { $this->data['PHONE_2'] = constant('MPESA_PHONE_2'); } if (defined('MPESA_EMAIL')) { $this->data['EMAIL'] = constant('MPESA_EMAIL'); } if (defined('MPESA_VENDOR_REF')) { $this->data['VENDOR_REF'] = constant('MPESA_VENDOR_REF'); } if (defined('MPESA_MPESA')) { $this->data['MPESA'] = constant('MPESA_MPESA'); } }
/** * woothemes_metabox_create function. * * @access public * @param object $post * @param array $callback * @return void */ function woothemes_metabox_create($post, $callback) { global $post; // Allow child themes/plugins to act here. do_action('woothemes_metabox_create', $post, $callback); $seo_post_types = array('post', 'page'); if (defined('SEOPOSTTYPES')) { $seo_post_types_update = unserialize(constant('SEOPOSTTYPES')); } if (!empty($seo_post_types_update)) { $seo_post_types = $seo_post_types_update; } $template_to_show = $callback['args']; $woo_metaboxes = get_option('woo_custom_template', array()); $seo_metaboxes = get_option('woo_custom_seo_template', array()); if (empty($seo_metaboxes) && $template_to_show == 'seo') { return; } // Array sanity check. if (!is_array($woo_metaboxes)) { $woo_metaboxes = array(); } // Determine whether or not to display general fields. $display_general_fields = true; if (count($woo_metaboxes) <= 0) { $display_general_fields = false; } // Determine whether or not to display SEO fields. $display_seo_fields = true; if (get_option('seo_woo_hide_fields') == 'true' || get_option('seo_woo_use_third_party_data') == 'true') { $display_seo_fields = false; } $output = ''; // Add nonce for custom fields. $output .= wp_nonce_field('wooframework-custom-fields', 'wooframework-custom-fields-nonce', true, false); if ($callback['id'] == 'woothemes-settings') { // Add tabs. $output .= '<div class="wooframework-tabs">' . "\n"; $output .= '<ul class="tabber hide-if-no-js">' . "\n"; if ($display_general_fields) { $output .= '<li class="wf-tab-general"><a href="#wf-tab-general">' . __('General Settings', 'woothemes') . '</a></li>' . "\n"; } if ($display_seo_fields) { $output .= '<li class="wf-tab-seo"><a href="#wf-tab-seo">' . __('SEO', 'woothemes') . '</a></li>' . "\n"; } // Allow themes/plugins to add tabs to WooFramework custom fields. $output .= apply_filters('wooframework_custom_field_tab_headings', ''); $output .= '</ul>' . "\n"; } if ($display_general_fields) { $output .= woothemes_metabox_create_fields($woo_metaboxes, $callback, 'general'); } if ($display_seo_fields && array_search(get_post_type(), $seo_post_types) !== false) { $output .= woothemes_metabox_create_fields($seo_metaboxes, $callback, 'seo'); } // Allow themes/plugins to add tabs to WooFramework custom fields. $output = apply_filters('wooframework_custom_field_tab_content', $output); $output .= '</div>' . "\n"; echo $output; }
public function renderConfSettings() { $settings = ['JIG_COMPILE_CHECK' => Jig::COMPILE_CHECK_EXISTS, 'CACHING_SETTING' => Caching::CACHING_TIME, 'LIBRATO_STATSSOURCENAME' => null]; $output = ""; $output .= "<table class='table-serverSettings'>"; $output .= "<thead>"; $output .= "<th>Conf setting</th>"; $output .= "<th>Value</th>"; $output .= "</thead>"; $output .= "<body>"; foreach ($settings as $setting => $expectedValue) { $value = Config::getEnv(constant("ImagickDemo\\Config::{$setting}")); $class = 'good'; if ($expectedValue === null) { //Do nothing. } else { if ($value != $expectedValue) { $class = 'bad'; } } $value = var_export($value, true); $output .= "<tr>"; $output .= sprintf("<td class='%s'>%s</td><td class='%s'>%s</td>", $class, htmlentities($setting, ENT_DISALLOWED | ENT_HTML401 | ENT_NOQUOTES, 'UTF-8'), $class, htmlentities($value, ENT_DISALLOWED | ENT_HTML401 | ENT_NOQUOTES, 'UTF-8')); $output .= "</tr>"; } $output .= "</tbody></table>"; return $output; }
function eis_file(&$filename) { if (defined('INCLUDE_PATH') && constant('INCLUDE_PATH')) { return array('.', INCLUDE_PATH); } $inc_path_delim = substr(PHP_OS, 0, 3) == 'WIN' ? ';' : ':'; $path_delim = substr(PHP_OS, 0, 3) == 'WIN' ? "\\" : '/'; $ipath = explode($inc_path_delim, ini_get('include_path')); $file = implode($path_delim, explode("/", $filename)); //ищем файл $flag = false; foreach ($ipath as $path) { if ($path != ".") { $path = implode($path_delim, explode($path_delim, $path)); //обрезаем последний слэш $path = implode($path_delim, explode($path_delim, $path)) . $path_delim . ENGINE_VERSION . $path_delim . ENGINE_TYPE . $path_delim; } if (is_file($path . $path_delim . $file)) { $flag = true; break; } } if ($flag) { $filename = $path . $path_delim . $file; } return $flag; }
public function connect() { if (!isset(self::$_cacheObj)) { if (defined('KVSTORE_MEMCACHE_CONFIG') && constant('KVSTORE_MEMCACHE_CONFIG')) { self::$_cacheObj = new Memcache(); $config = explode(',', KVSTORE_MEMCACHE_CONFIG); foreach ($config as $row) { $row = trim($row); if (strpos($row, 'unix:///') === 0) { continue; //暂不支持 } else { $tmp = explode(':', $row); self::$_cacheObj->addServer($tmp[0], $tmp[1]); } } } else { trigger_error('can\'t load KVSTORE_MEMCACHE_CONFIG, please check it', E_USER_ERROR); } //检查是否有可用kv服务器 $status = self::$_cacheObj->getExtendedStats(); if (!$status || !is_array($status)) { trigger_error('can\'t connect to kv-storage system', E_USER_ERROR); } foreach ($status as $key => $value) { if ($value === false) { unset($status[$key]); } } if (count($status) == 0) { trigger_error('can\'t connect to kv-storage system', E_USER_ERROR); } } }
/** * Example: * {secauthaction comp="Stories::" inst=".*" level="ACCESS_ADMIN" assign="auth"} * * true/false will be returned. * * This file is a plugin for Zikula_View, the Zikula implementation of Smarty * @param array $params All attributes passed to this function from the template * @param object &$smarty Reference to the Smarty object * @return boolean authorized? */ function smarty_function_secauthaction($params, &$smarty) { LogUtil::log(__f('Warning! Template plugin {%1$s} is deprecated, please use {%2$s} instead.', array('secauthaction', 'checkpermission')), E_USER_DEPRECATED); $assign = isset($params['assign']) ? $params['assign'] : null; $comp = isset($params['comp']) ? $params['comp'] : null; $inst = isset($params['inst']) ? $params['inst'] : null; $level = isset($params['level']) ? $params['level'] : null; if (!$comp) { $smarty->trigger_error(__f('Error! in %1$s: the %2$s parameter must be specified.', array('smarty_function_secauthaction', 'comp'))); return false; } if (!$inst) { $smarty->trigger_error(__f('Error! in %1$s: the %2$s parameter must be specified.', array('smarty_function_secauthaction', 'inst'))); return false; } if (!$level) { $smarty->trigger_error(__f('Error! in %1$s: the %2$s parameter must be specified.', array('smarty_function_secauthaction', 'level'))); return false; } $result = SecurityUtil::checkPermission($comp, $inst, constant($level)); if ($assign) { $smarty->assign($assign, $result); } else { return $result; } }
public function setUsers(array $users) { $this->users = array(); foreach ($users as $user) { if (!isset($user['permission'])) { throw new \InvalidArgumentException(sprintf('setUsers() expects an array where each item contains a "permission" key, but got %s.', json_encode($user))); } if (!defined($constant = 'AmazonS3::GRANT_' . strtoupper($user['permission']))) { throw new \InvalidArgumentException('The permission must be the suffix for one of the AmazonS3::GRANT_ constants.'); } $user['permission'] = constant($constant); if (isset($user['group'])) { if (!defined($constant = 'AmazonS3::USERS_' . strtoupper($user['group']))) { throw new \InvalidArgumentException('The group must be the suffix for one of the AmazonS3::USERS_ constants.'); } $user['id'] = constant($constant); unset($user['group']); } else { if (!isset($user['id'])) { throw new \InvalidArgumentException(sprintf('Either "group", or "id" must be set for each user, but got %s.', json_encode($user))); } } $this->users[] = $user; } }
/** * Formats a given decimal value to a local aware currency value * * * @link http://framework.zend.com/manual/de/zend.currency.options.html * @param float $value Value can have a coma as a decimal separator * @param array $config * @param string $position where the currency symbol should be displayed * @return float|string */ function smarty_modifier_currency($value, $config = null, $position = null) { if (!Enlight_Application::Instance()->Bootstrap()->hasResource('Currency')) { return $value; } if (!empty($config) && is_string($config)) { $config = strtoupper($config); if (defined('Zend_Currency::' . $config)) { $config = array('display' => constant('Zend_Currency::' . $config)); } else { $config = array(); } } else { $config = array(); } if (!empty($position) && is_string($position)) { $position = strtoupper($position); if (defined('Zend_Currency::' . $position)) { $config['position'] = constant('Zend_Currency::' . $position); } } $currency = Enlight_Application::Instance()->Currency(); $value = floatval(str_replace(',', '.', $value)); $value = $currency->toCurrency($value, $config); if (function_exists('mb_convert_encoding')) { $value = mb_convert_encoding($value, 'HTML-ENTITIES', 'UTF-8'); } $value = htmlentities($value, ENT_COMPAT, 'UTF-8', false); return $value; }
function email($headers = '') { if ($headers == '') { $headers = array(); } $this->html_images = array(); $this->headers = array(); if (EMAIL_LINEFEED == 'CRLF') { $this->lf = "\r\n"; } else { $this->lf = "\n"; } /** * If you want the auto load functionality * to find other mime-image/file types, add the * extension and content type here. */ $this->image_types = array('gif' => 'image/gif', 'jpg' => 'image/jpeg', 'jpeg' => 'image/jpeg', 'jpe' => 'image/jpeg', 'bmp' => 'image/bmp', 'png' => 'image/png', 'tif' => 'image/tiff', 'tiff' => 'image/tiff', 'swf' => 'application/x-shockwave-flash'); $this->build_params['html_encoding'] = 'quoted-printable'; $this->build_params['text_encoding'] = '7bit'; $this->build_params['html_charset'] = constant('CHARSET'); $this->build_params['text_charset'] = constant('CHARSET'); $this->build_params['text_wrap'] = 998; /** * Make sure the MIME version header is first. */ $this->headers[] = 'MIME-Version: 1.0'; reset($headers); while (list(, $value) = each($headers)) { if (tep_not_null($value)) { $this->headers[] = $value; } } }
/** * Compatibility list of params were saved in config files * @param string|null $group * @return array|object */ public function getList($group = null) { $ymlConfig = $this->app->path->path('jbapp:config') . '/yml_config.php'; if (JFile::exists($ymlConfig)) { require_once $ymlConfig; } $config = $this->app->path->path('jbapp:config') . '/config.php'; if (JFile::exists($config)) { require_once $config; } $result = array(); foreach ($this->_oldVersionMap as $key => $value) { if (!defined($key)) { continue; } if (in_array($key, array('JBZOO_CONFIG_YML_TYPE', 'JBZOO_CONFIG_YML_APP_LIST'))) { $result[$value] = explode(':', constant($key)); } else { $result[$value] = constant($key); } } if (!empty($group)) { $result = JBModelConfig::model()->getGroup($group, $result); } return $this->app->data->create($result); }
function at_block_titles() { $runningconfig = atGetRunningConfig(); extract($runningconfig); $blocktitle = trim(strip_tags($block['title'], "")); // Check if title is a language define if ($blocktitle[0] == "_" && defined($blocktitle)) { $blocktitle = constant($blocktitle); } // Look for image in themes/thename/images/lang/ then themes/thename/images/ $titleimage = strtolower(preg_replace("^\\W|_^", "", $blocktitle)); if (@file_exists($imagepath . "{$language}/{$titleimage}.gif")) { $block['title'] = "<img src=\"{$imagepath}" . "{$language}/{$titleimage}.gif\" border=\"0\" alt=\"{$blocktitle}\" />"; } elseif (@file_exists($imagepath . "{$titleimage}.gif")) { $block['title'] = "<img src=\"{$imagepath}" . "{$titleimage}.gif\" border=\"0\" alt=\"{$blocktitle}\" />"; } elseif (@file_exists($imagepath . "{$language}/{$titleimage}.jpg")) { $block['title'] = "<img src=\"{$imagepath}" . "{$language}/{$titleimage}.jpg\" border=\"0\" alt=\"{$blocktitle}\" />"; } elseif (@file_exists($imagepath . "{$titleimage}.jpg")) { $block['title'] = "<img src=\"{$imagepath}" . "{$titleimage}.jpg\" border=\"0\" alt=\"{$blocktitle}\" />"; } elseif (@file_exists($imagepath . "{$language}/{$titleimage}.png")) { $block['title'] = "<img src=\"{$imagepath}" . "{$language}/{$titleimage}.png\" border=\"0\" alt=\"{$blocktitle}\" />"; } elseif (@file_exists($imagepath . "{$titleimage}.png")) { $block['title'] = "<img src=\"{$imagepath}" . "{$titleimage}.png\" border=\"0\" alt=\"{$blocktitle}\" />"; } atCommandBuild($block, "block"); }
public static function get($var) { $return = FALSE; if (MEMCACHED_ENABLED) { $cache = Cache::Instance(); $return = $cache->get(array('system_company_settings', $var)); } if (FALSE === $return) { //if it's a constant, use that $c_var = 'self::' . $var; if (defined($c_var)) { $return = constant($c_var); } else { //check for a db-field corresponding to the value. and use that $sc = new Systemcompany(); if (EGS_COMPANY_ID !== 'null' && $sc->isField($var)) { $res = $sc->load(EGS_COMPANY_ID); $return = $sc->{$var}; } else { //_ indicates a default for a DB-value $c_var = 'self::_' . $var; if (defined($c_var)) { $return = constant($c_var); } } } if (MEMCACHED_ENABLED) { $cache->add(array('system_company_settings', $var), $return, 28800); } } return $return; }
function introspect_config_item($name, &$propbag) { if ($name == 'utf8_parse') { $propbag->add('type', 'boolean'); $propbag->add('name', PLUGIN_EVENT_XHTMLCLEANUP_UTF8); $propbag->add('description', PLUGIN_EVENT_XHTMLCLEANUP_UTF8_DESC); $propbag->add('default', 'true'); } elseif ($name == 'xhtml_parse') { $propbag->add('type', 'boolean'); $propbag->add('name', PLUGIN_EVENT_XHTMLCLEANUP_XHTML); $propbag->add('description', PLUGIN_EVENT_XHTMLCLEANUP_XHTML_DESC); $propbag->add('default', 'true'); } elseif ($name == 'youtube') { $propbag->add('type', 'boolean'); $propbag->add('name', PLUGIN_EVENT_XHTMLCLEANUP_YOUTUBE); $propbag->add('description', PLUGIN_EVENT_XHTMLCLEANUP_YOUTUBE_DESC); $propbag->add('default', 'false'); } else { $propbag->add('type', 'boolean'); $propbag->add('name', constant($name)); $propbag->add('description', sprintf(APPLY_MARKUP_TO, constant($name))); $propbag->add('default', 'true'); } return true; }
public static function suite() { $suite = new PHPUnit_Framework_TestSuite('Zend Framework - Zend_Ldap'); $suite->addTestSuite('Zend_Ldap_OfflineTest'); if (defined('TESTS_ZEND_LDAP_ONLINE_ENABLED') && constant('TESTS_ZEND_LDAP_ONLINE_ENABLED')) { /** * @see Zend_Ldap_ConnectTest */ require_once 'Zend/Ldap/ConnectTest.php'; $suite->addTestSuite('Zend_Ldap_ConnectTest'); /** * @see Zend_Ldap_BindTest */ require_once 'Zend/Ldap/BindTest.php'; $suite->addTestSuite('Zend_Ldap_BindTest'); /** * @see Zend_Ldap_CanonTest */ require_once 'Zend/Ldap/CanonTest.php'; $suite->addTestSuite('Zend_Ldap_CanonTest'); } else { $suite->addTest(new Zend_Ldap_SkipOnlineTests()); } return $suite; }
public function setUp() { if (!constant('TESTS_ZEND_SERIALIZER_ADAPTER_IGBINARY_ENABLED')) { $this->markTestSkipped('Zend_Serializer IgBinary tests are not enabled'); } $this->_adapter = new \Zend\Serializer\Adapter\Igbinary(); }
/** * {@inheritdoc} * @return mixed * @throws \InvalidArgumentException */ public function evaluate(array $data) { if (!isset($data['value']) || !defined($data['value'])) { throw new \InvalidArgumentException('Constant name is expected.'); } return constant($data['value']); }
function buildBlocks() { if (defined('TEMPLATE_BLOCK_GROUPS') && tep_not_null(TEMPLATE_BLOCK_GROUPS)) { $tbgroups_array = explode(';', TEMPLATE_BLOCK_GROUPS); foreach ($tbgroups_array as $group) { $module_key = 'MODULE_' . strtoupper($group) . '_INSTALLED'; if (defined($module_key) && tep_not_null(constant($module_key))) { $modules_array = explode(';', constant($module_key)); foreach ($modules_array as $module) { $class = basename($module, '.php'); if (!class_exists($class)) { if (file_exists(DIR_WS_LANGUAGES . $_SESSION['language'] . '/modules/' . $group . '/' . $module)) { include DIR_WS_LANGUAGES . $_SESSION['language'] . '/modules/' . $group . '/' . $module; } if (file_exists(DIR_WS_MODULES . $group . '/' . $class . '.php')) { include DIR_WS_MODULES . $group . '/' . $class . '.php'; } } if (class_exists($class)) { $mb = new $class(); if ($mb->isEnabled()) { $mb->execute(); } } } } } } }