Ejemplo n.º 1
1
 /**
  * Standard modular run function for snippet hooks. Generates XHTML to insert into a page using AJAX.
  *
  * @return tempcode  The snippet
  */
 function run()
 {
     $type = get_param('type');
     if (!has_zone_access(get_member(), 'adminzone')) {
         return new ocp_tempcode();
     }
     decache('main_staff_checklist');
     require_lang('staff_checklist');
     switch ($type) {
         case 'add':
             $recurinterval = get_param_integer('recurinterval', 0);
             $task_title = get_param('tasktitle', false, true);
             $id = $GLOBALS['SITE_DB']->query_insert('customtasks', array('tasktitle' => $task_title, 'datetimeadded' => time(), 'recurinterval' => $recurinterval, 'recurevery' => get_param('recurevery'), 'taskisdone' => NULL), true);
             require_code('notifications');
             $subject = do_lang('CT_NOTIFICATION_MAIL_SUBJECT', get_site_name(), $task_title);
             $mail = do_lang('CT_NOTIFICATION_MAIL', comcode_escape(get_site_name()), comcode_escape($task_title));
             dispatch_notification('checklist_task', NULL, $subject, $mail);
             return do_template('BLOCK_MAIN_STAFF_CHECKLIST_CUSTOM_TASK', array('TASKTITLE' => comcode_to_tempcode(get_param('tasktitle', false, true)), 'DATETIMEADDED' => display_time_period(time()), 'RECURINTERVAL' => $recurinterval == 0 ? '' : integer_format($recurinterval), 'RECUREVERY' => get_param('recurevery'), 'TASKDONE' => 'not_completed', 'ID' => strval($id)));
         case 'delete':
             $GLOBALS['SITE_DB']->query_delete('customtasks', array('id' => get_param_integer('id')), '', 1);
             break;
         case 'mark_done':
             $GLOBALS['SITE_DB']->query_update('customtasks', array('taskisdone' => time()), array('id' => get_param_integer('id')), '', 1);
             break;
         case 'mark_undone':
             $GLOBALS['SITE_DB']->query_update('customtasks', array('taskisdone' => NULL), array('id' => get_param_integer('id')), '', 1);
             break;
     }
     return new ocp_tempcode();
 }
Ejemplo n.º 2
0
 public function test_reset()
 {
     $cycle = new Cycle('one', 'two');
     $cycle->next_value();
     $cycle->reset();
     $this->assertEquals('one', strval($cycle));
 }
Ejemplo n.º 3
0
 function save($formdata_element = array(), $field_header = '', $formcontent_item_array = array())
 {
     if (!empty($formdata_element[$field_header . '_input_value'])) {
         $formcontent_item_array['value'] = $formdata_element[$field_header . '_input_value'];
     }
     $temp_options = explode("\n", $formdata_element[$field_header . '_options']);
     foreach ($temp_options as $temp_option) {
         $temp_option_details = explode('=', $temp_option);
         $formcontent_item_array['options'][strval($temp_option_details[0])] = trim($temp_option_details[1]);
     }
     $formcontent_item_array['legend'] = $formdata_element[$field_header . '_legend'];
     $formcontent_item_array['id'] = $formdata_element[$field_header . '_input_id'];
     $formcontent_item_array['ghost'] = $formdata_element[$field_header . '_ghost'];
     $formcontent_item_array['ghost_value'] = $formdata_element[$field_header . '_ghost_value'];
     $formcontent_item_array['label_over'] = $formdata_element[$field_header . '_label_over'];
     $formcontent_item_array['hide_label'] = $formdata_element[$field_header . '_hide_label'];
     $formcontent_item_array['multiline_start'] = $formdata_element[$field_header . '_multiline_start'];
     $formcontent_item_array['multiline_add'] = $formdata_element[$field_header . '_multiline_add'];
     $formcontent_item_array['enable_dynamic_data'] = $formdata_element[$field_header . '_enable_dynamic_data'];
     $formcontent_item_array['data_path'] = $formdata_element[$field_header . '_data_path'];
     $formcontent_item_array['value_key'] = $formdata_element[$field_header . '_value_key'];
     $formcontent_item_array['text_key'] = $formdata_element[$field_header . '_text_key'];
     $formcontent_item_array['radios_over'] = $formdata_element[$field_header . '_radios_over'];
     $formcontent_item_array['title'] = $formdata_element[$field_header . '_input_title'];
     $formcontent_item_array['validations'] = $formdata_element[$field_header . '_validations'];
     $formcontent_item_array['smalldesc'] = $formdata_element[$field_header . '_instructions'];
     $formcontent_item_array['tooltip'] = $formdata_element[$field_header . '_tooltip'];
     $formcontent_item_array['type'] = $formdata_element['type'];
     return $formcontent_item_array;
 }
Ejemplo n.º 4
0
 public function buat_SEP()
 {
     $timezone = date_default_timezone_get();
     date_default_timezone_set('UTC');
     $timestamp = strval(time() - strtotime('1970-01-01 00:00:00'));
     //cari timestamp
     $signature = hash_hmac('sha256', '27952' . '&' . $timestamp, 'rsm32h1', true);
     $encoded_signature = base64_encode($signature);
     $http_header = array('Accept: application/json', 'Content-type: application/xml', 'X-cons-id: 27952', 'X-timestamp: ' . $timestamp, 'X-signature: ' . $encoded_signature);
     date_default_timezone_set($timezone);
     //nama variabel sesuai dengan nama di xml
     $noMR = $this->input->post('no_cm');
     $noKartu = $this->input->post('no_bpjs');
     $noRujukan = $this->input->post('no_sjp');
     $ppkRujukan = $this->input->post('ppk_rujukan');
     $jnsPelayanan = $this->input->post('pelayanan');
     $klsRawat = $this->input->post('kelas_pasien');
     $diagAwal = $this->input->post('nm_diagnosa');
     $poliTujuan = $this->input->post('nm_poli');
     $catatan = $this->input->post('catatan');
     $user = '******';
     $ppkPelayanan = '0601R001';
     $tglSep = date('Y-m-d H:i:s');
     $tglRujukan = date('Y-m-d H:i:s');
     $data = '<request><data><t_sep>' . '<noKartu>' . $noKartu . '</noKartu>' . '<tglSep>' . $tglSep . '</tglSep>' . '<tglRujukan>' . $tglRujukan . '</tglRujukan>' . '<noRujukan>' . $noRujukan . '</noRujukan>' . '<ppkRujukan>' . $ppkRujukan . '</ppkRujukan>' . '<ppkPelayanan>' . $ppkPelayanan . '</ppkPelayanan>' . '<jnsPelayanan>' . $jnsPelayanan . '</jnsPelayanan>' . '<catatan>' . $catatan . '</catatan>' . '<diagAwal>' . $diagAwal . '</diagAwal>' . '<poliTujuan>' . $poliTujuan . '</poliTujuan>' . '<klsRawat>' . $klsRawat . '</klsRawat>' . '<user>' . $user . '</user>' . '<noMR>' . $noMR . '</noMR>' . '</t_sep></data></request>';
     $ch = curl_init('http://api.asterix.co.id/SepWebRest/sep/create/');
     curl_setopt($ch, CURLOPT_POST, true);
     curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
     curl_setopt($ch, CURLOPT_HTTPHEADER, $http_header);
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
     $result = curl_exec($ch);
     curl_close($ch);
     $sep = json_decode($result)->response;
     echo $sep;
 }
Ejemplo n.º 5
0
 public function store($id, $name, $strict = FALSE)
 {
     $namelen = strlen($name);
     if ($namelen < 1 || $namelen > 255) {
         throw new Exception('invalid-name', $name);
     }
     if (!ctype_digit(strval($id))) {
         throw new Exception('invalid-id', $id);
     }
     $namecheck = $this->byID($id);
     if ($namecheck == $name) {
         return TRUE;
     }
     if ($namecheck !== null) {
         $this->delete($id, $namecheck);
     }
     $idcheck = $this->byName($name);
     if ($id != $idcheck && $idcheck !== null) {
         if ($strict) {
             throw new Exception('name-taken');
         }
         $this->delete($idcheck, $name);
     }
     $table = $this->table();
     $db = $this->db();
     $sql = "INSERT INTO `{$table}` (`id`, `name`) VALUES (%i, %s)";
     if (!$strict) {
         $sql .= " ON DUPLICATE KEY UPDATE `id` = VALUES(`id`), `name` = VALUES(`name`)";
     }
     $rs = $db->execute($sql, $id, $name);
     return TRUE;
 }
 public function testToString()
 {
     $this->sut->addEnvironment('RACK_ENV=development');
     $this->sut->addEnvironment('SESSION_SECRET');
     $expected = "environment: \n" . "    - RACK_ENV=development\n" . '    - SESSION_SECRET';
     $this->assertEquals($expected, strval($this->sut));
 }
 /**
  * Returns TRUE, if the given property ($value) is a valid array consistent of two equal passwords and their length
  * is between 'minimum' (defaults to 0 if not specified) and 'maximum' (defaults to infinite if not specified)
  * to be specified in the validation options.
  *
  * If at least one error occurred, the result is FALSE.
  *
  * @param mixed $value The value that should be validated
  * @return void
  * @throws \TYPO3\Flow\Validation\Exception\InvalidSubjectException
  */
 protected function isValid($value)
 {
     if (!is_array($value)) {
         throw new \TYPO3\Flow\Validation\Exception\InvalidSubjectException('The given value was not an array.', 1324641197);
     }
     $password = trim(strval(array_shift($value)));
     $repeatPassword = trim(strval(array_shift($value)));
     $passwordNotEmptyValidator = new \TYPO3\Flow\Validation\Validator\NotEmptyValidator();
     $passwordNotEmptyValidatorResult = $passwordNotEmptyValidator->validate($password);
     $repeatPasswordNotEmptyValidator = new \TYPO3\Flow\Validation\Validator\NotEmptyValidator();
     $repeatPasswordNotEmptyValidatorResult = $repeatPasswordNotEmptyValidator->validate($repeatPassword);
     if ($passwordNotEmptyValidatorResult->hasErrors() === TRUE && $repeatPasswordNotEmptyValidatorResult->hasErrors() === TRUE) {
         if (!isset($this->options['allowEmpty']) || isset($this->options['allowEmpty']) && intval($this->options['allowEmpty']) === 0) {
             $this->addError('The given password was empty.', 1324641097);
         }
         return;
     }
     if (strcmp($password, $repeatPassword) !== 0) {
         $this->addError('The passwords did not match.', 1324640997);
         return;
     }
     $stringLengthValidator = new \TYPO3\Flow\Validation\Validator\StringLengthValidator(array('minimum' => $this->options['minimum'], 'maximum' => $this->options['maximum']));
     $stringLengthValidatorResult = $stringLengthValidator->validate($password);
     if ($stringLengthValidatorResult->hasErrors() === TRUE) {
         foreach ($stringLengthValidatorResult->getErrors() as $error) {
             $this->result->addError($error);
         }
     }
 }
 /**
  * 解析从ListMultipartUpload接口的返回数据
  *
  * @return ListMultipartUploadInfo
  */
 protected function parseDataFromResponse()
 {
     $content = $this->rawResponse->body;
     $xml = simplexml_load_string($content);
     $encodingType = isset($xml->EncodingType) ? strval($xml->EncodingType) : "";
     $bucket = isset($xml->Bucket) ? strval($xml->Bucket) : "";
     $keyMarker = isset($xml->KeyMarker) ? strval($xml->KeyMarker) : "";
     $keyMarker = OssUtil::decodeKey($keyMarker, $encodingType);
     $uploadIdMarker = isset($xml->UploadIdMarker) ? strval($xml->UploadIdMarker) : "";
     $nextKeyMarker = isset($xml->NextKeyMarker) ? strval($xml->NextKeyMarker) : "";
     $nextKeyMarker = OssUtil::decodeKey($nextKeyMarker, $encodingType);
     $nextUploadIdMarker = isset($xml->NextUploadIdMarker) ? strval($xml->NextUploadIdMarker) : "";
     $delimiter = isset($xml->Delimiter) ? strval($xml->Delimiter) : "";
     $delimiter = OssUtil::decodeKey($delimiter, $encodingType);
     $prefix = isset($xml->Prefix) ? strval($xml->Prefix) : "";
     $prefix = OssUtil::decodeKey($prefix, $encodingType);
     $maxUploads = isset($xml->MaxUploads) ? intval($xml->MaxUploads) : 0;
     $isTruncated = isset($xml->IsTruncated) ? strval($xml->IsTruncated) : "";
     $listUpload = array();
     if (isset($xml->Upload)) {
         foreach ($xml->Upload as $upload) {
             $key = isset($upload->Key) ? strval($upload->Key) : "";
             $key = OssUtil::decodeKey($key, $encodingType);
             $uploadId = isset($upload->UploadId) ? strval($upload->UploadId) : "";
             $initiated = isset($upload->Initiated) ? strval($upload->Initiated) : "";
             $listUpload[] = new UploadInfo($key, $uploadId, $initiated);
         }
     }
     return new ListMultipartUploadInfo($bucket, $keyMarker, $uploadIdMarker, $nextKeyMarker, $nextUploadIdMarker, $delimiter, $prefix, $maxUploads, $isTruncated, $listUpload);
 }
Ejemplo n.º 9
0
 public function to_money($number, $do_encode = false)
 {
     if (!is_numeric($number)) {
         $number = $this->to_number($number);
     }
     if ($number === false) {
         return '';
     }
     $negative = '';
     if (strpos(strval($number), '-') !== false) {
         $negative = '-';
         $number = floatval(substr($number, 1));
     }
     $money = number_format($number, $this->currency['decimals'], $this->currency['decimal_separator'], $this->currency['thousand_separator']);
     if ($money == '0.00') {
         $negative = '';
     }
     $symbol_left = !empty($this->currency['symbol_left']) ? $this->currency['symbol_left'] . $this->currency['symbol_padding'] : '';
     $symbol_right = !empty($this->currency['symbol_right']) ? $this->currency['symbol_padding'] . $this->currency['symbol_right'] : '';
     if ($do_encode) {
         $symbol_left = html_entity_decode($symbol_left);
         $symbol_right = html_entity_decode($symbol_right);
     }
     return $negative . $symbol_left . $money . $symbol_right;
 }
Ejemplo n.º 10
0
 /**
  * Checks if given value is valid International Bank Account Number (IBAN).
  *
  * @param  mixed  $value
  * @return boolean
  */
 public static function isIban($value)
 {
     // build replacement arrays
     $iban_replace_chars = range('A', 'Z');
     foreach (range(10, 35) as $tempvalue) {
         $iban_replace_values[] = strval($tempvalue);
     }
     // prepare string
     $tempiban = strtoupper($value);
     $tempiban = str_replace(' ', '', $tempiban);
     // check iban length
     if (self::getIbanLength($tempiban) != strlen($tempiban)) {
         return false;
     }
     // build checksum
     $tempiban = substr($tempiban, 4) . substr($tempiban, 0, 4);
     $tempiban = str_replace($iban_replace_chars, $iban_replace_values, $tempiban);
     $tempcheckvalue = intval(substr($tempiban, 0, 1));
     for ($strcounter = 1; $strcounter < strlen($tempiban); $strcounter++) {
         $tempcheckvalue *= 10;
         $tempcheckvalue += intval(substr($tempiban, $strcounter, 1));
         $tempcheckvalue %= 97;
     }
     // only modulo 1 is iban
     return $tempcheckvalue == 1;
 }
function rgbToHex($red, $green, $blue, $format = false)
{
    $red = intval($red);
    $green = intval($green);
    $blue = intval($blue);
    if ($red >= 0 && $red <= 255 && $green >= 0 && $green <= 255 && $blue >= 0 && $blue <= 255) {
        $redhex = strval(dechex($red));
        $greenhex = strval(dechex($green));
        $bluehex = strval(dechex($blue));
        if (strlen($redhex) < 2) {
            $redhex = strval("0" . $redhex);
        }
        if (strlen($greenhex) < 2) {
            $greenhex = strval("0" . $greenhex);
        }
        if (strlen($bluehex) < 2) {
            $bluehex = strval("0" . $bluehex);
        }
        if ($format) {
            return "#" . $redhex . $greenhex . $bluehex;
        } else {
            return $redhex . $greenhex . $bluehex;
        }
    } else {
        return false;
    }
}
Ejemplo n.º 12
0
 /**
  * Forms the HTML response from our prediction results.
  */
 private function formHTML($prediction, $encodedTeam)
 {
     //get the name of the other team
     $this->data["their_team"] = $this->League->getTeamName($encodedTeam);
     $this->data["their_code"] = strtolower($encodedTeam);
     $this->data["score"] = strval($prediction[0][0] . " : " . $prediction[1][0]);
     $this->data["our_game_average"] = $prediction[0][1];
     $this->data["their_game_average"] = $prediction[1][1];
     $this->data["our_10_game_average"] = $prediction[0][2];
     $this->data["their_10_game_average"] = $prediction[1][2];
     $this->data["our_game_average_against"] = $prediction[0][3];
     $this->data["their_game_average_against"] = $prediction[1][3];
     //get the html we're going to return
     if ($prediction[0][0] > $prediction[1][0]) {
         $this->data["win_lose"] = "Win";
         $this->data["message"] = "Go Cowboys!";
     } elseif ($prediction[0][0] < $prediction[1][0]) {
         $this->data["win_lose"] = "Lose";
         $this->data["message"] = "Oh no!";
     } else {
         $this->data["win_lose"] = "Tie";
         $this->data["message"] = "Almost had 'em Cowboys!";
     }
     return $this->parser->parse('_prediction', $this->data, true);
 }
Ejemplo n.º 13
0
 public function testPages()
 {
     $params = array('title' => 'My test page', 'content_type' => 'page', 'is_active' => 1);
     //saving
     $parent_page = save_content($params);
     $page_link = content_link($parent_page);
     $params = array('title' => 'My test sub page', 'content_type' => 'page', 'parent' => $parent_page, 'is_active' => 1);
     $sub_page = save_content($params);
     //getting
     $params = array('parent' => $parent_page, 'content_type' => 'page', 'single' => true, 'is_active' => 1);
     $get_sub_page = get_content($params);
     $sub_page_parents = content_parents($get_sub_page['id']);
     //clean
     $delete_parent = delete_content($parent_page);
     $delete_sub_page = delete_content($sub_page);
     //PHPUnit
     $this->assertEquals(true, in_array($parent_page, $sub_page_parents));
     $this->assertEquals(true, strval($page_link) != '');
     $this->assertEquals(true, intval($parent_page) > 0);
     $this->assertEquals(true, intval($sub_page) > 0);
     $this->assertEquals(true, is_array($get_sub_page));
     $this->assertEquals(true, is_array($delete_parent));
     $this->assertEquals(true, is_array($delete_sub_page));
     $this->assertEquals('My test sub page', $get_sub_page['title']);
     $this->assertEquals($sub_page, $get_sub_page['id']);
 }
 public function run()
 {
     $whereGeo = array();
     //$this->getGeoQuery($_POST);
     $where = array('geo' => array('$exists' => true));
     $where = array_merge($where, $whereGeo);
     $events = PHDB::find(PHType::TYPE_EVENTS, $where);
     foreach ($events as $event) {
         //dans le cas où un événement n'a pas de position geo,
         //on lui ajoute grace au CP
         //il sera visible sur la carte au prochain rechargement
         if (!isset($event["geo"])) {
             $cp = $event["location"]["address"]["addressLocality"];
             $queryCity = array("cp" => strval(intval($cp)), "geo" => array('$exists' => true));
             $city = Yii::app()->mongodb->cities->findOne($queryCity);
             //->limit(1)
             if ($city != null) {
                 $newPos = array('geo' => array("@type" => "GeoCoordinates", "longitude" => floatval($city['geo']['coordinates'][0]), "latitude" => floatval($city['geo']['coordinates'][1])), 'geoPosition' => $city['geo']);
                 Yii::app()->mongodb->events->update(array("_id" => $event["_id"]), array('$set' => $newPos));
             }
         }
     }
     $events["origine"] = "ShowLocalEvents";
     Rest::json($events);
     Yii::app()->end();
 }
Ejemplo n.º 15
0
function styleJsonEncode($var)
{
    switch (gettype($var)) {
        case 'boolean':
            return $var ? 'true' : 'false';
        case 'NULL':
            return 'null';
        case 'integer':
            return (int) $var;
        case 'double':
        case 'float':
            return (double) $var;
        case 'string':
            return '"' . addslashes(str_replace(array("\r\n", "\n", "\r", "\t"), array('<br />', '<br />', '<br />', ''), $var)) . '"';
        case 'array':
            if (count($var) && array_keys($var) !== range(0, sizeof($var) - 1)) {
                $properties = array();
                foreach ($var as $name => $value) {
                    $properties[] = styleJsonEncode(strval($name)) . ':' . styleJsonEncode($value);
                }
                return '{' . join(',', $properties) . '}';
            }
            $elements = array_map('pwJsonEncode', $var);
            return '[' . join(',', $elements) . ']';
    }
    return false;
}
Ejemplo n.º 16
0
 function ajax_query()
 {
     // options
     $options = acf_parse_args($_POST, array('post_id' => 0, 's' => '', 'field_key' => '', 'nonce' => ''));
     // load field
     $field = acf_get_field($options['field_key']);
     if (!$field) {
         die;
     }
     // vars
     $r = array();
     $s = false;
     // search
     if ($options['s'] !== '') {
         // search may be integer
         $s = strval($options['s']);
         // strip slashes
         $s = wp_unslash($s);
     }
     // loop through choices
     if (!empty($field['choices'])) {
         foreach ($field['choices'] as $k => $v) {
             // if searching, but doesn't exist
             if ($s !== false && stripos($v, $s) === false) {
                 continue;
             }
             // append
             $r[] = array('id' => $k, 'text' => strval($v));
         }
     }
     // return JSON
     echo json_encode($r);
     die;
 }
Ejemplo n.º 17
0
 public function input($native, $for = '')
 {
     if ($native === null) {
         return null;
     }
     return strval($native);
 }
Ejemplo n.º 18
0
 /**
  * Input construct.
  *
  * @param array $name
  * @param mixed $value
  * @param array|null $inputConfig
  * @throws InvalidArgumentException
  */
 public function __construct($name, $value, $inputConfig)
 {
     if (!is_array($value)) {
         if (is_object($value) && in_array("__toString", get_class_methods($value))) {
             $value = strval($value->__toString());
         } else {
             $value = strval($value);
         }
         $value = trim($value);
         if ($value !== '') {
             $value = str_replace('&quot;', '"', $value);
             $value = json_decode($value, true);
             // strict mode
             //                if (json_last_error() != JSON_ERROR_NONE || !is_array($value)) {
             //                    throw new InvalidArgumentException('Invalid string to convert to array');
             //                }
         }
     }
     if (is_array($value)) {
         $value = array_merge($this->defaultOptions, $value);
     } else {
         $value = $this->defaultOptions;
     }
     parent::__construct($name, $value, $inputConfig);
 }
 /**
  * Override the default process of key generating
  *
  * @param string $key the key passed over
  * @return bool|string string key or false
  */
 public function key($key)
 {
     if (empty($key)) {
         return false;
     }
     return strval($key);
 }
Ejemplo n.º 20
0
 /**
  * 我的兑换 do_personal_index
  */
 public function do_personal_index()
 {
     /* 初始化变量 */
     $user_id = I('get.user_id');
     $page_num = I('get.page_num');
     $page_num = empty($page_num) || $page_num < 0 ? 1 : $page_num;
     /* 查询条件 */
     $field = 'pay_order.trade_no,pay_order.shop_coupon_info,pay_order.shop_id,pay_order.trade_state,shop.title as shop_title';
     $where['pay_order.user_id'] = array('EQ', $user_id);
     $where['pay_order.display'] = array('EQ', 1);
     $order = 'pay_order.id desc';
     /* 查询数据 */
     $list = $this->alias('pay_order')->field($field)->where($where)->join('LEFT JOIN __SHOP__ shop on pay_order.shop_id = shop.id')->order($order)->limit(C('PAGE_NUM'))->page($page_num)->select();
     foreach ($list as $k => $v) {
         $shop_coupon_info = json_decode($v['shop_coupon_info'], true);
         $list[$k]['coupon_id'] = $shop_coupon_info['id'];
         $list[$k]['coupon_title'] = $shop_coupon_info['title'];
         if ($shop_coupon_info['coupon_type'] == 1) {
             $list[$k]['coupon_tag'] = strval(0);
         } else {
             $list[$k]['coupon_tag'] = $shop_coupon_info['coupon_worth'];
         }
         $list[$k]['coupon_content'] = $shop_coupon_info['content'];
         unset($list[$k]['shop_coupon_info']);
         /* 过滤数据 */
         if (!empty($v['coupon_title'])) {
             $list[$k]['coupon_title'] = htmlspecialchars_decode($v['coupon_title']);
         }
     }
     /* 读取json */
     $list = empty($list) ? array() : $list;
     $jsonInfo['list'] = arr_content_replace($list);
     return $jsonInfo;
 }
Ejemplo n.º 21
0
 /**
  * @param string $testKey
  * @param array $weights an associative array of variation ID => weights
  * @param AB2_Selector_Randomizer $randomizer
  * @throws Exception_ArgumentException
  */
 public function __construct($weights, $randomizer)
 {
     if (!is_array($weights)) {
         throw new InvalidArgumentException("weights must be a numerical array");
     }
     if (is_null($randomizer)) {
         throw new InvalidArgumentException('A non-null randomizer is required.');
     }
     // check the weights and build the partition array
     $sum = 0;
     $parts = array();
     foreach ($weights as $var => $w) {
         if (!(is_numeric($w) && $w >= 0)) {
             throw new InvalidArgumentException("invalid weight: {$w}");
         }
         // ignore the 0-weighted variations
         if ($w > 0) {
             $sum += floatval($w);
             $parts[strval($sum)] = $var;
         }
     }
     $this->_weights = $weights;
     $this->_sumWeights = $sum;
     $this->_partitions = $parts;
     $this->_randomizer = $randomizer;
 }
Ejemplo n.º 22
0
function _mkService($uris = null, $type_uris = null, $delegate = null, $dent = '        ')
{
    $chunks = array($dent, "<Service>\n");
    $dent2 = $dent . '    ';
    if ($type_uris) {
        foreach ($type_uris as $type_uri) {
            $chunks = array_merge($chunks, array($dent2 . '<Type>', $type_uri, "</Type>\n"));
        }
    }
    if ($uris) {
        foreach ($uris as $uri) {
            if (is_array($uri)) {
                list($uri, $prio) = $uri;
            } else {
                $prio = null;
            }
            $chunks = array_merge($chunks, array($dent2, '<URI'));
            if ($prio !== null) {
                $chunks = array_merge($chunks, array(' priority="', strval($prio), '"'));
            }
            $chunks = array_merge($chunks, array('>', $uri, "</URI>\n"));
        }
    }
    if ($delegate) {
        $chunks = array_merge($chunks, array($dent2, '<openid:Delegate>', $delegate, "</openid:Delegate>\n"));
    }
    $chunks = array_merge($chunks, array($dent, "</Service>\n"));
    return implode("", $chunks);
}
Ejemplo n.º 23
0
 /**
  */
 protected function _init()
 {
     global $injector, $notification, $page_output;
     $this->_assertCategory('Ingo_Rule_System_Whitelist', _("Whitelist"));
     $ingo_storage = $injector->getInstance('Ingo_Factory_Storage')->create();
     $whitelist = $ingo_storage->getSystemRule('Ingo_Rule_System_Whitelist');
     /* Token checking & perform requested actions. */
     switch ($this->_checkToken(array('rule_update'))) {
         case 'rule_update':
             try {
                 $whitelist->addresses = $this->vars->whitelist;
                 $ingo_storage->updateRule($whitelist);
                 $notification->push(_("Changes saved."), 'horde.success');
                 $injector->getInstance('Ingo_Factory_Script')->activateAll();
             } catch (Ingo_Exception $e) {
                 $notification->push($e);
             }
             break;
     }
     /* Prepare the view. */
     $view = new Horde_View(array('templatePath' => INGO_TEMPLATES . '/basic/whitelist'));
     $view->addHelper('Horde_Core_View_Helper_Help');
     $view->addHelper('Horde_Core_View_Helper_Label');
     $view->addHelper('Text');
     $view->disabled = $whitelist->disable;
     $view->formurl = $this->_addToken(self::url());
     $view->whitelist = implode("\n", $whitelist->addresses);
     $page_output->addScriptFile('whitelist.js');
     $page_output->addInlineJsVars(array('IngoWhitelist.filtersurl' => strval(Ingo_Basic_Filters::url()->setRaw(true))));
     $this->title = _("Whitelist Edit");
     $this->output = $view->render('whitelist');
 }
Ejemplo n.º 24
0
 /**
  * Builds the regex and censor cache value for a find/replace pair
  *
  * @param string $find
  * @param string $replace
  *
  * @return array|bool
  */
 public static function buildCensorCacheValue($find, $replace)
 {
     $find = trim(strval($find));
     if ($find === '') {
         return false;
     }
     $prefixWildCard = preg_match('#^\\*#', $find);
     $suffixWildCard = preg_match('#\\*$#', $find);
     $replace = is_int($replace) ? '' : trim(strval($replace));
     if ($replace === '') {
         $replace = utf8_strlen($find);
         if ($prefixWildCard) {
             $replace--;
         }
         if ($suffixWildCard) {
             $replace--;
         }
     }
     $regexFind = $find;
     if ($prefixWildCard) {
         $regexFind = substr($regexFind, 1);
     }
     if ($suffixWildCard) {
         $regexFind = substr($regexFind, 0, -1);
     }
     if (!strlen($regexFind)) {
         return false;
     }
     $regex = '#' . ($prefixWildCard ? '' : '(?<=\\W|^)') . preg_quote($regexFind, '#') . ($suffixWildCard ? '' : '(?=\\W|$)') . '#iu';
     return array('word' => $find, 'regex' => $regex, 'replace' => $replace);
 }
Ejemplo n.º 25
0
 /** {@inheritDoc} */
 public function getPath()
 {
     if (!($requestPath = $this->getServerVar("REQUEST_URI")) && !($requestPath = $this->getServerVar("ORIG_PATH_INFO"))) {
         $requestPath = $this->getIisRequestUri();
     }
     return "/" . trim(rawurldecode(strval(parse_url($requestPath, PHP_URL_PATH))), "/");
 }
Ejemplo n.º 26
0
 function ajax_query()
 {
     // options
     $options = acf_parse_args($_GET, array('post_id' => 0, 's' => '', 'field_key' => '', 'nonce' => ''));
     // load field
     $field = acf_get_field($options['field_key']);
     if (!$field) {
         die;
     }
     // vars
     $r = array();
     // strip slashes
     $options['s'] = wp_unslash($options['s']);
     if (!empty($field['choices'])) {
         foreach ($field['choices'] as $k => $v) {
             // search
             if ($options['s'] && stripos($v, $options['s']) === false) {
                 continue;
             }
             // append
             $r[] = array('id' => $k, 'text' => strval($v));
         }
     }
     // return JSON
     echo json_encode($r);
     die;
 }
Ejemplo n.º 27
0
 /**
  * Retrieve Default desplay Currency value for current scope
  *
  * @return string
  */
 protected function _getCurrencyDefault()
 {
     if (!($value = $this->getData('groups/options/fields/default/value'))) {
         $value = Mage::getConfig()->getNode(Mage_Directory_Model_Currency::XML_PATH_CURRENCY_DEFAULT, $this->getScope(), $this->getScopeId());
     }
     return strval($value);
 }
Ejemplo n.º 28
0
 public function getTableArray()
 {
     $data = $this->getAttribute('table');
     $data['_id'] = strval($data['_id']);
     $data['variant']['_id'] = strval($data['variant']['_id']);
     return $data;
 }
Ejemplo n.º 29
0
 /**
  * @param null $currentRev
  * @return array
  * @throws \Exception
  */
 public static function getAvailableUpdates($currentRev = null)
 {
     if (!$currentRev) {
         $currentRev = Version::$revision;
     }
     self::cleanup();
     if (PIMCORE_DEVMODE) {
         $xmlRaw = Tool::getHttpData("http://" . self::$updateHost . "/v2/getUpdateInfo.php?devmode=1&revision=" . $currentRev);
     } else {
         $xmlRaw = Tool::getHttpData("http://" . self::$updateHost . "/v2/getUpdateInfo.php?revision=" . $currentRev);
     }
     $xml = simplexml_load_string($xmlRaw, null, LIBXML_NOCDATA);
     $revisions = array();
     $releases = array();
     if ($xml instanceof \SimpleXMLElement) {
         if (isset($xml->revision)) {
             foreach ($xml->revision as $r) {
                 $date = new \Zend_Date($r->date);
                 if (strlen(strval($r->version)) > 0) {
                     $releases[] = array("id" => strval($r->id), "date" => strval($r->date), "version" => strval($r->version), "text" => strval($r->id) . " - " . $date->get(\Zend_Date::DATETIME_MEDIUM));
                 } else {
                     $revisions[] = array("id" => strval($r->id), "date" => strval($r->date), "text" => strval($r->id) . " - " . $date->get(\Zend_Date::DATETIME_MEDIUM));
                 }
             }
         }
     } else {
         throw new \Exception("Unable to retrieve response from update server. Please ensure that your server is allowed to connect to update.pimcore.org:80");
     }
     return array("revisions" => $revisions, "releases" => $releases);
 }
 private function convertLessThan1000($number)
 {
     $output = '';
     if ($number < 20) {
         $output = self::$oneToNineteen[$number];
     } else {
         $numberString = str_pad(strval($number), 3, '0', STR_PAD_LEFT);
         if ($numberString[0] !== '0') {
             $output = self::$oneToNineteen[intval($numberString[0])] . ' hundred';
         }
         if ($numberString[0] !== '0' && ($numberString[1] !== '0' || $numberString[2] !== '0')) {
             $output .= ' and ';
         }
         if ($numberString[1] !== '0') {
             $output .= self::$tens[intval($numberString[1])];
         }
         if ($numberString[2] !== '0') {
             if ($numberString[1] !== '0') {
                 $output .= ' ';
             }
             $output .= self::$oneToNineteen[intval($numberString[2])];
         }
     }
     return $output;
 }