function showEventBrief($idEvent, $showRelationship = true) { if (!isUserLoggedIn()) { throw new RuntimeException("You need to be logged in."); } if (!canSeeEvent($_SESSION["userid"], $idEvent)) { throw new RuntimeException("You do not have access to this event."); } $event = getEvent($idEvent); $canEdit = isUserLoggedIn() && $event["owner"] === getUserID(); echo '<div class="event_brief" id="event' . $idEvent . '">'; echo '<div class="name"><a href="view_event.php?id=' . $idEvent . '">'; echo '<h2>' . htmlspecialchars($event["name"]) . '</h2>'; echo '</a></div>'; if ($showRelationship) { if ($canEdit) { echo '<div class="owner"></div>'; } else { if (isUserRegisteredInEvent(getUserID(), $idEvent)) { echo '<div class="registered"></div>'; } else { echo '<div class="not_registered"></div>'; } } } echo '<img src="database/event_image.php?id=' . $idEvent . '" alt="' . htmlspecialchars($event["name"]) . '" width="64" height="64" />'; echo '<div class="description">'; echo '<p class="description">' . htmlspecialchars($event["description"]) . '</p>'; echo '</div>'; echo '<datetime>' . htmlspecialchars($event["date"]) . '</datetime>'; echo '</div>'; }
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())); } } }
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.')); } } } }
function createPostXML($row) { global $site_url, $image_folder, $thumbnail_url, $post, $misc; $parent_id = $row['parent']; if ($parent_id == 0) { $parent_id = ''; } $has_notes = $post->has_notes($row['id']); if ($has_notes) { $has_notes = 'true'; } else { $has_notes = 'false'; } $has_comments = !empty($row['last_comment']); if ($has_comments) { $has_comments = 'true'; } else { $has_comments = 'false'; } $has_children = $post->has_children($row['id']); if ($has_children) { $has_children = 'true'; } else { $has_children = 'false'; } $file_url = $site_url . '/' . $image_folder . '/' . $row['directory'] . '/' . $row['image']; return '<post height="' . $row['height'] . '" score="' . $row['score'] . '" file_url="' . $file_url . '" parent_id="' . $parent_id . '" sample_url="' . $file_url . '" sample_width="' . $row['width'] . '" sample_height="' . $row['height'] . '" preview_url="' . $thumbnail_url . $misc->getThumb($row['image'], $row['directory']) . '" rating="' . strtolower(substr($row['rating'], 0, 1)) . '" tags="' . fixTags($row['tags']) . '" id="' . $row['id'] . '" width="' . $row['width'] . '" change="UNIMPLEMENTED" md5="' . $row['hash'] . '" creator_id="' . getUserID($row['owner']) . '" has_children="' . $has_children . '" created_at="' . $row['creation_date'] . '" status="UNIMPLEMENTED" source="' . $row['source'] . '" has_notes="' . $has_notes . '" has_comments="' . $has_comments . '" preview_width="150" preview_height="150"/>' . "\r\n"; }
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)); } }
function constructQuery() { global $smarty; $query = array(); $query_select = "SELECT p.*, s.username, f.*\n FROM photos AS p, signup AS s, photo_flags AS f\n WHERE p.PID = f.PID AND f.UID = s.UID"; $query_count = "SELECT COUNT(f.PID) AS total_photos\n FROM photos AS p, signup AS s, photo_flags AS f\n WHERE p.PID = f.PID AND f.UID = s.UID"; $query_option = array(); $option = array('flagger' => '', 'sort' => 'p.PID', 'order' => 'DESC', 'display' => 10); if (isset($_POST['search_flags'])) { $option['flagger'] = trim($_POST['flagger']); $option['sort'] = trim($_POST['sort']); $option['order'] = trim($_POST['order']); $option['display'] = trim($_POST['display']); } if ($option['flagger'] != '') { $UID = getUserID($option['flagger']); $UID = $UID ? intval($UID) : 0; $query_option[] = "AND f.UID = " . $UID; } $query_option[] = " ORDER BY " . $option['sort'] . " " . $option['order']; $query['select'] = $query_select . implode(' ', $query_option); $query['count'] = $query_count . implode(' ', $query_option); $query['page_items'] = $option['display']; $smarty->assign('option', $option); return $query; }
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)); } } } }
public function index() { $myID = getUserID(); $id = $this->input->get('id'); $this->mdb->delete_event($myID, $id); generate_json(array('status' => 1)); }
private function InsertShortUrl($url) { $this->db_con(); $sql_url = "INSERT INTO {$this->table} (`id`, `long_url`, `short_code`, `date_created`, `userid`, `title`, options) \n\t\t\t\tVALUES (null,?,?,now(),?,?,?)"; #$mysqli =new mysqli(); $mysqli = $this->db; if (!$this->hasHTTP($url)) { $url = 'http://' . $url; } $options_url = array("ouv" => false, "hf" => false); $options_url = serialize($options_url); $longurl = $mysqli->real_escape_string($url); $shortcode = $this->genShortCode(); $title = $this->getTitle($url); $usrid = getUserID(); $stmt = $mysqli->prepare($sql_url); $stmt->bind_param('ssiss', $longurl, $shortcode, $usrid, $title, $options_url); if ($stmt->execute()) { $this->scode = $shortcode; $sql_url_options = "INSERT INTO \n\t\t\t\t\t\t`url_options`(`id`, `url_id_fk`, `only_unique_visit`, `hide_referrer`, `except_country`, `con_redirect_url`)\n\t\t\t\t\t\t VALUES (NULL," . $stmt->insert_id . ", 0, 0,NULL,NULL)"; $mysqli->query($sql_url_options); return true; } else { if ($stmt->errno == 1062) { if (strrpos($stmt->error, 'short_code')) { return $this->InsertShortUrl($url); } } } }
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)); }
public function index($pid = 0) { $myID = getUserID(); $id = (int) jsonInput('id'); $pid = (int) $pid; $tid = (int) $tid; }
public function beforeSave() { parent::beforeSave(); if ($this->isNew()) { $this->user_id = getUserID(); } }
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.')); } }
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)); }
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)); }
function projectLogs_add($type, $pid, $data = array()) { $myID = getUserID(); $ci = get_instance(); switch ($type) { // data: task_name, task_id case 'task_complete': $redir = "#/app/projects/{$pid}/task/" . $data['task_id']; $tagData = array(htmlentities($data['task_name'])); $ci->db->insert('project_logs', array('type' => $type, 'project_id' => $pid, 'actor_id' => $myID, 'redirect' => $redir, 'tag_data' => serialize($tagData), 'date_added' => today())); break; case 'task_uncomplete': // data: task_name, task_id $redir = "#/app/projects/{$pid}/task/" . $data['task_id']; $tagData = array(htmlentities($data['task_name'])); $ci->db->insert('project_logs', array('type' => $type, 'project_id' => $pid, 'actor_id' => $myID, 'redirect' => $redir, 'tag_data' => serialize($tagData), 'date_added' => today())); break; case 'task_add': // data: task_name, task_id $redir = "#/app/projects/{$pid}/task/" . $data['task_id']; $tagData = array(htmlentities($data['task_name'])); $ci->db->insert('project_logs', array('type' => $type, 'project_id' => $pid, 'actor_id' => $myID, 'redirect' => $redir, 'tag_data' => serialize($tagData), 'date_added' => today())); break; case 'task_delete': // data: task_name, task_id $redir = ""; $tagData = array(htmlentities($data['task_name'])); $ci->db->insert('project_logs', array('type' => $type, 'project_id' => $pid, 'actor_id' => $myID, 'redirect' => $redir, 'tag_data' => serialize($tagData), 'date_added' => today())); break; case 'member_leave': $redir = "#/app/profile/{$myID}"; $tagData = array($ci->session->userdata('display_name')); $ci->db->insert('project_logs', array('type' => $type, 'project_id' => $pid, 'actor_id' => $myID, 'redirect' => $redir, 'tag_data' => serialize($tagData), 'date_added' => today())); break; case 'member_new': // data: user_name, user_id $redir = "#/app/profile/" . $data['user_id']; $tagData = array($data['user_name']); $ci->db->insert('project_logs', array('type' => $type, 'project_id' => $pid, 'actor_id' => $myID, 'redirect' => $redir, 'tag_data' => serialize($tagData), 'date_added' => today())); break; case 'member_remove': // data: user_name, user_id $redir = "#/app/profile/" . $data['user_id']; $tagData = array($data['user_name']); $ci->db->insert('project_logs', array('type' => $type, 'project_id' => $pid, 'actor_id' => $myID, 'redirect' => $redir, 'tag_data' => serialize($tagData), 'date_added' => today())); break; case 'member_promote': // data: user_name, user_id, user_role, target_role $redir = "#/app/profile/" . $data['user_id']; $tagData = array($data['user_name'], $data['user_role'], $data['target_role']); $ci->db->insert('project_logs', array('type' => $type, 'project_id' => $pid, 'actor_id' => $myID, 'redirect' => $redir, 'tag_data' => serialize($tagData), 'date_added' => today())); break; case 'member_demote': // data: user_name, user_id, user_role, target_role $redir = "#/app/profile/" . $data['user_id']; $tagData = array($data['user_name'], $data['user_role'], $data['target_role']); $ci->db->insert('project_logs', array('type' => $type, 'project_id' => $pid, 'actor_id' => $myID, 'redirect' => $redir, 'tag_data' => serialize($tagData), 'date_added' => today())); break; } }
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)); }
public function beforeSave() { parent::beforeSave(); if ($this->isNew()) { $this->user_id = getUserID(); } $this->slug = trim($this->cloakerAPIPath(), '/'); }
function loadMainView($template, $connection) { // Get the logged in user's user_id $usr_ID = getUserID($connection); // Fill in the user's routes. $template->setCurrentBlock("COURSELISTING"); $template->setVariable("DESC", ""); $template->parseCurrentBlock(); }
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.')); } }
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)); } }
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)); }
function dbFlexigrid($innerFunction, $headers = TRUE) { $userid = getUserID(); $profilingID = beginProfilingEntry(array("activity" => "database", "userid" => $userid)); $page = getSoft($_REQUEST, "page", -1); //flexigrid required $rp = getSoft($_REQUEST, "rp", -1); //flexigrid required: results per page if (!is_numeric($page) || $page <= 0) { $page = 1; } if (!is_numeric($rp) || $rp < 0) { $rp = 1; } // $rp == 0 means you just want the count, it is not a real interface with flexigrid $sortname = trim(getSoft($_REQUEST, "sortname", NULL)); if ($sortname == "undefined") { $sortname = NULL; } $sortorder = trim(getSoft($_REQUEST, "sortorder", "")); // not yet utilized: sortname, sortorder, qtype, query if (strtoupper($sortorder) != "ASC") { $sortorder = "DESC"; } global $db_query_info; $result = $innerFunction(" LIMIT " . ($page - 1) * $rp . ", " . $rp . " ", $sortname, $sortorder); if ($headers) { header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); header("Last-Modified: " . gmdate("D, d M Y H:i:s") . "GMT"); header("Cache-Control: no-cache, must-revalidate"); header("Pragma: no-cache"); header("Content-type: text/x-json"); } $activity = "database-"; if (array_key_exists('type', $db_query_info)) { $activity .= $db_query_info['type']; unset($db_query_info['type']); } if (is_array($result)) { // success case $result['page'] = $page; $db_query_info['result'] = 'success'; endProfilingEntry($profilingID, array("activity" => $activity, "meta" => $db_query_info)); return json_encode($result); } else { $db_query_info['result'] = 'error'; endProfilingEntry($profilingID, array("activity" => $activity, "meta" => $db_query_info)); return json_encode("Error: " . $result); // failure case; just sending a string. } }
public function index() { $myID = getUserID(); $id = (int) jsonInput('id'); $title = trim(jsonInput('title')); $status = jsonInput('status'); $status = $status == "true" ? 1 : 0; if (empty($title)) { generate_json(array('status' => 0, 'message' => 'Title is empty.')); } else { $query = $this->mdb->update(array('id' => $id, 'user_id' => $myID), array('status' => $status, 'description' => $title)); generate_json(array('status' => $query)); } }
public function index() { $myID = getUserID(); $displayName = trim(jsonInput('display_name')); $firstname = trim(jsonInput('firstname')); $lastname = trim(jsonInput('lastname')); $middlename = jsonInput('middlename'); $email = jsonInput('email'); $email_privacy = (int) jsonInput('email_privacy'); $gender = jsonInput('gender'); $contact = jsonInput('contact'); $address = strtolower(jsonInput('address')); $address_privacy = (int) jsonInput('address_privacy'); $company = trim(jsonInput('company')); $serializedContacts = ''; $location = array('location' => $address, 'privacy' => $address_privacy); if (is_array($contact) && count($contact) > 0) { $contactArr = array(); foreach ($contact as $cont) { if (trim($cont->contact)) { if (!is_numeric($cont->contact)) { generate_json(array('status' => 0, 'message' => $cont->contact . ' is not a valid number.')); exit; } $contactArr[] = array('contact' => $cont->contact, 'privacy' => (int) $cont->privacy); } } $serializedContacts = serialize($contactArr); } if (strlen($displayName) < 3) { generate_json(array('status' => 0, 'message' => 'Display name too short.')); } elseif (empty($firstname)) { generate_json(array('status' => 0, 'message' => 'First name is required.')); } elseif (empty($lastname)) { generate_json(array('status' => 0, 'message' => 'Last name is required.')); } elseif ($this->mdb->check_if_emailTaken($myID, $email)) { generate_json(array('status' => 0, 'message' => 'Email address is already in use.')); } else { //update users info table $where = array('user_id' => $myID); $this->mdb->update_user_info($where, array('firstname' => $firstname, 'lastname' => $lastname, 'middlename' => $middlename, 'gender' => $gender, 'location' => serialize($location), 'contact_number' => $serializedContacts, 'company' => $company, 'email_privacy' => $email_privacy)); //update users table $where = array('id' => $myID); $this->mdb->update_user($where, array('display_name' => $displayName, 'email_address' => $email)); //update session $sessionUpdate = array('display_name' => $displayName, 'email_address' => $email); $this->session->set_userdata($sessionUpdate); generate_json(array('status' => 1, 'message' => 'Successfully Updated.')); } }
public function index() { $myID = getUserID(); $q = $this->input->get('q'); $value = $this->input->get('value'); $query = $this->mdb->get_social(array('title' => $q)); if ($query->num_rows()) { $row = $query->row(); $this->mdb->update_social_data($row->id, $myID, $value); generate_json(array('status' => 1)); } else { generate_json(array('status' => 0, 'message' => 'Social Category not found.')); } }
public function index() { $myID = getUserID(); $date = today(); $title = trim(jsonInput('title')); $content = jsonInput('content'); $category = trim(jsonInput('category')); if (empty($title)) { generate_json(array('status' => 0, 'message' => 'Title is required.')); } else { $insert_id = $this->mdb->insert_note(array('user_id' => $myID, 'title' => $title, 'content' => $content, 'category' => $category, 'date_created' => $date)); generate_json(array('status' => 1, 'message' => 'Note successfully created.')); } }
public function index() { $myID = getUserID(); $new_pass = jsonInput('password'); $re_type_pass = jsonInput('password2'); if ($new_pass != $re_type_pass) { generate_json(array('status' => 0, 'message' => 'Password does not match.')); } elseif (strlen($new_pass) < 4) { generate_json(array('status' => 0, 'message' => 'Password too short.')); } else { $where = array('id' => $myID); $this->mdb->update_user($where, array('password' => ts_hash($new_pass))); generate_json(array('status' => 1, 'message' => 'Password successfuly changed.')); } }
function constructQuery() { global $smarty; $query = array(); $query_select = "SELECT * FROM notice"; $query_count = "SELECT COUNT(NID) AS total_notices FROM notice"; $query_add = " WHERE"; $query_option = array(); $option_orig = array('username' => '', 'title' => '', 'content' => '', 'sort' => 'UID', 'order' => 'DESC', 'display' => 10); $all = isset($_GET['all']) ? intval($_GET['all']) : 0; if ($all == 1) { unset($_SESSION['search_notices_option']); } $option = isset($_SESSION['search_notices_option']) ? $_SESSION['search_notices_option'] : $option_orig; if (isset($_POST['search_notices'])) { $option['username'] = trim($_POST['username']); $option['title'] = trim($_POST['title']); $option['content'] = trim($_POST['content']); $option['sort'] = trim($_POST['sort']); $option['order'] = trim($_POST['order']); $option['display'] = trim($_POST['display']); if ($option['username'] != '' || isset($_GET['UID'])) { if ($option['username'] != '') { $UID = getUserID($option['username']); } else { $UID = isset($_GET['UID']) && is_numeric($_GET['UID']) ? $_GET['UID'] : 0; } $UID = $UID ? intval($UID) : 0; $query_option[] = $query_add . " UID = " . $UID; $query_add = " AND"; } if ($option['title'] != '') { $query_option[] = $query_add . " title LIKE '%" . mysql_real_escape_string($option['title']) . "%'"; $query_add = " AND"; } if ($option['content'] != '') { $query_option[] = $query_add . " content LIKE '%" . mysql_real_escape_string($option['content']) . "%'"; $query_add = " AND"; } $_SESSION['search_notices_option'] = $option; } $query_sort = " ORDER BY " . $option['sort'] . " " . $option['order']; $query['select'] = $query_select . implode(' ', $query_option) . $query_sort; $query['count'] = $query_count . implode(' ', $query_option); $query['page_items'] = $option['display']; $smarty->assign('option', $option); return $query; }
function _showTeme() { isUserLoggedIn(); if (getUserType() == 'admin' || getUserType() == 'profesor') { $data['msg'][] = View::do_fetch(VIEW_PATH . 'afisareTemeProfesor.tpl.php'); View::do_dump(VIEW_PATH . 'layout.php', $data); } else { $grupaMea = new Grupa(getdbh()); $result = $grupaMea->getGrupaUserCurent(getUserID()); $idGrupaMea = (int) $result[0]['ID_GRUPA']; $tema = new Teme(getdbh()); $result['tema'] = $tema->getTemeStudentCurent($idGrupaMea); $data['msg'][] = View::do_fetch(VIEW_PATH . 'afisareTemeStudent.tpl.php', $result); View::do_dump(VIEW_PATH . 'layout.php', $data); } }