function addLocation() { $request = Slim::getInstance()->request(); $body = json_decode($request->getBody()); //print_r($body);exit; if (isset($body->id)) { unset($body->id); } $unique_field = array(); $unique_field['city'] = $body->city; $unique_field['country_id'] = $body->country_id; $rowcount = rowCountByCondition($unique_field, 'locations'); //echo $rowcount;exit; if ($rowcount == 0) { $allinfo['save_data'] = $body; //$allinfo['unique_data'] = $unique_field; $location_details = add(json_encode($allinfo), 'locations'); //var_dump($location_details); //exit; if (!empty($location_details)) { /* $user_details = add(json_encode($allinfo),'coupons'); $user_details = json_decode($user_details);*/ $result = '{"type":"success","message":"Added Succesfully"}'; } else { $result = '{"type":"error","message":"Not Added"}'; } } else { $result = '{"type":"error","message":"Already exists"}'; } echo $result; }
function add($productId, $qty = 1) { if (is_array($productId)) { foreach ($productId as $pid => $qty) { add($pid, $qty); } return getList(); } $user = \cf\User::getLoggedIn(); if ($user) { $cartId = create(); $oldQty = \cf\query2var('SELECT amount FROM cf_products_in_cart WHERE cart_id=:cid AND product_id=:pid AND status=0', array('cid' => $cartId, 'pid' => $productId)); if ($oldQty) { \cf\execQuery('UPDATE cf_products_in_cart SET amount=:amt WHERE cart_id=:cid AND product_id=:pid', array('cid' => $cartId, 'pid' => $productId, 'amt' => $qty + $oldQty)); } else { \cf\execQuery('INSERT INTO cf_products_in_cart (cart_id,product_id,amount) VALUES(:cid,:pid,:amt)', array('cid' => $cartId, 'pid' => $productId, 'amt' => $qty)); } } else { $c = create(); $products = $c->getParam('ready'); if (array_key_exists($productId, $products)) { $products[$productId] += (int) $qty; } else { $products[$productId] = (int) $qty; } $c->setParam('ready', $products); $c->set(); } return getList(); }
function getIt() { if (isset($GLOBALS["HTTP_RAW_POST_DATA"])) { $number = getLastId(); $sitrng = "poczekalnia/z" . "{$number}" . ".png"; // Get the data $imageData = $GLOBALS['HTTP_RAW_POST_DATA']; // Remove the headers (data:,) part. // A real application should use them according to needs such as to check image type $filteredData = substr($imageData, strpos($imageData, ",") + 1); // Need to decode before saving since the data we received is already base64 encoded $unencodedData = base64_decode($filteredData); //echo "unencodedData".$unencodedData; // Save file. This example uses a hard coded filename for testing, // but a real application can specify filename in POST variable $fp = fopen($sitrng, 'wb'); fwrite($fp, $unencodedData); fclose($fp); add($sitrng, $_COOKIE['words'], $_COOKIE['author'], $_COOKIE['nick'], $_COOKIE['book'], $_COOKIE['tag']); setcookie("words", "", time()); $files = glob('upload/*'); // get all file names foreach ($files as $file) { // iterate files if (is_file($file)) { unlink($file); } // delete file } } }
function remove($_POST) { # processes db_connect(); # Get vars extract($_POST); $id += 0; if (isset($back)) { return add($_POST); } # validate input require_lib("validate"); $v = new validate(); # display errors, if any if ($v->isError()) { $confirm = ""; $errors = $v->getErrors(); foreach ($errors as $e) { $confirm .= "<li class='err'>" . $e["msg"] . "</li>"; } $confirm .= "<p><input type='button' onClick='JavaScript:history.back();' value='« Correct submission'>"; return $confirm; } db_conn('cubit'); $sql = "DELETE FROM batch_cashbook WHERE cashid='{$id}'"; $accntRslt = db_exec($sql) or errDie("ERROR: Unable to retrieve bank deposits details from database.", SELF); # Status report $write = "\n\t\t\t\t\t<table " . TMPL_tblDflts . " width='100%'>\n\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t<th>Batch Cashbook entry deleted</th>\n\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t<tr class='datacell'>\n\t\t\t\t\t\t\t<td>Batch Cashbook entry has been deleted</td>\n\t\t\t\t\t\t</tr>\n\t\t\t\t\t</table>"; # Main table (layout with menu) $OUTPUT = "\n\t\t\t\t<center>\n\t\t\t\t<table width = 90%>\n\t\t\t\t\t<tr valign='top'>\n\t\t\t\t\t\t<td width='50%'>{$write}</td>\n\t\t\t\t\t\t<td align='center'>\n\t\t\t\t\t\t<table " . TMPL_tblDflts . " width='80%'>\n\t\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t\t<th>Quick Links</th>\n\t\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t\t<tr class='" . bg_class() . "'>\n\t\t\t\t\t\t\t\t<td><a href='bank-pay-add.php'>Add Bank Payment</a></td>\n\t\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t\t<tr class='" . bg_class() . "'>\n\t\t\t\t\t\t\t\t<td><a href='bank-recpt-add.php'>Add Bank Receipt</a></td>\n\t\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t\t<tr class='" . bg_class() . "'>\n\t\t\t\t\t\t\t\t<td><a href='cashbook-view.php'>View Cash Book</a></td>\n\t\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t\t<script>document.write(getQuicklinkSpecial());</script>\n\t\t\t\t\t\t</table>\n\t\t\t\t\t\t</td>\n\t\t\t\t\t</tr>\n\t\t\t\t</table>"; return $OUTPUT; }
function show_error($msg) { global $w; add('', $msg, 'Fehler'); echo $w->toxml(); exit; }
public function getRecordWhere($data) { $result = null; $adapter = GlobalAdapterFeature::getStaticAdapter(); $connection = $adapter->getDriver()->getConnection($data); $connection->beginTransaction(); try { function add($datas) { global $data; $data = $datas; } add($data); function set(Select $select) { global $data; foreach ($data as $key => $value) { $select->where->like($key, "%{$value}%"); } } $result = $this->area->select(function (Select $select) { set($select); }); $connection->commit(); } catch (\Exception $e) { $connection->rollback(); } return $result; }
function addCat() { $request = Slim::getInstance()->request(); $body = json_decode($request->getBody()); //print_r($body);exit; if (isset($body->id)) { unset($body->id); } $unique_field = array(); $unique_field['name'] = $body->name; $rowcount = rowCount(json_encode($unique_field), 'category'); //echo $rowcount;exit; if ($rowcount == 0) { $allinfo['save_data'] = $body; if (!empty($body->icon)) { $body->icon->filename = time() . $body->icon->filename; file_put_contents('category_icons/' . $body->icon->filename, base64_decode($body->icon->base64)); $body->icon = $body->icon->filename; } //$allinfo['unique_data'] = $unique_field; $cat_details = add(json_encode($allinfo), 'category'); if (!empty($cat_details)) { /* $user_details = add(json_encode($allinfo),'coupons'); $user_details = json_decode($user_details);*/ $result = '{"type":"success","message":"Added Succesfully"}'; } else { $result = '{"type":"error","message":"Not Added"}'; } } else { $result = '{"type":"error","message":"Already exists"}'; } echo $result; }
function write() { extract($_POST); if (isset($back)) { return add($_POST); } require_lib("validate"); $v = new validate(); $v->isOk($bankid, "num", 1, 30, "Invalid Bank Account."); if ($v->isError()) { $confirm = ""; $errors = $v->getErrors(); foreach ($errors as $e) { $confirm .= "<li class=err>" . $e["msg"]; } $confirm .= "<p><input type=button onClick='JavaScript:history.back();' value='« Correct submission'>"; return $confirm; } $bank = qryBankAcct($bankid); $cols = grp(m("type", "Banking Details Account"), m("label", "BANK_DET"), m("value", $bankid), m("descript", "Bank Account: ({$bank['acctype']}) {$bank['accname']} - {$bank['bankname']}"), m("div", USER_DIV)); $qry = new dbUpdate("set", "cubit", $cols, "label = 'BANK_DET' AND div = '" . USER_DIV . "'"); $qry->run(DB_REPLACE); $write = "\n\t<table " . TMPL_tblDflts . ">\n\t<tr>\n\t\t<th>Bank Details Account</th>\n\t</tr>\n\t<tr class='text'>\n\t\t<td>Bank Details Account have been set to Bank Account: ({$bank['acctype']}) {$bank['accname']} - {$bank['bankname']}.</td>\n\t</tr>\n\t</table>" . mkQuickLinks(); return $write; }
function printS($id) { $ci =& get_instance(); $s = new Section(); $s->get_by_id($id); $s->e = anchor($ci->app->app_url('edit/') . $s->id, 'Edit'); $s->d = anchor($ci->app->app_url('delete/') . $s->id, 'Delete'); $output = "<li>"; $output .= $s->id . '|'; $output .= $s->name; $output .= add($id, 0, "add first child for {$s->name}"); $output .= '|'; $output .= $s->e; $output .= '|'; $output .= $s->d; $c = new Section(); $c->where('parent_section', $id); $c->order_by('sort', 'asc'); $c->get(); if (count($c->all) > 0) { $output .= "<ul>"; foreach ($c->all as $item) { $output .= printS($item->id); $output .= "<li>" . add($id, $item->sort + 1) . "</li>"; } $output .= "</ul>"; } $output .= "</li>"; return $output; }
function transform($a, $tx, $ty) { $x = trim($a[0]); $y = trim($a[1]); $x = add($x, $tx); $y = add($y, $ty); return $x . "," . $y; }
function main() { $a = new Foo(); $a->identity(232); $a->identity(42); $a->identity(0); add(1, 1); add(0, 0); }
function add($i) { if ($i < 1) { return $i; } else { run(); return $i + add($i - 1); } }
public function signup() { if (isset($_POST['form_action'])) { $input = array('email' => $_POST['email'], 'password' => $_POST['password']); print_r($input); add('User', $input); } $vars['user'] = new User(); $this->l('Template')->load('user/signup', 'base', $vars)->output(); }
function add($array, $n, $len, $cnt) { if ($cnt == 0) { return array_splice($array, $len - $cnt, 0, $n); } if ($n < $array[$len - $cnt]) { array_splice($array, $len - $cnt, 0, $n); return $array; } return add($array, $n, $len, $cnt - 1); }
public function __construct($patNum) { //check if patient table already exists $database = new Database(); $database->query('SELECT TableNum, Discharged FROM patients WHERE HosNum = :num'); $database->bind(':num', $patNum); $row = $database->single(); if ($row) { } else { add(); } }
function Mandelbrot($x, $y) { $z = 0; $c = array($x, $y); for ($i = 0; $i < N; ++$i) { $z = add(square($z), $c); if (value($z) > M) { return $i; } } return true; }
function multiply($a, $b) { if (is_numeric($a) && is_numeric($b)) { $i = 0; for ($c = 0; $c < $b; $c++) { $i = $i + add($a, $a); } return $i; } else { return error($a, $b, 'regular'); } }
function set_add_entry($act, $idx, $base, $date, $time, $domain) { if ($act == "add") { add($base . "entry:" . $idx . "/date", $date); add($base . "entry:" . $idx . "/time", $time); add($base . "entry:" . $idx . "/domain", $domain); } else { if ($act == "set") { set($base . "entry:" . $idx . "/date", $date); set($base . "entry:" . $idx . "/time", $time); set($base . "entry:" . $idx . "/domain", $domain); } } }
function add_each($list, $path, $node) { //echo "# add_each(".$list.",".$path.",".$node.")\n"; $i = 0; $cnt = scut_count($list, ""); while ($i < $cnt) { $val = scut($list, $i, ""); if ($val != "") { add($path . "/" . $node, $val); } $i++; } return $cnt; }
function controller() { $id = $_REQUEST["id"]; $action = $_REQUEST["action"]; switch ($id) { case "recommand": include "model/recommand_data.php"; if ($action == 'upload') { add($_REQUEST, $_FILES); } else { read(); } break; case "news": include "model/news_data.php"; if ($action == 'upload') { add($_REQUEST, $_FILES); } else { read(); } break; case "local": include 'model/local_data.php'; if ($action == 'upload') { add($_REQUEST, $_FILES); } else { read(); } break; case "image": include 'model/image_data.php'; if ($action == 'upload') { add($_REQUEST, $_FILES); } else { read(); } break; case "entertainment": include 'model/entertainment_data.php'; if ($action == 'upload') { add($_REQUEST, $_FILES); } else { read(); } break; default: break; } }
function add($input) { if (!is_array($input)) { return $input; } $total = 0; foreach ($input as $key => $item) { if (is_array($item)) { $total += add($item); } else { $total += $item; } } return $total; }
function add($number, $numbers, $len) { $newNumbers = []; if ($len == 0) { return $newNumbers; } for ($i = 0; $i < $len; $i += 1) { if ($number > $numbers[$i] && $number < $numbers[$i + 1]) { $newNumbers[] = $numbers[$i]; $newNumbers[] = $number; } else { $newNumbers[] = $numbers[$i]; } } return add($number, $numbers, $len - 1); }
function addNewBlog() { $rarray = array(); $request = Slim::getInstance()->request(); $body = json_decode($request->getBody()); $allinfo['save_data'] = $body; //$allinfo['save_data']['offer_to_date'] = $body->offer_to_date.' 23:59:59'; $save = add(json_encode($allinfo), 'blogs'); if (!empty($save)) { $rarray = array('type' => 'success', 'offers' => $save); } else { $rarray = array('type' => 'error', 'message' => 'Internal error please try again later.'); } echo json_encode($rarray); //echo $result; }
function f_sqltransform($inp = array(), $onlykey = "all", $keymap = array()) { if (count($inp) > 0) { if ($onlykey === "all") { $onlykey = array_keys($inp[0]); } else { if ($onlykey === "allm") { $onlykey = array_keys($keymap); } } return add(array(array_keys(f_mapkeys(f_getflds($onlykey, $inp[0]), $keymap))), map($inp, function ($inp) use($onlykey) { return array_values(f_getflds($onlykey, $inp)); })); } else { return array(); } }
function addBankDetails() { $request = Slim::getInstance()->request(); $body = json_decode($request->getBody()); $allinfo['save_data'] = $body; //$allinfo['unique_data'] = $unique_field; $cat_details = add(json_encode($allinfo), 'bank_details'); //echo $cat_details; //exit; if (!empty($cat_details)) { $result = '{"type":"success","message":"Added Succesfully"}'; } else { $result = '{"type":"error","message":"Not Added"}'; } echo $result; exit; }
function addMerchantMenuCategory() { $request = Slim::getInstance()->request(); $body = json_decode($request->getBody()); $allinfo['save_data'] = $body; //print_r($allinfo); //$allinfo['unique_data'] = $unique_field; $cat_details = add(json_encode($allinfo), 'merchant_menu_categories'); //echo $cat_details; //exit; if (!empty($cat_details)) { $result = '{"type":"success","message":"Added Succesfully","data":' . $cat_details . '}'; } else { $result = '{"type":"error","message":"Not Added"}'; } echo $result; exit; }
function addCoupon() { $request = Slim::getInstance()->request(); $body = json_decode($request->getBody()); if (isset($body->id)) { unset($body->id); } $allinfo['save_data'] = $body; //$allinfo['unique_data'] = $unique_field; $coupon_details = add(json_encode($allinfo), 'coupons'); if (!empty($coupon_details)) { /* $user_details = add(json_encode($allinfo),'coupons'); $user_details = json_decode($user_details);*/ $result = '{"type":"success","message":"Added Succesfully"}'; } else { $result = '{"type":"error","message":"Not Added"}'; } echo $result; }
function main() { global $result; switch ($_REQUEST['query']) { case "add": add(); break; case "modify": modify(); break; case "delete": del(); break; default: $result['status'] = 404; $result['msg'] = "No such query type" . $_REQUEST['query']; } echo json_encode($result); }
function jump($action) { switch ($action) { case 'add': add(); break; case 'edit_del': if (array_key_exists('edit', $_REQUEST)) { edit(); } elseif (array_key_exists('delete', $_REQUEST)) { delete_confirm(); } else { error('invalid edit_del'); } break; case 'update': if (array_key_exists('cancel', $_REQUEST)) { message('Edit canceled'); main_page(); } else { update(); } break; case 'delete_do': if (array_key_exists('cancel', $_REQUEST)) { message('Delete canceled'); main_page(); } else { delete_do(); } break; default: error_message('unhandled jump: ' . $action); main_page(); } // fall-through message('jump > fall-through (%s)', $action); main_page(); }
function process($argv) { if (!isset($argv[1])) { displayHelp(); exit; } switch ($argv[1]) { case 'install': install(); break; case 'add': add($argv); break; case 'rm': remove($argv); break; case 'help': default: displayHelp(); break; } }