• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP generate_json函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中generate_json函数的典型用法代码示例。如果您正苦于以下问题:PHP generate_json函数的具体用法?PHP generate_json怎么用?PHP generate_json使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



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

示例1: files

 public function files()
 {
     requireadmin();
     $file = isset($_FILES["file"]) ? $_FILES["file"] : false;
     if ($file) {
         $name = $file['name'];
         $extArr = explode(".", $name);
         $ext = end($extArr);
         if (strtolower($ext) == 'tsfbak') {
             $tmpFile = 'static/temp/' . strtotime('now') . '.zip';
             move_uploaded_file($file["tmp_name"], $tmpFile);
             $zip = new ZipArchive();
             if ($zip->open($tmpFile) === TRUE) {
                 $zip->extractTo(FCPATH);
                 $zip->close();
                 unlink($tmpFile);
                 generate_json(array('status' => 1));
             } else {
                 generate_json(array('status' => 0, 'message' => 'Failed to extract file, maybe its corrupted.'));
             }
         } else {
             generate_json(array('status' => 0, 'message' => 'Invalid backup file.'));
         }
     } else {
         generate_json(array('status' => 0, 'message' => 'No file to upload.'));
     }
 }
开发者ID:rodino25,项目名称:tsv2,代码行数:27,代码来源:Restore.php


示例2: do_login

 public function do_login()
 {
     $username = $this->input->post('username');
     $password = ts_hash($this->input->post('password'));
     $status = 1;
     $message = '';
     $query = $this->model->login($username, $password);
     if ($query->num_rows()) {
         $row = $query->row();
         switch ($row->status) {
             case 0:
                 $status = 0;
                 $message = sprintf('Account not yet verified. <br /><a href="%s">Resend Verification?</a>', base_url('signup/resend_verification?token=' . $row->token . '&t=' . strtotime('now')));
                 break;
             case 2:
                 $status = 0;
                 $message = 'This account has been banned.';
                 break;
             default:
                 $uniqueToken = random_string('unique');
                 $this->model->user_update(array('last_active' => today(), 'token' => $uniqueToken), array('id' => $row->id));
                 $sessData = array('user_id' => $row->id, 'username' => $row->username, 'userlevel' => $row->userlevel, 'display_name' => $row->display_name, 'email_address' => $row->email_address, 'token' => $uniqueToken);
                 $this->session->set_userdata($sessData);
                 $message = $uniqueToken;
         }
     } else {
         $status = 0;
         $message = 'Incorrect Username / Password.';
     }
     generate_json(array('status' => $status, 'message' => $message));
 }
开发者ID:rodino25,项目名称:tsv2,代码行数:31,代码来源:Login.php


示例3: index

 public function index()
 {
     $myID = getUserID();
     $query = $this->mdb->get_active($myID);
     $priorities = $this->config->item('priorities');
     $priorityColors = array('bg-light', 'bg-warning dker', 'bg-danger');
     $items = array();
     foreach ($query->result() as $row) {
         $start = 'TBA';
         $startOrig = '';
         $end = 'TBA';
         $endOrig = '';
         $dateCompleted = 'TBA';
         $isOverdue = 0;
         if (strtotime($row->date_start)) {
             $start = convert_datetime($row->date_start);
             $start = date("M d, Y", strtotime($row->date_start));
             $startOrig = date("m/d/Y", strtotime($row->date_start));
         }
         if (strtotime($row->date_end)) {
             $end = convert_datetime($row->date_end);
             $end = date("M d, Y", strtotime($row->date_end));
             $endOrig = date("m/d/Y", strtotime($row->date_end));
             $endDateOnly = date("Y-m-d", strtotime($row->date_end));
             $endDateOnlyStr = strtotime($endDateOnly);
             $isOverdue = strtotime(date("Y-m-d")) >= $endDateOnlyStr ? 1 : 0;
         }
         if (strtotime($row->date_completed)) {
             $dateCompleted = convert_datetime($row->date_completed);
             $dateCompleted = date("M d, Y", strtotime($row->date_completed));
         }
         $items[] = array('id' => $row->id, 'name' => $row->title, 'safe_name' => htmlentities($row->title), 'project_id' => $row->project_id, 'project_name' => $row->project_name, 'description' => htmlentities($row->description), 'priority' => $row->priority, 'priority_name' => $priorities[$row->priority], 'priority_class' => isset($priorityColors[$row->priority]) ? $priorityColors[$row->priority] : $priorityColors[0], 'date_start' => $start, 'date_start_orig' => $startOrig, 'date_end' => $end, 'date_end_orig' => $endOrig, 'is_overdue' => $isOverdue, 'date_completed' => $dateCompleted, 'task_master' => array('id' => $row->creator_id, 'name' => $row->task_master));
     }
     generate_json(array('status' => 1, 'items' => $items));
 }
开发者ID:rodino25,项目名称:tsv2,代码行数:35,代码来源:Lists.php


示例4: task

 public function task($pid = 0)
 {
     requirelogin();
     updateLastActive();
     $keyword = $this->input->get('q');
     $tid = (int) $this->input->get('folder');
     $page = (int) $this->input->get('page');
     $page = $page > 1 ? $page : 1;
     $pageOrig = $page > 1 ? $page - 1 : 0;
     $itemsPerPage = 10;
     $sqStart = $pageOrig * $itemsPerPage;
     if ($tid > 0) {
         $query = $this->fdb->get_task_files($pid, $tid, 0, $keyword, $sqStart, $itemsPerPage);
         $items = $this->processItems($query);
         $qAllItems = $this->fdb->get_task_files($pid, $tid, 0, $keyword, 0, 0);
         $allItems = (int) $qAllItems->num_rows();
         $total_page = $allItems > 0 ? ceil($allItems / $itemsPerPage) : 1;
         generate_json(array('status' => 1, 'items' => $items, 'total_page' => number_format($total_page), 'current_page' => $page, 'previous_page' => $page > 1 ? $page - 1 : '', 'next_page' => $page < $total_page ? $page + 1 : '', 'total_items' => number_format($allItems)));
     } else {
         $query = $this->fdb->get_tasks($pid, $keyword, $sqStart, $itemsPerPage);
         $items = array();
         foreach ($query->result() as $row) {
             $items[] = array('id' => $row->id, 'attachment_type' => 'folder', 'uploader_id' => 0, 'uploader_name' => '', 'filename' => $row->title, 'filesize' => '', 'uploaded' => '', 'icon' => 'folder');
         }
         $qAllItems = $this->fdb->get_tasks($pid, $keyword, 0, 0);
         $allItems = (int) $qAllItems->num_rows();
         $total_page = $allItems > 0 ? ceil($allItems / $itemsPerPage) : 1;
         generate_json(array('status' => 1, 'items' => $items, 'total_page' => number_format($total_page), 'current_page' => $page, 'previous_page' => $page > 1 ? $page - 1 : '', 'next_page' => $page < $total_page ? $page + 1 : '', 'total_items' => number_format($allItems)));
     }
 }
开发者ID:rodino25,项目名称:tsv2,代码行数:30,代码来源:Files.php


示例5: index

 public function index()
 {
     $myID = getUserID();
     $id = $this->input->get('id');
     $this->mdb->update_notif(array('id' => $id, 'notify_to' => $myID), array('is_read' => 1, 'is_new' => 0));
     generate_json(array('status' => 1));
 }
开发者ID:rodino25,项目名称:tsv2,代码行数:7,代码来源:Read.php


示例6: index

 public function index()
 {
     $myID = getUserID();
     $id = (int) $this->input->get('id');
     $query = $this->mdb->delete_contact($myID, $id);
     generate_json(array('status' => $query ? 1 : 0));
 }
开发者ID:rodino25,项目名称:tsv2,代码行数:7,代码来源:Delete.php


示例7: index

 public function index()
 {
     $myID = getUserID();
     $id = (int) $this->input->get('id');
     if ($id == $myID) {
         generate_json(array('status' => 0, 'message' => 'You cannot add yourself.'));
     } else {
         $query = $this->mdb->get_contact($myID, $id);
         if ($query->num_rows()) {
             generate_json(array('status' => 0, 'message' => 'You are already in contact with this user.'));
         } else {
             $query = $this->model->getUserInfo(array('id' => $id));
             if ($query->num_rows()) {
                 $this->mdb->add_contact($myID, $id);
                 notify('contact_added', $id);
                 // Send mail
                 $myName = $this->session->userdata('display_name');
                 $redirectLink = base_url('#/app/profile/' . $myID);
                 do_sendmail($id, "New Contact", "{$myName} added you to his/her address book. Visit <a href='{$redirectLink}'>" . $myName . "</a>");
                 generate_json(array('status' => 1));
             } else {
                 generate_json(array('status' => 0, 'message' => 'User not found.'));
             }
         }
     }
 }
开发者ID:rodino25,项目名称:tsv2,代码行数:26,代码来源:Add.php


示例8: index

 public function index()
 {
     $myID = getUserID();
     $id = $this->input->get('id');
     $this->mdb->delete_event($myID, $id);
     generate_json(array('status' => 1));
 }
开发者ID:rodino25,项目名称:tsv2,代码行数:7,代码来源:Remove.php


示例9: index

 public function index()
 {
     $myID = getUserID();
     $title = trim(jsonInput('title'));
     $description = jsonInput('description');
     $location = jsonInput('location');
     $start = strtotime(jsonInput('start'));
     $end = strtotime(jsonInput('end'));
     if (empty($title)) {
         generate_json(array('status' => 0, 'message' => 'Please type event title.'));
     } else {
         if (!$start) {
             generate_json(array('status' => 0, 'message' => 'Start Date is required.'));
         } else {
             if ($end && $start > $end) {
                 generate_json(array('status' => 0, 'message' => 'Dates mismatch.'));
             } else {
                 $start = date("Y-m-d", $start);
                 $end = $end ? date("Y-m-d", $end) : $start;
                 $this->mdb->add_event(array('title' => $title, 'description' => $description, 'location' => $location, 'type' => 'default', 'start' => $start, 'end' => $end, 'date_added' => today(), 'source' => 'local', 'user_id' => $myID));
                 generate_json(array('status' => 1));
             }
         }
     }
 }
开发者ID:rodino25,项目名称:tsv2,代码行数:25,代码来源:Add_event.php


示例10: disagree

 public function disagree($id = 0, $cid = 0)
 {
     $myID = getUserID();
     $cid = (int) $cid;
     $query = $this->mdb->get_feed_info($id);
     $errMsg = '';
     if ($query->num_rows() == 0) {
         generate_json(array('status' => 0, 'message' => 'Post not found.'));
     } else {
         $row = $query->row();
         if (!validate_access('valid_member', array('project_id' => $row->project_id, 'user_id' => $myID))) {
             generate_json(array('status' => 0, 'message' => 'You are not authorized to do this.'));
         } else {
             $do = $this->mdb->disagree($row->id, $cid, $myID);
             $result = $this->mdb->get_adc_counts($row->id, $cid);
             if ($do > 0) {
                 if ($cid > 0) {
                     //notify commentor
                     $qComment = $this->mdb->get_comment_details($row->id, $cid);
                     if ($qComment->num_rows()) {
                         $commentRow = $qComment->row();
                         notify('comment_disagree', $commentRow->user_id, array('project_id' => $row->project_id, 'post_id' => $row->id, 'task_id' => $row->task_id, 'comment_id' => $cid));
                     }
                 } else {
                     //notify poster
                     notify('post_disagree', $row->poster_id, array('project_id' => $row->project_id, 'post_id' => $row->id, 'task_id' => $row->task_id));
                 }
             }
             generate_json(array('status' => 1, 'response' => $result->row()));
         }
     }
 }
开发者ID:rodino25,项目名称:tsv2,代码行数:32,代码来源:Post.php


示例11: do_update

 public function do_update()
 {
     requirelogin();
     updateLastActive();
     $myID = getUserID();
     $pid = (int) jsonInput('id');
     $myRole = (int) get_project_roles($pid, $myID);
     $query = $this->mdb->project_get($pid);
     if ($query->num_rows()) {
         $row = $query->row();
         if ($myRole > 0 || $myID == $row->creator_id) {
             $title = trim(jsonInput('title'));
             $description = jsonInput('description');
             $status = (int) jsonInput('status');
             $privacy = (int) jsonInput('privacy');
             $task_approval = jsonInput('task_approval') ? 1 : 0;
             $project_approval = jsonInput('project_approval') ? 1 : 0;
             if (empty($title)) {
                 generate_json(array('status' => 0, 'message' => 'Project title is required.'));
             } elseif ($status < 0 || $status > 1) {
                 generate_json(array('status' => 0, 'message' => 'Invalid status.'));
             } elseif ($privacy < 0 || $privacy > 2) {
                 generate_json(array('status' => 0, 'message' => 'Invalid privacy settings.'));
             } else {
                 $sql = $this->mdb->project_update($pid, array('project_name' => $title, 'description' => $description, 'completed' => $status, 'privacy' => $privacy));
                 $this->mdb->projSettings_update(array('project_id' => $pid), array('task_approval' => $task_approval, 'project_approval' => $project_approval));
                 generate_json(array('status' => 1));
             }
         } else {
             generate_json(array('status' => 0, 'message' => 'You are not allowed here.'));
         }
     } else {
         generate_json(array('status' => 0, 'message' => 'Project not found.'));
     }
 }
开发者ID:rodino25,项目名称:tsv2,代码行数:35,代码来源:Settings.php


示例12: index

 public function index()
 {
     $myID = getUserID();
     $get1stDayOfWeek = date("Y-m-d 00:00:00");
     //$this->getFirstDayOfWeek();
     $getLastDayOfWeek = date("Y-m-d 23:59:59", strtotime("+11 day"));
     $items = array();
     //events
     $query = $this->mdb->get_events($myID, $get1stDayOfWeek, $getLastDayOfWeek);
     foreach ($query->result() as $row) {
         $startDate = date("m/d/Y", strtotime($row->start));
         $endDate = strtotime($row->end) ? date("m/d/Y", strtotime($row->end)) : 'TBA';
         $items[] = array('type' => 'event', 'title' => $row->title, 'description' => $row->description, 'start' => $startDate, 'end' => $endDate, 'location' => $row->location, 'url' => '', 'order_date' => $row->order_date);
     }
     //tasks
     $query = $this->mdb->get_task_events($myID, $get1stDayOfWeek, $getLastDayOfWeek);
     foreach ($query->result() as $row) {
         $startDate = date("m/d/Y", strtotime($row->date_start));
         $endDate = strtotime($row->date_end) ? date("m/d/Y", strtotime($row->date_end)) : 'TBA';
         $items[] = array('type' => 'task', 'title' => $row->title, 'description' => $row->description, 'start' => $startDate, 'end' => $endDate, 'location' => '', 'url' => '#/app/projects/' . $row->project_id . '/task/' . $row->id, 'order_date' => $row->order_date);
     }
     //sort arrays
     usort($items, function ($a, $b) {
         $a = strtotime($a['order_date']);
         $b = strtotime($b['order_date']);
         if ($a == $b) {
             return 0;
         }
         return $a < $b ? -1 : 1;
     });
     generate_json(array('status' => 1, 'items' => $items));
 }
开发者ID:rodino25,项目名称:tsv2,代码行数:32,代码来源:Upcoming.php


示例13: index

 public function index()
 {
     $myID = getUserID();
     $filepath = "uploads/gallery/{$myID}/";
     if (!file_exists($filepath)) {
         mkdir($filepath, 0777, true);
     }
     if (!file_exists($filepath . 'thumbs/')) {
         mkdir($filepath . 'thumbs/', 0777, true);
     }
     $config = array('upload_path' => $filepath, 'allowed_types' => 'gif|jpg|png|jpeg', 'encrypt_name' => true);
     $this->load->library('upload', $config);
     if ($this->upload->do_upload('photoimg')) {
         $data = $this->upload->data();
         $thumbSize = 128;
         $thumbPath = "uploads/gallery/{$myID}/thumbs/" . $data["file_name"];
         $config = array('image_library' => 'gd2', 'source_image' => $data['full_path'], 'new_image' => $thumbPath, 'create_thumb' => true, 'thumb_marker' => "", 'maintain_ratio' => true, 'width' => $thumbSize, 'height' => $thumbSize);
         $this->load->library('image_lib', $config);
         $this->image_lib->resize();
         $this->cropImg($data['full_path'], $thumbPath, $data['image_width'], $data['image_height'], $thumbSize);
         $this->mdb->update_user_info(array('user_id' => $myID), array('profile_pic' => $data['file_name']));
         generate_json(array('status' => 1));
     } else {
         $errors = $this->upload->display_errors('', '|');
         $errorsArr = explode("|", $errors);
         $msg = isset($errorsArr[0]) ? $errorsArr[0] : '';
         generate_json(array('status' => 0, 'message' => $msg));
     }
 }
开发者ID:rodino25,项目名称:tsv2,代码行数:29,代码来源:Upload_avatar.php


示例14: lists

 public function lists()
 {
     requireadmin();
     $this->load->helper('directory');
     $database = directory_map('backup/database');
     $files = directory_map('backup/files');
     generate_json(array('status' => 1, 'database' => is_array($database) ? array_reverse($database) : array(), 'files' => is_array($files) ? array_reverse($files) : array()));
 }
开发者ID:rodino25,项目名称:tsv2,代码行数:8,代码来源:Backup.php


示例15: np_validations

 private function np_validations()
 {
     $name = trim(jsonInput('name'));
     if (empty($name) || strlen($name) < 2) {
         generate_json(array('status' => 0, 'message' => 'Project name must be atleast 2 characters long.'));
         exit;
     }
     return true;
 }
开发者ID:rodino25,项目名称:tsv2,代码行数:9,代码来源:New_project.php


示例16: index

 public function index()
 {
     $q = trim($this->input->get('q'));
     if (!empty($q)) {
         $qUsers = $this->mdb->searchUser($q, 0, 0);
         $qProjs = $this->mdb->searchProjects($q, 0, 0);
         generate_json(array('total' => number_format($qUsers->num_rows() + $qProjs->num_rows()), 'users' => number_format($qUsers->num_rows()), 'projects' => number_format($qProjs->num_rows())));
     }
 }
开发者ID:rodino25,项目名称:tsv2,代码行数:9,代码来源:Stat.php


示例17: index

 public function index()
 {
     $myID = getUserID();
     $id = (int) $this->input->get('id');
     $id = $id ? $id : $myID;
     $query = $this->mdb->get_userinfo($id);
     if ($query->num_rows()) {
         $row = $query->row();
         $checkIfAddedtoContact = $this->mdb->checkIfAlreadyInContacts($myID, $row->id);
         $fullname = '';
         /* fullname area */
         if (!empty($row->lastname)) {
             $fullname .= $row->lastname . ', ';
         }
         if (!empty($row->firstname)) {
             $fullname .= $row->firstname;
         }
         if (!empty($row->middlename)) {
             $fullname .= " " . $row->middlename;
         }
         /* fullname end */
         $contactNo = array();
         $contactNoQ = unserialize($row->contact_number);
         if (is_array($contactNoQ) && count($contactNoQ)) {
             foreach ($contactNoQ as $rContact) {
                 if (isset($rContact['privacy']) && $rContact['privacy'] == 0) {
                     $contactNo[] = $rContact['contact'];
                 }
             }
         }
         $address = '';
         $addressQ = unserialize($row->location);
         if ($addressQ) {
             $address = $addressQ['privacy'] == 0 ? $addressQ['location'] : 'Private';
         }
         #STATS
         $connections = $this->mdb->getConnections($row->id);
         $stats = array('achievements' => number_format(0), 'connections' => number_format($connections));
         #SOCIAL ACCOUNT
         $qSocial = $this->mdb->get_socials();
         $social = array();
         foreach ($qSocial->result() as $socialRow) {
             $qUserSocial = $this->mdb->get_user_social($socialRow->id, $row->id);
             $socialValue = '';
             if ($qUserSocial->num_rows()) {
                 $userSocialRow = $qUserSocial->row();
                 $socialValue = $userSocialRow->description;
             }
             $social[$socialRow->title] = $socialValue;
         }
         $items = array('id' => $row->id, 'title' => $row->id == $myID ? 'My Profile' : $row->display_name, 'display_name' => $row->display_name, 'profile_pic' => 'pictures/avatar/' . $row->id, 'profile_pic_full' => 'pictures/avatar/' . $row->id . '/full', 'is_me' => $row->id == $myID ? 1 : 0, 'is_friend' => $checkIfAddedtoContact ? 1 : 0, 'fullname' => empty($fullname) ? '-' : $fullname, 'firstname' => $row->firstname, 'lastname' => $row->lastname, 'middlename' => $row->middlename, 'email' => $row->id == $myID || $row->email_privacy == 0 ? $row->email_address : 'Hidden', 'email_privacy' => $row->email_privacy, 'company' => $row->company, 'gender' => ucfirst($row->gender), 'address' => empty($address) ? '-' : $address, 'address2' => isset($addressQ['location']) ? $addressQ['location'] : '', 'address_privacy' => $addressQ['privacy'], 'contacts' => count($contactNo) ? implode(", ", $contactNo) : 'None', 'contacts_arr' => $contactNoQ, 'stat' => $stats, 'social' => $social);
         generate_json(array('status' => 1, 'items' => $items));
     } else {
         generate_json(array('status' => 0, 'message' => 'User not found.'));
     }
 }
开发者ID:rodino25,项目名称:tsv2,代码行数:56,代码来源:Info.php


示例18: index

 public function index()
 {
     $id = (int) $this->input->get('id');
     $query = $this->mdb->project_get($id);
     $content = array();
     if ($query->num_rows()) {
         $row = $query->row();
         $content = array('description' => empty($row->description) ? '(none)' : htmlentities($row->description), 'tasks' => number_format($row->tasks), 'members' => number_format($row->members), 'files' => number_format($row->files), 'posts' => number_format($row->posts));
     }
     generate_json(array('status' => 1, 'content' => $content));
 }
开发者ID:rodino25,项目名称:tsv2,代码行数:11,代码来源:Overview.php


示例19: index

 public function index()
 {
     $myID = getUserID();
     $type = $this->input->get('q');
     $query = $this->mdb->get_data($myID, $type);
     $items = array();
     foreach ($query->result() as $row) {
         $items[] = array('id' => $row->id, 'title' => $row->description, 'status' => $row->status == 1 ? true : false, 'date_create' => $row->date_added);
     }
     generate_json(array('status' => 1, 'items' => $items));
 }
开发者ID:rodino25,项目名称:tsv2,代码行数:11,代码来源:Data.php


示例20: index

 public function index()
 {
     $myID = getUserID();
     $title = trim(jsonInput('title'));
     if (empty($title)) {
         generate_json(array('status' => 0, 'message' => 'Title is empty.'));
     } else {
         $query = $this->mdb->insert($myID, $title);
         generate_json(array('status' => 1));
     }
 }
开发者ID:rodino25,项目名称:tsv2,代码行数:11,代码来源:Create.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP generate_key函数代码示例发布时间:2022-05-15
下一篇:
PHP generate_id函数代码示例发布时间:2022-05-15
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap