Esempio n. 1
2
/**
 * utf8::str_pad
 *
 * @package    Core
 * @author     Kohana Team
 * @copyright  (c) 2007 Kohana Team
 * @copyright  (c) 2005 Harry Fuecks
 * @license    http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt
 */
function _str_pad($str, $final_str_length, $pad_str = ' ', $pad_type = STR_PAD_RIGHT)
{
    if (utf8::is_ascii($str) and utf8::is_ascii($pad_str)) {
        return str_pad($str, $final_str_length, $pad_str, $pad_type);
    }
    $str_length = utf8::strlen($str);
    if ($final_str_length <= 0 or $final_str_length <= $str_length) {
        return $str;
    }
    $pad_str_length = utf8::strlen($pad_str);
    $pad_length = $final_str_length - $str_length;
    if ($pad_type == STR_PAD_RIGHT) {
        $repeat = ceil($pad_length / $pad_str_length);
        return utf8::substr($str . str_repeat($pad_str, $repeat), 0, $final_str_length);
    }
    if ($pad_type == STR_PAD_LEFT) {
        $repeat = ceil($pad_length / $pad_str_length);
        return utf8::substr(str_repeat($pad_str, $repeat), 0, floor($pad_length)) . $str;
    }
    if ($pad_type == STR_PAD_BOTH) {
        $pad_length /= 2;
        $pad_length_left = floor($pad_length);
        $pad_length_right = ceil($pad_length);
        $repeat_left = ceil($pad_length_left / $pad_str_length);
        $repeat_right = ceil($pad_length_right / $pad_str_length);
        $pad_left = utf8::substr(str_repeat($pad_str, $repeat_left), 0, $pad_length_left);
        $pad_right = utf8::substr(str_repeat($pad_str, $repeat_right), 0, $pad_length_left);
        return $pad_left . $str . $pad_right;
    }
    trigger_error('utf8::str_pad: Unknown padding type (' . $type . ')', E_USER_ERROR);
}
Esempio n. 2
1
 /**
  * Factory method that creates a cache object based on configuration
  * @param $name Name of definitions handled by cache
  * @param $config Instance of HTMLPurifier_Config
  */
 public function create($type, $config)
 {
     $method = $config->get('Cache', 'DefinitionImpl');
     if ($method === null) {
         return new HTMLPurifier_DefinitionCache_Null($type);
     }
     if (!empty($this->caches[$method][$type])) {
         return $this->caches[$method][$type];
     }
     if (isset($this->implementations[$method]) && class_exists($class = $this->implementations[$method], false)) {
         $cache = new $class($type);
     } else {
         if ($method != 'Serializer') {
             trigger_error("Unrecognized DefinitionCache {$method}, using Serializer instead", E_USER_WARNING);
         }
         $cache = new HTMLPurifier_DefinitionCache_Serializer($type);
     }
     foreach ($this->decorators as $decorator) {
         $new_cache = $decorator->decorate($cache);
         // prevent infinite recursion in PHP 4
         unset($cache);
         $cache = $new_cache;
     }
     $this->caches[$method][$type] = $cache;
     return $this->caches[$method][$type];
 }
Esempio n. 3
1
 function calculateGFRResult()
 {
     $tmpArr = array();
     $tmpArr[] = date('Y-m-d H:i:s');
     //observation time
     $tmpArr[] = 'GFR (CALC)';
     //desc
     $gender = NSDR::populate($this->_patientId . "::com.clearhealth.person.displayGender");
     $crea = NSDR::populate($this->_patientId . "::com.clearhealth.labResults[populate(@description=CREA)]");
     $genderFactor = null;
     $creaValue = null;
     $personAge = null;
     $raceFactor = 1;
     switch ($gender[key($gender)]) {
         case 'M':
             $genderFactor = 1;
             break;
         case 'F':
             $genderFactor = 0.742;
             break;
     }
     if ((int) strtotime($crea['observation_time']) >= strtotime('now - 60 days') && strtolower($crea[key($crea)]['units']) == 'mg/dl') {
         $creaValue = $crea[key($crea)]['value'];
     }
     $person = new Person();
     $person->personId = $this->_patientId;
     $person->populate();
     if ($person->age > 0) {
         $personAge = $person->age;
     }
     $personStat = new PatientStatistics();
     $personStat->personId = $this->_patientId;
     $personStat->populate();
     if ($personStat->race == "AFAM") {
         $raceFactor = 1.21;
     }
     $gfrValue = "INC";
     if ($personAge > 0 && $creaValue > 0) {
         $gfrValue = "" . (int) round(pow($creaValue, -1.154) * pow($personAge, -0.203) * $genderFactor * $raceFactor * 186);
     }
     trigger_error("gfr:: " . $gfrValue, E_USER_NOTICE);
     $tmpArr[] = $gfrValue;
     // lab value
     $tmpArr[] = 'mL/min/1.73 m2';
     //units
     $tmpArr[] = '';
     //ref range
     $tmpArr[] = '';
     //abnormal
     $tmpArr[] = 'F';
     //status
     $tmpArr[] = date('Y-m-d H:i:s') . '::' . '0';
     // observationTime::(boolean)normal; 0 = abnormal, 1 = normal
     $tmpArr[] = '0';
     //sign
     //$this->_calcLabResults[uniqid()] = $tmpArr;
     $this->_calcLabResults[1] = $tmpArr;
     // temporarily set index to one(1) to be able to include in selected lab results
     return $tmpArr;
 }
 /**
  * Setup the config based on either the Configure::read() values
  * or the PaypalIpnConfig in config/paypal_ipn_config.php
  *
  * Will attempt to read configuration in the following order:
  *   Configure::read('PaypalIpn')
  *   App::import() of config/paypal_ipn_config.php
  *   App::import() of plugin's config/paypal_ipn_config.php
  */
 function __construct()
 {
     $this->config = Configure::read('PaypalIpn');
     if (empty($this->config)) {
         $importConfig = array('type' => 'File', 'name' => 'PaypalIpn.PaypalIpnConfig', 'file' => CONFIGS . 'paypal_ipn_config.php');
         if (!class_exists('PaypalIpnConfig')) {
             App::import($importConfig);
         }
         if (!class_exists('PaypalIpnConfig')) {
             // Import from paypal plugin configuration
             $importConfig['file'] = 'config' . DS . 'paypal_ipn_config.php';
             App::import($importConfig);
         }
         if (!class_exists('PaypalIpnConfig')) {
             trigger_error(__d('paypal_ipn', 'PaypalIpnConfig: The configuration could not be loaded.', true), E_USER_ERROR);
         }
         if (!PHP5) {
             $config =& new PaypalIpnConfig();
         } else {
             $config = new PaypalIpnConfig();
         }
         $vars = get_object_vars($config);
         foreach ($vars as $property => $configuration) {
             if (strpos($property, 'encryption_') === 0) {
                 $name = substr($property, 11);
                 $this->encryption[$name] = $configuration;
             } else {
                 $this->config[$property] = $configuration;
             }
         }
     }
     parent::__construct();
 }
Esempio n. 5
0
 function __construct($oTemplate = false)
 {
     if (isset($GLOBALS['bxDolClasses'][get_class($this)])) {
         trigger_error('Multiple instances are not allowed for the class: ' . get_class($this), E_USER_ERROR);
     }
     parent::__construct($oTemplate ? $oTemplate : BxDolStudioTemplate::getInstance());
 }
Esempio n. 6
0
/**
 * Main function for the routines functionality
 *
 * @return nothing
 */
function PMA_RTN_main()
{
    global $db;
    PMA_RTN_setGlobals();
    /**
     * Process all requests
     */
    PMA_RTN_handleEditor();
    PMA_RTN_handleExecute();
    PMA_RTN_handleExport();
    /**
     * Display a list of available routines
     */
    $columns = "`SPECIFIC_NAME`, `ROUTINE_NAME`, `ROUTINE_TYPE`, ";
    $columns .= "`DTD_IDENTIFIER`, `ROUTINE_DEFINITION`";
    $where = "ROUTINE_SCHEMA='" . PMA_Util::sqlAddSlashes($db) . "'";
    $items = PMA_DBI_fetch_result("SELECT {$columns} FROM `INFORMATION_SCHEMA`.`ROUTINES` WHERE {$where};");
    echo PMA_RTE_getList('routine', $items);
    /**
     * Display the form for adding a new routine, if the user has the privileges.
     */
    echo PMA_RTN_getFooterLinks();
    /**
     * Display a warning for users with PHP's old "mysql" extension.
     */
    if ($GLOBALS['cfg']['Server']['extension'] === 'mysql') {
        trigger_error(__('You are using PHP\'s deprecated \'mysql\' extension, ' . 'which is not capable of handling multi queries. ' . '[strong]The execution of some stored routines may fail![/strong] ' . 'Please use the improved \'mysqli\' extension to ' . 'avoid any problems.'), E_USER_WARNING);
    }
}
 /**
  * Page のアクション.
  *
  * @return void
  */
 public function action()
 {
     $objDeliv = new SC_Helper_Delivery_Ex();
     $mode = $this->getMode();
     if (!empty($_POST)) {
         $objFormParam = new SC_FormParam_Ex();
         $objFormParam->setParam($_POST);
         $this->arrErr = $this->lfCheckError($mode, $objFormParam);
         if (!empty($this->arrErr['deliv_id'])) {
             trigger_error('', E_USER_ERROR);
             return;
         }
     }
     switch ($mode) {
         case 'delete':
             // ランク付きレコードの削除
             $objDeliv->delete($_POST['deliv_id']);
             $this->objDisplay->reload();
             // PRG pattern
             break;
         case 'up':
             $objDeliv->rankUp($_POST['deliv_id']);
             $this->objDisplay->reload();
             // PRG pattern
             break;
         case 'down':
             $objDeliv->rankDown($_POST['deliv_id']);
             $this->objDisplay->reload();
             // PRG pattern
             break;
         default:
             break;
     }
     $this->arrDelivList = $objDeliv->getList();
 }
Esempio n. 8
0
 public static function formatMessage(Rule $rule, $withValue = TRUE)
 {
     $message = $rule->message;
     if ($message instanceof Nette\Utils\Html) {
         return $message;
     } elseif ($message === NULL && is_string($rule->validator) && isset(static::$messages[$rule->validator])) {
         $message = static::$messages[$rule->validator];
     } elseif ($message == NULL) {
         // intentionally ==
         trigger_error("Missing validation message for control '{$rule->control->getName()}'.", E_USER_WARNING);
     }
     if ($translator = $rule->control->getForm()->getTranslator()) {
         $message = $translator->translate($message, is_int($rule->arg) ? $rule->arg : NULL);
     }
     $message = preg_replace_callback('#%(name|label|value|\\d+\\$[ds]|[ds])#', function ($m) use($rule, $withValue) {
         static $i = -1;
         switch ($m[1]) {
             case 'name':
                 return $rule->control->getName();
             case 'label':
                 return $rule->control->translate($rule->control->caption);
             case 'value':
                 return $withValue ? $rule->control->getValue() : $m[0];
             default:
                 $args = is_array($rule->arg) ? $rule->arg : array($rule->arg);
                 $i = (int) $m[1] ? $m[1] - 1 : $i + 1;
                 return isset($args[$i]) ? $args[$i] instanceof IControl ? $withValue ? $args[$i]->getValue() : "%{$i}" : $args[$i] : '';
         }
     }, $message);
     return $message;
 }
Esempio n. 9
0
 public function output(Pagemill_Data $data, Pagemill_Stream $stream)
 {
     //$inner = $data->parseVariables($this->rawOutput(), false);
     $tmp = new Pagemill_Stream(true);
     foreach ($this->children() as $child) {
         $child->process($data, $tmp);
     }
     $inner = html_entity_decode($tmp->peek(), ENT_COMPAT, 'UTF-8');
     $data->set('value', $inner);
     $use = $data->parseVariables($this->getAttribute('use'));
     if ($use) {
         // Use the requested editor if available
         if (class_exists($use)) {
             if (is_subclass_of($use, __CLASS__)) {
                 $sub = new $use($this->name(), $this->attributes(), $this, $this->docType());
                 $sub->output($data, $stream);
                 return;
             } else {
                 trigger_error("Requested editor class '{$cls}' does not appear to be an editor subclass.");
             }
         } else {
             trigger_error("Requested editor class '{$cls}' does not exist.");
         }
     }
     if (TYPEF_DEFAULT_EDITOR != '') {
         // Use the requested editor if available
         $use = TYPEF_DEFAULT_EDITOR;
         if (class_exists($use)) {
             if (is_subclass_of($use, __CLASS__)) {
                 $sub = new $use($this->name(), $this->attributes(), $this, $this->docType());
                 $sub->output($data, $stream);
                 return;
             } else {
                 trigger_error("Configured editor class '{$use}' does not appear to be an editor subclass.");
             }
         } else {
             trigger_error("Configured editor class '{$use}' does not exist.");
         }
     }
     // Use CKEditor if available
     if (class_exists('Typeframe_Tag_Editor_CkEditor')) {
         $sub = new Typeframe_Tag_Editor_CkEditor($this->name(), $this->attributes(), $this, $this->docType());
         $sub->process($data, $stream);
         return;
     }
     // No editor available. Use a plain textarea.
     $attribs = '';
     foreach ($this->attributes() as $k => $v) {
         if ($k != 'use') {
             $attribs .= " {$k}=\"" . $data->parseVariables($v) . "\"";
         }
     }
     if (!$this->getAttribute('cols')) {
         $attribs .= ' cols="80"';
     }
     if (!$this->getAttribute('rows')) {
         $attribs .= ' rows="25"';
     }
     $stream->puts("<textarea{$attribs}>" . $inner . "</textarea>");
 }
Esempio n. 10
0
 /**
  * Main function executed automatically by the controller
  *
  * @param	object		$registry		Registry object
  * @return	@e void
  */
 public function doExecute(ipsRegistry $registry)
 {
     /* From App */
     $app = trim($this->request['f_app']);
     $area = trim($this->request['f_area']);
     $relid = intval($this->request['f_relid']);
     if (!$app or !$area or empty($relid)) {
         trigger_error("Missing data in " . __FILE__ . ' ' . __LINE__);
     }
     /* Init some data */
     require_once IPS_ROOT_PATH . 'sources/classes/like/composite.php';
     /*noLibHook*/
     $this->_like = classes_like::bootstrap($app, $area);
     $this->registry->getClass('class_localization')->loadLanguageFile(array('public_like'), 'core');
     /* What to do? */
     switch ($this->request['do']) {
         case 'setDialogue':
             $this->_setDialogue($app, $area, $relid);
             break;
         case 'save':
             $this->_save($relid);
             break;
         case 'unset':
             $this->_unset($relid);
             break;
         case 'more':
             $this->_more($relid);
             break;
     }
 }
Esempio n. 11
0
 /**
  * update file contents and meta
  * or create new file, if not existing
  * @param int $ttl
  * @return bool
  */
 public function save($ttl = 0)
 {
     $ttl = $ttl ?: $this->ttl;
     if (empty($this->file)) {
         trigger_error('Unable to save. No file specified.');
         return false;
     }
     if (is_null($this->content)) {
         trigger_error(sprintf('Unable to save. Contents of file `%s´ is NULL.', $this->file));
         return false;
     }
     if ($this->changed) {
         $this->fs->write($this->file, (string) $this->content);
         if ($this->f3->get('CACHE')) {
             $cache = \Cache::instance();
             $cacheHash = $this->getCacheHash($this->file);
             if ($this->ttl) {
                 $cache->set($cacheHash, $this->content, $this->ttl);
             } elseif ($cache->exists($cacheHash)) {
                 $cache->clear($cacheHash);
             }
         }
     }
     $this->changed = false;
     $this->metaHandle->save($this->file, $this->meta, $ttl);
     return true;
 }
Esempio n. 12
0
 /**
  * Constructor method. Will populate other information beyond IP address from the outlet itself.
  *
  * @param $ip_address
  */
 public function __construct($ip_address)
 {
     $this->ip_address = $ip_address;
     if (!$this->refresh()) {
         trigger_error("Unable to connect to outlet at " . $ip_address, E_USER_WARNING);
     }
 }
Esempio n. 13
0
 /**
  * kick start the View, which creates the response
  * based on our previously set content data.
  * finally echo the response or overwrite this method
  * and do something else with it.
  * @return string
  */
 public function afterroute()
 {
     if (!$this->response) {
         trigger_error('No View has been set.');
     }
     echo $this->response->render();
 }
 public function set_user_affiliation($user_id, $type, $scope = 'domain', $target_id = null)
 {
     $allowed_types = array('admin', 'member', 'none', 'outcast', 'owner');
     $allowed_scope = array('domain', 'site', 'conv');
     if (!in_array($type, $allowed_types)) {
         trigger_error('You cannot set a Livefyre user\'s affiliation to a type other than the allowed: ' . implode(', ', $allowed_types), E_USER_ERROR);
         return false;
     } else {
         if (!in_array($scope, $allowed_scope)) {
             trigger_error('You cannot set a Livefyre user\'s affiliation within a scope other than the allowed: ' . implode(', ', $allowed_scope), E_USER_ERROR);
             return false;
         }
         $user_jid = $user_id . '@' . $this->get_host();
         $systemuser = $this->user('system');
         $request_url = 'http://' . $this->get_host() . '/api/v1.1/private/management/user/' . $user_jid . '/role/?lftoken=' . $this->user('system')->token();
         $post_data = array('affiliation' => $type);
         if ($scope == 'domain') {
             $post_data['domain_wide'] = '1';
         } elseif ($scope == 'conv') {
             $post_data['conv_id'] = $target_id;
         } elseif ($scope == 'site') {
             $post_data['site_id'] = $target_id;
         }
         return $this->http->request($request_url, array('method' => 'POST', 'data' => $post_data));
     }
     return false;
 }
Esempio n. 15
0
 /**
  * wird ausgeführt, wenn Cache über "Cache leeren" Button geleert wird
  * @param array $data
  * @return mixed
  */
 public function run($data = null)
 {
     $functionData = explode('_', $data['name'], 3);
     if (!isset($functionData[0]) || !isset($functionData[1]) || !isset($functionData[2])) {
         trigger_error('Malformed function name data given: "' . $data['name'] . '"');
         return false;
     }
     $vendorKey = $functionData[0];
     $moduleKey = $functionData[1];
     $functionName = $functionData[2];
     $classFile = \fpcm\classes\baseconfig::$moduleDir . $vendorKey . '/' . $moduleKey . '/events/apiCallFunction.php';
     if (!file_exists($classFile)) {
         trigger_error('Event class "apiCallFunction" not found in ' . \fpcm\model\files\ops::removeBaseDir($classFile, true));
         return false;
     }
     $classkey = $vendorKey . '/' . $moduleKey;
     $eventClass = \fpcm\model\abstracts\module::getModuleEventNamespace($classkey, 'apiCallFunction');
     /**
      * @var \fpcm\model\abstracts\event
      */
     $module = new $eventClass();
     if (!$this->is_a($module)) {
         return false;
     }
     $data['name'] = $functionName;
     return $module->run($data);
 }
Esempio n. 16
0
 /**
  * Returns a specific character in UTF-8.
  * @param  int     codepoint
  * @return string
  */
 public static function chr($code)
 {
     if (func_num_args() > 1 && strcasecmp(func_get_arg(1), 'UTF-8')) {
         trigger_error(__METHOD__ . ' supports only UTF-8 encoding.', E_USER_DEPRECATED);
     }
     return iconv('UTF-32BE', 'UTF-8//IGNORE', pack('N', $code));
 }
Esempio n. 17
0
 /**
  * Dispatch the requested action
  *
  * @param string $action Method name of action
  * @return void
  */
 public function dispatch($action)
 {
     $action = str_replace("Action", "", $action);
     // Notify helpers of action preDispatch state
     $this->_helper->notifyPreDispatch();
     $this->preDispatch();
     if ($this->getRequest()->isDispatched()) {
         if (null === $this->_classMethods) {
             $this->_classMethods = get_class_methods($this);
         }
         // preDispatch() didn't change the action, so we can continue
         if ($this->getInvokeArg('useCaseSensitiveActions') || in_array($action, $this->_classMethods)) {
             if ($this->getInvokeArg('useCaseSensitiveActions')) {
                 trigger_error('Using case sensitive actions without word separators is deprecated; please do not rely on this "feature"');
             }
             $this->{$action}();
             $this->view->setVars($this->fields);
         } else {
             $this->__call($action, array());
             $this->view->setVars($this->fields);
         }
         $this->postDispatch();
     }
     // whats actually important here is that this action controller is
     // shutting down, regardless of dispatching; notify the helpers of this
     // state
     $this->_helper->notifyPostDispatch();
 }
Esempio n. 18
0
 /**
  * Generates and checks presenter class name.
  * @param  string  presenter name
  * @return string  class name
  * @throws InvalidPresenterException
  */
 public function getPresenterClass(&$name)
 {
     if (isset($this->cache[$name])) {
         return $this->cache[$name];
     }
     if (!is_string($name) || !Nette\Utils\Strings::match($name, '#^[a-zA-Z\\x7f-\\xff][a-zA-Z0-9\\x7f-\\xff:]*\\z#')) {
         throw new InvalidPresenterException("Presenter name must be alphanumeric string, '{$name}' is invalid.");
     }
     $class = $this->formatPresenterClass($name);
     if (!class_exists($class)) {
         throw new InvalidPresenterException("Cannot load presenter '{$name}', class '{$class}' was not found.");
     }
     $reflection = new \ReflectionClass($class);
     $class = $reflection->getName();
     if (!$reflection->implementsInterface('Nette\\Application\\IPresenter')) {
         throw new InvalidPresenterException("Cannot load presenter '{$name}', class '{$class}' is not Nette\\Application\\IPresenter implementor.");
     } elseif ($reflection->isAbstract()) {
         throw new InvalidPresenterException("Cannot load presenter '{$name}', class '{$class}' is abstract.");
     }
     $this->cache[$name] = $class;
     if ($name !== ($realName = $this->unformatPresenterClass($class))) {
         trigger_error("Case mismatch on presenter name '{$name}', correct name is '{$realName}'.", E_USER_WARNING);
         $name = $realName;
     }
     return $class;
 }
Esempio n. 19
0
function arrayToJsArray($array, $name, $nl = "\n", $encoding = false)
{
    if (is_array($array)) {
        $jsArray = $name . ' = new Array();' . $nl;
        foreach ($array as $key => $value) {
            switch (gettype($value)) {
                case 'unknown type':
                case 'resource':
                case 'object':
                    break;
                case 'array':
                    $jsArray .= arrayToJsArray($value, $name . '[' . valueToJsValue($key, $encoding) . ']', $nl);
                    break;
                case 'NULL':
                    $jsArray .= $name . '[' . valueToJsValue($key, $encoding) . '] = null;' . $nl;
                    break;
                case 'boolean':
                    $jsArray .= $name . '[' . valueToJsValue($key, $encoding) . '] = ' . ($value ? 'true' : 'false') . ';' . $nl;
                    break;
                case 'string':
                    $jsArray .= $name . '[' . valueToJsValue($key, $encoding) . '] = ' . valueToJsValue($value, $encoding) . ';' . $nl;
                    break;
                case 'double':
                case 'integer':
                    $jsArray .= $name . '[' . valueToJsValue($key, $encoding) . '] = ' . $value . ';' . $nl;
                    break;
                default:
                    trigger_error('Hoppa, egy j t�us a PHP-ben?' . __CLASS__ . '::' . __FUNCTION__ . '()!', E_USER_WARNING);
            }
        }
        return $jsArray;
    } else {
        return false;
    }
}
Esempio n. 20
0
 function hash_equals($known_str, $user_str)
 {
     if (!is_string($known_str)) {
         trigger_error("Expected known_str to be a string, {$known_str} given", E_USER_WARNING);
         return false;
     }
     if (!is_string($user_str)) {
         trigger_error("Expected user_str to be a string, {$user_str} given", E_USER_WARNING);
         return false;
     }
     $known_len = strlen($known_str);
     $user_len = strlen($user_str);
     if ($known_len != $user_len) {
         // if different lengths, do comparison as well, to have time constant
         // but return false as expected
         $user_str = $known_str;
         $result = 1;
     } else {
         $result = 0;
     }
     /* This is security sensitive code. Do not optimize this for speed. */
     for ($j = 0; $j < $known_len; $j++) {
         $result |= ord($known_str[$j] ^ $user_str[$j]);
     }
     return $result == 0;
 }
Esempio n. 21
0
/**
 * Smarty {math} function plugin
 *
 * Type:     function<br>
 * Name:     nest<br>
 * Purpose:  handle math computations in template
 * <br>
 *
 * @author   Levon Naghashyan <levon at naghashyan dot com>
 * @site http://naghashyan.com
 * @mail levon@naghashyan.com
 * @year 2012-2015
 * @version 2.0.0
 * @param array $params parameters
 * @param object $template template object
 * @return render template|null
 */
function smarty_function_nest($params, $template)
{
    if (!isset($params['ns'])) {
        trigger_error("nest: missing 'ns' parameter");
        return;
    }
    if (!$template->tpl_vars["ns"]) {
        $template->tpl_vars["ns"] = $template->smarty->smarty->tpl_vars["ns"];
    }
    $nsValue = $template->tpl_vars["ns"]->value;
    $pmValue = $template->tpl_vars["pm"]->value;
    $namespace = $nsValue["inc"][$params["ns"]]["namespace"];
    $include_file = $nsValue["inc"][$params["ns"]]["filename"];
    $_tpl = $template->smarty->createTemplate($include_file, null, null, $nsValue["inc"][$params["ns"]]["params"]);
    foreach ($template->tpl_vars as $key => $tplVars) {
        $_tpl->assign($key, $tplVars);
    }
    $_tpl->assign("ns", $nsValue["inc"][$params["ns"]]["params"]);
    $_tpl->assign("pm", $pmValue);
    if ($_tpl->mustCompile()) {
        $_tpl->compileTemplateSource();
    }
    //$_tpl->renderTemplate();
    $_output = $_tpl->display();
    if (NGS()->isJsFrameworkEnable() && !NGS()->getHttpUtils()->isAjaxRequest()) {
        $jsonParams = $nsValue["inc"][$params["ns"]]["jsonParam"];
        $parentLoad = $nsValue["inc"][$params["ns"]]["parent"];
        $jsString = '<script type="text/javascript">';
        $jsString .= 'NGS.setNestedLoad("' . $parentLoad . '", "' . $namespace . '", ' . json_encode($jsonParams) . ')';
        $jsString .= '</script>';
        $_output = $jsString . $_output;
    }
    return $_output;
}
Esempio n. 22
0
 function kBankHide(&$registry)
 {
     //create new object
     if (is_object($registry)) {
         $this->registry =& $registry;
     } else {
         trigger_error("vB_Database::Registry object is not an object", E_USER_ERROR);
     }
     //Check if user is banned
     $is_banned = !($this->registry->usergroupcache[$this->registry->userinfo['usergroupid']]['genericoptions'] & $this->registry->bf_ugp_genericoptions['isnotbannedgroup']) ? true : false;
     if (is_member_of($this->registry->userinfo, 3, 4) or $is_banned or THIS_SCRIPT == 'misc') {
         $this->settings['banned'] = true;
     }
     //Check if we need to use html version
     if (in_array(THIS_SCRIPT, array('ajax', 'editpost', 'misc', 'newthread', 'newreply', 'printthread', 'showpost', 'showthread'))) {
         $this->settings['dohtml'] = true;
         //Let's use html!
     } else {
         $this->settings['dohtml'] = false;
         //Plain text only
     }
     if (isset($this->registry->kbank['hide']['shortcut'])) {
         foreach ($this->tags as $key => $tag) {
             if (strtolower($tag['name']) == strtolower($this->registry->kbank['hide']['shortcut'])) {
                 $this->tags[$key]['name'] .= '|HIDE';
             }
         }
     }
     //Prepair regex
     foreach ($this->tags as $key => $tag) {
         $this->tags[$key]['regex'] = "\\[({$tag['name']})(=(&quot;|\"|'|)?([0-9]+)\\3)?\\]((.|\r|\n)*)\\[\\/\\1\\]";
         //$this->tags[$key]['regex_close'] = "\[\/($tag[name])\]"; - not needed
         $this->tags[$key]['regex_open'] = "\\[({$tag['name']})(=(&quot;|\"|'|)?([0-9]+)\\3)?\\]";
     }
 }
Esempio n. 23
0
 /**
  * Set ID of supplementary file.
  * @param $suppFileId int
  */
 function setSuppFileId($suppFileId)
 {
     if (Config::getVar('debug', 'deprecation_warnings')) {
         trigger_error('Deprecated function.');
     }
     return $this->setId($suppFileId);
 }
 static function query_and_render($args)
 {
     $ctype = p2p_type($args['ctype']);
     if (!$ctype) {
         trigger_error(sprintf("Unregistered connection type '%s'.", $ctype), E_USER_WARNING);
         return '';
     }
     $directed = $ctype->find_direction($args['item']);
     if (!$directed) {
         return '';
     }
     $context = $args['context'];
     $extra_qv = array('p2p:per_page' => -1, 'p2p:context' => $context);
     $connected = call_user_func(array($directed, $args['method']), $args['item'], $extra_qv, 'abstract');
     switch ($args['mode']) {
         case 'inline':
             $render_args = array('separator' => ', ');
             break;
         case 'ol':
             $render_args = array('before_list' => '<ol id="' . $ctype->name . '_list">', 'after_list' => '</ol>');
             break;
         case 'ul':
         default:
             $render_args = array('before_list' => '<ul id="' . $ctype->name . '_list">', 'after_list' => '</ul>');
             break;
     }
     $render_args['echo'] = false;
     $html = self::render($connected, $render_args);
     return apply_filters("p2p_{$context}_html", $html, $connected, $directed, $args['mode']);
 }
Esempio n. 25
0
 function resize(&$target, $widths)
 {
     set_time_limit(30);
     trigger_error(sprintf(AMP_TEXT_ACTION_NOTICE, AMP_TEXT_RECALCULATE, $target->getName()));
     #$content_image = &new Content_Image( $target->getName() );
     $crop_path = AMP_image_path($target->getName(), AMP_IMAGE_CLASS_CROP);
     $thumb_path = AMP_image_path($target->getName(), AMP_IMAGE_CLASS_THUMB);
     $pic_path = AMP_image_path($target->getName());
     $action_flag = false;
     if (isset($widths['thumb'])) {
         if (file_exists($crop_path)) {
             $crop_target =& new AMP_System_File_Image($crop_path);
         } else {
             $crop_target =& $target;
         }
         if ($this->_rewriteVersion($crop_target, $widths['thumb'], $thumb_path)) {
             $action_flag = true;
         }
     }
     if (isset($widths['tall']) && $target->height >= $target->width) {
         if ($this->_rewriteVersion($target, $widths['tall'], $pic_path)) {
             $action_flag = true;
         }
     }
     if (isset($widths['wide']) && $target->width > $target->height) {
         if ($this->_rewriteVersion($target, $widths['wide'], $pic_path)) {
             $action_flag = true;
         }
     }
     if ($action_flag) {
         ++$this->_committed_qty;
     }
 }
 public function main($id, $mode)
 {
     global $config, $request, $template, $user;
     $this->config = $config;
     $this->request = $request;
     $this->template = $template;
     $this->user = $user;
     // Add the common lang file
     $this->user->add_lang(array('acp/common'));
     // Add the board snowstormlights ACP lang file
     $this->user->add_lang_ext('prosk8er/snowstormlights', 'info_acp_snowstorm_lights');
     // Load a template from adm/style for our ACP page
     $this->tpl_name = 'snowstorm_lights';
     // Set the page title for our ACP page
     $this->page_title = $user->lang['ACP_SNOWSTORM_LIGHTS'];
     // Define the name of the form for use as a form key
     $form_key = 'acp_snowstorm_lights';
     add_form_key($form_key);
     // If form is submitted or previewed
     if ($this->request->is_set_post('submit')) {
         // Test if form key is valid
         if (!check_form_key($form_key)) {
             trigger_error('FORM_INVALID');
         }
         // Store the config enable/disable state
         $scl_enabled = $this->request->variable('scl_enabled', 0);
         $this->config->set('scl_enabled', $scl_enabled);
         $snow_enabled = $request->variable('snow_enabled', 0);
         $this->config->set('snow_enabled', $snow_enabled);
         // Output message to user for the update
         trigger_error($this->user->lang('SNOWSTORM_LIGHTS_SAVED') . adm_back_link($this->u_action));
     }
     // Output data to the template
     $this->template->assign_vars(array('SCL_ENABLED' => isset($this->config['scl_enabled']) ? $this->config['scl_enabled'] : '', 'SNOW_ENABLED' => isset($this->config['snow_enabled']) ? $this->config['snow_enabled'] : '', 'U_ACTION' => $this->u_action));
 }
 function setImage($image)
 {
     if (!rex_image::isValid($image)) {
         trigger_error('Given image is not a valid rex_image_abstract', E_USER_ERROR);
     }
     $this->image = $image;
 }
 /**
  * Constructor - checks that the registry object has been passed correctly.
  *
  * @param	vB_Registry	Instance of the vBulletin data registry object - expected to have the database object as one of its $this->db member.
  * @param	integer		One of the ERRTYPE_x constants
  */
 function vB_DataManager_ThreadPost(&$registry, $errtype = ERRTYPE_STANDARD)
 {
     if (!is_subclass_of($this, 'vB_DataManager_ThreadPost')) {
         trigger_error("Direct Instantiation of vB_DataManager_ThreadPost class prohibited.", E_USER_ERROR);
     }
     parent::vB_DataManager($registry, $errtype);
 }
Esempio n. 29
0
/**
 * Main function for the routines functionality
 *
 * @param string $type 'FUNCTION' for functions,
 *                     'PROCEDURE' for procedures,
 *                     null for both
 *
 * @return void
 */
function PMA_RTN_main($type)
{
    global $db;
    PMA_RTN_setGlobals();
    /**
     * Process all requests
     */
    PMA_RTN_handleEditor();
    PMA_RTN_handleExecute();
    PMA_RTN_handleExport();
    /**
     * Display a list of available routines
     */
    if (!PMA_isValid($type, array('FUNCTION', 'PROCEDURE'))) {
        $type = null;
    }
    $items = $GLOBALS['dbi']->getRoutines($db, $type);
    echo PMA_RTE_getList('routine', $items);
    /**
     * Display the form for adding a new routine, if the user has the privileges.
     */
    echo PMA_RTN_getFooterLinks();
    /**
     * Display a warning for users with PHP's old "mysql" extension.
     */
    if (!PMA\libraries\DatabaseInterface::checkDbExtension('mysqli')) {
        trigger_error(__('You are using PHP\'s deprecated \'mysql\' extension, ' . 'which is not capable of handling multi queries. ' . '[strong]The execution of some stored routines may fail![/strong] ' . 'Please use the improved \'mysqli\' extension to ' . 'avoid any problems.'), E_USER_WARNING);
    }
}
 function __set($name, $value)
 {
     switch ($name) {
         case 'identity':
             if (strlen($value = trim((string) $value))) {
                 if (preg_match('#^xri:/*#i', $value, $m)) {
                     $value = substr($value, strlen($m[0]));
                 } elseif (!preg_match('/^(?:[=@+\\$!\\(]|https?:)/i', $value)) {
                     $value = "http://{$value}";
                 }
                 if (preg_match('#^https?://[^/]+$#i', $value, $m)) {
                     $value .= '/';
                 }
             }
             $this->{$name} = $this->claimed_id = $value;
             break;
         case 'trustRoot':
         case 'realm':
             $this->trustRoot = trim($value);
             break;
         case 'xrdsOverride':
             if (is_array($value)) {
                 list($pattern, $replacement) = $value;
                 $this->xrds_override_pattern = $pattern;
                 $this->xrds_override_replacement = $replacement;
             } else {
                 trigger_error('Invalid value specified for "xrdsOverride".', E_USER_ERROR);
             }
             break;
     }
 }