public function go()
 {
     //$feed = file_get_contents($_SERVER['DOCUMENT_ROOT'].'/_add-ons/wordpress/wp_posts.xml');
     //$items = simplexml_load_string($feed);
     $posts_object = simplexml_load_file($_SERVER['DOCUMENT_ROOT'] . '/_add-ons/wordpress/roobottom_old_posts.xml');
     $posts = object_to_array($posts_object);
     $yaml_path = $_SERVER['DOCUMENT_ROOT'] . '/_content/01-blog/';
     foreach ($posts['table'] as $post) {
         if ($post['column'][8] == "publish") {
             $slug = Slug::make($post['column'][5]);
             $slug = preg_replace('/[^a-z\\d]+/i', '-', $slug);
             if (substr($slug, -1) == '-') {
                 $slug = substr($slug, 0, -1);
             }
             $date = date('Y-m-d-Hi', strtotime($post['column'][3]));
             $file = $date . "-" . $slug . ".md";
             if (!File::exists($yaml_path . $file)) {
                 $yaml = [];
                 $yaml['title'] = $post['column'][5];
                 $content = $post['column'][4];
                 $markdown = new HTML_To_Markdown($content, array('header_style' => 'atx'));
                 File::put($yaml_path . $file, YAML::dump($yaml) . '---' . "\n" . $markdown);
             }
             echo $slug . "-" . $date;
             echo "<br/><hr/><br/>";
         }
     }
     return "ok";
 }
Example #2
0
 public function saveScore()
 {
     try {
         $score = new Score();
         $score->setScore();
         $nCoolType = $score->getType();
         $this->_setScoreDatabase($nCoolType);
         $this->_setScoreCollection($nCoolType);
         $result = $this->connect();
         if (!$result) {
             Log::write('ScoreRecord::saveRecord():connect() failed', 'log');
             return false;
         }
         $this->addIndex(array('insert_time' => -1, 'id' => 1, 'cpid' => 1, 'cyid' => 1, 'cpcy' => array('cpid' => 1, 'cyid' => 1)));
         $result = $this->_mongo->insert($this->_collection, object_to_array($score));
         if ($result === false) {
             Log::write('ScoreRecord::saveRecord():insert() failed', 'log');
             return false;
         }
         return true;
     } catch (Exception $e) {
         Log::write('ScoreRecord::saveRecord() exception, mongErr:' . $this->_mongo->getError() . ' err:' . ' file:' . $e->getFile() . ' line:' . $e->getLine() . ' message:' . $e->getMessage() . ' trace:' . $e->getTraceAsString(), 'log');
     }
     return false;
 }
function json_encode2($param)
{
    if (is_object($param) || is_array($param)) {
        $param = object_to_array($param);
    }
    return json_encode($param);
}
function getMoviesAsArray($endpoint)
{
    include 'config.php';
    $movies = json_decode(file_get_contents($baseUrl . $endpoint));
    $movies = object_to_array($movies);
    return $movies;
}
Example #5
0
 public function index()
 {
     $p = I('p', 1);
     $sort = I('sort', 'new');
     $cid = I('cid');
     $top = $this->_get_top();
     $req = $top->load_api('FtxiaShuangItemcatsGetRequest');
     $req->setFields('id,name');
     $resp = $top->execute($req);
     $cats = object_to_array($resp->itemcats);
     $this->assign('cats', $cats);
     $top = $this->_get_top();
     $req = $top->load_api('FtxiaShuangItemsGetRequest');
     $req->setFields('num_iid,title,pic_url,price,volume');
     $req->setPageNo($p);
     $req->setCid($cid);
     $req->setSort($sort);
     $req->setTime(date("Y-m-d H"));
     $resp = $top->execute($req);
     $count = $resp->totals;
     $items = object_to_array($resp->items);
     $this->assign('items', $items);
     $pager = $this->_pager($count, '60');
     $this->assign('page', $pager->kshow());
     $this->assign('total', $count);
     $this->assign('cid', $cid);
     $this->assign('sort', $sort);
     $this->assign('nav_curr', 'shuang');
     $this->_config_seo(array('title' => ' 淘宝双十二秒杀专区,1212最值得买的爆款商品	-	' . C('ftx_site_name')));
     $this->display();
 }
Example #6
0
/**
 * CRM API 加减积分函数封装
 * @param type $vipcode vip卡号
 * @return list
 */
function postnwvipbonusadjust2($vipcode, $vipaccountno, $bonus)
{
    $parm = new StdClass();
    $parm->astr_request = new StdClass();
    $parm->astr_request->header = new StdClass();
    $parm->astr_request->header->username = C('NWVIP_USERNAME');
    $parm->astr_request->header->password = C('NWVIP_PASSWORD');
    $parm->astr_request->header->pagerecords = 20;
    //每页显示多少条信息
    $parm->astr_request->header->pageno = 0;
    //当前第几页
    $parm->astr_request->header->updatecount = 1;
    $parm->astr_request->bonusadjust->vipcode = $vipcode;
    $parm->astr_request->bonusadjust->vipaccountno = $vipaccountno;
    $parm->astr_request->bonusadjust->txdate_yyyymmdd = date('Ymd', time());
    $parm->astr_request->bonusadjust->bonus = $bonus;
    $parm->astr_request->bonusadjust->amount = '0';
    $parm->astr_request->bonusadjust->action = 'A';
    $parm->astr_request->bonusadjust->remark = '';
    $parm->astr_request->bonusadjust->issueby = 'NwVipWeb';
    $parm->astr_request->bonusadjust->reasoncode = '';
    $parm->astr_request->bonusadjust->bonusadjustdocno = '';
    $client = new SoapClient(C('NWVIP_SERVICE_URL'), array('trace' => 1, 'exceptions' => 0));
    $result = $client->postnwvipbonusadjust2($parm);
    return object_to_array($result);
}
Example #7
0
function getEntitiesArray($params, $show_password = false)
{
    $return_array = array();
    $entities = getEntities($params);
    if ($entities) {
        foreach ($entities as $entity) {
            $return_array[] = object_to_array($entity);
        }
    }
    return $return_array;
    $return = array();
    $entities = Entity::getEntitiesArray($params, $show_password);
    if (is_array($entities)) {
        foreach ($entities as $entity) {
            $entity['type'] = $params['type'];
            foreach ($entity as $key => $value) {
                if (!is_array($value)) {
                    $value = html_entity_decode($value);
                    $value = strip_tags($value);
                }
                $entity[$key] = $value;
            }
            $return[] = $entity;
        }
        return $return;
    } else {
        return array();
    }
}
Example #8
0
 static function LoadModel($model)
 {
     if (isset($this) && $this instanceof OrmManager) {
         $me = $this;
     } else {
         $me = self::singleton();
     }
     if (!$me->outlet) {
         return;
     }
     $models = explode(",", $model);
     //print_pre($models);
     $ret = array();
     foreach ($models as $model) {
         $ormmodel = new OrmModel($model);
         $ormmodel->LoadModel();
         $ret[$model] = $ormmodel;
         if (!empty($ormmodel->classes)) {
             $foo = object_to_array($ormmodel->classes);
             try {
                 $me->outlet->getConfig()->addEntities($foo);
             } catch (Exception $e) {
                 Logger::Error("OrmManager: " . $e->GetMessage());
             }
         }
     }
     $me->outlet->createClasses();
     $me->outlet->createProxies();
     return $ret;
 }
Example #9
0
 public function index()
 {
     $this->load->library(['pagination', 'table']);
     $page = !empty($this->uri->segment(4)) ? $this->_perpage * ($this->uri->segment(4) - 1) : 0;
     $config['base_url'] = base_url($this->base . '/index/');
     $config['total_rows'] = $this->{$this->router->fetch_class()}->count_all();
     $this->_set_datagrid_header(isset($this->data['recursive']) ? $this->data['recursive'][1] : NULL);
     $unshift = [$this->primary_key => 'Primary Key'] + $this->data['datagrid_header'] + ['role' => 'Role'];
     $items = $this->_get_items();
     $this->user->order_by($this->primary_key, 'ASC');
     $this->user->limit($this->_perpage, $page);
     foreach ($this->user->with('user_role')->get_all() as $index => $row) {
         $row = object_to_array($row);
         foreach ($row as $k => $v) {
             if (!empty($items) && array_key_exists($k, $items)) {
                 $row[$k] = empty($v) ? $v : $items[$k][$v];
             }
         }
         $row['role'] = '';
         foreach ($row['user_role'] as $key => $value) {
             $role = $this->role->get($value['role_id']);
             $row['role'] .= '<span class="label label-info">' . $role->role_name . '</span> ';
         }
         $row = array_intersect_key($row, $unshift);
         $this->data['datagrid'][$index] = array_to_object($row);
     }
     $this->pagination->initialize($config);
     $this->data['links'] = $this->pagination->create_links();
 }
 /**
  * @param $get_page_arguments
  * @param $new_arr
  *
  * @return false|string
  */
 private function find_post_type($get_page_arguments, $new_arr)
 {
     $post_type = 'page';
     if (array_key_exists('post_type', $get_page_arguments)) {
         $post_type = $get_page_arguments['post_type'];
         return $post_type;
     } else {
         $temp_items = array_values($new_arr);
         $first_item = $temp_items[0];
         if (is_object($first_item)) {
             $first_item = object_to_array($first_item);
         }
         if (is_array($first_item)) {
             if (array_key_exists('post_type', $first_item)) {
                 $post_type = $first_item['post_type'];
                 return $post_type;
             } elseif (array_key_exists('ID', $first_item)) {
                 $post_type = $this->sitepress->get_wp_api()->get_post_type($first_item['ID']);
                 return $post_type;
             }
             return $post_type;
         } elseif (is_numeric($first_item)) {
             $post_type = $this->sitepress->get_wp_api()->get_post_type($first_item);
             return $post_type;
         }
         return $post_type;
     }
 }
Example #11
0
/**
 * Convert a value to JSON
 *
 * This function returns a JSON representation of $param. It uses json_encode
 * to accomplish this, but converts objects and arrays containing objects to
 * associative arrays first. This way, objects that do not expose (all) their
 * properties directly but only through an Iterator interface are also encoded
 * correctly.
 */
function json_encode_all(&$param)
{
    if (is_object($param) || is_array($param)) {
        return json_encode(object_to_array($param));
    }
    return json_encode($param);
}
Example #12
0
/**
 * Convert an object into an associative array
 *
 * This function converts an object into an associative array by iterating
 * over its public properties. Because this function uses the foreach
 * construct, Iterators are respected. It also works on arrays of objects.
 *
 * @return array
 */
function object_to_array($var, $loop_exclude = array())
{
    if (is_object($var)) {
        if ($var instanceof JsonSerializable) {
            return $var->jsonSerialize();
        }
        if (in_array($var, $loop_exclude, true)) {
            return '*RECURSION*';
        }
        $loop_exclude[] = $var;
        if ($var instanceof ArrayObject) {
            $var = $var->getArrayCopy();
        } elseif (method_exists($var, 'toArray')) {
            $var = $var->toArray();
        } elseif ($var instanceof Traversable) {
            $var = iterator_to_array($var, true);
        } else {
            $var = get_object_vars($var);
        }
    } elseif (!is_array($var)) {
        throw new InvalidArgumentException('object_to_array can only convert arrays and objects');
    }
    // loop over elements/properties
    foreach ($var as &$value) {
        // recursively convert objects
        if (is_object($value) || is_array($value)) {
            $value = object_to_array($value, $loop_exclude);
        }
    }
    return $var;
}
Example #13
0
 public function index()
 {
     $p = I('p', 1, 'intval');
     $cid = I('cid', '', 'intval');
     $top = $this->_get_top();
     $req = $top->load_api('FtxiaJuCatsGetRequest');
     $req->setFields('cid,name');
     $resp = $top->execute($req);
     $cats = object_to_array($resp->cats);
     $this->assign('cats', $cats);
     $ltop = $this->_get_top();
     $req = $ltop->load_api('FtxiaJuListsGetRequest');
     $req->setPage($p);
     $req->setCid($cid);
     $req->setTime(date("y-m-d-h", time()));
     $resp = $ltop->execute($req);
     $jus = object_to_array($resp->lists);
     $count = $jus['totalPage'];
     $html = Newiconv("GBK", "UTF-8", urldecode($jus['html']));
     $html = str_replace("data-ks-lazyload", "src", $html);
     $html = str_replace("&amp;id=", "&tm=", $html);
     $html = str_replace("http://detail.ju.taobao.com/home.htm?item_id=", "?m=jump&a=index&iid=", $html);
     $html = str_replace("&tm=", "&from=open.ftxia.com", $html);
     $pager = $this->_pager($count, '1');
     $this->assign('page', $pager->kshow());
     $this->assign('html', $html);
     $this->assign('cid', $cid);
     $this->assign('nav_curr', 'ju');
     $this->_config_seo(array('title' => ' 汇聚最划算的团购商品 - '));
     $this->display();
 }
Example #14
0
 /** 
  *  转换返回数据
  * 
  *  @access public 
  *  @param  $result 返回结果
  *  @return object 
  */
 function get_format_result($result)
 {
     $r = new OperationResult();
     if (is_object($result)) {
         $result = object_to_array($result);
     }
     if ($result['Status'] == 200) {
         $r->status = 1;
         $r->message = '处理成功';
         $r->data = '';
         if (isset($result['Data']['TotalCount'])) {
             $r->data = new stdClass();
             $r->data->total = $result['Data']['TotalCount'];
             $r->data->rows = isset($result['Data']['List']) ? $result['Data']['List'] : array();
         }
         if (empty($r->data) && !empty($result['Data'])) {
             $r->data = $result['Data'];
         }
     } else {
         $r->status = 0;
         //$r->message = '处理失败';
         $r->message = $result['Message'];
         $r->data = empty($result['Data']) ? '' : $result['Data'];
     }
     return $r;
 }
 function icl_register_admin_options($array, $key = "", $option = array())
 {
     if (is_object($option)) {
         $option = object_to_array($option);
     }
     foreach ($array as $k => $v) {
         $option = $key === '' ? array($k => maybe_unserialize($this->get_option_without_filtering($k))) : $option;
         if (is_array($v)) {
             $this->icl_register_admin_options($v, $key . '[' . $k . ']', $option[$k]);
         } else {
             $context = $this->get_context($key, $k);
             if ($v === '') {
                 icl_unregister_string($context, $key . $k);
             } elseif (isset($option[$k]) && ($key === '' || preg_match_all('#\\[([^\\]]+)\\]#', (string) $key, $opt_key_matches) > 0)) {
                 icl_register_string($context, $key . $k, $option[$k]);
                 $vals = array($k => 1);
                 $opt_keys = isset($opt_key_matches) ? array_reverse($opt_key_matches[1]) : array();
                 foreach ($opt_keys as $opt) {
                     $vals = array($opt => $vals);
                 }
                 update_option('_icl_admin_option_names', array_merge_recursive((array) get_option('_icl_admin_option_names'), $vals));
             }
         }
     }
 }
Example #16
0
 public function edit()
 {
     $data['user'] = unserialize($_SESSION['login_user']);
     $bank = $this->db->query("SELECT * FROM bank")->result();
     $data['bank'] = object_to_array($bank, 'nama_bank');
     $this->authlibrary->check_login();
     $this->template->load('template/template_main', 'member/profile/edit', $data);
 }
Example #17
0
function object_to_array($obj)
{
    $_arr = is_object($obj) ? get_object_vars($obj) : $obj;
    foreach ($_arr as $key => $val) {
        $val = is_array($val) || is_object($val) ? object_to_array($val) : $val;
        $arr[$key] = $val;
    }
    return $arr;
}
Example #18
0
 public function konfirmasi($id_transfer)
 {
     $rule = $this->_rule();
     $this->form_validation->set_rules($rule);
     $transfer = $this->transferreferrallibrary->getData($id_transfer);
     $data['transfer'] = $transfer;
     $data['id_transfer'] = $id_transfer;
     $data['user'] = unserialize($_SESSION['login_user']);
     $data['referral'] = $this->member_model->getData($transfer->data->id_referral, 'id');
     // Form validation
     if ($this->form_validation->run() == FALSE) {
         $bank = $this->db->query("SELECT * FROM bank WHERE country_code = '" . $data['user']->attributes('country_code') . "'")->result();
         $data['bank'] = object_to_array($bank, 'nama_bank');
         $this->template->load('template/template_main', 'member/konfirmasi/konfirmasi_transfer', $data);
     } else {
         $file_name = date('Y-m-j_H-i-s') . "_" . $id_transfer;
         $this->load->library('upload', $this->_upload_conf($file_name));
         if (isset($_FILES['userfile']) && $_FILES['userfile']['size'] > 0) {
             if (!$this->upload->do_upload()) {
                 $this->session->set_flashdata('message', $this->upload->display_errors());
                 $this->session->set_flashdata('sukses', false);
                 redirect(base_url() . "transfer/konfirmasi/" . $id_transfer);
             } else {
                 $data_upload = $this->upload->data();
                 $file = $this->input->post();
                 $file['id_transfer_referral'] = $id_transfer;
                 $file['transfered_at'] = date("Y-m-d");
                 $file['bukti_transfer'] = $file_name . $data_upload['file_ext'];
                 //resize image
                 $this->load->library('image_lib', $this->_resize_conf($file_name . $data_upload['file_ext']));
                 if (!$this->image_lib->resize()) {
                     $this->session->set_flashdata('message', $this->image_lib->display_errors());
                     $this->session->set_flashdata('sukses', false);
                     redirect(base_url() . "transfer/konfirmasi/" . $id_transfer);
                 } else {
                     $this->transferreferrallibrary->transfered($file, $id_transfer);
                     $this->session->set_flashdata('message', "Transfer berhasil harap tunggu verifikasi");
                     $this->session->set_flashdata('sukses', true);
                     redirect(base_url());
                 }
             }
         } else {
             // in here means no file was provided to upload
             // choose to ignore or let them know
             $file = $this->input->post();
             $file['id_transfer_referral'] = $id_transfer;
             $file['transfered_at'] = date("Y-m-d");
             $file['bukti_transfer'] = '';
             $this->transferreferrallibrary->transfered($file, $id_transfer);
             $this->session->set_flashdata('message', "Transfer berhasil harap tunggu verifikasi");
             $this->session->set_flashdata('sukses', true);
             redirect(base_url());
         }
     }
     //end else
 }
Example #19
0
 public function testObjectToArray()
 {
     $obj1 = new stdClass();
     $obj1->foo = 'bar';
     $obj2 = new stdClass();
     $obj2->foo = $obj1;
     $this->assertEquals([], object_to_array(new stdClass()));
     $this->assertEquals(['foo' => 'bar'], object_to_array($obj1));
     $this->assertEquals(['foo' => ['foo' => 'bar']], object_to_array($obj2));
 }
Example #20
0
 public function setData($data)
 {
     if (!is_array($data)) {
         if (!is_object($data)) {
             throw new \InvalidArgumentException("Write data must be array or object, given: " . gettype($data));
         }
         $data = object_to_array($data);
     }
     $this->data = $data;
 }
Example #21
0
 private function get_templates()
 {
     $this->load->model('template_model');
     $ids = $this->config->item('index_template_ids');
     $params = buildQueryOperation(array(), $this->common->get_start_row(), $this->common->get_page_size());
     foreach ((array) $ids as $id) {
         $params->QueryOperator->Filter[] = array_to_object(array('Name' => 'ID', 'Value' => $id));
     }
     $result = wrapWcfResult($this->template_model->get_templates_list($params, 'object'), 'Template');
     return empty($result->Data['rows']) ? [] : object_to_array($result->Data['rows']);
 }
function object_to_array(&$mixed)
{
    if (is_object($mixed)) {
        $mixed = (array) $mixed;
    }
    if (is_array($mixed)) {
        foreach ($mixed as $key => &$val) {
            object_to_array($mixed[$key]);
        }
    }
}
Example #23
0
/**
 * @param array|object $array
 * @return string
 */
function xml_encode_all(&$array)
{
    $dom = new DOMDocument('1.0', 'utf-8');
    $doc = create_xml_node('data', null, $dom);
    foreach (object_to_array($array) as $key => $value) {
        $doc->appendChild(create_xml_node($key, $value, $dom));
    }
    $dom->appendChild($doc);
    $dom->formatOutput = true;
    return $dom->saveXML();
}
Example #24
0
 function object_to_array($obj)
 {
     if (is_array($obj) || is_object($obj)) {
         $result = array();
         foreach ($obj as $key => $value) {
             $result[$key] = object_to_array($value);
         }
         return $result;
     }
     return $obj;
 }
Example #25
0
function object_to_array($data)
{
    if (is_array($data) || is_object($data)) {
        $result = array();
        foreach ($data as $key => $value) {
            $result[$key] = object_to_array($value);
        }
        return $result;
    }
    return $data;
}
 public static function objectToArray($object)
 {
     if (is_array($object) || is_object($object)) {
         $array = array();
         foreach ($object as $key => $value) {
             $array[$key] = object_to_array($value);
         }
         return $array;
     }
     return $object;
 }
Example #27
0
/**
 * 将对象转化为数组
 * @Author   EricJi
 * @DateTime 2015-12-08T21:48:05+0800
 * @param    [type]                   $obj [description]
 * @return   [type]                        [description]
 */
function object_to_array($obj)
{
    $ret = array();
    foreach ($obj as $key => $value) {
        if (gettype($value) == "array" || gettype($value) == "object") {
            $ret[$key] = object_to_array($value);
        } else {
            $ret[$key] = $value;
        }
    }
    return $ret;
}
Example #28
0
 public function index()
 {
     $p = I('p', 1, 'intval');
     $sort = I('sort', 'new', 'trim');
     $top = $this->_get_top();
     $req = $top->load_api('TmallItemsGetRequest');
     $req->setFields('num_iid,title,pic_url,price,volume');
     $req->setPageNo($p);
     $req->setSort($sort);
     $req->setTime(date("Y-m-d H-i"));
     $resp = $top->execute($req);
     $count = $resp->totals;
     $items_list = object_to_array($resp->items);
     $items = array();
     $pagecount = 0;
     $seller_arr = array();
     $sellers = '';
     foreach ($items_list as $key => $val) {
         $items[$key] = $val;
         $items[$key]['class'] = $this->_mod->status($val['status'], $val['coupon_start_time'], $val['coupon_end_time']);
         $items[$key]['zk'] = round($val['coupon_price'] / $val['price'] * 10, 1);
         if (!$val['click_url']) {
             $items[$key]['click_url'] = U('jump/index', array('id' => $val['id']));
         }
         if ($val['coupon_start_time'] > time()) {
             $items[$key]['click_url'] = U('item/index', array('id' => $val['id']));
             $items[$key]['timeleft'] = $val['coupon_start_time'] - time();
         } else {
             $items[$key]['timeleft'] = $val['coupon_end_time'] - time();
         }
         $items[$key]['cate_name'] = $cate_list['p'][$val['cate_id']]['name'];
         $url = C('ftx_site_url') . U('item/index', array('id' => $val['id']));
         $items[$key]['url'] = urlencode($url);
         $items[$key]['urltitle'] = urlencode($val['title']);
         $items[$key]['price'] = number_format($val['price'], 1);
         $items[$key]['coupon_price'] = number_format($val['coupon_price'], 1);
         $pagecount++;
         if ($val['sellerId']) {
             $seller_arr[] = $val['sellerId'];
         }
     }
     $seller_arr = array_unique($seller_arr);
     $sellers = implode(",", $seller_arr);
     $this->assign('sellers', $sellers);
     $this->assign('items_list', $items);
     $pager = $this->_pager($count, '60');
     $this->assign('page', $pager->fshow());
     $this->assign('sort', $sort);
     $this->assign('nav_curr', 'tmall');
     $this->_config_seo(array('title' => '商城优选 — 精选最值得买的爆款商品 — '));
     $this->display();
 }
Example #29
0
 function testNonDestructive()
 {
     $prop = new stdClass();
     $prop->foo = 1;
     $prop2 = new ArrayObject();
     $prop2[] = $prop;
     $foo = new stdClass();
     $foo->a = $prop;
     $class = array($foo);
     $print_r = print_r($class, true);
     object_to_array($class);
     $this->assertEquals(print_r($class, true), $print_r);
 }
function object_to_array(stdClass $Class)
{
    # Typecast to (array) automatically converts stdClass -> array.
    $Class = (array) $Class;
    # Iterate through the former properties looking for any stdClass properties.
    # Recursively apply (array).
    foreach ($Class as $key => $value) {
        if (is_object($value) && get_class($value) === 'stdClass') {
            $Class[$key] = object_to_array($value);
        }
    }
    return $Class;
}