Exemplo n.º 1
1
 /**
  * 加载语言定义(不区分大小写)
  * @param string $file 语言文件
  * @param string $range 作用域
  * @return mixed
  */
 public static function load($file, $range = '')
 {
     $range = $range ? $range : self::$range;
     $lang = is_file($file) ? include $file : [];
     // 批量定义
     return self::$lang[$range] = array_merge(self::$lang[$range], array_change_key_case($lang));
 }
Exemplo n.º 2
0
 /**
  *
  * @param array $where
  * @return stdClass
  * @throws Exception
  */
 public static function getPrivilegios(array $where = null)
 {
     $sucesso = new stdClass();
     try {
         $sql = 'SELECT ID
                      , ID_UNIDADE
                      , ID_RECURSO
                      , PERMISSAO
                   FROM TB_PRIVILEGIOS
                  WHERE ID_UNIDADE = :ID_UNIDADE';
         if (isset($where['ID_RECURSO'])) {
             $sql .= ' AND ID_RECURSO = :ID_RECURSO';
         }
         $stmt = Controlador::getInstance()->getConnection()->connection->prepare($sql);
         if (isset($where['ID_RECURSO'])) {
             $stmt->bindParam('ID_RECURSO', $where['ID_RECURSO'], PDO::PARAM_INT);
         }
         $stmt->bindParam('ID_UNIDADE', $where['ID_UNIDADE'], PDO::PARAM_INT);
         $stmt->execute();
         $out = $stmt->fetchAll(PDO::FETCH_ASSOC);
         $out = array_change_key_case($out, CASE_LOWER);
         $sucesso->success = true;
         if (count($out) > 0) {
             $sucesso->result = $out;
         } else {
             $sucesso->result = false;
         }
     } catch (PDOException $e) {
         $sucesso->error = true;
         $sucesso->result = 'Error Query: [' . $e->getMessage() . ']';
     }
     return $sucesso;
 }
Exemplo n.º 3
0
 function C($name = null, $value = null, $default = null)
 {
     static $_config = array();
     // 无参数时获取所有
     if (empty($name)) {
         return $_config;
     }
     // 优先执行设置获取或赋值
     if (is_string($name)) {
         if (!strpos($name, '.')) {
             $name = strtoupper($name);
             if (is_null($value)) {
                 return isset($_config[$name]) ? $_config[$name] : $default;
             }
             $_config[$name] = $value;
             return null;
         }
         // 二维数组设置和获取支持
         $name = explode('.', $name);
         $name[0] = strtoupper($name[0]);
         if (is_null($value)) {
             return isset($_config[$name[0]][$name[1]]) ? $_config[$name[0]][$name[1]] : $default;
         }
         $_config[$name[0]][$name[1]] = $value;
         return null;
     }
     // 批量设置
     if (is_array($name)) {
         $_config = array_merge($_config, array_change_key_case($name, CASE_UPPER));
         return null;
     }
     return null;
     // 避免非法参数
 }
Exemplo n.º 4
0
 /**
  * Cookie 设置、获取、删除
  *
  * @param string $name  cookie名称
  * @param mixed  $value cookie值
  * @param mixed  $option 可选参数 可能会是 null|integer|string
  *
  * @return mixed
  * @internal param mixed $options cookie参数
  */
 public static function set($name, $value = '', $option = null)
 {
     !isset(self::$init) && self::init();
     // 参数设置(会覆盖黙认设置)
     if (!is_null($option)) {
         if (is_numeric($option)) {
             $option = ['expire' => $option];
         } elseif (is_string($option)) {
             parse_str($option, $option);
         }
         $config = array_merge(self::$config, array_change_key_case($option));
     } else {
         $config = self::$config;
     }
     $name = $config['prefix'] . $name;
     // 设置cookie
     if (is_array($value)) {
         array_walk_recursive($value, 'self::jsonFormatProtect', 'encode');
         $value = 'think:' . json_encode($value);
     }
     $expire = !empty($config['expire']) ? $_SERVER['REQUEST_TIME'] + intval($config['expire']) : 0;
     if ($config['setcookie']) {
         setcookie($name, $value, $expire, $config['path'], $config['domain'], $config['secure'], $config['httponly']);
     }
     $_COOKIE[$name] = $value;
 }
Exemplo n.º 5
0
 /**
  * Initialize log
  *
  * @return  Zend_Log
  * @throws  Zend_Application_Resource_Exception
  */
 public function init()
 {
     $log = $this->getLog();
     $options = array_change_key_case($this->getOptions(), CASE_LOWER);
     foreach ($options as $key => $value) {
         switch ($key) {
             case 'filters':
                 // @todo Filter support
                 require_once 'Zend/Application/Resource/Exception.php';
                 throw new Zend_Application_Resource_Exception('Unsupported 
                     option.');
                 break;
             case 'formatters':
                 // @todo Formatter support
                 require_once 'Zend/Application/Resource/Exception.php';
                 throw new Zend_Application_Resource_Exception('Unsupported 
                     option.');
                 break;
             case 'writers':
                 $this->getWriters($value);
                 break;
             default:
                 break;
         }
     }
     return $log;
 }
Exemplo n.º 6
0
 /**
  * Get verbose error message by Error Code
  * @param $errorCode
  * @return string | false
  */
 public function getErrorMessageByCode($errorCode)
 {
     $errorMessages = array('REJECTED_BY_ACQUIRER' => Mage::helper('bankdebit')->__('Your customers bank declined the transaction, your customer can contact their bank for more information'), 'Error_Generic' => Mage::helper('bankdebit')->__('An unhandled exception occurred'), '3DSecureDirectoryServerError' => Mage::helper('bankdebit')->__('A problem with Visa or MasterCards directory server, that communicates transactions for 3D-Secure verification'), 'AcquirerComunicationError' => Mage::helper('bankdebit')->__('Communication error with the acquiring bank'), 'AmountNotEqualOrderLinesTotal' => Mage::helper('bankdebit')->__('The sum of your order lines is not equal to the price set in initialize'), 'CardNotEligible' => Mage::helper('bankdebit')->__('Your customers card is not eligible for this kind of purchase, your customer can contact their bank for more information'), 'CreditCard_Error' => Mage::helper('bankdebit')->__('Some problem occurred with the credit card, your customer can contact their bank for more information'), 'PaymentRefusedByFinancialInstitution' => Mage::helper('bankdebit')->__('Your customers bank declined the transaction, your customer can contact their bank for more information'), 'Merchant_InvalidAccountNumber' => Mage::helper('bankdebit')->__('The merchant account number sent in on request is invalid'), 'Merchant_InvalidIpAddress' => Mage::helper('bankdebit')->__('The IP address the request comes from is not registered in PayEx, you can set it up in PayEx Admin under Merchant profile'), 'Access_MissingAccessProperties' => Mage::helper('bankdebit')->__('The merchant does not have access to requested functionality'), 'Access_DuplicateRequest' => Mage::helper('bankdebit')->__('Your customers bank declined the transaction, your customer can contact their bank for more information'), 'Admin_AccountTerminated' => Mage::helper('bankdebit')->__('The merchant account is not active'), 'Admin_AccountDisabled' => Mage::helper('bankdebit')->__('The merchant account is not active'), 'ValidationError_AccountLockedOut' => Mage::helper('bankdebit')->__('The merchant account is locked out'), 'ValidationError_Generic' => Mage::helper('bankdebit')->__('Generic validation error'), 'ValidationError_HashNotValid' => Mage::helper('bankdebit')->__('The hash on request is not valid, this might be due to the encryption key being incorrect'), 'ValidationError_InvalidParameter' => Mage::helper('bankdebit')->__('One of the input parameters has invalid data. See paramName and description for more information'), 'OperationCancelledbyCustomer' => Mage::helper('bankdebit')->__('The operation was cancelled by the client'), 'PaymentDeclinedDoToUnspecifiedErr' => Mage::helper('bankdebit')->__('Unexpecter error at 3rd party'), 'InvalidAmount' => Mage::helper('bankdebit')->__('The amount is not valid for this operation'), 'NoRecordFound' => Mage::helper('bankdebit')->__('No data found'), 'OperationNotAllowed' => Mage::helper('bankdebit')->__('The operation is not allowed, transaction is in invalid state'), 'ACQUIRER_HOST_OFFLINE' => Mage::helper('bankdebit')->__('Could not get in touch with the card issuer'), 'ARCOT_MERCHANT_PLUGIN_ERROR' => Mage::helper('bankdebit')->__('The card could not be verified'), 'REJECTED_BY_ACQUIRER_CARD_BLACKLISTED' => Mage::helper('bankdebit')->__('There is a problem with this card'), 'REJECTED_BY_ACQUIRER_CARD_EXPIRED' => Mage::helper('bankdebit')->__('The card expired'), 'REJECTED_BY_ACQUIRER_INSUFFICIENT_FUNDS' => Mage::helper('bankdebit')->__('Insufficient funds'), 'REJECTED_BY_ACQUIRER_INVALID_AMOUNT' => Mage::helper('bankdebit')->__('Incorrect amount'), 'USER_CANCELED' => Mage::helper('bankdebit')->__('Payment cancelled'), 'CardNotAcceptedForThisPurchase' => Mage::helper('bankdebit')->__('Your Credit Card not accepted for this purchase'));
     $errorMessages = array_change_key_case($errorMessages, CASE_UPPER);
     $errorCode = mb_strtoupper($errorCode);
     return isset($errorMessages[$errorCode]) ? $errorMessages[$errorCode] : false;
 }
Exemplo n.º 7
0
 /** @return Deployer */
 private function createDeployer($config)
 {
     $config = array_change_key_case($config, CASE_LOWER) + ['local' => '', 'passivemode' => TRUE, 'ignore' => '', 'allowdelete' => TRUE, 'purge' => '', 'before' => '', 'after' => '', 'preprocess' => TRUE];
     if (empty($config['remote']) || !parse_url($config['remote'])) {
         throw new \Exception("Missing or invalid 'remote' URL in config.");
     }
     $server = parse_url($config['remote'], PHP_URL_SCHEME) === 'sftp' ? new SshServer($config['remote']) : new FtpServer($config['remote'], (bool) $config['passivemode']);
     if (!preg_match('#/|\\\\|[a-z]:#iA', $config['local'])) {
         if ($config['local'] && getcwd() !== dirname($this->configFile)) {
             $this->logger->log('WARNING: the "local" path is now relative to the directory where ' . basename($this->configFile) . ' is placed', 'red');
         }
         $config['local'] = dirname($this->configFile) . '/' . $config['local'];
     }
     $deployment = new Deployer($server, $config['local'], $this->logger);
     if ($config['preprocess']) {
         $deployment->preprocessMasks = $config['preprocess'] == 1 ? ['*.js', '*.css'] : self::toArray($config['preprocess']);
         // intentionally ==
         $preprocessor = new Preprocessor($this->logger);
         $deployment->addFilter('js', [$preprocessor, 'expandApacheImports']);
         $deployment->addFilter('js', [$preprocessor, 'compressJs'], TRUE);
         $deployment->addFilter('css', [$preprocessor, 'expandApacheImports']);
         $deployment->addFilter('css', [$preprocessor, 'expandCssImports']);
         $deployment->addFilter('css', [$preprocessor, 'compressCss'], TRUE);
     }
     $deployment->ignoreMasks = array_merge(['*.bak', '.svn', '.git*', 'Thumbs.db', '.DS_Store'], self::toArray($config['ignore']));
     $deployment->deploymentFile = empty($config['deploymentfile']) ? $deployment->deploymentFile : $config['deploymentfile'];
     $deployment->allowDelete = $config['allowdelete'];
     $deployment->toPurge = self::toArray($config['purge'], TRUE);
     $deployment->runBefore = self::toArray($config['before'], TRUE);
     $deployment->runAfter = self::toArray($config['after'], TRUE);
     $deployment->testMode = !empty($config['test']) || $this->mode === 'test';
     return $deployment;
 }
Exemplo n.º 8
0
 /**
  * Read the Information from a picture according to the fields specified in CCK
  * @param $file
  * @param $arTagNames
  * @return array
  */
 public function readExifTags($file, $arTagNames = array())
 {
     if (!file_exists($file)) {
         return array();
     }
     $ar_supported_types = array('jpg', 'jpeg');
     if (!in_array(strtolower($this->getFileType($file)), $ar_supported_types)) {
         return array();
     }
     $exif = exif_read_data($file, 0);
     $arSmallExif = array();
     $arSmallExif = array_change_key_case((array) $exif, CASE_LOWER);
     $arSmallExif['computed'] = array_change_key_case((array) $arSmallExif['computed'], CASE_LOWER);
     //why this function isn't recursive is beyond me
     $arSmallExif['thumbnail'] = array_change_key_case((array) $arSmallExif['thumbnail'], CASE_LOWER);
     $arSmallExif['comment'] = array_change_key_case((array) $arSmallExif['comment'], CASE_LOWER);
     $info = array();
     foreach ($arTagNames as $tagName) {
         if ($tagName['section'] != 'iptc') {
             if (!empty($arSmallExif[$tagName['tag']])) {
                 $info[$tagName['section'] . '_' . $tagName['tag']] = $arSmallExif[$tagName['tag']];
             } elseif (!empty($arSmallExif[$tagName['section']][$tagName['tag']])) {
                 $info[$tagName['section'] . '_' . $tagName['tag']] = $arSmallExif[$tagName['section']][$tagName['tag']];
             }
         }
     }
     foreach ($info as $tag => $value) {
         if (!is_array($value)) {
             $info[$tag] = utf8_encode($value);
         }
     }
     return $info;
 }
Exemplo n.º 9
0
 /**
  * Initialization hook method.
  *
  * @return void
  */
 public function initialize(array $params)
 {
     self::$instance =& $this;
     $session = $this->request->session();
     // load botdetect captcha library
     LibraryLoader::load($session);
     // change the keys in $param array to lowercase,
     // this will avoid user being able to pass in a lowercase option (e.g. captchaconfig)
     $params = array_change_key_case($params, CASE_LOWER);
     if (empty($params) || !array_key_exists('captchaconfig', $params) || empty($params['captchaconfig'])) {
         $errorMessage = 'The BotDetect Captcha component requires you to declare "captchaConfig" option and assigns a captcha configuration key defined in config/captcha.php file.<br>';
         $errorMessage .= 'For example: $this->loadComponent(\'CakeCaptcha.Captcha\', [\'captchaConfig\' => \'ContactCaptcha\']);';
         throw new InvalidArgumentException($errorMessage);
     }
     $captchaId = $params['captchaconfig'];
     // get captcha config
     $config = UserCaptchaConfiguration::get($captchaId);
     if (null === $config) {
         throw new InvalidArgumentException(sprintf('The "%s" option could not be found in config/captcha.php file.', $captchaId));
     }
     if (!is_array($config)) {
         throw new UnexpectedTypeException($config, 'array');
     }
     // save user's captcha configuration options
     UserCaptchaConfiguration::save($config);
     // init botdetect captcha instance
     $this->initCaptcha($config);
 }
Exemplo n.º 10
0
 /**
  * Clean wrong fields and operations from filter.
  * @param array $filter Filter.
  * @return array Filter after clean.
  */
 public function cleanFilter(array $filter)
 {
     $possibleFields = $this->entity->getFieldsForFilter();
     $mapFields = $this->entity->getFieldsForMap();
     $whiteFilter = array();
     $filter = array_change_key_case($filter, CASE_UPPER);
     foreach ($filter as $key => $value) {
         if (is_numeric($key) && is_array($value)) {
             continue;
         }
         if (preg_match('/^([^a-zA-Z]*)(.*)/', $key, $matches)) {
             $operation = $matches[1];
             $field = $matches[2];
             if (!in_array($operation, $this->allowedOperations, true)) {
                 continue;
             }
             if (isset($possibleFields[$field])) {
                 if (isset($mapFields[$field])) {
                     $value = call_user_func_array($mapFields[$field]['IN'], array($value));
                 }
                 $whiteFilter[$key] = $value;
             }
         }
     }
     return $whiteFilter;
 }
Exemplo n.º 11
0
 /**
  * Post request into gateway
  *
  * @param DataObject $request
  * @param ConfigInterface $config
  *
  * @return DataObject
  * @throws \Zend_Http_Client_Exception
  */
 public function postRequest(DataObject $request, ConfigInterface $config)
 {
     $result = new DataObject();
     $clientConfig = ['maxredirects' => 5, 'timeout' => 30, 'verifypeer' => $config->getValue('verify_peer')];
     if ($config->getValue('use_proxy')) {
         $clientConfig['proxy'] = $config->getValue('proxy_host') . ':' . $config->getValue('proxy_port');
         $clientConfig['httpproxytunnel'] = true;
         $clientConfig['proxytype'] = CURLPROXY_HTTP;
     }
     /** @var ZendClient $client */
     $client = $this->httpClientFactory->create();
     $client->setUri((bool) $config->getValue('sandbox_flag') ? $config->getValue('transaction_url_test_mode') : $config->getValue('transaction_url'));
     $client->setConfig($clientConfig);
     $client->setMethod(\Zend_Http_Client::POST);
     $client->setParameterPost($request->getData());
     $client->setHeaders(['X-VPS-VIT-CLIENT-CERTIFICATION-ID' => '33baf5893fc2123d8b191d2d011b7fdc', 'X-VPS-Request-ID' => $this->mathRandom->getUniqueHash(), 'X-VPS-CLIENT-TIMEOUT' => 45]);
     $client->setUrlEncodeBody(false);
     try {
         $response = $client->request();
         $responseArray = [];
         parse_str(strstr($response->getBody(), 'RESULT'), $responseArray);
         $result->setData(array_change_key_case($responseArray, CASE_LOWER));
         $result->setData('result_code', $result->getData('result'));
     } catch (\Zend_Http_Client_Exception $e) {
         $result->addData(['response_code' => -1, 'response_reason_code' => $e->getCode(), 'response_reason_text' => $e->getMessage()]);
         throw $e;
     } finally {
         $this->logger->debug(['request' => $request->getData(), 'result' => $result->getData()], (array) $config->getValue('getDebugReplacePrivateDataKeys'), (bool) $config->getValue('debug'));
     }
     return $result;
 }
Exemplo n.º 12
0
 /**
  * Init new cache file
  *
  * @param   string   $filename name of cache file
  * @param   array    $skip_classes list of skipped from cache classes
  * @return  void
  */
 public static function init($filename = NULL, array $skip_classes = NULL)
 {
     if (self::$_init) {
         self::save();
     }
     if ($filename === NULL) {
         $filename = self::$default_filename;
     }
     if (!self::$cache_dir) {
         self::$cache_dir = Kohana::$cache_dir ? Kohana::$cache_dir : APPPATH . 'cache';
     }
     $filename = self::$cache_dir . DIRECTORY_SEPARATOR . $filename . EXT;
     $is_file = is_file($filename);
     if ($is_file) {
         //			timer('requere start');
         require $filename;
         //			timer('requere stop');
     }
     if ($skip_classes !== NULL) {
         self::$skip_classes += array_change_key_case(array_combine($skip_classes, $skip_classes), CASE_LOWER);
     } else {
         self::$skip_classes = array();
     }
     self::$_cache[] = array('filename' => $filename, 'is_file' => $is_file, 'mtime' => $is_file ? @filemtime($filename) : FALSE, 'size' => $is_file ? @filesize($filename) : FALSE, 'files' => array());
     self::$_files =& self::$_cache[count(self::$_cache) - 1]['files'];
     if (self::$_init === NULL) {
         spl_autoload_unregister(array('Kohana', 'auto_load'));
         spl_autoload_register(array('Ku_Loader', 'auto_load'));
         register_shutdown_function(array('Ku_Loader', 'shutdown_handler'));
         self::$_init = TRUE;
     }
     //		die ('Init');
 }
Exemplo n.º 13
0
    /**
     * Get Consolidated
     *
     * @access public
     * @param string $tas_uid, Task Uid
     * @return array
     *
     * @author Brayan Pereyra (Cochalo) <*****@*****.**>
     * @copyright Colosa - Bolivia
    */
    public function get ($tas_uid)
    {
        $criteria = new Criteria();
        $criteria->addSelectColumn(CaseConsolidatedCorePeer::DYN_UID);
        $criteria->addSelectColumn(\ReportTablePeer::REP_TAB_NAME);
        $criteria->addSelectColumn(\ReportTablePeer::REP_TAB_UID);
        $criteria->addSelectColumn(ContentPeer::CON_VALUE);
        $criteria->addSelectColumn(CaseConsolidatedCorePeer::CON_STATUS);

        $criteria->addJoin( CaseConsolidatedCorePeer::REP_TAB_UID, ReportTablePeer::REP_TAB_UID, Criteria::LEFT_JOIN );
        $criteria->addJoin( CaseConsolidatedCorePeer::REP_TAB_UID, ContentPeer::CON_ID, Criteria::LEFT_JOIN );
        $criteria->add( ContentPeer::CON_CATEGORY, "REP_TAB_TITLE");
        $criteria->add( ContentPeer::CON_LANG, SYS_LANG);

        $criteria->add( CaseConsolidatedCorePeer::TAS_UID, $tas_uid, Criteria::EQUAL );
        $criteria->add( CaseConsolidatedCorePeer::CON_STATUS, 'ACTIVE', Criteria::EQUAL );

        $dataset = CaseConsolidatedCorePeer::doSelectRS($criteria);
        $dataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
        if ($dataset->next()) {
            $response = $dataset->getRow();
        } else {
            $response = array(
                'REP_TAB_UID'   => '',
                'REP_TAB_NAME'  => '__' . $tas_uid,
                'CON_VALUE'     => '__' . $tas_uid,
            );
        }
        return array_change_key_case($response, CASE_LOWER);;
    }
Exemplo n.º 14
0
 /**
  * {@inheritdoc}
  */
 public function run(OptionsResolverInterface $resolver)
 {
     $records = array();
     $localRecords = $this->localSource->execute();
     $results = $this->ridicSource->execute();
     foreach ($results as $key => $result) {
         $result = array_change_key_case($result, CASE_LOWER);
         $mrn = $result['hup_mrn'];
         try {
             $result['previous_record'] = $this->provider->getPatientByMRN($mrn);
         } catch (PatientNotFoundException $e) {
             unset($result, $results[$key]);
             continue;
         }
         $result['identifier'] = $result['course_ser'];
         $result['patient'] = $result['hup_mrn'];
         $result['activity_date'] = $result['first_treatment_dt'];
         $result['import_description'] = sprintf('%s ridic dose on the %s.', $result['course_ser'], $result['hup_mrn']);
         $record = $resolver->resolve($result);
         if ($record['patient'] && !in_array($record['course_ser'], $localRecords)) {
             $records[] = $record;
         }
         unset($results[$key]);
     }
     return $records;
 }
Exemplo n.º 15
0
 public function parseXmlAttr($attr, $tag)
 {
     $attr = str_replace('&', '___', $attr);
     $xml = '<tpl><tag ' . $attr . ' /></tpl>';
     $xml = simplexml_load_string($xml);
     if (!$xml) {
         throw_exception(L('_XML_TAG_ERROR_') . ' : ' . $attr);
     }
     $xml = (array) $xml->tag->attributes();
     $array = array_change_key_case($xml['@attributes']);
     if ($array) {
         $attrs = explode(',', $this->tags[strtolower($tag)]['attr']);
         if (isset($this->tags[strtolower($tag)]['must'])) {
             $must = explode(',', $this->tags[strtolower($tag)]['must']);
         } else {
             $must = array();
         }
         foreach ($attrs as $name) {
             if (isset($array[$name])) {
                 $array[$name] = str_replace('___', '&', $array[$name]);
             } elseif (false !== array_search($name, $must)) {
                 throw_exception(L('_PARAM_ERROR_') . ':' . $name);
             }
         }
         return $array;
     }
 }
Exemplo n.º 16
0
function __DSGetInitData()
{
    $map = new \Bitrix\MobileApp\Designer\ConfigMap();
    $params = $map->getParamsByGroups();
    $groups = array_keys($params);
    $tmpLangs = array_change_key_case($map->getLangMessages(), CASE_LOWER);
    $langs = array();
    foreach ($tmpLangs as $k => $v) {
        $langs[str_replace("_", "/", $k)] = $v;
    }
    $result = \Bitrix\Mobileapp\Designer\AppTable::getList(array("select" => array("CODE", "FOLDER", "DESCRIPTION", "SHORT_NAME", "NAME", "CONFIG.PLATFORM", "CONFIG.PARAMS")));
    $fetchedApps = $result->fetchAll();
    $apps = array();
    $count = count($fetchedApps);
    for ($i = 0; $i < $count; $i++) {
        $apps[] = array("code" => $fetchedApps[$i]["CODE"], "name" => $fetchedApps[$i]["NAME"], "folder" => $fetchedApps[$i]["FOLDER"], "desc" => $fetchedApps[$i]["DESCRIPTION"], "params" => $fetchedApps[$i]["MOBILEAPP_DESIGNER_APP_CONFIG_PARAMS"], "platform" => $fetchedApps[$i]["MOBILEAPP_DESIGNER_APP_CONFIG_PLATFORM"]);
    }
    $dbres = \CSiteTemplate::GetList();
    $templates = array();
    while ($t = $dbres->Fetch()) {
        $templates[] = $t;
    }
    $data = array("map" => array("groups" => $groups, "groupedParams" => $params, "params" => $map->getDescriptionConfig(), "lang" => $tmpLangs), "apps" => $apps, "templates" => $templates);
    return $data;
}
Exemplo n.º 17
0
/**
 * 配置文件处理函数
 *处理以下几种情况:
 * 0:   C();获得所有的配置信息
 * 1:   C("tom"); //取tom的值
 * 2:   C("tom", '1'); //设置tom的值
 * 3:   C("tom.age", '2');  设置tom的年龄(二维数组)的值为2
 * 4:   C("tom.age");  取得tom的年龄
 * 5:   C(array("tom"=>2));  合并数组到主配置文件数组中
 * 2015-5-9上午10:14:42
 */
function C($name = null, $value = null)
{
    static $config = array();
    if (is_null($name)) {
        return $config;
    }
    if (is_string($name)) {
        $name = strtolower($name);
        if (!strstr($name, ".")) {
            if (is_null($value)) {
                return isset($config[$name]) ? $config[$name] : null;
            } else {
                $config[$name] = $value;
                return;
            }
        } else {
            $name = explode(".", $name);
            if (is_null($value)) {
                return isset($config[$name[0][1]]) ? $config[0][1] : null;
            } else {
                $config[$name[0][1]] = $value;
                return;
            }
        }
    }
    if (is_array($name)) {
        $config = array_merge($config, array_change_key_case($name));
        return true;
    }
}
Exemplo n.º 18
0
 public final function setLocale($a_lang)
 {
     $path = $this->m_path . Zoombi::DS . $a_lang . Zoombi::DS;
     if (is_dir($path) == false) {
         zlog('Language path: ' . $path . ' is not exist.');
         return;
     }
     $handle = opendir($path);
     if ($handle === false) {
         return;
     }
     while (false !== ($file = readdir($handle))) {
         if (strpos($file, '.ini') > 0) {
             $filepath = $path . $file;
             $this->m_inis[$file] = new Zoombi_Ini($filepath);
         }
     }
     $array = array();
     foreach ($this->m_inis as $ini) {
         if (!$ini) {
             continue;
         }
         $array = array_merge($array, $ini->values());
     }
     $this->m_locale = array_change_key_case($array, CASE_UPPER);
 }
Exemplo n.º 19
0
function server_http_headers($host, $ip, $port)
{
    global $timeout;
    // first check if server is http. otherwise long timeout.
    $ch = curl_init("https://" . $ip . ":" . $port);
    curl_setopt($ch, CURLOPT_TIMEOUT, $timeout);
    curl_setopt($ch, CURLOPT_NOBODY, true);
    curl_setopt($ch, CURLOPT_HTTPHEADER, array("Host: {$host}"));
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_FAILONERROR, true);
    curl_setopt($ch, CURLOPT_FRESH_CONNECT, true);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, false);
    if (curl_exec($ch) === false) {
        curl_close($ch);
        return false;
    }
    curl_close($ch);
    stream_context_set_default(array("ssl" => array("verify_peer" => false, "capture_session_meta" => true, "verify_peer_name" => false, "peer_name" => $host, "allow_self_signed" => true, "sni_enabled" => true), 'http' => array('method' => 'GET', 'max_redirects' => 1, 'header' => 'Host: ' . $host, 'timeout' => $timeout)));
    $headers = get_headers("https://{$ip}:{$port}", 1);
    if (!empty($headers)) {
        $headers = array_change_key_case($headers, CASE_LOWER);
        return $headers;
    }
}
Exemplo n.º 20
0
 private function fetch_next()
 {
     if ($row = $this->sth->fetch()) {
         $row = array_change_key_case($row, CASE_LOWER);
     }
     return $row;
 }
 function getGroupPopedom($groupid)
 {
     if ($groupid) {
         $arrPopedomList = $this->where('groupid=' . $groupid)->field('menuid,modelid,arraction,type')->findAll();
         foreach ($arrPopedomList as $key => $val) {
             $modelname = TS_D('SyNode')->where('id=' . $val['modelid'])->field('name')->find();
             $arraction = unserialize($val['arraction']);
             $map['id'] = array('in', $arraction);
             $actionlist = TS_D('SyNode')->where($map)->field('title,name,containaction')->findall();
             foreach ($actionlist as $k => $v) {
                 foreach (unserialize($v['containaction']) as $kk => $vv) {
                     $arr[strtoupper($vv['name'])] = true;
                 }
             }
             if ($val['type'] == 'admin') {
                 $result['ADMIN'][strtoupper($modelname['name'])] = $arr;
             } else {
                 $result[strtoupper($modelname['name'])]['ADMIN'] = $arr;
             }
             unset($arr);
             unset($map);
         }
     }
     $r = array_change_key_case($result, CASE_UPPER);
     return $result;
 }
 /**
  * Creates UpdateEntityResult from HTTP response headers.
  * 
  * @param array $headers The HTTP response headers.
  * 
  * @return \WindowsAzure\Table\Models\UpdateEntityResult 
  */
 public static function create($headers)
 {
     $result = new UpdateEntityResult();
     $clean = array_change_key_case($headers);
     $result->setETag($clean[Resources::ETAG]);
     return $result;
 }
Exemplo n.º 23
0
 public function GetParameters()
 {
     $aResult = array();
     $aLowerTokensMap = array_change_key_case($this->aMap['tokens'], CASE_LOWER);
     $aLowerSpecialMap = array_change_key_case($this->aMap['tokensWithSpecialTreatmentImport'], CASE_LOWER);
     if ($this->aContainer && 0 < count($this->aContainer)) {
         foreach ($this->aContainer as $sHeaderName => $sValue) {
             $sHeaderName = trim($sHeaderName);
             $sValue = trim($sValue);
             if (!empty($sValue)) {
                 if (!empty($aLowerTokensMap[strtolower($sHeaderName)])) {
                     $aResult[$aLowerTokensMap[strtolower($sHeaderName)]] = $sValue;
                 } else {
                     if (!empty($aLowerSpecialMap[strtolower($sHeaderName)])) {
                         $sFunctionName = $aLowerSpecialMap[strtolower($sHeaderName)];
                         $mFuncResult = call_user_func_array(array(&$this, $sFunctionName), array($sHeaderName, $sValue));
                         if (is_array($mFuncResult) && 0 < count($mFuncResult)) {
                             foreach ($mFuncResult as $sKey => $mResult) {
                                 if (!empty($mResult)) {
                                     $aResult[$sKey] = $mResult;
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
     return $aResult;
 }
Exemplo n.º 24
0
 function openHandler(&$parser, $name, $attrs)
 {
     global $my_files;
     $name = strtolower($name);
     $attrs = array_change_key_case($attrs, CASE_LOWER);
     $elements = array('img' => 'src', 'a' => 'href', 'object' => array('data', 'classid'), 'applet' => array('classid', 'archive'), 'script' => 'src', 'input' => 'src', 'iframe' => 'src', 'embed' => 'src');
     /* check if this attribute specifies the files in different ways: (ie. java) */
     if (is_array($elements[$name])) {
         $items = $elements[$name];
         foreach ($items as $item) {
             if ($attrs[$item] != '') {
                 /* some attributes allow a listing of files to include seperated by commas (ie. applet->archive). */
                 if (strpos($attrs[$item], ',') !== false) {
                     $files = explode(',', $attrs[$item]);
                     foreach ($files as $file) {
                         $my_files[] = trim($file);
                     }
                 } else {
                     $my_files[] = $attrs[$item];
                 }
             }
         }
     } else {
         if (isset($elements[$name]) && $attrs[$elements[$name]] != '') {
             /* we know exactly which attribute contains the reference to the file. */
             $my_files[] = $attrs[$elements[$name]];
         }
     }
 }
Exemplo n.º 25
0
 /**
  * 取得数据表的字段信息
  * @access public
  * @param string $tableName
  * @return array
  */
 public function getFields($tableName)
 {
     $this->initConnect(true);
     list($tableName) = explode(' ', $tableName);
     $sql = "SELECT   column_name,   data_type,   column_default,   is_nullable\n        FROM    information_schema.tables AS t\n        JOIN    information_schema.columns AS c\n        ON  t.table_catalog = c.table_catalog\n        AND t.table_schema  = c.table_schema\n        AND t.table_name    = c.table_name\n        WHERE   t.table_name = '{$tableName}'";
     // 调试开始
     $this->debug(true);
     $pdo = $this->linkID->query($sql);
     // 调试结束
     $this->debug(false, $sql);
     $result = $pdo->fetchAll(PDO::FETCH_ASSOC);
     $info = [];
     if ($result) {
         foreach ($result as $key => $val) {
             $val = array_change_key_case($val);
             $info[$val['column_name']] = ['name' => $val['column_name'], 'type' => $val['data_type'], 'notnull' => (bool) ('' === $val['is_nullable']), 'default' => $val['column_default'], 'primary' => false, 'autoinc' => false];
         }
     }
     $sql = "SELECT column_name FROM information_schema.key_column_usage WHERE table_name='{$tableName}'";
     // 调试开始
     $this->debug(true);
     $pdo = $this->linkID->query($sql);
     // 调试结束
     $this->debug(false, $sql);
     $result = $pdo->fetch(PDO::FETCH_ASSOC);
     if ($result) {
         $info[$result['column_name']]['primary'] = true;
     }
     return $this->fieldCase($info);
 }
Exemplo n.º 26
0
 /**
  * Cookie 设置、获取、删除
  *
  * @param string $name cookie名称
  * @param mixed $value cookie值
  * @param mixed $options cookie参数
  *
  * @return mixed
  */
 public static function set($name, $value = '', $option = null)
 {
     // 参数设置(会覆盖黙认设置)
     if (!is_null($option)) {
         if (is_numeric($option)) {
             $option = array('expire' => $option);
         } elseif (is_string($option)) {
             parse_str($option, $option);
         }
         $config = array_merge(static::$config, array_change_key_case($option));
     } else {
         $config = static::$config;
     }
     // 合并前缀
     $name = $config['prefix'] . $name;
     // 设置cookie
     if (is_array($value)) {
         $value = 'think:' . json_encode(array_map('urlencode', $value));
     }
     // 计算时间
     $expire = !empty($config['expire']) ? time() + intval($config['expire']) : 0;
     // cookie配置
     setcookie($name, $value, $expire, $config['path'], $config['domain']);
     // 保存cookie
     $_COOKIE[$name] = $value;
 }
Exemplo n.º 27
0
 /**
  * Get features from request
  *
  * @param  array $request $_SERVER variable
  * @return array
  */
 public static function getFromRequest($request, array $config)
 {
     if (!class_exists('TeraWurfl')) {
         // If TeraWurfl class not found, see if we can load it from
         // configuration
         //
         if (!isset($config['terawurfl'])) {
             // No configuration
             require_once 'Zend/Http/UserAgent/Features/Exception.php';
             throw new Zend_Http_UserAgent_Features_Exception('"TeraWurfl" configuration is not defined');
         }
         $config = $config['terawurfl'];
         if (empty($config['terawurfl_lib_dir'])) {
             // No lib_dir given
             require_once 'Zend/Http/UserAgent/Features/Exception.php';
             throw new Zend_Http_UserAgent_Features_Exception('The "terawurfl_lib_dir" parameter is not defined');
         }
         // Include the Tera-WURFL file
         require_once $config['terawurfl_lib_dir'] . '/TeraWurfl.php';
     }
     // instantiate the Tera-WURFL object
     $wurflObj = new TeraWurfl();
     // Get the capabilities of the current client.
     $matched = $wurflObj->getDeviceCapabilitiesFromRequest(array_change_key_case($request, CASE_UPPER));
     return self::getAllCapabilities($wurflObj);
 }
 /**
  * @see sfConfigHandler
  */
 public static function getConfiguration(array $configFiles)
 {
     $config = static::flattenConfiguration(static::parseYamls($configFiles));
     // change all of the keys to lowercase
     $config = array_change_key_case($config);
     return $config;
 }
 function __construct($view, $moduleName, $packageName = '', $client = '')
 {
     $GLOBALS['log']->debug(get_class($this) . ": __construct()");
     // Set the client
     $this->client = $client;
     // Simple validation
     if (!in_array($view, $this->allowedViews)) {
         sugar_die("ListLayoutMetaDataParser: View {$view} is not supported");
     }
     if (empty($packageName)) {
         require_once 'modules/ModuleBuilder/parsers/views/DeployedMetaDataImplementation.php';
         $this->implementation = new DeployedMetaDataImplementation($view, $moduleName, $client);
     } else {
         require_once 'modules/ModuleBuilder/parsers/views/UndeployedMetaDataImplementation.php';
         $this->implementation = new UndeployedMetaDataImplementation($view, $moduleName, $packageName, $client);
     }
     $this->view = $view;
     $this->_fielddefs = $this->implementation->getFielddefs();
     //$this->_paneldefs = $this->implementation->getPanelDefs();
     $this->_standardizeFieldLabels($this->_fielddefs);
     $this->_viewdefs = array_change_key_case($this->implementation->getViewdefs());
     // force to lower case so don't have problems with case mismatches later
     // Set the module name
     $this->_moduleName = $moduleName;
 }
Exemplo n.º 30
0
function cmssavecache($name = '', $fields = '')
{
    $Model = D($name);
    $list = $Model->select();
    $data = array();
    foreach ($list as $key => $val) {
        if (empty($fields)) {
            $data[$val[$Model->getPk()]] = $val;
        } else {
            // 获取需要的字段
            if (is_string($fields)) {
                $fields = explode(',', $fields);
            }
            if (count($fields) == 1) {
                $data[$val[$Model->getPk()]] = $val[$fields[0]];
            } else {
                foreach ($fields as $field) {
                    $data[$val[$Model->getPk()]][] = $val[$field];
                }
            }
        }
    }
    $savefile = cmsgetcache($name);
    // 所有参数统一为大写
    $content = "<?php\nreturn " . var_export(array_change_key_case($data, CASE_UPPER), true) . ";\n?>";
    file_put_contents($savefile, $content);
}