当前位置: 首页>>代码示例>>PHP>>正文


PHP PerchUtil::json_safe_decode方法代码示例

本文整理汇总了PHP中PerchUtil::json_safe_decode方法的典型用法代码示例。如果您正苦于以下问题:PHP PerchUtil::json_safe_decode方法的具体用法?PHP PerchUtil::json_safe_decode怎么用?PHP PerchUtil::json_safe_decode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PerchUtil的用法示例。


在下文中一共展示了PerchUtil::json_safe_decode方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: to_array

 public function to_array($template_ids = false, $PerchGallery_ImageVersions = false)
 {
     $out = parent::to_array();
     if ($out['imageDynamicFields'] != '') {
         $dynamic_fields = PerchUtil::json_safe_decode($out['imageDynamicFields'], true);
         if (PerchUtil::count($dynamic_fields)) {
             foreach ($dynamic_fields as $key => $value) {
                 $out['perch_' . $key] = $value;
             }
         }
         $out = array_merge($dynamic_fields, $out);
     }
     $versions = $this->get_versions_for_image($PerchGallery_ImageVersions);
     if (PerchUtil::count($versions)) {
         $bucket_name = $this->details['imageBucket'];
         $Perch = Perch::fetch();
         $bucket = $Perch->get_resource_bucket($bucket_name);
         foreach ($versions as $Version) {
             $out[$Version->versionKey()] = $Version->path($bucket);
             $out[$Version->versionKey() . '-w'] = $Version->versionWidth();
             $out[$Version->versionKey() . '-h'] = $Version->versionHeight();
             $out[$Version->versionKey() . '-id'] = $Version->versionID();
             $out[$Version->versionKey() . '-key'] = $Version->versionKey();
         }
     }
     $out['_id'] = $this->id();
     return $out;
 }
开发者ID:connor-baer,项目名称:waterford-website,代码行数:28,代码来源:PerchGallery_Image.class.php

示例2: _generate_session

 /**
  * Create a new session, add it to the session store, set the cookie, expire any old sessions
  * @param  integer $memberID [description]
  * @return [type]            [description]
  */
 protected function _generate_session($user_row = false)
 {
     $session_id = sha1(uniqid(mt_rand(), true));
     $http_footprint = $this->_get_http_footprint();
     if (PerchUtil::count($user_row)) {
         $memberID = $user_row['memberID'];
         if (isset($user_row['memberProperties']) && $user_row['memberProperties'] != '') {
             $properties = PerchUtil::json_safe_decode($user_row['memberProperties'], true);
             $user_row = array_merge($properties, $user_row);
             unset($user_row['memberProperties']);
         }
         $session_data = $user_row;
         $session_data['tags'] = $this->_load_tags($memberID);
         $session_data['token'] = $this->_generate_csrf_token($session_id);
     } else {
         $memberID = 0;
         $session_data = array();
     }
     $data = array('sessionID' => $session_id, 'sessionExpires' => date('Y-m-d H:i:s', strtotime(' + ' . PERCH_MEMBERS_SESSION_TIME)), 'sessionHttpFootprint' => $http_footprint, 'memberID' => $memberID, 'sessionData' => serialize($session_data));
     if ($this->db->insert(PERCH_DB_PREFIX . 'members_sessions', $data)) {
         PerchUtil::setcookie(PERCH_MEMBERS_COOKIE, $session_id, '', '/', '', '', true);
         $_COOKIE[PERCH_MEMBERS_COOKIE] = $session_id;
         $this->_expire_old_sessions();
     }
 }
开发者ID:jaredmedley,项目名称:Perch-Core-Files,代码行数:30,代码来源:PerchMembers_Auth.class.php

示例3: to_array

 public function to_array($template_ids = false, $PerchGallery_ImageVersions = false)
 {
     $out = parent::to_array();
     if ($out['imageDynamicFields'] != '') {
         $dynamic_fields = PerchUtil::json_safe_decode($out['imageDynamicFields'], true);
         if (PerchUtil::count($dynamic_fields)) {
             foreach ($dynamic_fields as $key => $value) {
                 $out['perch_' . $key] = $value;
             }
         }
         $out = array_merge($dynamic_fields, $out);
     }
     $versions = $this->get_versions_for_image($PerchGallery_ImageVersions);
     if (PerchUtil::count($versions)) {
         foreach ($versions as $Version) {
             $out[$Version->versionKey()] = PERCH_RESPATH . '/' . $Version->versionPath();
             $out[$Version->versionKey() . '-w'] = $Version->versionWidth();
             $out[$Version->versionKey() . '-h'] = $Version->versionHeight();
             $out[$Version->versionKey() . '-id'] = $Version->versionID();
             $out[$Version->versionKey() . '-key'] = $Version->versionKey();
         }
     }
     $out['_id'] = $this->id();
     return $out;
 }
开发者ID:pete-naish,项目名称:4hair,代码行数:25,代码来源:PerchGallery_Image.class.php

示例4: userProperty

 /**
  * Return property from the userAccountData json store
  * with an optional default for missing values
  *
  * @param $key
  * @param null $default
  * @return null
  */
 public function userProperty($key, $default = null)
 {
     $accountData = PerchUtil::json_safe_decode($this->userAccountData(), true);
     if (isset($accountData[$key]) && $accountData[$key]) {
         return $accountData[$key];
     }
     return $default;
 }
开发者ID:drewm,项目名称:Perch-Activity-Log,代码行数:16,代码来源:JwActivityLog_Action.class.php

示例5: get_stored_users_unique

 /**
  * Fetch the unique stored users from the database and
  * decode the stored user data.
  *
  * @return array
  */
 public function get_stored_users_unique()
 {
     $return = array();
     $sql = "SELECT `userAccountData` FROM " . $this->table . " GROUP BY `userAccountID` ORDER BY `actionDateTime` DESC";
     $results = $this->db->get_rows($sql);
     if (PerchUtil::count($results)) {
         foreach ($results as $row) {
             $return[] = PerchUtil::json_safe_decode($row['userAccountData'], true);
         }
     }
     return $return;
 }
开发者ID:drewm,项目名称:Perch-Activity-Log,代码行数:18,代码来源:JwActivityLog_Actions.class.php

示例6: to_array

 public function to_array()
 {
     $out = parent::to_array();
     if ($out['categoryDynamicFields'] != '') {
         $dynamic_fields = PerchUtil::json_safe_decode($out['categoryDynamicFields'], true);
         if (PerchUtil::count($dynamic_fields)) {
             foreach ($dynamic_fields as $key => $value) {
                 $out['perch_' . $key] = $value;
             }
         }
         $out = array_merge($dynamic_fields, $out);
     }
     return $out;
 }
开发者ID:jimcurran,项目名称:bdmusichub,代码行数:14,代码来源:PerchEvents_Category.class.php

示例7: to_array

 public function to_array()
 {
     $out = $this->details;
     $dynamic_field_col = str_replace('ID', 'DynamicFields', $this->pk);
     if (isset($out[$dynamic_field_col]) && $out[$dynamic_field_col] != '') {
         $dynamic_fields = PerchUtil::json_safe_decode($out[$dynamic_field_col], true);
         if (PerchUtil::count($dynamic_fields)) {
             foreach ($dynamic_fields as $key => $value) {
                 $out['perch_' . $key] = $value;
             }
             $out = array_merge($dynamic_fields, $out);
         }
     }
     return $out;
 }
开发者ID:Bloom-web,项目名称:bloom-web,代码行数:15,代码来源:PerchBase.class.php

示例8: get_members

 public function get_members($status, $Paging = false)
 {
     $out = $this->get_by('memberStatus', $status, $Paging);
     $sql = 'SELECT c.*
             FROM ' . $this->table . ' c';
     if ($status != 'ALL') {
         $sql .= ' WHERE c.memberStatus=' . $this->db->pdb($status);
     }
     $members = $this->db->get_rows($sql);
     foreach ($members as $key => $value) {
         $dynamic_fields = PerchUtil::json_safe_decode($value['memberProperties'], true);
         foreach ($dynamic_fields as $dynamic_fields_key => $dynamic_fields_value) {
             $members[$key][$dynamic_fields_key] = $dynamic_fields_value;
         }
     }
     return $members;
 }
开发者ID:amillionmonkeys,项目名称:perchd,代码行数:17,代码来源:Members.class.php

示例9: mark_as_spam

 public function mark_as_spam()
 {
     $data = array();
     $data['responseSpam'] = '1';
     $this->update($data);
     $json = PerchUtil::json_safe_decode($this->responseSpamData(), true);
     if (PerchUtil::count($json)) {
         $API = new PerchAPI(1, 'perch_forms');
         $Forms = new PerchForms_Forms($API);
         $Form = $Forms->find($this->formID());
         if ($Form) {
             $opts = $Form->get_settings();
             if (isset($opts['akismet']) && $opts['akismet']) {
                 if (isset($opts['akismetAPIKey']) && $opts['akismetAPIKey'] != '') {
                     PerchForms_Akismet::submit_spam($opts['akismetAPIKey'], $json['fields'], $json['environment']);
                 }
             }
         }
     }
 }
开发者ID:scottbrabazon,项目名称:scottbrabazon.com,代码行数:20,代码来源:PerchForms_Response.class.php

示例10: load_translations

 private function load_translations()
 {
     $out = false;
     if (file_exists($this->lang_file)) {
         $json = file_get_contents($this->lang_file);
         $out = PerchUtil::json_safe_decode($json, true);
     } else {
         if (is_writable($this->lang_dir)) {
             touch($this->lang_file);
         }
         $out = array();
     }
     if (is_array($out)) {
         $this->translations = $out;
     } else {
         $json = file_get_contents($this->lang_dir . DIRECTORY_SEPARATOR . 'en-gb.txt');
         $this->translations = PerchUtil::json_safe_decode($json, true);
         PerchUtil::debug('Unable to load language file: ' . $this->lang, 'error');
     }
 }
开发者ID:Bloom-web,项目名称:bloom-web,代码行数:20,代码来源:PerchAPI_Lang.class.php

示例11: get_flat_for_region

 /**
  * Get a flat array of the items (or single item) in a region, for the edit form
  *
  * @param string $regionID
  * @param string $rev
  * @param string $item_id
  * @return void
  * @author Drew McLellan
  */
 public function get_flat_for_region($regionID, $rev, $item_id = false, $limit = false)
 {
     $sql = 'SELECT * FROM ' . $this->table . '
             WHERE regionID=' . $this->db->pdb((int) $regionID) . ' AND itemRev=' . $this->db->pdb((int) $rev);
     if ($item_id !== false) {
         $sql .= ' AND itemID=' . $this->db->pdb((int) $item_id);
     }
     $sql .= ' ORDER BY itemOrder ASC';
     if ($limit !== false) {
         $sql .= ' LIMIT ' . intval($limit);
     }
     $rows = $this->db->get_rows($sql);
     if (PerchUtil::count($rows)) {
         foreach ($rows as &$row) {
             $fields = PerchUtil::json_safe_decode($row['itemJSON'], true);
             if (is_array($fields)) {
                 $row = array_merge($fields, $row);
             }
         }
     }
     return $rows;
 }
开发者ID:Bloom-web,项目名称:bloom-web,代码行数:31,代码来源:PerchContent_Items.class.php

示例12: to_array

 public function to_array($template_ids = false)
 {
     $out = parent::to_array();
     if (PerchUtil::count($template_ids) && in_array('postURL', $template_ids)) {
         $API = new PerchAPI(1.0, 'perch_blog');
         $Posts = new PerchBlog_Posts($API);
         $Post = $Posts->find($this->postID());
         if (is_object($Post)) {
             $out['postURL'] = $Post->postURL();
         }
     }
     if ($out['commentDynamicFields'] != '') {
         $dynamic_fields = PerchUtil::json_safe_decode($out['commentDynamicFields'], true);
         if (PerchUtil::count($dynamic_fields)) {
             foreach ($dynamic_fields as $key => $value) {
                 $out['perch_' . $key] = $value;
             }
         }
         $out = array_merge($dynamic_fields, $out);
     }
     return $out;
 }
开发者ID:scottbrabazon,项目名称:scottbrabazon.com,代码行数:22,代码来源:PerchBlog_Comment.class.php

示例13: to_array

 public function to_array()
 {
     $out = parent::to_array();
     if ($out['listingDynamicFields'] != '') {
         $dynamic_fields = PerchUtil::json_safe_decode($out['listingDynamicFields'], true);
         if (PerchUtil::count($dynamic_fields)) {
             foreach ($dynamic_fields as $key => $value) {
                 $out['perch_' . $key] = $value;
             }
         }
         $out = array_merge($dynamic_fields, $out);
     }
     if (isset($out['memberProperties']) && $out['memberProperties'] != '') {
         $dynamic_fields = PerchUtil::json_safe_decode($out['memberProperties'], true);
         if (PerchUtil::count($dynamic_fields)) {
             foreach ($dynamic_fields as $key => $value) {
                 $out['perch_' . $key] = $value;
             }
         }
         $out = array_merge($dynamic_fields, $out);
     }
     return $out;
 }
开发者ID:amillionmonkeys,项目名称:perchd,代码行数:23,代码来源:Listing.class.php

示例14: to_array

 public function to_array($template_ids = false)
 {
     $out = parent::to_array();
     $Categories = new PerchEvents_Categories();
     $cats = $Categories->get_for_event($this->id());
     $out['category_slugs'] = '';
     $out['category_names'] = '';
     if (PerchUtil::count($cats)) {
         $slugs = array();
         $names = array();
         foreach ($cats as $Category) {
             $slugs[] = $Category->categorySlug();
             $names[] = $Category->categoryTitle();
             // for template
             $out[$Category->categorySlug()] = true;
         }
         $out['category_slugs'] = implode(' ', $slugs);
         $out['category_names'] = implode(', ', $names);
     }
     if (PerchUtil::count($template_ids) && in_array('eventURL', $template_ids)) {
         $Settings = PerchSettings::fetch();
         $url_template = $Settings->get('perch_events_detail_url')->val();
         $this->tmp_url_vars = $out;
         $out['eventURL'] = preg_replace_callback('/{([A-Za-z0-9_\\-]+)}/', array($this, "substitute_url_vars"), $url_template);
         $this->tmp_url_vars = false;
     }
     if (isset($out['eventDynamicFields']) && $out['eventDynamicFields'] != '') {
         $dynamic_fields = PerchUtil::json_safe_decode($out['eventDynamicFields'], true);
         if (PerchUtil::count($dynamic_fields)) {
             foreach ($dynamic_fields as $key => $value) {
                 $out['perch_' . $key] = $value;
             }
         }
         $out = array_merge($dynamic_fields, $out);
     }
     return $out;
 }
开发者ID:jimcurran,项目名称:bdmusichub,代码行数:37,代码来源:PerchEvents_Event.class.php

示例15: activate

 private function activate()
 {
     /*
         Any attempt to circumvent activation invalidates your license.
         We're a small company trying to make something useful at a fair price.
         Please don't steal from us.
     */
     $Perch = PerchAdmin::fetch();
     $host = 'activation.grabaperch.com';
     $path = '/activate/';
     $url = 'http://' . $host . $path;
     $data = '';
     $data['key'] = PERCH_LICENSE_KEY;
     $data['host'] = $_SERVER['SERVER_NAME'];
     $data['version'] = $Perch->version;
     $data['php'] = phpversion();
     $content = http_build_query($data);
     $result = false;
     $use_curl = false;
     if (function_exists('curl_init')) {
         $use_curl = true;
     }
     if ($use_curl) {
         PerchUtil::debug('Activating via CURL');
         $ch = curl_init();
         curl_setopt($ch, CURLOPT_URL, $url);
         curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
         curl_setopt($ch, CURLOPT_TIMEOUT, 10);
         curl_setopt($ch, CURLOPT_POST, true);
         curl_setopt($ch, CURLOPT_POSTFIELDS, $content);
         $result = curl_exec($ch);
         PerchUtil::debug($result);
         $http_status = (int) curl_getinfo($ch, CURLINFO_HTTP_CODE);
         if ($http_status != 200) {
             $result = false;
             PerchUtil::debug('Not HTTP 200: ' . $http_status);
         }
         curl_close($ch);
     } else {
         if (function_exists('fsockopen')) {
             PerchUtil::debug('Activating via sockets');
             $fp = fsockopen($host, 80, $errno, $errstr, 10);
             if ($fp) {
                 $out = "POST {$path} HTTP/1.1\r\n";
                 $out .= "Host: {$host}\r\n";
                 $out .= "Content-Type: application/x-www-form-urlencoded\r\n";
                 $out .= "Content-Length: " . strlen($content) . "\r\n";
                 $out .= "Connection: Close\r\n\r\n";
                 $out .= $content . "\r\n";
                 fwrite($fp, $out);
                 stream_set_timeout($fp, 10);
                 while (!feof($fp)) {
                     $result .= fgets($fp, 128);
                 }
                 fclose($fp);
             }
             if ($result != '') {
                 $parts = preg_split('/[\\n\\r]{4}/', $result);
                 if (is_array($parts)) {
                     $result = $parts[1];
                 }
             }
         }
     }
     // Should have a $result now
     if ($result) {
         $json = PerchUtil::json_safe_decode($result);
         if (is_object($json) && $json->result == 'SUCCESS') {
             // update latest version setting
             $Settings = new PerchSettings();
             $Settings->set('latest_version', $json->latest_version);
             $Settings->set('on_sale_version', $json->on_sale_version);
             PerchUtil::debug($json);
             PerchUtil::debug('Activation: success');
             return true;
         } else {
             PerchUtil::debug('Activation: failed');
             $this->activation_failed = true;
             return false;
         }
     }
     // If activation can't complete, assume honesty. That's how I roll.
     return true;
 }
开发者ID:Bloom-web,项目名称:bloom-web,代码行数:84,代码来源:PerchAuthenticatedUser.class.php


注:本文中的PerchUtil::json_safe_decode方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。