Esempio n. 1
16
 public function addCommandsFromClass($className, $passThrough = null)
 {
     $roboTasks = new $className();
     $commandNames = array_filter(get_class_methods($className), function ($m) {
         return !in_array($m, ['__construct']);
     });
     foreach ($commandNames as $commandName) {
         $command = $this->createCommand(new TaskInfo($className, $commandName));
         $command->setCode(function (InputInterface $input) use($roboTasks, $commandName, $passThrough) {
             // get passthru args
             $args = $input->getArguments();
             array_shift($args);
             if ($passThrough) {
                 $args[key(array_slice($args, -1, 1, TRUE))] = $passThrough;
             }
             $args[] = $input->getOptions();
             $res = call_user_func_array([$roboTasks, $commandName], $args);
             if (is_int($res)) {
                 exit($res);
             }
             if (is_bool($res)) {
                 exit($res ? 0 : 1);
             }
             if ($res instanceof Result) {
                 exit($res->getExitCode());
             }
         });
         $this->add($command);
     }
 }
Esempio n. 2
2
 /**
  * Get link definition defined in 'fields' metadata. In linkDefs can be used as value (e.g. "type": "hasChildren") and/or variables (e.g. "entityName":"{entity}"). Variables should be defined into fieldDefs (in 'entityDefs' metadata).
  *
  * @param  string $entityName
  * @param  array  $fieldDef
  * @param  array  $linkFieldDefsByType
  * @return array | null
  */
 public function getLinkDefsInFieldMeta($entityName, $fieldDef, array $linkFieldDefsByType = null)
 {
     if (!isset($fieldDefsByType)) {
         $fieldDefsByType = $this->getFieldDefsByType($fieldDef);
         if (!isset($fieldDefsByType['linkDefs'])) {
             return null;
         }
         $linkFieldDefsByType = $fieldDefsByType['linkDefs'];
     }
     foreach ($linkFieldDefsByType as $paramName => &$paramValue) {
         if (preg_match('/{(.*?)}/', $paramValue, $matches)) {
             if (in_array($matches[1], array_keys($fieldDef))) {
                 $value = $fieldDef[$matches[1]];
             } else {
                 if (strtolower($matches[1]) == 'entity') {
                     $value = $entityName;
                 }
             }
             if (isset($value)) {
                 $paramValue = str_replace('{' . $matches[1] . '}', $value, $paramValue);
             }
         }
     }
     return $linkFieldDefsByType;
 }
 /**
  * {@inheritdoc}
  */
 public function getEntityAlias($entityClass)
 {
     if ($this->configManager->hasConfig($entityClass)) {
         // check for enums
         $enumCode = $this->configManager->getProvider('enum')->getConfig($entityClass)->get('code');
         if ($enumCode) {
             $entityAlias = $this->getEntityAliasFromConfig($entityClass);
             if (null !== $entityAlias) {
                 return $entityAlias;
             }
             return $this->createEntityAlias(str_replace('_', '', $enumCode));
         }
         // check for dictionaries
         $groups = $this->configManager->getProvider('grouping')->getConfig($entityClass)->get('groups');
         if (!empty($groups) && in_array(GroupingScope::GROUP_DICTIONARY, $groups, true)) {
             // delegate aliases generation to default provider
             return null;
         }
         // exclude hidden entities
         if ($this->configManager->isHiddenModel($entityClass)) {
             return false;
         }
         // check for custom entities
         if (ExtendHelper::isCustomEntity($entityClass)) {
             $entityAlias = $this->getEntityAliasFromConfig($entityClass);
             if (null !== $entityAlias) {
                 return $entityAlias;
             }
             return $this->createEntityAlias('Extend' . ExtendHelper::getShortClassName($entityClass));
         }
     }
     return null;
 }
Esempio n. 4
1
 public function fetch_all($cachenames, $lv)
 {
     global $_G;
     $data = array();
     if ($lv > 1 && !$cachenames) {
         $cachenames = $_G[_config][cache_list];
     }
     if (defined('DEBUG')) {
         $name = $this->obj->name;
         if (in_array($name, array('memcache', 'baichuan'))) {
             $_G['memory_debug']['get'] = array();
             if (is_array($cachenames)) {
                 $_G['memory_debug']['get'] = $cachenames;
             } else {
                 $_G['memory_debug']['get'][] = $key;
             }
         }
     }
     $data = $this->obj->get($cachenames);
     if ($data === false || $data === NULL) {
         $this->update($cachenames);
     }
     if (is_array($cachenames)) {
         foreach ($data as $k => $v) {
             if ($v === false) {
                 $data[$k] = $this->update($k);
             }
         }
     }
     return $data;
 }
 public function setType($type = self::TYPE_UNDEFINED)
 {
     $type = (int) $type;
     if (in_array($type, array(self::TYPE_PAGE, self::TYPE_TEMPLATE, self::TYPE_UNDEFINED))) {
         $this->type = $type;
     }
 }
Esempio n. 6
1
 /**
  * Throw file upload error, return true if error has been thrown, false if error has been catched
  *
  * @param int $number
  * @param string $text
  * @access public
  */
 public function throwError($number, $text = false, $exit = true)
 {
     if ($this->_catchAllErrors || in_array($number, $this->_skipErrorsArray)) {
         return false;
     }
     switch ($number) {
         case CKFINDER_CONNECTOR_ERROR_INVALID_REQUEST:
         case CKFINDER_CONNECTOR_ERROR_INVALID_NAME:
         case CKFINDER_CONNECTOR_ERROR_THUMBNAILS_DISABLED:
         case CKFINDER_CONNECTOR_ERROR_UNAUTHORIZED:
             header("HTTP/1.0 403 Forbidden");
             header("X-CKFinder-Error: " . $number);
             break;
         case CKFINDER_CONNECTOR_ERROR_ACCESS_DENIED:
             header("HTTP/1.0 500 Internal Server Error");
             header("X-CKFinder-Error: " . $number);
             break;
         default:
             header("HTTP/1.0 404 Not Found");
             header("X-CKFinder-Error: " . $number);
             break;
     }
     if ($exit) {
         exit;
     }
 }
Esempio n. 7
1
 /**
  * Add all the routes in the router in parameter
  * @param $router Router
  */
 public function generateRoute(Router $router)
 {
     foreach ($this->classes as $class) {
         $classMethods = get_class_methods($this->namespace . $class . 'Controller');
         $rc = new \ReflectionClass($this->namespace . $class . 'Controller');
         $parent = $rc->getParentClass();
         $parent = get_class_methods($parent->name);
         $className = $this->namespace . $class . 'Controller';
         foreach ($classMethods as $methodName) {
             if (in_array($methodName, $parent) || $methodName == 'index') {
                 continue;
             } else {
                 foreach (Router::getSupportedHttpMethods() as $httpMethod) {
                     if (strstr($methodName, $httpMethod)) {
                         continue 2;
                     }
                     if (in_array($methodName . $httpMethod, $classMethods)) {
                         $router->add('/' . strtolower($class) . '/' . $methodName, new $className(), $methodName . $httpMethod, $httpMethod);
                         unset($classMethods[$methodName . $httpMethod]);
                     }
                 }
                 $router->add('/' . strtolower($class) . '/' . $methodName, new $className(), $methodName);
             }
         }
         $router->add('/' . strtolower($class), new $className(), 'index');
     }
 }
Esempio n. 8
1
/**
 * Sanitizes $message, taking into account our special codes
 * for formatting.
 *
 * If you want to include result in element attribute, you should escape it.
 *
 * Examples:
 *
 * <p><?php echo PMA_sanitize($foo); ?></p>
 *
 * <a title="<?php echo PMA_sanitize($foo, true); ?>">bar</a>
 *
 * @uses    preg_replace()
 * @uses    strtr()
 * @param   string   the message
 * @param   boolean  whether to escape html in result
 *
 * @return  string   the sanitized message
 *
 * @access  public
 */
function PMA_sanitize($message, $escape = false, $safe = false)
{
    if (!$safe) {
        $message = strtr($message, array('<' => '&lt;', '>' => '&gt;'));
    }
    $replace_pairs = array('[i]' => '<em>', '[/i]' => '</em>', '[em]' => '<em>', '[/em]' => '</em>', '[b]' => '<strong>', '[/b]' => '</strong>', '[strong]' => '<strong>', '[/strong]' => '</strong>', '[tt]' => '<code>', '[/tt]' => '</code>', '[code]' => '<code>', '[/code]' => '</code>', '[kbd]' => '<kbd>', '[/kbd]' => '</kbd>', '[br]' => '<br />', '[/a]' => '</a>', '[sup]' => '<sup>', '[/sup]' => '</sup>');
    $message = strtr($message, $replace_pairs);
    $pattern = '/\\[a@([^"@]*)@([^]"]*)\\]/';
    if (preg_match_all($pattern, $message, $founds, PREG_SET_ORDER)) {
        $valid_links = array('http', './Do', './ur');
        foreach ($founds as $found) {
            // only http... and ./Do... allowed
            if (!in_array(substr($found[1], 0, 4), $valid_links)) {
                return $message;
            }
            // a-z and _ allowed in target
            if (!empty($found[2]) && preg_match('/[^a-z_]+/i', $found[2])) {
                return $message;
            }
        }
        if (substr($found[1], 0, 4) == 'http') {
            $message = preg_replace($pattern, '<a href="' . PMA_linkURL($found[1]) . '" target="\\2">', $message);
        } else {
            $message = preg_replace($pattern, '<a href="\\1" target="\\2">', $message);
        }
    }
    if ($escape) {
        $message = htmlspecialchars($message);
    }
    return $message;
}
Esempio n. 9
1
	function PrepareSettings($arUserField)
	{
		$arUserField["SETTINGS"] = (is_array($arUserField["SETTINGS"]) ? $arUserField["SETTINGS"] : @unserialise($arUserField["SETTINGS"]));
		$arUserField["SETTINGS"] = (is_array($arUserField["SETTINGS"]) ? $arUserField["SETTINGS"] : array());
		$tmp = array("CHANNEL_ID" => intval($arUserField["SETTINGS"]["CHANNEL_ID"]));

		if ($arUserField["SETTINGS"]["CHANNEL_ID"] == "add")
		{
			$tmp["CHANNEL_TITLE"] = trim($arUserField["SETTINGS"]["CHANNEL_TITLE"]);
			$tmp["CHANNEL_SYMBOLIC_NAME"] = trim($arUserField["SETTINGS"]["CHANNEL_SYMBOLIC_NAME"]);
			$tmp["CHANNEL_USE_CAPTCHA"] = ($arUserField["SETTINGS"]["CHANNEL_USE_CAPTCHA"] == "Y" ? "Y" : "N");
		}

		$uniqType = $arUserField["SETTINGS"]["UNIQUE"];
		if (is_array($arUserField["SETTINGS"]["UNIQUE"]))
		{
			$uniqType = 0;
			foreach ($arUserField["SETTINGS"]["UNIQUE"] as $z){
				$uniqType |= $z;
			}
			$uniqType += 5;
		}

		$tmp["UNIQUE"] = $uniqType;
		$tmp["UNIQUE_IP_DELAY"] = is_array($arUserField["SETTINGS"]["UNIQUE_IP_DELAY"]) ?
			$arUserField["SETTINGS"]["UNIQUE_IP_DELAY"] : array();
		$tmp["NOTIFY"] = (in_array($arUserField["SETTINGS"]["NOTIFY"], array("I", "Y", "N")) ?
			$arUserField["SETTINGS"]["NOTIFY"] : "N");

		return $tmp;
	}
 public static function all_for_post($post_id, $args = array())
 {
     $enclosures = array();
     $file_types_for_this_episode = array();
     $wordpress_enclosures = get_post_meta($post_id, 'enclosure', false);
     foreach ($wordpress_enclosures as $enclosure_data) {
         $enclosure = Enclosure::from_enclosure_meta($enclosure_data, $post_id);
         if ($enclosure->file_type && !in_array($enclosure->file_type->id, $file_types_for_this_episode)) {
             $file_types_for_this_episode[] = $enclosure->file_type->id;
         }
         $enclosures[] = $enclosure;
     }
     // process podPress files
     $podPress_enclosures = get_post_meta($post_id, '_podPressMedia', false);
     if (is_array($podPress_enclosures) && !empty($podPress_enclosures)) {
         foreach ($podPress_enclosures[0] as $file) {
             $enclosure = Enclosure::from_enclosure_podPress($file, $post_id);
             if (in_array($enclosure->file_type->id, $file_types_for_this_episode)) {
                 continue;
             }
             $file_types_for_this_episode[] = $enclosure->file_type->id;
             $enclosures[] = $enclosure;
         }
     }
     // if ( isset( $args['only_valid'] ) && $args['only_valid'] ) {
     // 	foreach ( $enclosures as $enclosure ) {
     // 		if ( $enclosure->errors ) {
     // 			// unset( current( $enclosure ) );
     // 		}
     // 	}
     // }
     return $enclosures;
 }
Esempio n. 11
1
	protected function _validate($context)
	{
		$config = $this->_config;
		$row = $context->caller;

		if (is_uploaded_file($row->file) && $config->restrict && !in_array($row->extension, $config->ignored_extensions->toArray())) 
		{
			if ($row->isImage()) 
			{
				if (getimagesize($row->file) === false) {
					$context->setError(JText::_('WARNINVALIDIMG'));
					return false;
				}
			}
			else 
			{
				$mime = KFactory::get('com://admin/files.database.row.file')->setData(array('path' => $row->file))->mimetype;

				if ($config->check_mime && $mime) 
				{
					if (in_array($mime, $config->illegal_mimetypes->toArray()) || !in_array($mime, $config->allowed_mimetypes->toArray())) {
						$context->setError(JText::_('WARNINVALIDMIME'));
						return false;
					}
				}
				elseif (!$config->authorized) {
					$context->setError(JText::_('WARNNOTADMIN'));
					return false;
				}
			}
		}
	}
 public function beforeAction($action)
 {
     if (!$this->owner instanceof MobileController && !in_array($this->owner->action->getId(), array_keys($this->actions()))) {
         return true;
     }
     Yii::app()->user->loginUrl = array('/mobile/login');
     Yii::app()->params->isMobileApp = true;
     // fix profile linkable behavior since model was instantiated before action
     if (!preg_match('/\\/mobileView$/', Yii::app()->params->profile->asa('X2LinkableBehavior')->viewRoute)) {
         Yii::app()->params->profile->asa('X2LinkableBehavior')->viewRoute .= '/mobileView';
     }
     $this->dataUrl = $this->owner->createAbsoluteUrl($action->getId());
     $this->pageId = lcfirst(preg_replace('/Controller$/', '', get_class($this->owner))) . '-' . $action->getId();
     $cookie = new CHttpCookie('isMobileApp', 'true');
     // create cookie
     $cookie->expire = 2147483647;
     // max expiration time
     Yii::app()->request->cookies['isMobileApp'] = $cookie;
     // save cookie
     if (!$this->owner instanceof MobileController) {
         $this->owner->layout = $this->pathAliasBase . 'views.layouts.main';
         if ($this->owner->module) {
             $this->owner->setAssetsUrl(Yii::app()->getAssetManager()->publish(Yii::getPathOfAlias($this->pathAliasBase . 'assets'), false, -1, true));
             $this->owner->module->assetsUrl = $this->owner->assetsUrl;
             Yii::app()->clientScript->packages = MobileModule::getPackages($this->owner->module->assetsUrl);
         } else {
             Yii::app()->clientScript->packages = MobileModule::getPackages($this->owner->assetsUrl);
         }
     }
     return true;
 }
Esempio n. 13
1
 /**
  * {@inheritdoc}
  */
 public function apply(DataSourceInterface $dataSource, $name, $data, array $options)
 {
     $expressionBuilder = $dataSource->getExpressionBuilder();
     if (is_array($data) && !isset($data['type'])) {
         $data['type'] = isset($options['type']) ? $options['type'] : self::TYPE_CONTAINS;
     }
     if (!is_array($data)) {
         $data = ['type' => self::TYPE_CONTAINS, 'value' => $data];
     }
     $fields = array_key_exists('fields', $options) ? $options['fields'] : [$name];
     $type = $data['type'];
     $value = array_key_exists('value', $data) ? $data['value'] : null;
     if (!in_array($type, [self::TYPE_NOT_EMPTY, self::TYPE_EMPTY], true) && '' === trim($value)) {
         return;
     }
     if (1 === count($fields)) {
         $dataSource->restrict($this->getExpression($expressionBuilder, $type, current($fields), $value));
         return;
     }
     $expressions = [];
     foreach ($fields as $field) {
         $expressions[] = $this->getExpression($expressionBuilder, $type, $field, $value);
     }
     $dataSource->restrict($expressionBuilder->orX(...$expressions));
 }
/**	
 * Performs payment module specific configuration validation
 * 
 * @param string &$errorMessage			- error message when return result is not true
 * 
 * @return bool 						- true if configuration is valid, false otherwise
 * 
 * 
 */
function moduleValidateConfiguration(&$errorMessage)
{
    global $providerConf;
    $commomResult = commonValidateConfiguration($errorMessage);
    if (!$commomResult) {
        return false;
    }
    if (strlen(trim($providerConf['Param_sid'])) == 0) {
        $errorMessage = '\'Account number\' field is empty';
        return false;
    }
    if (!in_array($providerConf['Param_pay_method'], array('CC', 'CK'))) {
        $errorMessage = '\'Pay method\' field has incorrect value';
        return false;
    }
    if (strlen(trim($providerConf['Param_secret_word'])) == 0) {
        $errorMessage = '\'Secret word\' field is empty';
        return false;
    }
    if (strlen(trim($providerConf['Param_secret_word'])) > 16 || strpos($providerConf['Param_secret_word'], ' ') !== false) {
        $errorMessage = '\'Secret word\' field has incorrect value';
        return false;
    }
    return true;
}
Esempio n. 15
1
 public static function convertDateMomentToPhp($format)
 {
     $tokens = ["M" => "n", "Mo" => "nS", "MM" => "m", "MMM" => "M", "MMMM" => "F", "D" => "j", "Do" => "jS", "DD" => "d", "DDD" => "z", "DDDo" => "zS", "DDDD" => "zS", "d" => "w", "do" => "wS", "dd" => "D", "ddd" => "D", "dddd" => "l", "e" => "w", "E" => "N", "w" => "W", "wo" => "WS", "ww" => "W", "W" => "W", "Wo" => "WS", "WW" => "W", "YY" => "y", "YYYY" => "Y", "gg" => "o", "gggg" => "o", "GG" => "o", "GGGG" => "o", "A" => "A", "a" => "a", "H" => "G", "HH" => "H", "h" => "g", "hh" => "h", "m" => "i", "mm" => "i", "s" => "s", "ss" => "s", "S" => "", "SS" => "", "SSS" => "", "z or zz" => "T", "Z" => "P", "ZZ" => "O", "X" => "U", "LT" => "g:i A", "L" => "m/d/Y", "l" => "n/j/Y", "LL" => "F jS Y", "ll" => "M j Y", "LLL" => "F js Y g:i A", "lll" => "M j Y g:i A", "LLLL" => "l, F jS Y g:i A", "llll" => "D, M j Y g:i A"];
     // find all tokens from string, using regular expression
     $regExp = "/(\\[[^\\[]*\\])|(\\\\)?(LT|LL?L?L?|l{1,4}|Mo|MM?M?M?|Do|DDDo|DD?D?D?|ddd?d?|do?|w[o|w]?|W[o|W]?|YYYYY|YYYY|YY|gg(ggg?)?|GG(GGG?)?|e|E|a|A|hh?|HH?|mm?|ss?|SS?S?|X|zz?|ZZ?|.)/";
     $matches = array();
     preg_match_all($regExp, $format, $matches);
     //  if there is no match found then return the string as it is
     //  TODO: might return escaped string
     if (empty($matches) || is_array($matches) === false) {
         return $format;
     }
     //  to match with extracted tokens
     $momentTokens = array_keys($tokens);
     $phpMatches = array();
     //  ----------------------------------
     foreach ($matches[0] as $id => $match) {
         // if there is a matching php token in token list
         if (in_array($match, $momentTokens)) {
             // use the php token instead
             $string = $tokens[$match];
         } else {
             $string = $match;
         }
         $phpMatches[$id] = $string;
     }
     // join and return php specific tokens
     return implode("", $phpMatches);
 }
Esempio n. 16
1
 function addnew()
 {
     if ($_POST) {
         $image = $_FILES['logo'];
         $image_name = $image['name'];
         $image_tmp = $image['tmp_name'];
         $image_size = $image['size'];
         $error = $image['error'];
         $file_ext = explode('.', $image_name);
         $file_ext = strtolower(end($file_ext));
         $allowed_ext = array('jpg', 'jpeg', 'bmp', 'png', 'gif');
         $file_on_server = '';
         if (in_array($file_ext, $allowed_ext)) {
             if ($error === 0) {
                 if ($image_size < 3145728) {
                     $file_on_server = uniqid() . '.' . $file_ext;
                     $destination = './brand_img/' . $file_on_server;
                     move_uploaded_file($image_tmp, $destination);
                 }
             }
         }
         $values = array('name' => $this->input->post('name'), 'description' => $this->input->post('desc'), 'logo' => $file_on_server, 'is_active' => 1);
         if ($this->brand->create($values)) {
             $this->session->set_flashdata('message', 'New Brand added successfully');
         } else {
             $this->session->set_flashdata('errormessage', 'Oops! Something went wrong!!');
         }
         redirect(base_url() . 'brands/');
     }
     $this->load->helper('form');
     $this->load->view('includes/header', array('title' => 'Add Brand'));
     $this->load->view('brand/new_brand');
     $this->load->view('includes/footer');
 }
 /**
  * Return a OpenSeadragon image viewer for the provided files.
  * 
  * @param File|array $files A File record or an array of File records.
  * @param int $width The width of the image viewer in pixels.
  * @param int $height The height of the image viewer in pixels.
  * @return string|null
  */
 public function openseadragon($files)
 {
     if (!is_array($files)) {
         $files = array($files);
     }
     // Filter out invalid images.
     $images = array();
     $imageNames = array();
     foreach ($files as $file) {
         // A valid image must be a File record.
         if (!$file instanceof File) {
             continue;
         }
         // A valid image must have a supported extension.
         $extension = pathinfo($file->original_filename, PATHINFO_EXTENSION);
         if (!in_array(strtolower($extension), $this->_supportedExtensions)) {
             continue;
         }
         $images[] = $file;
         $imageNames[explode(".", $file->filename)[0]] = openseadragon_dimensions($file, 'original');
     }
     // Return if there are no valid images.
     if (!$images) {
         return;
     }
     return $this->view->partial('common/openseadragon.php', array('images' => $images, 'imageNames' => $imageNames));
 }
Esempio n. 18
1
 /**
  * 登录
  */
 public function indexOp()
 {
     if (!$this->isQQLogin()) {
         if (empty($_POST['username']) || empty($_POST['password']) || !in_array($_POST['client'], $this->client_type_array)) {
             output_error('登录失败');
         }
     }
     $model_member = Model('member');
     $array = array();
     if ($this->isQQLogin()) {
         $array['member_qqopenid'] = $_SESSION['openid'];
     } else {
         $array['member_name'] = $_POST['username'];
         $array['member_passwd'] = md5($_POST['password']);
     }
     $member_info = $model_member->getMemberInfo($array);
     if (!empty($member_info)) {
         $token = $this->_get_token($member_info['member_id'], $member_info['member_name'], $_POST['client']);
         if ($token) {
             if ($this->isQQLogin()) {
                 setNc2Cookie('username', $member_info['member_name']);
                 setNc2Cookie('key', $token);
                 header("location:" . WAP_SITE_URL . '/tmpl/member/member.html?act=member');
             } else {
                 output_data(array('username' => $member_info['member_name'], 'key' => $token));
             }
         } else {
             output_error('登录失败');
         }
     } else {
         output_error('用户名密码错误');
     }
 }
Esempio n. 19
0
 /**
  * Dynamically set config key values.
  *
  * @param  string  $property
  * @param  string  $value
  * @return void
  */
 public function __set($property, $value)
 {
     $protected = array('repository');
     if (!in_array($property, $protected)) {
         $this->{$property} = $value;
     }
 }
Esempio n. 20
0
 function display($map, $values, $type = 'discount')
 {
     $id = $type . '_' . $map;
     $js = 'window.hikashop.ready( function(){ updateSubscription(\'' . $id . '\'); });';
     if (!HIKASHOP_PHP5) {
         $doc =& JFactory::getDocument();
     } else {
         $doc = JFactory::getDocument();
     }
     $doc->addScriptDeclaration($js);
     if (empty($values)) {
         $values = 'none';
     }
     $choiceValue = $values == 'none' ? $values : 'special';
     $return = JHTML::_('hikaselect.radiolist', $this->choice, "choice_" . $id, 'onchange="updateSubscription(\'' . $id . '\');"', 'value', 'text', $choiceValue);
     $return .= '<input type="hidden" name="data[' . $type . '][' . $map . ']" id="hidden_' . $id . '" value="' . $values . '"/>';
     $valuesArray = explode(',', $values);
     $listAccess = '<div style="display:none" id="div_' . $id . '"><table>';
     foreach ($this->groups as $oneGroup) {
         $listAccess .= '<tr><td>';
         if (version_compare(JVERSION, '1.6.0', '>=') || !in_array($oneGroup->value, array(29, 30))) {
             $listAccess .= '<input type="radio" onchange="updateSubscription(\'' . $id . '\');" value="' . $oneGroup->value . '" ' . (in_array($oneGroup->value, $valuesArray) ? 'checked' : '') . ' name="special_' . $id . '" id="special_' . $id . '_' . $oneGroup->value . '"/>';
         }
         $listAccess .= '</td><td><label for="special_' . $id . '_' . $oneGroup->value . '">' . $oneGroup->text . '</label></td></tr>';
     }
     $listAccess .= '</table></div>';
     $return .= $listAccess;
     return $return;
 }
Esempio n. 21
0
 /**
  * 
  * Sanitizes a file-upload information array.  If no file has been 
  * uploaded, the information will be returned as null.
  * 
  * @param array $value An array of file-upload information.
  * 
  * @return mixed The sanitized upload information array, or null.
  * 
  */
 public function sanitizeUpload($value)
 {
     // if the value is not required, and is blank, sanitize to null
     $null = !$this->_filter->getRequire() && $this->_filter->validateBlank($value);
     if ($null) {
         return null;
     }
     // has to be an array
     if (!is_array($value)) {
         return null;
     }
     // presorted list of expected keys
     $expect = array('error', 'name', 'size', 'tmp_name', 'type');
     // remove unexpected keys
     foreach ($value as $key => $val) {
         if (!in_array($key, $expect)) {
             unset($value[$key]);
         }
     }
     // sort the list of remaining actual keys
     $actual = array_keys($value);
     sort($actual);
     // make sure the expected and actual keys match up
     if ($expect != $actual) {
         return null;
     }
     // if all the non-error values are empty, still null
     $empty = empty($value['name']) && empty($value['size']) && empty($value['tmp_name']) && empty($value['type']);
     if ($empty) {
         return null;
     }
     // everything looks ok, return as-is
     return $value;
 }
Esempio n. 22
0
 public function getMethod($address, $total)
 {
     $this->load->language('payment/alipay_direct');
     $query = $this->db->query("SELECT * FROM " . DB_PREFIX . "zone_to_geo_zone WHERE geo_zone_id = '" . (int) $this->config->get('pp_standard_geo_zone_id') . "' AND country_id = '" . (int) $address['country_id'] . "' AND (zone_id = '" . (int) $address['zone_id'] . "' OR zone_id = '0')");
     if ($this->config->get('alipay_direct_total') > $total) {
         $status = false;
     } elseif (!$this->config->get('alipay_direct_geo_zone_id')) {
         $status = true;
     } elseif ($query->num_rows) {
         $status = true;
     } else {
         $status = false;
     }
     //判断是否移动设备访问
     $this->load->helper('mobile');
     if (is_mobile()) {
         $status = false;
     }
     $currencies = array('CNY');
     if (!in_array(strtoupper($this->currency->getCode()), $currencies)) {
         $status = false;
     }
     $method_data = array();
     if ($status) {
         $method_data = array('code' => 'alipay_direct', 'title' => $this->language->get('text_title'), 'terms' => '', 'sort_order' => $this->config->get('alipay_direct_sort_order'));
     }
     return $method_data;
 }
 /**
  * @param \PHP_CodeSniffer_File $phpCsFile
  * @param int $stackPointer
  *
  * @return void
  */
 public function process(\PHP_CodeSniffer_File $phpCsFile, $stackPointer)
 {
     $tokens = $phpCsFile->getTokens();
     $docBlockEndIndex = $this->findRelatedDocBlock($phpCsFile, $stackPointer);
     if (!$docBlockEndIndex) {
         return;
     }
     $docBlockStartIndex = $tokens[$docBlockEndIndex]['comment_opener'];
     for ($i = $docBlockStartIndex + 1; $i < $docBlockEndIndex; $i++) {
         if ($tokens[$i]['type'] !== 'T_DOC_COMMENT_TAG') {
             continue;
         }
         if (!in_array($tokens[$i]['content'], ['@return'])) {
             continue;
         }
         $classNameIndex = $i + 2;
         if ($tokens[$classNameIndex]['type'] !== 'T_DOC_COMMENT_STRING') {
             continue;
         }
         $content = $tokens[$classNameIndex]['content'];
         $appendix = '';
         $spaceIndex = strpos($content, ' ');
         if ($spaceIndex) {
             $appendix = substr($content, $spaceIndex);
             $content = substr($content, 0, $spaceIndex);
         }
         if (empty($content)) {
             continue;
         }
         $parts = explode('|', $content);
         $this->fixParts($phpCsFile, $classNameIndex, $parts, $appendix);
     }
 }
 /**
  * Main method : call the specified function or get the result from cache
  *
  * @param  callback $callback         A valid callback
  * @param  array    $parameters       Function parameters
  * @param  array    $tags             Cache tags
  * @param  int      $specificLifetime If != false, set a specific lifetime for this cache record (null => infinite lifetime)
  * @param  int      $priority         integer between 0 (very low priority) and 10 (maximum priority) used by some particular backends
  * @return mixed Result
  */
 public function call($callback, array $parameters = array(), $tags = array(), $specificLifetime = false, $priority = 8)
 {
     if (!is_callable($callback, true, $name)) {
         Zend_Cache::throwException('Invalid callback');
     }
     $cacheBool1 = $this->_specificOptions['cache_by_default'];
     $cacheBool2 = in_array($name, $this->_specificOptions['cached_functions']);
     $cacheBool3 = in_array($name, $this->_specificOptions['non_cached_functions']);
     $cache = ($cacheBool1 || $cacheBool2) && !$cacheBool3;
     if (!$cache) {
         // Caching of this callback is disabled
         return call_user_func_array($callback, $parameters);
     }
     $id = $this->_makeId($callback, $parameters);
     if (($rs = $this->load($id)) && isset($rs[0], $rs[1])) {
         // A cache is available
         $output = $rs[0];
         $return = $rs[1];
     } else {
         // A cache is not available (or not valid for this frontend)
         ob_start();
         ob_implicit_flush(false);
         $return = call_user_func_array($callback, $parameters);
         $output = ob_get_contents();
         ob_end_clean();
         $data = array($output, $return);
         $this->save($data, $id, $tags, $specificLifetime, $priority);
     }
     echo $output;
     return $return;
 }
 /**
  * Add a privilege to a group
  *
  * @access public
  * @param  string           $account    The team or individual account name.
  * @param  string           $groupOwner The account that owns the group.
  * @param  string           $groupSlug  The group identifier.
  * @param  string           $privilege  Either admin or collaborator.
  * @return MessageInterface
  *
  * @throws \InvalidArgumentException
  */
 public function create($account, $groupOwner, $groupSlug, $privilege)
 {
     if (!in_array($privilege, array('admin', 'collaborator'))) {
         throw new \InvalidArgumentException("Invalid privilege provided.");
     }
     return $this->requestPost(sprintf('users/%s/privileges/%s/%s', $account, $groupOwner, $groupSlug), array('privileges' => $privilege));
 }
Esempio n. 26
0
 /**
  * Throw file upload error, return true if error has been thrown, false if error has been catched
  *
  * @param int $number
  * @param string $text
  * @access public
  */
 function throwError($number, $uploaded = false, $exit = true)
 {
     if ($this->_catchAllErrors || in_array($number, $this->_skipErrorsArray)) {
         return false;
     }
     $oRegistry =& CKFinder_Connector_Core_Factory::getInstance("Core_Registry");
     $sFileName = $oRegistry->get("FileUpload_fileName");
     $sFileUrl = $oRegistry->get("FileUpload_url");
     header('Content-Type: text/html; charset=utf-8');
     /**
      * echo <script> is not called before CKFinder_Connector_Utils_Misc::getErrorMessage
      * because PHP has problems with including files that contain BOM character.
      * Having BOM character after <script> tag causes a javascript error.
      */
     echo "<script type=\"text/javascript\">";
     if (!empty($_GET['CKEditor'])) {
         $errorMessage = CKFinder_Connector_Utils_Misc::getErrorMessage($number, $sFileName);
         if (!$uploaded) {
             $sFileUrl = "";
             $sFileName = "";
         }
         $funcNum = preg_replace("/[^0-9]/", "", $_GET['CKEditorFuncNum']);
         echo "window.parent.CKEDITOR.tools.callFunction({$funcNum}, '" . str_replace("'", "\\'", $sFileUrl . $sFileName) . "', '" . str_replace("'", "\\'", $errorMessage) . "');";
     } else {
         if (!$uploaded) {
             echo "window.parent.OnUploadCompleted(" . $number . ", '', '', '') ;";
         } else {
             echo "window.parent.OnUploadCompleted(" . $number . ", '" . str_replace("'", "\\'", $sFileUrl . $sFileName) . "', '" . str_replace("'", "\\'", $sFileName) . "', '') ;";
         }
     }
     echo "</script>";
     if ($exit) {
         exit;
     }
 }
Esempio n. 27
0
 /**
  * Tokenize
  * 
  * @param string $action reset|confirm
  * @param string $field password|email
  * @param array $data CakeRequest::data
  * 
  * @return array $user User::find
  */
 public function tokenize(Model $Model, $action, $field, $data = array())
 {
     if (empty($field) || empty($action) || !in_array($field, array('password', 'email')) || !in_array($action, array('reset', 'confirm'))) {
         throw new InvalidArgumentException('Invalid agruments');
     }
     return $this->dispatchMethod('_' . Inflector::variable(sprintf('tokenize_%s_%s', $action, $field)), array($Model, $data));
 }
 /**
  * Returns TRUE if the associated action in _GET is allowed.
  *
  * @return boolean
  */
 public function actionIsAllowed()
 {
     if (!in_array(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('action'), array('route', 'getAPI'))) {
         return FALSE;
     }
     return TRUE;
 }
Esempio n. 29
0
 public static function Add($Number, $Nickname = null)
 {
     $Admins = Config::Get('Admins');
     if ($Admins !== false) {
         if (!in_array($Number, self::GetNumbersFromList($Admins))) {
             $Admins[] = array($Number, $Nickname);
             $Saved = Config::Set('Admins', $Admins);
             if ($Saved) {
                 Std::Out("[Info] [Admin] {$Number}" . (empty($Nickname) ? null : ":{$Nickname}") . ' added');
             } else {
                 Std::Out("[Warning] [Admin] Error while trying to add {$Number}" . (empty($Nickname) ? null : ":{$Nickname}"));
             }
             return $Saved;
         } else {
             Std::Out("[Info] [Admin] {$Number}" . (empty($Nickname) ? null : ":{$Nickname}") . ' already exists in admin list');
             return 1;
         }
     } else {
         $Saved = Config::Set('Admins', array(array($Number, $Nickname)));
         if ($Saved) {
             Std::Out("[Info] [Admin] {$Number}" . (empty($Nickname) ? null : ":{$Nickname}") . ' added');
         } else {
             Std::Out("[Warning] [Admin] Error while trying to add {$Number}" . (empty($Nickname) ? null : ":{$Nickname}"));
         }
         return $Saved;
     }
 }
Esempio n. 30
-1
 public function action_discrepancies()
 {
     if (!Group::current('is_admin')) {
         throw new HTTP_Exception_403('Forbidden');
     }
     $list = Database_Mongo::collection('jobs')->find(array('discrepancies' => array('$nin' => array(NULL, '', 0))));
     $ids = array();
     foreach ($list as $job) {
         $discr = Database_Mongo::collection('discrepancies')->find(array('job_key' => $job['_id']))->sort(array('update_time' => -1))->getNext();
         $fl = true;
         foreach ($discr['data'] as $key => $value) {
             if ($key == 44) {
                 $status = preg_replace('/[^a-z]/i', '', strtolower($value['old_value']));
                 $status2 = preg_replace('/[^a-z]/i', '', strtolower($value['new_value']));
                 $status0 = preg_replace('/[^a-z]/i', '', strtolower(Arr::get($job['data'], $key, '')));
                 if ($status == $status0) {
                     continue;
                 }
                 if ($status == 'tested' && $status2 != 'tested' || $status == 'built' && ($status2 != 'built' && $status2 != 'tested') || $status != $status2 && in_array($status2, array('deferred', 'dirty', 'heldnbn'), true)) {
                     $fl = false;
                     continue;
                 }
             } elseif ($value['old_value'] != Arr::get($job['data'], $key, '')) {
                 $fl = false;
                 continue;
             }
         }
         if ($fl) {
             $ids[] = $job['_id'];
         }
     }
     Database_Mongo::collection('jobs')->update(array('_id' => array('$in' => $ids)), array('$unset' => array('discrepancies' => 1)), array('multiple' => 1));
     header('Content-type: application/json');
     die(json_encode(array('success' => true)));
 }