public function handle($data)
 {
     $this->validate_request(["assessment" => ["profile", "questions"]]);
     $assessment = $data->{"assessment"};
     $profileJson = $assessment->{"profile"};
     if (isset($profileJson->{"assessment-id"})) {
         $id = Token::decode($profileJson->{"assessment-id"});
     } else {
         $id = Token::generateNewToken(TOKEN_ASSESSMENT);
     }
     $name = $profileJson->{"assessment-name"};
     $displayname = isset($profileJson->{"display-name"}) ? $profileJson->{"display-name"} : $name;
     $profile = new AssessmentProfile($id, $name, $displayname);
     $questions = [];
     foreach ($assessment->{"questions"} as $questionData) {
         $questionJson = obj_to_array($questionData);
         if (isset($questionData->{"question-id"})) {
             $questionId = Token::decode($questionData->{"question-id"});
         } else {
             $questionId = Token::generateNewToken(TOKEN_QUESTION);
         }
         $question = [];
         $question["id"] = $questionId->toString();
         $question["data"] = $questionJson;
         $questions[] = $question;
     }
     return ["assessment" => AssessmentBackend::create_assessment($profile, $questions)->toExternalForm()];
 }
 /**
  * 获得全部文章分类--无限极分类(编辑菜单时选项)
  *
  * @descript  递归组合无限极分类,为了编辑页面和增加页面select 展示
  * @param $name 表单name名称
  * @param $id 当前id
  * @return array
  * @author yangyifan <*****@*****.**>
  */
 public static function getAllForSchemaOption($name, $id = 0, $first = true)
 {
     //加载函数库
     load_func('common');
     $data = $id > 0 ? merge_tree_node(obj_to_array(self::where('id', '<>', $id)->where('user_info_id', '=', is_user_login())->where('deleted_at', '=', '0000-00-00 00:00:00')->get())) : merge_tree_node(obj_to_array(self::where('user_info_id', '=', is_user_login())->get()));
     $first == true && array_unshift($data, ['id' => '0', $name => '顶级分类']);
     return $data;
 }
 /**
  * 获得全部分类
  *
  * @return \Illuminate\Database\Eloquent\Collection|static[]
  */
 public static function getAllCategory()
 {
     //加载函数库
     load_func('common');
     $data = obj_to_array(self::all());
     $data = array_to_obj(merge_tree_child_node($data));
     return $data;
 }
 /**
  * 获得当前栏目全部角色权限
  *
  * @param null $role_id
  * @return mixed
  * @author yangyifan <*****@*****.**>
  */
 public static function getUserForumCat($forum_cat_id)
 {
     if (!empty($forum_cat_id)) {
         //加载函数库
         load_func('common');
         return obj_to_array(DB::table('forum_access AS fa')->select('r.id', 'r.role_name')->join('role AS r', 'fa.role_id', '=', 'r.id')->where('fa.forum_cat_id', '=', $forum_cat_id)->get());
     }
     return false;
 }
示例#5
0
function obj_to_array($obj)
{
    $array = is_object ? (array) $obj : $obj;
    foreach ($array as $k => $v) {
        if (is_object($v) or is_array($v)) {
            $array[$k] = obj_to_array($v);
        }
    }
    return $array;
}
 /**
  * 写入用户信息到SESSION
  *
  * @param $user_info
  * @author yangyifan <*****@*****.**>
  */
 private static function saveUserSession($user_info)
 {
     //引入函数库
     load_func('common');
     $user_info = obj_to_array($user_info);
     $user_info['user_user_data'] = ['id' => $user_info['id'], 'email' => $user_info['email'], 'updated_at' => $user_info['updated_at']];
     $user_info['sign'] = hash_user_sign($user_info['user_user_data']);
     Session::put('user_info', $user_info);
     Session::save();
 }
 private function handlePost($data)
 {
     $this->validate_request(["question"]);
     $profile = AssessmentBackend::fetch_assessment_profile(Token::decode($this->params['id']));
     $questionId = Token::decode($this->params['question']);
     $question = [];
     $question["id"] = $questionId->toString();
     $question["data"] = obj_to_array($data->{"question"});
     AssessmentBackend::update_question($profile, $questionId, $question);
     return $this->handleGet($data);
 }
 /**
  * 获得全部分类
  *
  * @return mixed
  * @author yangyifan <*****@*****.**>
  */
 public static function getUserChoseCagetory()
 {
     //加载函数库
     load_func('common');
     //获得当前用户全部新闻分类
     $user_new_category_id = self::getUserCagetory();
     $all_category = self::all();
     if (!empty($all_category)) {
         foreach ($all_category as &$category) {
             $category->checked = in_array($category->id, $user_new_category_id) ? true : false;
         }
     }
     $all_category = obj_to_array($all_category);
     return array_to_obj(merge_tree_child_node($all_category));
 }
示例#9
0
/**
 * 顯示滑動圖.
 */
function get_slider()
{
    //滑動頁數量
    $_int_count_slider = 5;
    //取得文章資料
    $_obj_posts = get_posts(array('numberposts' => $_int_count_slider, 'meta_key' => '_thumbnail_id'));
    //將物件轉陣列
    $_arr_posts = obj_to_array($_obj_posts);
    //取得特色圖網址
    foreach ($_arr_posts as $val) {
        $val['url_thumb_img'] = wp_get_attachment_url(get_post_thumbnail_id($val['ID']));
        $_arr_slider_posts[] = $val;
    }
    include_once 'slider.php';
}
 /**
  * 获得组合用户全部分类[组合好]
  *
  * @param null $role_id
  * @return array
  * @author yangyifan <*****@*****.**>
  */
 public static function getFullUserMenu($role_id = null)
 {
     //加载函数库
     load_func('common');
     $role_id = self::getRoleId($role_id);
     $all_menu = self::where('deleted_at', '=', '0000-00-00 00:00:00')->get();
     $all_user_menu = self::getUserRelationMenu($role_id);
     if (!empty($all_menu)) {
         foreach ($all_menu as &$menu) {
             $menu->checked = in_array($menu->id, $all_user_menu) ? true : false;
         }
     }
     //组合数据
     $all_menu = merge_tree_child_node(obj_to_array($all_menu));
     return array_to_obj($all_menu);
 }
 public function handle($data)
 {
     $this->validate_request(["question"]);
     $assessment = AssessmentBackend::fetch_assessment_profile(Token::decode($this->params['id']));
     $questionJson = obj_to_array($data->{"question"});
     if (isset($data->{"question"}->{"question-id"})) {
         $questionId = Token::decode($data->{"question"}->{"question-id"});
     } else {
         $questionId = Token::generateNewToken(TOKEN_QUESTION);
     }
     $question = [];
     $question["id"] = $questionId->toString();
     $question["data"] = $questionJson;
     AssessmentBackend::add_question($assessment, $question);
     return [];
 }
示例#12
0
/**
 * 快递模块
 * 
 * @access public
 * @param string $str
 * @return string
 */
function is_express($str)
{
    if (is_numeric($str)) {
        $postid = strlen($str);
        switch ($postid) {
            case 10:
                $type = "yuantong";
                break;
            case 12:
                $type = "shunfeng";
                break;
            case 13:
                $type = "yunda";
                break;
        }
        if (isset($type)) {
            $data = obj_to_array(json_decode(express($type, $str)));
            return get_express_data($data);
        }
    }
}
 /**
  * @return array
  */
 public function getCategories()
 {
     return ["select"] + obj_to_array(get_terms('category', array('hide_empty' => 0)), 'term_id', 'name');
 }
示例#14
0
 /**
  * 获得全部论坛分类
  *
  * @param $data
  * @author yangyifan <*****@*****.**>
  */
 public static function getForumLocation($data)
 {
     //加载函数库
     load_func('common');
     $all_category = obj_to_array(self::select('cat_name', 'id', 'pid')->get());
     $data = get_location($all_category, $data->forum_cat_id);
     //翻转函数
     $data = array_reverse($data);
     return $data;
 }
示例#15
0
/**
 * 对象转数组
 * 
 * @access public
 * @param object $obj
 * @return array
 */
function obj_to_array($obj)
{
    $ret = array();
    foreach ($obj as $key => $value) {
        if (gettype($value) == 'array' || gettype($value) == 'object') {
            $ret[$key] = obj_to_array($value);
        } else {
            $ret[$key] = $value;
        }
    }
    return $ret;
}
示例#16
0
 /**
  * 获得当前用户全部菜单--递归(左侧菜单显示)
  *
  * @return array
  * @author yangyifan <*****@*****.**>
  */
 public static function getUserMenuSide()
 {
     //加载函数库
     return merge_tree_child_node(obj_to_array(DB::table('role_relation_menu AS rrm')->select('m.*')->join('menu AS m', 'rrm.menu_id', '=', 'm.id')->where('role_id', '=', self::getRoleId())->get()));
 }
示例#17
0
 /**
  * 获得全部菜单--递归(左侧菜单显示)
  *
  * @return array
  * @auther yangyifan <*****@*****.**>
  */
 public static function getAllForMenuSide()
 {
     //加载函数库
     load_func('common');
     return merge_tree_child_node(obj_to_array(self::all()));
 }
示例#18
0
 /**
  * 获得角色列表
  *
  * @return mixed
  * @author yangyifan <*****@*****.**>
  */
 public static function getRoleList()
 {
     //加载函数库
     load_func('common');
     return obj_to_array(DB::table('role')->where('status', '=', 1)->get());
 }
function getLyric($artist, $song)
{
    $url = str_replace('\'', '', 'http://api.chartlyrics.com/apiv1.asmx/SearchLyricDirect?artist=' . urlencode($artist) . '&song=' . urlencode($song));
    $xml = simplexml_load_file($url, 'SimpleXMLElement', LIBXML_NOCDATA);
    $xml = obj_to_array($xml);
    //	print_r($xml);
    if ($xml['LyricId'] && $xml['Lyric'] != array()) {
        return $xml['Lyric'];
    } else {
        return 'Sorry, there\'s no lyric found for this song';
    }
}
示例#20
0
 /**
  * 获得全部分类
  *
  * @return \Illuminate\Database\Eloquent\Collection|static[]
  */
 public static function getAllCategory()
 {
     //加载函数库
     load_func('common');
     $data = obj_to_array(self::where('status', '=', 1)->where('deleted_at', '=', '0000-00-00 00:00:00')->get());
     $data = array_to_obj(merge_tree_child_node($data));
     return $data;
 }
示例#21
0
 /**
  * 获得全部文章分类
  *
  * @return array
  * @auther yangyifan <*****@*****.**>
  */
 public static function getAll()
 {
     //加载函数库
     load_func('common');
     return merge_tree_node(obj_to_array(self::mergeData(self::all())));
 }
 /**
  * 构建tree数据
  *
  * @param $data
  * @return \Illuminate\View\View
  * @author yangyifan <*****@*****.**>
  */
 public function builderTreeData($data)
 {
     //加载函数库
     load_func('common');
     $this->tree_data = merge_tree_node(obj_to_array($data));
     return $this;
 }
示例#23
0
 /**
  * 获得全部文章分类--无限极分类(编辑菜单时选项)
  *
  * @descript  递归组合无限极分类,为了编辑页面和增加页面select 展示
  * @param $name 表单name名称
  * @param $id 当前id
  * @return array
  * @auther yangyifan <*****@*****.**>
  */
 public static function getAllForSchemaOption($name, $id = 0)
 {
     //加载函数库
     load_func('common');
     $data = $id > 0 ? merge_tree_node(obj_to_array(self::where('id', '<>', $id)->get())) : merge_tree_node(obj_to_array(self::all()));
     array_unshift($data, ['id' => '0', $name => '顶级分类']);
     return $data;
 }
 /**
  * 获得全部文章分类
  *
  * @return array
  * @author yangyifan <*****@*****.**>
  */
 public static function getAll()
 {
     //加载函数库
     load_func('common');
     return merge_tree_node(obj_to_array(self::mergeData(self::where('status', '=', 1)->where('deleted_at', '=', '0000-00-00 00:00:00')->get())));
 }
示例#25
0
// 获取管理员id
// $my_uin = get_friend_uin($friend_list);
//http://s.web2.qq.com/api/get_friend_uin2?tuin={$tuin}&verifysession=&type=1&code=&vfwebqq={$vfwebqq}c&t=136610165502
print_r($cookie);
//var_dump($my_uin);
// print_r($friend_list);
print_r($group_name_list);
// 回复数据
$reply = unserialize(read_file("parse.ini"));
$face = array("9" => array("哭啥?有啥不开心的?说出来让我们开心一下"), "5" => array("不哭,乖", "哭啥?有啥不开心的?说出来让我们开心一下"), "13" => array("笑得这么开心?", "在笑哪个妹子呢?"), "58" => array("老板,来根大麻", "红塔山多少钱一包?"), "105" => array("鄙视俺的人那么多,你排队去", "不许插队,吼吼!~~~"));
// =======================================================
// |新开进程进行监控
// =======================================================
while (TRUE) {
    $d = poll($cookie['login']['psessionid'], $cookie['clientid']);
    $msg = obj_to_array(json_decode($d));
    echo $d;
    if ($msg['retcode'] === 0) {
        foreach ($msg['result'] as $v) {
            // 			print_r($v);
            // 针对个人
            if ($v['poll_type'] == "message") {
                $data = trim($v['value']['content'][1]);
                // 处理换行
                $data = implode("\\\\n", explode("\n", $data));
                // 普通回复
                if (array_key_exists($data, $reply)) {
                    if (is_array($reply[$data]) && ($count = count($reply[$data]))) {
                        send_buddy_msg($v['value']['from_uin'], $reply[$data][mt_rand(0, $count - 1)], $cookie['login']['psessionid'], $cookie['clientid']);
                    } else {
                        send_buddy_msg($v['value']['from_uin'], $reply[$data], $cookie['login']['psessionid'], $cookie['clientid']);
示例#26
0
文件: adm.php 项目: akhwan90/cat
 public function h_ujian()
 {
     $this->cek_aktif();
     //var def session
     $a['sess_level'] = $this->session->userdata('admin_level');
     $a['sess_user'] = $this->session->userdata('admin_user');
     $a['sess_konid'] = $this->session->userdata('admin_konid');
     //var def uri segment
     $uri2 = mysql_real_escape_string($this->uri->segment(2));
     $uri3 = mysql_real_escape_string($this->uri->segment(3));
     $uri4 = mysql_real_escape_string($this->uri->segment(4));
     //var post from json
     $p = json_decode(file_get_contents('php://input'));
     //return as json
     $jeson = array();
     $wh_1 = $a['sess_level'] == "admin" ? "SELECT tr_guru_tes.*, m_mapel.nama AS mapel, m_guru.nama AS nama_guru FROM tr_guru_tes INNER JOIN m_mapel ON tr_guru_tes.id_mapel = m_mapel.id INNER JOIN m_guru ON tr_guru_tes.id_guru = m_guru.id" : "SELECT tr_guru_tes.*, m_mapel.nama AS mapel, m_guru.nama AS nama_guru FROM tr_guru_tes INNER JOIN m_mapel ON tr_guru_tes.id_mapel = m_mapel.id INNER JOIN m_guru ON tr_guru_tes.id_guru = m_guru.id WHERE tr_guru_tes.id_guru = '" . $a['sess_konid'] . "'";
     $a['data'] = $this->db->query($wh_1)->result();
     $a['p_mapel'] = obj_to_array($this->db->query("SELECT * FROM m_mapel")->result(), "id,nama");
     if ($uri3 == "det") {
         $a['detil_tes'] = $this->db->query("SELECT m_mapel.nama AS namaMapel, m_guru.nama AS nama_guru, \n\t\t\t\t\t\t\t\t\t\t\t\ttr_guru_tes.* \n\t\t\t\t\t\t\t\t\t\t\t\tFROM tr_guru_tes \n\t\t\t\t\t\t\t\t\t\t\t\tINNER JOIN m_mapel ON tr_guru_tes.id_mapel = m_mapel.id\n\t\t\t\t\t\t\t\t\t\t\t\tINNER JOIN m_guru ON tr_guru_tes.id_guru = m_guru.id\n\t\t\t\t\t\t\t\t\t\t\t\tWHERE tr_guru_tes.id = '{$uri4}'")->row();
         $a['statistik'] = $this->db->query("SELECT MAX(nilai) AS max_, MIN(nilai) AS min_, AVG(nilai) AS avg_ \n\t\t\t\t\t\t\t\t\t\t\tFROM tr_ikut_ujian\n\t\t\t\t\t\t\t\t\t\t\tWHERE tr_ikut_ujian.id_tes = '{$uri4}'")->row();
         $a['hasil'] = $this->db->query("SELECT m_siswa.nama, tr_ikut_ujian.nilai, tr_ikut_ujian.jml_benar, tr_ikut_ujian.nilai_bobot\n\t\t\t\t\t\t\t\t\t\t\tFROM tr_ikut_ujian\n\t\t\t\t\t\t\t\t\t\t\tINNER JOIN m_siswa ON tr_ikut_ujian.id_user = m_siswa.id\n\t\t\t\t\t\t\t\t\t\t\tWHERE tr_ikut_ujian.id_tes = '{$uri4}'")->result();
         $a['p'] = "m_guru_tes_hasil_detil";
         //echo $this->db->last_query();
     } else {
         $a['p'] = "m_guru_tes_hasil";
     }
     $this->load->view('aaa', $a);
 }
示例#27
0
文件: functions.php 项目: cruide/wasp
 function obj_to_array($obj)
 {
     if (!is_object($obj)) {
         return false;
     }
     $publics = function ($obj) {
         return get_object_vars($obj);
     };
     $values = $publics($obj);
     foreach ($values as $key => $val) {
         if (is_object($val)) {
             $values[$key] = obj_to_array($val);
         }
     }
     return $values;
 }
示例#28
0
/**
 * 获取群里的指定用户
 * 
 * @access public
 * @param string $data
 * @return array
 */
function get_group_user_find_uid($data)
{
    $r = obj_to_array(json_decode($data));
    foreach ($r["result"]["minfo"] as $v) {
        if ($v['nick'] == "秋风" && $v['uin'] != USERNAME) {
            return $v;
        }
    }
}