function go_mark_read() { global $wpdb; $messages = get_user_meta(get_current_user_id(), 'go_admin_messages', true); if ($_POST['type'] == 'unseen') { if ($messages[1][$_POST['date']][1] == 1) { $messages[1][$_POST['date']][1] = 0; (int) ($messages[0] = (int) $messages[0] - 1); } } elseif ($_POST['type'] == 'remove') { if ($messages[1][$_POST['date']][1] == 1) { (int) ($messages[0] = (int) $messages[0] - 1); } unset($messages[1][$_POST['date']]); } else { if ($_POST['type'] == 'seen') { if ($messages[1][$_POST['date']][1] == 0) { $messages[1][$_POST['date']][1] = 1; (int) ($messages[0] = (int) $messages[0] + 1); } } } update_user_meta(get_current_user_id(), 'go_admin_messages', $messages); echo JSON_encode(array(0 => $_POST['date'], 1 => $_POST['type'], 2 => $messages[0])); die; }
public function loging() { //var_dump($this->input->post()); $sql = "SELECT * FROM user "; $sql .= " WHERE "; $sql .= " userid='" . $this->input->post('email') . "'"; $sql .= " and password='******'password') . "'"; //echo $sql; $query = $this->db->query($sql); //echo "Numrows=".$query->num_rows(); if ($query->num_rows() > 0) { // get existing array from session var (returns false if first time called) $row = $query->row(); //$userid = $row('email'); //$username = $row('name'); $this->session->set_userdata('userlogin', $row); //$var = $this->session->userdata; //echo $var['username']; //**************************************** //$userlogin = $row; // add new $key=>$val to array //$userlogin['userid'] = $this->input->post('email'); //$userlogin['username'] = $this->input->post('name'); // pass it back to the session var //$this->session->set_userdata('userlogin',$userlogin); echo JSON_encode($row); //echo "Login completed ..."; //$this->output->set_header('refresh:5;url=../eportfolio/home'); // echo JSON_encode($userlogin); } else { //echo "Login error"; //$this->output->set_header('refresh:5;url=../user/loginform'); echo '{"result":true,"count":1}'; } }
/** * Smarty {json_encode} function plugin * * Type: function<br> * Name: json_encode<br> * Purpose: encode given object to JSON format * Input:<br> * - obj = object to encode (required) * @author Karel Kozlik <*****@*****.**> * @version 1.0 * @param array parameters * @param Smarty * @return string|null */ function smarty_function_json_encode($params, &$smarty) { if (!in_array('obj', array_keys($params))) { $smarty->trigger_error("array_count: missing 'obj' parameter"); return; } return JSON_encode($params['obj']); }
public function TH_customername_autocomplete() { $USERSTAMP=$this->Mdl_eilib_common_function->getSessionUserStamp(); $errorlist= $this->input->post('ErrorList'); $ErrorMessage= $this->Mdl_eilib_common_function->getErrorMessageList($errorlist); $result = $this->Mdl_report_tickler_history->customername_autocomplete($USERSTAMP,$ErrorMessage) ; echo JSON_encode($result); }
function bxtviz_add_chart() { global $bxttoptions; global $wpdb; $options = $bxttoptions; $charts = $wpdb->get_results("SELECT * FROM " . $wpdb->prefix . "bxtvisualization"); echo JSON_encode($charts); exit; }
private function action() { if ($db = new SQLiteDatabase(_MINDSRC_ . '/mind3rd/SQLite/mind')) { $result = $db->query("SELECT * FROM user where login='******' AND pwd='" . sha1($this->pwd) . "' AND status= 'A'"); $row = false; while ($result->valid()) { $row = $result->current(); $_SESSION['auth'] = JSON_encode($row); $_SESSION['login'] = $row['login']; break; } if (!$row) { Mind::write('auth_fail', true); return false; } } else { die('Database not found!'); } return $this; }
function go_clipboard_get_data() { global $wpdb; //grabs the selection // 0 = bonus currency // 1 = points // 2 = completed // 3 = mastered // 4 = currency // 5 = penalty $selection = $_POST['go_graph_selection']; if (isset($_POST['go_class_a'])) { $class_a_choice = $_POST['go_class_a']; } else { $class_a_choice = array(); } if (isset($_POST['go_choices_checked_names'])) { $go_choices_checked_names = $_POST['go_choices_checked_names']; } else { $go_choices_checked_names = array(); } $array = get_option('go_graphing_data', false); $users_in_class = array(); foreach ($class_a_choice as $value) { if (!array_key_exists($value, $users_in_class)) { $users_in_class[$value] = array(); } } $table_name_go_totals = $wpdb->prefix . 'go_totals'; $uids = $wpdb->get_results("SELECT uid FROM " . $table_name_go_totals . ""); // loops through game on users and places each user in their respective class_a foreach ($uids as $uid) { foreach ($uid as $id) { $user_class = get_user_meta($id, 'go_classifications', true); if ($user_class) { $class = array_keys($user_class); $check = array_intersect($class, array_keys($users_in_class)); if ($check) { if (count($check) > 1 || count($class) > 1) { foreach ($check as $value) { $users_in_class[$value][] = $id; } } else { $key = (string) $check[0]; $users_in_class[$key][] = $id; } } } } } // loops through users in each class and creates array of all their data foreach ($users_in_class as $class => $students) { // date is the unix timestamp of the last time data was collected using the go_clipboard_collect_data function foreach ($array as $id => $date) { if (in_array($id, $students)) { $getinfo = get_userdata($id); $id = $getinfo->user_login; $first = $getinfo->first_name; $last = $getinfo->last_name; $info[$id]['label'] = $last . ', ' . $first . ' (' . $id . ')'; $info[$id]['class_a'][] = $class; foreach ($date as $date => $content) { // Bonus Currency, penalty, points, completed, and mastered array associated with the unix timestamp when go_clipboard_collect_data function ran $content_array = explode(',', $content); // generates array of user data associated with a unix timestamp, then appends the unix timestamp$content_array's element which corresponds to the graph selection key above $info[$id]['data'][] = array($date * 1000, $content_array[$selection]); } } } } if ($go_choices_checked_names) { $info['checked'] = $go_choices_checked_names; } // stringifies the php array into a json object echo JSON_encode($info); die; }
/** * $this->state tárolása session -ba */ protected function saveState() { $session = JFactory::getSession(); $session->set($this->browserName . 'State', JSON_encode($this->state)); }
/** * browse task * @return void * @request integer limit * @request integer limitstart * @request integer order * @request integer filterStr * @request integer temakor * @request integer szavazas * @session object 'temakoroklist_status' */ public function browse() { jimport('hs.user.user'); JHTML::_('behavior.modal'); $total = 0; $pagination = null; $user = JFactory::getUser(); $db = JFactory::getDBO(); // alapértelmezett browser status beolvasása sessionból $session = JFactory::getSession(); $brStatusStr = $session->get($this->NAME . 'list_status'); if ($brStatusStr == '') { $brStatusStr = '{"limit":20,"limitstart":0,"order":1,"filterStr":"","temakor_id":0,"szavazas_id":0}'; } $brStatus = JSON_decode($brStatus); $limitStart = JRequest::getVar('limitstart', $brStatus->limitstart); $limit = JRequest::getVar('limit', $brStatus->limit); $order = JRequest::getVar('order', $brStatus->order); $filterStr = urldecode(JRequest::getVar('filterStr', $brStatus->filterStr)); if ($this->temakor_id == '') { $this->temakor_id = $brStatus->temakor_id; } if ($this->szavazas_id == '') { $this->szavazas_id = $brStatus->szavazas_id; } // browser status save to session and JRequest $brStatus->limit = $limit; $brStatus->limitStart = $limitStart; $brStatus->order = $order; $brStatus->filterStr = $filterStr; $brStatus->temakor_id = $this->temakor_id; $brStatus->szavazas_id = $this->szavazas_id; $session->set($this->NAME . 'list_status', JSON_encode($brStatus)); JRequest::setVar('limit', $limit); JRequest::setVar('limitstart', $limitstart); JRequest::setVar('order', $order); JRequest::setVar('filterStr', $filterStr); JRequest::setVar('temakor', $this->temakor_id); JRequest::setVar('szavazas', $this->szavazas_id); // adattábla tartalom elérése és átadása a view -nek $items = $this->model->getItems(); //DBG echo $this->model->getDBO()->getQuery(); if ($this->model->getError() != '') { $this->view->Msg = $this->model->getError(); } $this->view->set('Items', $items); $this->view->set('Temakor', $this->temakor); $this->view->set('Szavazas', $this->szavazas); $this->view->set('Title', JText::_('ALTERNATIVAK')); // browser müködéshez linkek definiálása if ($this->szavazas->vita1 == 1) { $itemLink = JURI::base() . 'index.php?option=com_alternativak&view=alternativak' . '&task=edit' . '&limit=' . JRequest::getVar('limit', '20') . '&limitstart=0' . '&filterStr=' . urlencode($filterStr) . '&order=' . JRequest::getVar('order', '1') . '&temakor=' . $this->temakor_id . '&szavazas=' . $this->szavazas_id; } else { $itemLink = ''; } $backLink = JURI::base() . 'index.php?option=com_szavazasok&view=szavazasoklist' . '&temakor=' . $this->temakor_id . '&task=browse'; $homeLink = JURI::base() . 'index.php?option=com_temakorok&view=temakoroklist' . '&task=browse'; $this->view->set('itemLink', $itemLink); $this->view->set('backLink', $backLink); $this->view->set('homeLink', $homeLink); // van ált. képviselője? $altKepviseloje = 0; $db->setQuery('select k.kepviselo_id, u.name from #__kepviselok k, #__users u where k.kepviselo_id = u.id and k.user_id = "' . $user->id . '" and k.temakor_id=0 and k.szavazas_id = 0 and k.lejarat >= "' . date('Y-m-d') . '"'); $res = $db->loadObject(); if ($db->getErrorNum() > 0) { $db->stderr(); } if ($res) { $altKepviseloje = $res->kepviselo_id; } // van témakör képviselője? $kepviseloje = 0; $db->setQuery('select k.kepviselo_id, u.name from #__kepviselok k, #__users u where k.kepviselo_id = u.id and k.user_id = "' . $user->id . '" and k.temakor_id=' . $this->temakor_id . ' and k.szavazas_id = 0 and k.lejarat >= "' . date('Y-m-d') . '"'); $res = $db->loadObject(); if ($db->getErrorNum() > 0) { $db->stderr(); } if ($res) { $kepviseloje = $res->kepviselo_id; } // Ő maga képviselő jelölt? $kepviseloJelolt = false; $db->setQuery('select user_id from #__kepviselojeloltek where user_id = "' . $user->id . '"'); $res = $db->loadObject(); if ($db->getErrorNum() > 0) { $db->stderr(); } if ($res) { $kepviseloJelolt = true; } // kik az alternativa felvivők? $alternativa_felvivo = $this->alternativa_felvivo(); // akciók definiálása $akciok = array(); if ($this->temakorokHelper->isAdmin($user) | $szavazas_felvivo == 10 & ($this->szavazas->szavazok = 1) & $user->id > 0 | $szavazas_felvivo == 10 & $this->userTag($this->temakor_id, $user) | $this->szavazasIndito($this->szavazas_id, $user)) { if ($this->szavazas->vita1 == 1) { $akciok['ujAlternativa'] = JURI::base() . 'index.php?option=com_' . $this->NAME . '&view=' . $this->NAME . '&task=add' . '&temakor=' . $this->temakor_id . '&szavazas=' . $this->szavazas_id . '&limit=' . JRequest::getVar('limit', 20) . '&limitstart=' . JRequest::getVar('limitstart', 0) . '&order=' . JRequest::getVar('order', 1) . '&filterStr=' . JRequest::getVar('filterStr', ''); } } if ($this->temakorokHelper->isAdmin($user) | $this->szavazas->letrehozo == $user->id) { $akciok['szavazasedit'] = JURI::base() . 'index.php?option=com_szavazasok&view=szavazasok&task=edit' . '&temakor=' . $this->temakor_id . '&szavazas=' . $this->szavazas_id; } if ($this->temakorokHelper->isAdmin($user) | $this->szavazas->letrehozo == $user->id) { $akciok['szavazastorles'] = JURI::base() . 'index.php?option=com_szavazasok&view=szavazasok&task=deleteform' . '&temakor=' . $this->temakor_id . '&szavazas=' . $this->szavazas_id; } if ($this->temakorokHelper->isAdmin($user) | $this->temakorIndito($this->temakor_id, $user)) { $akciok['temakoredit'] = JURI::base() . 'index.php?option=com_temakorok&view=temakorok&task=edit' . '&temakor=' . $this->temakor_id; } if ($this->temakorokHelper->isAdmin($user) | $this->temakorIndito($this->temakor_id, $user)) { $akciok['temakortorles'] = JURI::base() . 'index.php?option=com_temakorok&view=temakorok&task=deleteform' . '&temakor=' . $this->temakor_id; } if ($this->temakorokHelper->isAdmin($user) | $this->temakorIndito($this->temakor_id, $user)) { if ($this->szavazas->vita1 == 1) { $akciok['alternativaedit'] = JURI::base() . 'index.php?option=com_alternativak&view=alternativak&task=edit' . '&temakor=' . $this->temakor_id . '&szavazas=' . $this->szavazas_id; } } if ($this->temakorokHelper->isAdmin($user) | $this->temakorIndito($this->temakor_id, $user)) { if ($this->szavazas->vita1 == 1) { $akciok['alternativatorles'] = JURI::base() . 'index.php?option=com_alternativak&view=alternativak&task=deleteform' . '&temakor=' . $this->temakor_id . '&szavazas=' . $this->szavazas_id; } } if ($this->szavazas->szavazas == 1 & $user->id > 0) { $db = JFactory::getDBO(); $db->setQuery('select id from #__szavazatok where szavazas_id="' . $this->szavazas_id . '" and user_id="' . $user->id . '"'); $res = $db->loadObjectList(); if (count($res) == 0) { $akciok['szavazok'] = JURI::base() . 'index.php?option=com_szavazasok&view=szavazasok&task=szavazoform&temakor=' . $this->temakor_id . '&szavazas=' . $this->szavazas_id; } } if ($this->szavazas->lezart == 1) { $akciok['eredmeny'] = JURI::base() . 'index.php?option=com_szavazasok&view=szavazasok&task=eredmeny&temakor=' . $this->temakor_id . '&szavazas=' . $this->szavazas_id; } $akciok['tagok'] = JURI::base() . 'index.php?option=com_tagok&temakor=' . $this->temakor_id; $akciok['sugo'] = JURI::base() . 'index.php?option=com_content&view=article' . '&id=' . JText::_(strtoupper($this->NAME) . 'LIST_SUGO') . '&Itemid=435&tmpl=component'; $this->view->set('Akciok', $akciok); // globális képviselő/képviselő jelölt gombok definiálása $altKepviselo = array(); $altKepviselo['kepviselojeLink'] = ''; $kepviselo = array(); $kepviselo['kepviselojeLink'] = ''; $kepviselo['kepviseloJeloltLink'] = ''; $kepviselo['kepviselotValasztLink'] = ''; $kepviselo['ujJeloltLink'] = ''; if ($user->id > 0) { if ($altKepviseloje > 0) { $kepviseloUser = JFactory::getUser($altKepviseloje); if ($kepviseloUser) { $userEx = HsUser::getInstance($altKepviseloje); $altKepviselo['kepviselojeLink'] = JURI::base() . 'index.php?option=com_kepviselok&task=show&id=' . $altKepviseloje; if (isset($userEx->image)) { $altKepviselo['image'] = $userEx->get('image'); } else { $altKepviselo['image'] = '<img src="components/com_hs_users/asset/images/noimage.png" width="50" height="50" />'; } $altKepviselo['nev'] = $kepviseloUser->name; } } if ($kepviseloje > 0) { $kepviseloUser = JFactory::getUser($kepviseloje); if ($kepviseloUser) { $userEx = HsUser::getInstance($kepviseloje); $kepviselo['kepviselojeLink'] = JURI::base() . 'index.php?option=com_kepviselok&task=show&id=' . $kepviseloje; if (isset($userEx->image)) { $kepviselo['image'] = $userEx->get('image'); } else { $kepviselo['image'] = '<img src="components/com_hs_users/asset/images/noimage.png" width="50" height="50" />'; } $kepviselo['nev'] = $kepviseloUser->name; } } else { if ($kepviseloJelolt) { $kepviselo['kepviseloJeloltLink'] = JURI::base() . 'index.php?option=com_kepviselo&task=edit&id=' . $user->id; } else { $kepviselo['kepviselotValasztLink'] = JURI::base() . 'index.php?option=com_kepviselok&task=find&temekor=' . $this->temakor_id . '&szavazas=0'; $kepviselo['ujJeloltLink'] = JURI::base() . 'index.php?option=com_kepviselojeloltek&task=add&temekor=' . $this->temakor_id . '&szavazas=0&id=' . $user->id; } } } $this->view->set('Kepviselo', $kepviselo); $this->view->set('AltKepviselo', $altKepviselo); //lapozósor definiálása jimport('joomla.html.pagination'); $total = $this->model->getTotal($filterStr); $pagination = new JPagination($total, $limitStart, $limit); $pagination->setAdditionalUrlParam('order', $order); $pagination->setAdditionalUrlParam('filterStr', urlencode($filterStr)); $this->view->set('Lapozosor', $pagination->getListFooter()); $this->view->display(); }
public function bdyupdatefunction() { $USERSTAMP=$this->Mdl_eilib_common_function->getSessionUserStamp(); $result = $this->Mdl_email_template_entry_search_update->update_bdydata($USERSTAMP,$this->input->post('id'),$this->input->post('bodyvalue')) ; echo JSON_encode($result); }
<?php include 'db_connect.php'; if ($_POST['param'] == "getNames") { $stmt = $db->prepare('SELECT * FROM queriesJSON WHERE username = :username ORDER BY simName'); $stmt->execute(array(':username' => $_POST['username'])); foreach ($stmt as $row) { $data['simName'][] = $row['simName']; $data['qid'][] = $row['qid']; } echo JSON_encode($data); } if ($_POST['param'] == "saveSim") { $stmt = $db->prepare('INSERT INTO queriesJSON (username, simName, json) VALUES (:username, :simName, :json)'); $stmt->execute(array(':username' => $_POST['username'], ':simName' => $_POST['simName'], ':json' => $_POST['json'])); echo JSON_encode('Success'); } if ($_POST['param'] == "getSavedSim") { $stmt = $db->prepare('SELECT * FROM queriesJSON WHERE qid = :qid'); $stmt->execute(array(':qid' => $_POST['qid'])); foreach ($stmt as $row) { $data['data'] = $row['json']; $data['simName'] = $row['simName']; } echo JSON_encode($data); }
/** * Status Codes: * 0: Success. No issues. * 1: Student already has an order. * */ function respond($statusCode, $orderId = -1) { echo JSON_encode(array("status" => $statusCode, "orderId" => $orderId)); exit; }
$msg = "Invalid username or password. Try again."; $status = FALSE; } } else { $msg = "Missing password. "; $status = FALSE; } } else { $msg = "Missing username. "; $status = FALSE; } // If we got through all that without errors, start a session. if ($status == TRUE) { // Start a session. session_start() and not sessionInit() because this // is a file users should not access directly. session_start(); // Get the user's record and pull out the ID, add to the session. // (getUser() is in functions.php) $inUserRec = getUser($inName, $db); $_SESSION['uid'] = $inUserRec['id']; // Add the user's name to the session, flag that (s)he's logged in. $_SESSION['uname'] = $inName; $_SESSION['loggedin'] = TRUE; // Redirect to index.php in JavaScript, not here. } // Build the JSON response. $response = array('status' => $status, 'message' => $msg); // Send the JSON response. (NOTE: This Ajax messaging should be replaced // with a plain old PHP message in the session. A task for refactoring? echo JSON_encode($response);
<?php // Configuration values define('DATA_PATH', 'ppcmarket.txt'); // Get market data from file function market_info() { $info = json_decode(file_get_contents(DATA_PATH)); return $info; } // Return a JSON array of price / market cap / total supply echo JSON_encode(market_info());
public function babypersonalsave() { $USERSTAMP= $this->Mdl_eilib_common_function->getSessionUserStamp(); $result = $this->Mdl_personal_daily_entry_search_update_delete->babypersonalinsert($USERSTAMP) ; echo JSON_encode($result); }
<td title="<?php echo str_replace('"', "'", $card_bdd['attrs']); ?> "><pre><?php print_r($json); ?> </pre></td> </tr> <tr> <th>Compile log</th> <td><pre><?php $attrs = new attrs($card_bdd); ?> </pre></td> </tr> <tr> <th>Compiled</th> <td title="<?php echo str_replace('"', "'", JSON_encode($attrs)); ?> "><pre><?php print_r($attrs); ?> </pre></td> </tr> </form> </table> </body> </html>
public function deleteconformoption(){ $USERSTAMP=$this->Mdl_eilib_common_function->getSessionUserStamp(); $result = $this->Mdl_staff_detail_entry_search_update_delete->DeleteRecord($USERSTAMP,$this->input->post('rowid')) ; echo JSON_encode($result); }
/** * display show form * @request: ordering, limitstart, limit, filterStr, parent, id, Itemid * @session {$id}_poll * @result void */ public function show() { if (file_exists(JPATH_COMPONENT . DS . 'helpers' . DS . $this->viewName . '.php')) { include_once JPATH_COMPONENT . DS . 'helpers' . DS . $this->viewName . '.php'; $helperName = ucfirst($this->viewName) . 'Helper'; $this->helper = new $helperName(); } $model = $this->getModel($this->viewName); $model->setViewname($this->viewName); $view = $this->getView($this->viewName, 'html'); $view->setViewname($this->viewName); $view->setModel($model); // push lister staus to listStatusStack $session = JFactory::getSession(); $listStatusStack = JSON_decode($session->get('listStatusStack', '[]')); $listStatusStr = '{"ordering":"' . JRequest::getVar('ordering', 'id') . '",' . '"limitstart":"' . JRequest::getVar('limitstart', '0') . '",' . '"limit":"' . JRequest::getVar('limit', '20') . '",' . '"filterStr":"' . JRequest::getVar('filterStr', '') . '",' . '"parent":"' . JRequest::getVar('parent', '') . '"}'; $listStatusStack[] = JSON_decode($listStatusStr); $session->set('listStatusStack', JSON_encode($listStatusStack)); $item = $model->getItem(JRequest::getVar('id')); if ($this->helper) { if (!$this->helper->accessRight($item, 'show')) { $this->setMessage(JText::_(strtoupper($this->viewName) . '_ACCES_DENIED')); $this->cancel(); return; } } $view->Item = $item; $view->Title = JText::_(strtoupper($this->viewName) . '_SHOW'); $view->setLayout('show'); $view->display(); return; }
<?php include "includes.php"; ?> <?php $output = array(); $output["content"] = ""; //récup l'avis $rate = $_POST["vote"]; //récup l'id de l'item $itemId = $_POST["item-id"]; //$itemId = $_POST["itemId"]; $output["result"] += $itemId; //echo "RATE = ".$rate; //echo "ITEMID = ".$itemId; //envoi l'avis à la db $voteId = api__vote($itemId, $rate); if (USE_CACHE) { DatabaseData::getInstance()->cache__reloadVotes($itemId); DatabaseData::cache__save(); } //resultat $output = "item id : " . $itemId . ", vote id : " . $voteId; echo JSON_encode($output); //displayThanks(); //DatabaseData::clean();
<?php session_start(); require_once "php/DatabaseConnection.php"; $db = new DatabaseConnection(); $result = $db->get("SELECT * FROM games"); echo JSON_encode($result);
<?php session_start(); if (!$_SESSION['user_login_status'] == 1) { header("HTTP/1.0 403 Forbidden"); } else { $username = $_SESSION['username']; $class = $_SESSION['class']; $arr = []; $sql = "SELECT * FROM dailyForm WHERE username = '******' AND live = 1"; $mysqli = new mysqli("localhost", "root", "duckvin", "myDb"); if ($mysqli->connect_errno) { echo "Failed to connect to MySQL: " . $mysqli->connect_error; } if (!($result = $mysqli->query($sql))) { die('There was an error running the query [' . $mysqli->error . ']'); } if ($result->num_rows > 0) { while ($row = $result->fetch_assoc()) { $arr[] = $row; } echo JSON_encode($arr); } else { echo JSON_encode($arr); } } $mysqli->close();
} else { if ($attach_file_name == "") { $updatequery = "UPDATE JP_USER_LOGIN_DETAILS SET ULD_USERNAME='******',ULD_PASSWORD='******',ULD_COMPANY_NAME='{$companyname}',ULD_CONTACT_PERSON='{$contactperson}',ULD_EMAIL='{$useremail}',RC_ID=(SELECT RC_ID FROM JP_ROLE_CREATION WHERE RC_NAME='{$userstatus1}'),ULD_USERSTAMP_ID='{$uld_id}',ULD_NRICNO='{$nricno}' WHERE ULD_ID='{$tempuld}'"; } else { $updatequery = "UPDATE JP_USER_LOGIN_DETAILS SET ULD_USERNAME='******',ULD_PASSWORD='******',ULD_COMPANY_NAME='{$companyname}',ULD_CONTACT_PERSON='{$contactperson}',ULD_EMAIL='{$useremail}',RC_ID=(SELECT RC_ID FROM JP_ROLE_CREATION WHERE RC_NAME='{$userstatus1}'),ULD_USERSTAMP_ID='{$uld_id}',ULD_IMAGE_NAME='{$attach_file_name}',ULD_NRICNO='{$nricno}' WHERE ULD_ID='{$tempuld}'"; } mysqli_query($connection, $updatequery); } $tablerecords = UserTable(); echo JSON_encode($tablerecords); } elseif ($_REQUEST["Option"] == 'Delete') { $Rowid = $_REQUEST['Data']; $deletequery = "DELETE FROM JP_USER_LOGIN_DETAILS WHERE ULD_ID='{$Rowid}'"; mysqli_query($connection, $deletequery); $tablerecords = UserTable(); echo JSON_encode($tablerecords); } elseif ($_REQUEST["Option"] == 'Usercheck') { $username = $_REQUEST["User"]; $ulduserquery = "SELECT ULD_USERNAME FROM JP_USER_LOGIN_DETAILS WHERE ULD_USERNAME=BINARY('{$username}')"; $select = $connection->query($ulduserquery); $uldusername = ''; if ($record = mysqli_fetch_array($select)) { $uldusername = $record['ULD_USERNAME']; } echo $uldusername; } function UserTable() { global $connection; $selectquery = "SELECT ULD_ID,ULD_USERNAME,ULD_PASSWORD,ULD_COMPANY_NAME,ULD_CONTACT_PERSON,ULD_EMAIL,ULD_NRICNO,RC.RC_NAME,ULD_IMAGE_NAME FROM JP_USER_LOGIN_DETAILS ULD,JP_ROLE_CREATION RC WHERE ULD.RC_ID=RC.RC_ID ORDER BY ULD_USERNAME ASC"; $userrecord = mysqli_query($connection, $selectquery);
/** * Renders the debug messages * * @return string */ public function getDebugMessage() { $retval = '\'null\''; if ($GLOBALS['cfg']['DBG']['sql'] && empty($_REQUEST['no_debug']) && !empty($_SESSION['debug'])) { // Remove recursions and iterators from $_SESSION['debug'] self::_removeRecursion($_SESSION['debug']); $retval = JSON_encode($_SESSION['debug']); $_SESSION['debug'] = array(); return json_last_error() ? '\'false\'' : $retval; } $_SESSION['debug'] = array(); return $retval; }
static function d($debug, $cond = 1, $dies = 0, $file = 0) { #returns single instance from static context to be used as an object : Debug::d($debug); if (!$cond) { return; } #@ob_start();\Doctrine\Common\Util\Debug::dump($debug,4);$$debug=ob_get_clean();return pr1($debug);#doctrine way $obj = self::i(); init(); $bt = debug_backtrace(); if (count($bt) > 2) { array_shift($bt); } $call = array_shift($bt); $call = $call['file'] . ':' . $call['line']; #$tmp=explode('/',$call['file']);if(count($tmp)<2)$tmp=explode('\\',$call['file']);#nunows $debug = cleanRecursion($debug); cleanNullOrMaxDepthArrays($debug); if ($file) { file_put_contents($file, serialize(compact('call', 'debug'))); } #Keep a Memo if (0) { #*** $xt = (array) end($debug); $y = []; $y = array_keys($xt); $split = str_split($y[1]); foreach ($split as &$v) { $v .= '§' . ord($v); } unset($v); pr1(['line' => __LINE__, 'aborted', $split, isset($xt[PRIV . 'factetape'])] + $y, 1); #enfants,statut,data,*factetape ( public from proposition ); } #isSerializable, now ! #$debug=var_debug($debug); if (isset($_SERVER['HTTP_X_REQUESTED_WITH'])) { #AJAX if ($dies) { $debug = JSON_encode(compact('call', 'debug')); cleanOut($debug, 1); die($debug); } #return new JSON_response return compact('call', 'debug'); #return new JSON_response #return json_encode($debug); } if (!isset($_SERVER['HTTP_HOST'])) { $debug = print_r(compact('call', 'debug'), 1); die(CleanOut($debug)); } #Failsafe for first debug ( recursivity issues ) toggles advanced display -> is now flattened $debug = var_debug($debug); $debug = print_r(compact('call', 'debug'), 1); CleanOut($debug); /* know that #client referers to first client level $x = preg_replace("~\n[ ]+(bool|int)\(([a-z]*[0-9]*)\)~", "\\2", $x); $x = preg_replace("~\n[ ]+string\([0-9]+\)~", "", $x); #$x=preg_replace("~\n bool(false)~","0",$x); $x = preg_replace("~\n[ ]+([^\n]+\n[ ]+null|\[[^\n]+\] => null)~i", "", $x); $x = preg_replace("~\(([0-9]+)\) {\n[ ]+\.\.\.\n[ ]+}~", "(\\1)...", $x); */ if ($dies < 0) { file_put_contents(ini_get('error_log'), print_r($debug, 1)); return; } header('Content-Type: text/html; charset=utf-8', 1); echo "<link rel=stylesheet href='//ben/codes/debug.css'><script src='//ben/codes/debug.js' type='text/javascript'></script>"; # if ($dies) { die(pr1($debug)); } return pr1($debug); }
); } } class Article implements JsonSerializable { private $cislo; private $real; private $datum; private $person; function __construct($cislo, $real, $datum, $person) { $this->cislo = $cislo; $this->real = $real; $this->datum = $datum; $this->person = $person; } function jsonSerialize() { return array( 'cislo' => $this->cislo, 'real' => $this->real, 'datum' => array('#t' => 'Date', '#v' => $this->datum->format('c')), 'author' => $this->person, ); } } $john = new Person('John', 'Dee'); $article = new Article(42, 3.1415, new DateTime(), $john); echo JSON_encode($article);
/** * szellemi termelés változat adat térolás adatbázisba * @param object * @JRequest imgdel0,imgdel1,imgdel2,imgdel3 * @JRequest img0, img1, img2, img3 * @return boolean */ public function save($item) { $user = JFactory::getUser(); // eredeti rekord elérése $orig = $this->get_product_view_product_row($item->id); // eredeti images elérése if ($orig->images != '') { $origImages = JSON_decode($orig->images); } else { $origImages = array(); } while (count($origImages) < 4) { $origImages[] = ''; } // images_delete kérések teljesitése for ($i = 0; $i < 5; $i++) { $fn = 'imgdel' . $i; if (JRequest::getVar($fn) == 1) { unlink($origImages[$i]); $origImages[$i] = ''; } } // alapértelmezett értékek beirása $item->published = 1; if ($item->model == '') { $item->model = $user->username; } $item->alias = strtolower(preg_replace("/[^A-Za-z0-9]/", '', $item->name)); $item->date_added = date('Y-m-d H:i:s'); $item->category_id = JRequest::getVar('category_id', $orig->category_id); if ($item->category_id == '') { $item->category_id = $orig->category_id; } // tárolás adatbázisba $table = JTable::getInstance('products', 'EcommercewdTable'); foreach ($item as $fn => $fv) { $table->{$fn} = $fv; } $result = $table->store(); // új product_id lekérdezése $product_id = $table->id; $this->product_id = $product_id; // image uploadok végrehajtása, új images kialakitása if ($result) { for ($i = 0; $i < 5; $i++) { if (file_exists($_FILES['img' . $i]['tmp_name']) & is_uploaded_file($_FILES['img' . $i]['tmp_name'])) { $targetFile = 'media/com_ecommercewd/uploads/images/products/' . substr($product_id, 0, 2); if (!is_dir($targetFile)) { mkdir($targetFile, 0777); } $fileExt = strtolower(pathinfo($_FILES['img' . $i]['name'], PATHINFO_EXTENSION)); if ($fileExt == 'jpg' | $fileExt == 'png') { $targetFile .= '/' . $product_id . '_' . $_FILES['img' . $i]['name']; if (file_exists($targetFile)) { unlink($targetFile); } if (move_uploaded_file($_FILES['img' . $i]["tmp_name"], $targetFile)) { $origImages[$i] = $targetFile; } else { $this->setError(JTEXT::_('COM_ECOMMERCEWD_SAVE_ERROR_1')); $result = false; } } else { $this->setError(JTEXT::_('COM_ECOMMERCEWD_ILLEGAL_FILE_EXTENSION') . ' fileExt=' . $fileExt); $result = false; } } } // rekord update, új images adat kitárolása az adatbázisba $images = array(); foreach ($origImages as $image) { if ($image != '') { $images[] = $image; } } $table->images = JSON_encode($images); if ($table->store() == false) { $this->setError(JTEXT::_('COM_ECOMMERCEWD_SAVE_ERROR_2')); $result = false; } } else { $this->setError(JTEXT::_('COM_ECOMMERCEWD_SAVE_ERROR_0')); } return $result; }
/** * adat tárolás * @param object */ public function save($item) { $db = JFactory::getDBO(); // insert vagy update? $iName = $this->tableId; if ($item->{$iName} != '' & $item->{$iName} != 0) { $w = $this->getItem($item->{$iName}); } else { $w = false; } // ez jelzi, hogy insert kell if ($w) { // update } else { $manifest = $item->manifest_cache; // insert extension táblába $query = 'INSERT INTO #__extensions (`extension_id`, `name`, `type`, `element`, `folder`, `client_id`, `enabled`, `access`, `protected`, `manifest_cache`, `params` ) VALUES (0, ' . $db->quote($manifest->name) . ', "component", "com_' . $manifest->name . '", "", 1, 1, 0, 0, "' . JSON_encode($manifest) . '", "{}") '; $db->setQuery($query); $result = $db->query(); if ($db->getErrorNum() > 0) { $this->setError($db->getErrorNum() . ' ' . $db->getErrorMsg()); } // insert a menü táblába $args = new stdClass(); $args->title = $manifest->name; $args->alias = $manifest->name; $args->extension_name = 'com_' . $manifest->name; $args->menutype = 'main'; $this->menuAdd($args); // könyvtár létrehozás mkdir(JPATH_ROOT . '/components/com_' . $manifest->name); mkdir(JPATH_ROOT . '/administrator/components/com_' . $manifest->name); // rooter file létrehozása $this->saveRooter($item); // rooter_controller létrehozása $this->copyTemplate($item, JPATH_COMPONENT . '/templates/root_controller.php', JPATH_ROOT . '/components/com_' . $manifest->name . '/controller.php'); $this->copyTemplate($item, JPATH_COMPONENT . '/templates/root_controller.php', JPATH_ROOT . '/administrator/components/com_' . $manifest->name . '/controller.php'); // defView létrehozása $this->createView($item, $defView); } // insert vagy update ? return $result; }
/** * Publish a LivePress update. * * @param WP_Post $post WP_Post object. */ public function livepress_publish_post($post) { $permalink = get_permalink($post->ID); $data_to_js = array('title' => $post->post_title, 'author' => get_the_author_meta('login', $post->post_author), 'updated_at_gmt' => $post->post_modified_gmt . 'Z', 'link' => $permalink); $params = array('post_id' => $post->ID, 'post_title' => $post->post_title, 'post_link' => $permalink, 'data' => JSON_encode($data_to_js), 'blog_public' => get_option('blog_public')); try { $return = $this->livepress_communication->send_to_livepress_new_post($params); update_option(LP_PLUGIN_NAME . '_new_post', $return['oortle_msg']); LivePress_WP_Utils::save_on_post($post->ID, 'feed_link', $return['feed_link']); } catch (LivePress_Communication_Exception $e) { $e->log('new post'); } }
/** * All commands for which benchmarking could be useful * are executed by this method * * This allows for easy benchmarking */ protected function _call($command, array $args = array(), array $values = NULL) { $this->_connected or $this->connect(); extract($args); if (!empty($this->_config['profiling'])) { $_bm_name = isset($collection_name) ? $collection_name . '.' . $command : $command; if (isset($query)) { $_bm_name .= ' (' . JSON_encode($query) . ')'; } if (isset($criteria)) { $_bm_name .= ' (' . JSON_encode($criteria) . ')'; } if (isset($values)) { $_bm_name .= ' (' . JSON_encode($values) . ')'; } $_bm = Profiler::start("MangoDB {$this->_name}", $_bm_name); } if (isset($collection_name)) { $c = $this->_db->selectCollection($collection_name); } if (isset($options) && !array_key_exists('w', $options)) { $options['w'] = Arr::get($this->_config, 'writeConcern', 1); } switch ($command) { case 'ensure_index': $r = $c->ensureIndex($keys, $options); break; case 'create_collection': $r = $this->_db->createCollection($name, $capped, $size, $max); break; case 'drop_collection': $r = $this->_db->dropCollection($name); break; case 'command': $r = $this->_db->command($values); break; case 'execute': $r = $this->_db->execute($code, $args); break; case 'batch_insert': $r = $c->batchInsert($values, $options); break; case 'count': $r = $c->count($query); break; case 'find_one': $r = $c->findOne($query, $fields); break; case 'find': $r = $c->find($query, $fields); break; case 'group': $r = $c->group($keys, $initial, $reduce, $condition); break; case 'aggregate': $r = call_user_func_array(array($c, 'aggregate'), $arguments); break; case 'update': $r = $c->update($criteria, $values, $options); break; case 'insert': $r = $c->insert($values, $options); break; case 'remove': $r = $c->remove($criteria, $options); break; case 'save': $r = $c->save($values, $options); break; case 'get_file': $r = $this->gridFS()->findOne($criteria); break; case 'get_files': $r = $this->gridFS()->find($query, $fields); break; case 'set_file_bytes': $r = $this->gridFS()->storeBytes($bytes, $extra, $options); break; case 'set_file': $r = $this->gridFS()->storeFile($filename, $extra, $options); break; case 'remove_file': $r = $this->gridFS()->remove($criteria, $options); break; } if (isset($_bm)) { Profiler::stop($_bm); } return $r; }
// simplify product records $records = JSON_decode($trends)->items; $items = array(); foreach ($records as &$item) { $items[] = simplify($item); } // store complete simplified trends records file_put_contents('cache/trends.json', JSON_encode($items)); // tranche simplified trends records $slice = array_slice($items, 0, 8); // console output echo "<pre>"; print_r($slice); echo "</pre>"; // store simplifed trend record tranche $slice = JSON_encode($slice); file_put_contents('cache/trends-top.json', $slice); /* payload data */ $payload = "{\n" . '"categories": ' . $categories . ",\n" . '"vod": ' . $vod . ",\n" . '"trends": ' . $slice . "\n" . '}'; echo "<hr>"; echo "<pre>"; echo $payload; echo "</pre>"; file_put_contents('cache/payload.json', $payload); /* utils */ function fetch($endpoint) { global $apikey; return file_get_contents("http://api.walmartlabs.com/v1/{$endpoint}?format=json&apiKey={$apikey}"); } function oneOf($choices)