public function actionSave() { $services = Service::model()->findAllByAttributes(['status' => 0]); foreach ($services as $service) { $traffic = new Traffic(); $traffic->attributes = ['uid' => $service->uid, 'email' => $service->email, 'date' => date('Y-m-d', strtotime('yesterday')), 'traffic' => $service->used]; $traffic->save(); } echo "Success"; }
public function actionBilling() { $query = ['uid' => $this->user->getId()]; $model = Traffic::model(); $model->attributes = $query; $condition = ['condition' => 'uid=:uid', 'params' => ['uid' => $query['uid']]]; $pager = new CPagination($model->count($condition)); $pager->setPageSize(20); $condition['offset'] = $pager->getOffset(); $condition['limit'] = $pager->getLimit(); $condition['order'] = 'date desc'; $data = $model->findAll($condition); $this->render('billing', ['data' => new RedArrayDataProvider($data), 'pager' => $pager]); }
if ($searchOper == 'eq') { $searchString = $searchString; } if ($searchOper == 'bw' || $searchOper == 'bn') { $searchString .= '%'; } if ($searchOper == 'ew' || $searchOper == 'en') { $searchString = '%' . $searchString; } if ($searchOper == 'cn' || $searchOper == 'nc' || $searchOper == 'in' || $searchOper == 'ni') { $searchString = '%' . $searchString . '%'; } $where = "{$searchField} {$ops} '{$searchString}'"; $objects = Traffic::get_by_sql("SELECT * FROM " . T_TRAFFICS . " WHERE " . $where . " ORDER BY {$sidx} {$sord} LIMIT {$start} , {$limit}"); } else { $objects = Traffic::get_by_sql("SELECT * FROM " . T_TRAFFICS . " ORDER BY {$sidx} {$sord} LIMIT {$start} , {$limit}"); } header("Content-type: text/xml;charset=utf-8"); $s = "<?xml version='1.0' encoding='utf-8'?>"; $s .= "<rows>"; $s .= "<page>" . $page . "</page>"; $s .= "<total>" . $total_pages . "</total>"; $s .= "<records>" . $count . "</records>"; foreach ($objects as $object) { $s .= "<row id='" . $object->id . "'>"; $s .= "<cell></cell>"; $s .= "<cell>" . $object->id . "</cell>"; $s .= "<cell>" . $object->picture . "</cell>"; $s .= "<cell>" . $object->userid . "</cell>"; $s .= "<cell>" . $object->storeid . "</cell>"; $s .= "<cell>" . $object->status . "</cell>";
$sql .= " HAVING distance < " . $distance . " "; $sql .= " AND WHERE " . $where . " "; $sql .= " ORDER BY distance ASC"; if (isset($_GET['userlongitude']) && isset($_GET['userlatitude']) && $_GET['userlongitude'] != "" && $_GET['userlongitude'] != "0" && $_GET['userlatitude'] != "" && $_GET['userlatitude'] != "0") { $items = Store::get_by_sql($sql); } else { $items = Store::get_by_sql("SELECT * FROM " . T_STORES . " WHERE " . $where . $sort . $limit); } $filename = 0; foreach ($items as $item) { $item->distance = round($item->distance) > 0 ? round($item->distance) + "km" : round($item->distance / 0.001) + "m"; $sql = "SELECT * FROM traffics WHERE storeid = " . $item->id; if (!isset($_GET['1hour'])) { $sql .= " AND " . C_TRAFFIC_DATETIME . " BETWEEN DATE_SUB(NOW(), INTERVAL 1 HOUR) AND NOW()"; } $traffics = Traffic::get_by_sql($sql); $totaltraffics = 0; $lasttrafficdatetime = 0; if (count($traffics) > 0) { foreach ($traffics as $traffic) { $totaltraffics += $traffic->status; } } $item->averagestatus = true; $item->trafficcount = count($traffics); if ($item->trafficcount > 0) { $item->trafficlevel = $totaltraffics / $item->trafficcount; } if (count($traffics) > 0) { $item->lasttrafficdatetime = $traffics[count($traffics) - 1]->datetime; }
} if (isset($_GET['enabled'])) { $where .= " AND " . C_TRAFFIC_ENABLED . equallike($_GET['enabled'], "int"); } //====================================================== if (isset($_GET['limit'])) { $limit = " LIMIT " . $_GET['limit'] . " "; } if (isset($_GET['sortby']) && isset($_GET['sortorder'])) { $sort = " ORDER BY " . $_GET['sortby'] . " " . $_GET['sortorder'] . " "; } if (isset($_GET['sortby']) && !isset($_GET['sortorder'])) { $sort = " ORDER BY " . $_GET['sortby'] . $sortorder . " "; } //====================================================== $items = Traffic::get_by_sql("SELECT * FROM " . T_TRAFFICS . " WHERE " . $where . $sort . $limit); $filename = 0; if (!isset($_GET['blob'])) { foreach ($items as $item) { $filename++; $random = rand(0, 1); file_put_contents("images/" . $filename . "x" . $random . ".jpg", base64_decode($item->picture)); $item->picture = HOST . "includes/webservices/images/" . $filename . "x" . $random . ".jpg"; } } echo str_replace('\\/', '/', json_encode($items)); //echo json_encode($items, JSON_UNESCAPED_SLASHES); function equallike($field, $type) { $string = ""; if ($type == "string") {
<?php require_once "header.php"; if (isset($_GET['id'])) { $object = Traffic::get_by_id($_GET['id']); } else { header("location: index.php?negative"); } if (!$session->is_logged_in()) { header("location: index.php?negative"); } else { $loggeduser = User::get_by_id($session->userid); if ($loggeduser->enabled == DISABLED) { header("location: index.php?disabled"); } } $pathinfo = pathinfo($_SERVER["PHP_SELF"]); $basename = $pathinfo["basename"]; $currentFile = str_replace(".php", "", $basename); ?> <div class="container-fluid"> <div class="row-fluid"> <div class="span1"></div> <div class="span9"> <form id="theform" class="form-horizontal" action="#" method="post" enctype="multipart/form-data"> <fieldset> <legend> Update </legend>
$item->picture = HOST . "includes/webservices/images/" . $filename . "x" . $random . ".jpg"; $html .= "<tr>"; $html .= " <td>productid " . $item->productid . "</td>"; $html .= " <td><img src='" . $item->picture . "' height='40' width='40'/></td>"; $html .= " <td><a class='btn btn-primary' href='updateproductpic.php?id=" . $item->id . "'>Update</a></td>"; $html .= " <td><button class='btn btn-danger btndelete'>Delete <span hidden>" . $item->id . "</span></button></td>"; $html .= "</tr>"; } $filename = 0; echo $html; } else { echo "no data"; } } else { if ($_GET['itemtype'] == "traffic") { $items = Traffic::search($input); if (count($items) > 0) { foreach ($items as $item) { $filename++; $random = rand(0, 1); file_put_contents("images/" . $filename . "x" . $random . ".jpg", base64_decode($item->picture)); $item->picture = HOST . "includes/webservices/images/" . $filename . "x" . $random . ".jpg"; $html .= "<tr>"; $html .= " <td><img src='" . $item->picture . "' height='40' width='40'/></td>"; $html .= " <td>userid " . $item->userid . "</td>"; $html .= " <td>storeid " . $item->storeid . "</td>"; $html .= " <td>status " . $item->status . "</td>"; $html .= " <td>" . $item->comment . "</td>"; $html .= " <td><a class='btn btn-primary' href='updatetraffic.php?id=" . $item->id . "'>Update</a></td>"; $html .= " <td><button class='btn btn-danger btndelete'>Delete <span hidden>" . $item->id . "</span></button></td>"; $html .= "</tr>";
$object->userid = $_POST['userid']; $object->storeid = $_POST['storeid']; $object->status = $_POST['status']; $object->comment = $_POST['comment']; $object->pending = $_POST['pending']; $object->enabled = $_POST['enabled']; $object->create(); $log = new Log($session->userid, $clientip, "WEB", "CREATED TRAFFIC: " . $_POST['id']); $log->create(); } else { if ($_POST['oper'] == 'edit') { $object = Traffic::get_by_id($_POST['id']); $object->userid = $_POST['userid']; $object->storeid = $_POST['storeid']; $object->status = $_POST['status']; $object->comment = $_POST['comment']; $object->pending = $_POST['pending']; $object->enabled = $_POST['enabled']; $object->update(); $log = new Log($session->userid, $clientip, "WEB", "UPDATED TRAFFIC: " . $_POST['id']); $log->create(); } else { if ($_POST['oper'] == 'del') { if ($_POST['id'] != $session->userid) { $log = new Log($session->userid, $clientip, "WEB", "DELETED TRAFFIC: " . $_POST['id']); $log->create(); Traffic::get_by_id($_POST['id'])->delete(); } } } }
<?php require_once "../initialize.php"; $message = ""; if (isset($_POST['status']) && $_POST['status'] != "" && isset($_POST['userid']) && $_POST['userid'] != "" && isset($_POST['storeid']) && $_POST['storeid'] != "") { $object = new Traffic(); $object->userid = $_POST['userid']; $object->storeid = $_POST['storeid']; $object->status = $_POST['status']; $object->comment = $_POST['comment']; $object->longitude = $_POST['longitude']; $object->latitude = $_POST['latitude']; $object->pending = 0; $object->enabled = 1; if (isset($_FILES['picture'])) { $file = new File($_FILES['picture']); $object->picture = $file->data; } $object->create(); if (!$session->is_logged_in()) { $session->userid = 0; } $log = new Log($session->userid, $clientip, "WEB", "CREATED TRAFFIC: " . $object->id); $log->create(); $message .= "success"; } else { $message = "You have missed a required field."; } echo $message;
StoreType::get_by_id($_GET['itemid'])->delete(); } else { if ($_GET['itemtype'] == "storepic") { StorePic::get_by_id($_GET['itemid'])->delete(); } else { if ($_GET['itemtype'] == "product") { Product::get_by_id($_GET['itemid'])->delete(); } else { if ($_GET['itemtype'] == "producttype") { ProductType::get_by_id($_GET['itemid'])->delete(); } else { if ($_GET['itemtype'] == "productpic") { ProductPic::get_by_id($_GET['itemid'])->delete(); } else { if ($_GET['itemtype'] == "traffic") { Traffic::get_by_id($_GET['itemid'])->delete(); } else { if ($_GET['itemtype'] == "review") { Review::get_by_id($_GET['itemid'])->delete(); } else { if ($_GET['itemtype'] == "featureditem") { FeaturedItem::get_by_id($_GET['itemid'])->delete(); } else { $message = "unknown parameter passed"; } } } } } } }
} else { if ($_GET['itemtype'] == "traffic") { $traffics = Traffic::search($input); } else { if ($_GET['itemtype'] == "review") { $reviews = Review::search($input); } } } } } } else { $users = User::search($input); $stores = Store::search($input); $products = Product::search($input); $traffics = Traffic::search($input); $reviews = Review::search($input); } $tables = array(); if ($users != null) { $table = new Table("users", $users); array_push($tables, $table); } if ($stores != null) { $table = new Table("stores", $stores); array_push($tables, $table); } if ($products != null) { $table = new Table("products", $products); array_push($tables, $table); }
<?php require_once "../initialize.php"; $message = ""; if (isset($_POST['trafficid']) && $_POST['trafficid'] != "" && isset($_POST['status']) && $_POST['status'] != "" && isset($_POST['userid']) && $_POST['userid'] != "" && isset($_POST['storeid']) && $_POST['storeid'] != "") { $object = Traffic::get_by_id($_POST['trafficid']); $object->userid = $_POST['userid']; $object->storeid = $_POST['storeid']; $object->status = $_POST['status']; $object->longitude = $_POST['longitude']; $object->latitude = $_POST['latitude']; $object->comment = $_POST['comment']; $object->pending = $_POST['pending']; $object->enabled = $_POST['enabled']; $file = new File($_FILES['picture']); if ($file->valid) { $object->picture = $file->data; } else { $object->picture = base64_decode($object->picture); } $object->update(); $log = new Log($session->userid, $clientip, "WEB", "UPDATED TRAFFIC: " . $object->id); $log->create(); $message .= "success"; } else { $message = "You have missed a required field."; } echo $message;