public function inverse() { $determinant = new Determinant($this->matrix); $factor = $determinant->retrieve(); if ($factor === $this->valueZero) { throw new NotInverseException(); } $factor = 1 / $factor; $transposed = $this->transposed(); $operations = new Operations($transposed, $this->precision); $adjugate = $operations->adjugateMatrix(); $operations = new Operations($adjugate, $this->precision); return $operations->multiplicationScalar($factor); }
static function get_instance() { if (self::$instance == null) { self::$instance = new operations(); } return self::$instance; }
function new_user($data) { $data['status'] = 1; $data['time_added'] = time(); $data['date_added'] = TimeTools::get_time_id(date('Y-m-d')); $check = Operations::get_instance()->init($data, 'users'); Operations::get_instance()->init(array('user_id' => $check, 'time_added' => time(), 'date_added' => TimeTools::get_time_id(date('Y-m-d'))), 'users_img'); }
/** * Creates a new changes instance * * @param (text.json.patch.Operation|[:var])[] $operations */ public function __construct(...$operations) { foreach ($operations as $operation) { if ($operation instanceof Operation) { $this->operations[] = $operation; } else { $this->operations[] = Operations::named($operation['op'])->newInstance($operation); } } }
function savePlanning(&$model, $data, $time, $options = array()) { if (is_numeric($time)) { $format = $model->getDataSource()->columns['datetime']['format']; $time = date($format, $time); } $defaultOptions = array('stringOperators' => true, 'break' => true, 'absolute' => false, 'requery' => true, 'context' => null, 'dry' => false, 'validationExclude' => null); $options = array_merge($defaultOptions, (array) $options); //debug($options); if (!empty($data[$model->alias])) { $myData = $data[$model->alias]; } else { $myData = $data; } App::import('Lib', 'Operations'); if ($options['stringOperators']) { $myData = Operations::parseStringOperations($myData); } //debug($myData); $cacheData = $model->data; if (isset($myData['id'])) { $model->id = $myData['id']; } if (!empty($model->id)) { if ($options['requery']) { $model->Behaviors->attach('Containable'); $oldData = $model->findAt('first', array('conditions' => array($model->alias . '.id' => $model->id), 'time' => $time, 'contain' => array('Node'))); } else { $oldData = $cacheData; } //debug($oldData); if (isset($oldData['Node'])) { $node = $oldData['Node']; } else { $node = $model->node(null, false); $node = $node['Node']; } $newData = Operations::applyOperations($myData, $oldData[$model->alias]); //$model->validates(array('time'=>$time)); // à faire //debug($newData); $diffData = array_diff_assoc($newData, $oldData[$model->alias]); //debug($diffData); $plans = array(); $to_delete = array(); foreach ($diffData as $field => $val) { $solution = $model->getConflictSolution($val, $field, $time, null, array_merge($options, array('node' => $node))); if ($solution === false) { if ($options['break']) { return false; } else { continue; } } else { $plans = array_merge($plans, $solution['save']); $to_delete = array_merge($to_delete, $solution['delete']); } $plan = array('field' => $field, 'node_id' => $node['id'], 'active' => 1, 'value' => $val, 'date' => $time, 'absolute' => $options['absolute'], 'context' => $options['context']); if (is_array($myData[$field]) && !empty($myData[$field]['operator'])) { $plan['operation'] = $myData[$field]; } $plans[] = $plan; } //debug($this->buildPlanifiedFollowingLinks($model, $plans,$to_delete, array('dry'=>true))); if (!$options['dry']) { $this->savePlanningChanges($model, array('save' => $plans, 'delete' => $to_delete)); } else { return array('save' => $plans, 'delete' => $to_delete); } return true; } return false; }
function operations(&$eventOptions, $params) { if (!empty($params['operations']) && is_array($params['operations'])) { //debug($params); $defOpt = array('operations' => array()); $opt = array_merge($defOpt, $params); $opt['returnModel'] = true; list($model, $conditions) = $this->_selectEntriesCond($opt); if (!is_null($conditions)) { $findOpt = array('fields' => array_merge(array('id'), Set::extract('/field', $opt['operations'])), 'conditions' => $conditions, 'recursive' => -1); //debug($findOpt); //$this->Event = ClassRegistry::init('Event'); //$this->Event->debugEventStack($eventOptions); $entries = $model->find('all', $findOpt); App::import('Lib', 'Operations'); $count = 0; foreach ($entries as $entry) { foreach ($opt['operations'] as $op) { $fld = $op['field']; $newVal = Operations::simpleOperation($entry[$model->alias][$fld], $op['operator'], $op['value']); if ($newVal != $entry[$model->alias][$fld]) { $entry[$model->alias][$fld] = $newVal; } else { unset($entry[$model->alias][$fld]); } } if (count($entry[$model->alias]) > 1) { //only if there is more than the id in the data //debug($entry); if ($model->save($entry)) { $count++; } } } return $count; } } return false; }
public function changePassword($username, $oldPassword, $newPassword) { //Encrypt the passwords $oldPassword = Operations::encryptPassword($username, $oldPassword); $newPassword = Operations::encryptPassword($username, $newPassword); //Grab the account with the given username and password $account = $this->getAccount(array($username, $oldPassword), "user_pass"); //If not null, then the details existed, which means we can change the password if ($account != null) { $this->dbConnect(); $sql = "UPDATE users SET password = ? WHERE username = ?"; $stmt = $this->con->prepare($sql); $stmt->bindParam(1, $newPassword); $stmt->bindParam(2, $username); $stmt->execute(); $this->dbDisconnect(); return "password_changed"; } else { return "no_old_password_match"; } }
function __construct() { parent::__construct(); }
function testApplicableCond(&$model, $cond, $data = null, $alias = null, &$unfiltered = null) { if (is_null($alias)) { $alias = $model->alias; } if (is_null($data)) { $data = $model->data; } $filtered = $data; $unfiltered = $cond; //$cond['lol']=3; App::import('Lib', 'Operations'); foreach ($cond as $condkey => $condval) { $find = false; $matches = array(); //debug($key); if (is_numeric($condkey)) { } elseif (preg_match('/^((?:([A-Z][A-Za-z0-9_-]*).)?[A-Za-z0-9_-]*)\\s*(.*)\\s*$/', $condkey, $matches)) { //debug($matches); list($tmp, $path, $model, $operator) = $matches; if (empty($model)) { $path = $alias . '.' . $path; } $ex = Set::extract('{n}.' . $path, $filtered); $ex = array_combine(array_keys($filtered), $ex); //debug($condval); //debug($ex); foreach ($ex as $key => $val) { if (!is_null($val)) { $res = false; if (empty($operator)) { $res = $val == $condval; } else { $res = Operations::simpleOperation($val, $operator, $condval); } if ($res === false) { unset($filtered[$key]); } if (is_bool($res)) { $find = true; } } } } if ($find) { unset($unfiltered[$condkey]); } } return $filtered; }
<?php include "mysql_db.php"; $oper = new Operations(); $oper->setTodo(); ?>
require_once 'libs/SMSReceiver.php'; require_once 'libs/SMSSender.php'; define('APP_ID', 'APPID'); define('APP_PASSWORD', 'password'); $production = false; if ($production == false) { $ussdserverurl = 'http://localhost:7000/ussd/send'; $smsserverurl = 'http://localhost:7000/sms/send'; } else { $ussdserverurl = 'https://api.dialog.lk/ussd/send'; $smsserverurl = 'http://api.dialog.lk/sms/send'; } $receiver = new UssdReceiver(); $sender = new UssdSender($ussdserverurl, APP_ID, APP_PASSWORD); $smssender = new SMSSender($smsserverurl, APP_ID, APP_PASSWORD); $operations = new Operations(); $content = $receiver->getMessage(); // get the message content $address = $receiver->getAddress(); // get the sender's address $requestId = $receiver->getRequestID(); // get the request ID $applicationId = $receiver->getApplicationId(); // get application ID $encoding = $receiver->getEncoding(); // get the encoding value $version = $receiver->getVersion(); // get the version $sessionId = $receiver->getSessionId(); // get the session ID; $ussdOperation = $receiver->getUssdOperation();
<?php require_once CODE_ROOT . '/classes/report.php'; require_once CODE_ROOT . '/classes/operations.php'; require_once CODE_ROOT . '/classes/surgeons.php'; $report = new Report(); $operations = new Operations(); $surgeons = new Surgeons(); $report->result['views']['mainContent'] = 'report/form.php'; $yearsOperations = $operations->getOperationsYears(); if ($yearsOperations === false) { $report->result['message'][] = 'Ошибка при получении экстремумов даты операций'; $report->result['success'] = false; } $reportForm = filter_input(INPUT_GET, 'reportForm', FILTER_VALIDATE_INT, Helpers::$filterForIntPositive); if ($reportForm === 1) { $period = filter_input(INPUT_GET, 'period', FILTER_VALIDATE_INT, Helpers::$filterForIntPositive); $year = filter_input(INPUT_GET, 'year', FILTER_VALIDATE_INT, Helpers::$filterForIntPositive); $report->getGeneralStatistic($year, $period); $surgeonList = $surgeons->getList(); $surgeonDetails = $report->getSurgeonDetails($surgeonList); } $result = $report->result;
<?php header('Content-Type: application/json'); include 'Classes/operations.php'; /* START DB CREDINTIALS */ $hostname = "localhost"; $username = "******"; $password = ""; $dbname = "thesisdb"; /* END DB CREDINTIALS */ /* START CALLING NECESSARY CLASSES */ $operation = new Operations($hostname, $username, $password, $dbname); /* END CALLING NECESSARY CLASSES */ /* START GET WHAT TO DO */ if (isset($_GET['function'])) { switch ($_GET['function']) { case "get_auth": if (isset($_GET['password'])) { echo $operation->get_auth($_GET['password']); } else { exit($operation->encode_output(array('status' => 0, 'message' => "Lack of parameters!", 'data' => NULL))); } break; case "add_auth": if (isset($_GET['password'])) { echo $operation->add_auth($_GET['password']); } else { exit($operation->encode_output(array('status' => 0, 'message' => "Lack of parameters!", 'data' => NULL))); } break; case "del_auth":
//$table_name = "search_groundtruth_1000"; // $table_name = "search_detection"; //$table_name = "ad_detection"; //$table_name = "dishonest_ad_detection"; //$table_name = "dishonest_search_detection"; //$table_name = "search_sample_list_600_1"; // $table_name = "search_sample_list_600_combined"; //$table_name = "effective_abusive_linux"; //$table_name = "search_hot_24_month"; //$table_name = "detect_spammy_ad"; //$table_name = "detect_hot_ad"; //$table_name = "detect_hot_search"; $table_name = "detect_spammy_search"; } // echo $userFile . $googleFile . $table_name; $oper = new Operations(); // POST Handler if (isset($_POST["submit"])) { $action = $_POST["submit"]; if ($action == "submit") { $oper->processed($table_name, $_POST["response"], $_POST["id"], $_POST["url"], $_POST["user"]); } else { if ($action == "exit") { $oper->processed($table_name, "TODO", $_POST["id"]); } else { if ($action == "label and skip url") { $oper->processed($table_name, $_POST["response"], $_POST["id"], $_POST["url"], $_POST["user"]); $oper->skipUrl($table_name, $_POST["response"], $_POST["url"]); } } }
function parseStringOperation($val) { $_this =& Operations::getInstance(); foreach ($_this->operators as $op) { $op = Set::merge($_this->opDefOpt, $op); if (!empty($op['pattern'])) { if (preg_match($op['pattern'], (string) $val, $res)) { $oper = array('operator' => $op['name']); array_shift($res); foreach ($res as $k => $r) { if (!empty($op['named'][$k])) { $name = (array) $op['named'][$k]; $oper[$name[0]] = $r; } else { $oper[$k] = $r; } } return $oper; } } } return $val; }
function parseStringOperation($val, $options = array()) { if (is_numeric($val)) { return $val; } $_this =& Operations::getInstance(); $localOpt = array('type', 'error'); $defOpt = array('mode' => 'full', 'error' => false); $opt = array_merge($defOpt, $options); App::import('Lib', 'SetMulti'); foreach ($_this->operators as $op) { $op = Set::merge($_this->opDefOpt, $op, SetMulti::excludeKeys($opt, $localOpt)); if (empty($opt['type']) || in_array($op['type'], (array) $opt['type'])) { $pattern = $_this->getPattern($op); //debug($pattern); if (!empty($pattern)) { if (preg_match($pattern, (string) $val, $res)) { //debug($res); $oper = array('operator' => $op['name']); array_shift($res); foreach ($res as $k => $r) { if (!is_numeric($k)) { $oper[$k] = $r; } } return $oper; } } } } if ($opt['error'] == '(val)') { return $val; } else { return $opt['error']; } }
function calculSubItem($products, $order = null) { App::import('Lib', 'Shop.SetMulti'); if (SetMulti::isAssoc($products)) { $prods = array(&$products); } else { $prods =& $products; } foreach ($prods as &$prod) { $orderItemMode = isset($prod['item_price']); if ($orderItemMode) { $p =& $prod; } else { $p = $this->extractOrderItemData($p2 = $prod, $order); } $cur_price = $p['item_price']; $p['item_alone_price'] = $cur_price; $p['overwritten_price'] = false; $subItems = $this->extractSubItemData($prod, $order); if (!empty($subItems)) { //============ calculate ============// App::import('Lib', 'Shop.Operations'); foreach ($subItems as &$subItem) { //debug($subItem); if ($subItem['item_price'] != '' && !is_null($subItem['item_price'])) { $new_price = $cur_price; $subPrice = $subItem['item_price'] * $subItem['nb']; if ($subItem['item_operator'] == '=') { $new_price = $subPrice; $p['overwritten_price'] = true; } else { $new_price = Operations::simpleOperation($cur_price, $subItem['item_operator'], $subPrice); } $subItem['modif'] = $new_price - $cur_price; $cur_price = $new_price; } } $p['SubItem'] = $subItems; } $p['subitems_modif'] = $cur_price - $p['item_price']; $p['item_price'] = $cur_price; if (!$orderItemMode) { if (isset($prod['ShopProduct']['DynamicField'])) { $dprod =& $prod['ShopProduct']; } else { $dprod =& $prod; } $dprod['DynamicField']['subitems_modif'] = $p['subitems_modif']; $dprod['DynamicField']['alone_price'] = $p['item_alone_price']; $dprod['DynamicField']['price'] = $p['item_price']; $dprod['DynamicField']['overwritten_price'] = $p['overwritten_price']; } } return $products; }
$PASSWORD = "******"; if ($production == false) { $ussdserverurl = 'http://localhost:7000/ussd/send'; $LBS_SERVER_URL = "http://localhost:7000/lbs/locate"; $SMS_SERVER_URL = "http://localhost:7000/sms/send"; $SUBSCRIPTION_SERVER_URL = "http://localhost:7000/subscription/send"; } else { $ussdserverurl = 'https://api.dialog.lk/ussd/send'; $LBS_SERVER_URL = 'https://api.dialog.lk/lbs/locate'; $SMS_SERVER_URL = "https://api.dialog.lk/sms/send"; $SUBSCRIPTION_SERVER_URL = "http://api.dialog.lk:8080/subscription/send"; } $log = new Logger(); $receiver = new UssdReceiver(); $sender = new UssdSender($ussdserverurl, $APP_ID, $PASSWORD); $operations = new Operations(); $receiverSessionId = $receiver->getSessionId(); $content = $receiver->getMessage(); // get the message content $address = $receiver->getAddress(); // get the sender's address $requestId = $receiver->getRequestID(); // get the request ID $applicationId = $receiver->getApplicationId(); // get application ID $encoding = $receiver->getEncoding(); // get the encoding value $version = $receiver->getVersion(); // get the version $sessionId = $receiver->getSessionId(); // get the session ID;
function testCond($cond, $data, $or = false, $empty = false) { $valid = true; $def = $empty; $modifKeys = array('and', 'or'); App::import('Lib', 'Operations'); foreach ($cond as $key => $cnd) { $op = false; $path = $key; if (is_numeric($path)) { $val = $data; } elseif (in_array($path, $modifKeys)) { $val = $data; } elseif (array_key_exists($path, $data)) { $val = $data[$path]; } else { $op = Operations::parseStringOperation($path, array('mode' => 'left', 'type' => 'bool', 'sepPattern' => '\\h+')); if ($op) { $path = $op['subject']; } $val = Set::Extract($path, $data); } if ($op) { $op['subject'] = $val; $op['val'] = $cnd; $valid = Operations::applyOperation($op); } elseif (is_null($cnd)) { $valid = is_null($val); } elseif (is_array($cnd)) { $or = $path == 'or'; $valid = SetMulti::testCond($cnd, $val, $or); } elseif (!is_null($data)) { $valid = $val == $cnd; } else { $valid = false; } if ($valid == $or) { return $or; } $def = $valid; } return $def; }
<?php require_once CODE_ROOT . '/classes/operations.php'; require_once CODE_ROOT . '/classes/surgeons.php'; $operations = new Operations(); $surgeons = new Surgeons(); if (empty($request_uri[2])) { $request_uri[2] = ''; } $patId = filter_input(INPUT_GET, 'patId', FILTER_VALIDATE_INT); $hospId = filter_input(INPUT_GET, 'hospId', FILTER_VALIDATE_INT); switch ($request_uri[2]) { case '': $operations->_list($patId, $hospId); break; case 'add': $operations->edit(0, $hospId); if (filter_input(INPUT_POST, 'action', FILTER_VALIDATE_INT) === 1) { if (IS_AJAX === true) { $result = array('success' => $operations->result['success'], 'messages' => $operations->result['message'], 'hospId' => $hospId); echo json_encode($result); die; } else { if ($operations->result['success'] === true) { header('Location: /operations/?hospId=' . $hospId); die; } } } $operations->result['surgeonsList'] = $surgeons->getList(); if (empty($operations->result['surgeonsList'])) {
function mathOperation($options, $supplementItem, $order, $supplement_choice, $calcul) { $defOpt = array('operator' => '+', 'left' => null, 'right' => null, 'leftMethods' => null, 'rightMethods' => null, 'modifProp' => 'total'); $opt = array_merge($defOpt, $options); if (!is_null($opt['leftMethods'])) { $leftOpt = $this->calculFunct(key($opt['leftMethods']), reset($opt['leftMethods']), $supplementItem, $order, $supplement_choice, $calcul); $left = $leftOpt[$opt['modifProp']]; } elseif (!is_null($opt['left'])) { $left = $opt['left']; } else { $left = $supplementItem[$opt['modifProp']]; } if (!is_null($opt['rightMethods'])) { $rigthOpt = $this->calculFunct(key($opt['rightMethods']), reset($opt['rightMethods']), $supplementItem, $order, $supplement_choice, $calcul); $right = $rigthOpt[$opt['modifProp']]; } elseif (!is_null($opt['right'])) { $right = $opt['right']; } else { $right = 0; } App::import('Lib', 'Shop.Operations'); $supplementItem[$opt['modifProp']] = Operations::simpleOperation($left, $opt['operator'], $right); return $supplementItem; }
private function procces_img($user_id, $ad_id) { // if (Login::get_instance()->check_login() == 'valid') { $ds = DIRECTORY_SEPARATOR; $storeFolder = '..' . $ds . 'views' . $ds . 'temp_img'; $newFolder = '..' . $ds . 'views' . $ds . 'ads_img'; $targetPath = dirname(__FILE__) . $ds . $storeFolder . $ds; $newPath = dirname(__FILE__) . $ds . $newFolder . $ds; $images = glob($targetPath . $user_id . "_*.jpeg"); foreach ($images as $img) { $new_name = $ad_id . '_' . md5(rand(1, 5000000000)) . '.jpeg'; while (file_exists($newPath . $new_name)) { $new_name = $ad_id . '_' . md5(rand(1, 5000000000)) . '.jpeg'; } rename($img, $newPath . $new_name); Operations::get_instance()->init(array('ad_id' => $ad_id, 'img_name' => $new_name, 'time_added' => time(), 'date_added' => TimeTools::get_time_id(date('Y-m-d'))), 'ads_img'); } } }
private function img_upload($clinic_id) { if (Login::get_instance()->check_login() == 'valid') { $user_data = Register::get_instance()->get_current_user(); if ($user_data['status'] != 10) { exit; } $foo = new Upload($_FILES['clinic_img']); if ($foo->uploaded) { $this->del($clinic_id); $ds = DIRECTORY_SEPARATOR; $storeFolder = '..' . $ds . 'views' . $ds . 'clinics_img'; $targetPath = dirname(__FILE__) . $ds . $storeFolder . $ds; $targetName = $clinic_id . '_' . md5(rand(1, 5000000000)); while (file_exists($targetName)) { $targetName = $clinic_id . '_' . md5(rand(1, 5000000000)); } $targetFile = $targetPath . $targetName . '.jpeg'; $foo->file_new_name_body = $targetName; $foo->image_resize = true; $foo->image_convert = 'jpeg'; $foo->image_x = 1024; $foo->image_y = 768; $foo->image_ratio_crop = false; //$foo->image_ratio_y = true; $foo->Process($targetPath); if ($foo->processed) { $foo->Clean(); Operations::get_instance()->init(array('img_name' => $targetName . '.jpeg', 'clinic_id' => $clinic_id, 'time_added' => time(), 'date_added' => TimeTools::get_time_id(date('Y-m-d'))), 'clinics_img', 'update'); } } } }
function modifyTarget(&$options, $params) { debug($params); $this->Node = ClassRegistry::init('Node'); $nodes = $this->Node->getNodes($options['acos'], array('fields' => array('foreign_key', 'model'))); foreach ($nodes as $node) { if (!empty($node['Node']['model'])) { $model = ClassRegistry::init($node['Node']['model']); if ($model) { $target = $model->read(array($model->primaryKey, $params['name']), $node['Node']['foreign_key']); if ($target) { App::import('Lib', 'Operations'); if (isset($params['operation'])) { //debug($params['operation']); $target[$model->alias][$params['name']] = Operations::applyOperation($params['operation'], $target[$model->alias][$params['name']], true); } //debug($target); $model->save($target); } } } } //debug($node); //debug($params); }
function test() { $oper = new Operations(); $table_name = "my_table"; $googleFile = "google_sees"; $userFile = "user_sees"; // $oper->createTable($table_name); // $oper->loadComparisonTask($userFile, $googleFile, $table_name); $result = $oper->processing($table_name); print var_dump($result); $id = $result["id"]; $label = 'Yes'; $oper->processed($table_name, $label, $id); print $oper->countRows($table_name); }
public function handle() { if (Login::get_instance()->check_login() == 'valid') { $user_data = Register::get_instance()->get_current_user(); if ($user_data['status'] != 10) { exit; } if (is_array($_POST['users']) && is_numeric($_GET['t']) && $_GET['ty'] == 'users') { if ($_GET['t'] == 1) { $status = 1; } else { $status = 2; } foreach ($_POST['users'] as $id) { Operations::get_instance()->init(array('id' => intval($id), 'status' => $status), 'users', 'update'); } } else { if (is_array($_POST['ads']) && is_numeric($_GET['t']) && $_GET['ty'] == 'ads') { if ($_GET['t'] == 1) { $status = 1; } else { $status = 2; } foreach ($_POST['ads'] as $id) { Operations::get_instance()->init(array('id' => intval($id), 'status' => $status), 'ads', 'update'); } } else { if (is_array($_POST['clinics']) && is_numeric($_GET['t']) && $_GET['ty'] == 'clinics') { if ($_GET['t'] == 1) { $status = 1; } else { $status = 2; } foreach ($_POST['clinics'] as $id) { Operations::get_instance()->init(array('id' => intval($id), 'status' => $status), 'clinics', 'update'); } } } } } }