function save($id, $account) { // Update .... if (!$account['isNew']) { $this->db->update('person', ["firstname" => $account['firstname'], "lastname" => $account['lastname']], "id = '{$id}'"); $this->db->update('accountrole', ["role" => $account['role']], "accountid = '{$id}'"); if (isset($account['password']) && strlen($account['password']) > 5) { $this->db->update('account', ["password" => md5($account['password'])], "id = '{$id}'"); } else { $this->latestErr = "Password didn't match or shoter than 5 characters."; return false; } } else { $username = $account['username']; $this->db->from('account'); $this->db->where('username', $username); if (count($this->db->get()->result())) { $this->latestErr = "Email has already taken."; return false; } $this->db->insert('account', buildBaseParam(["id" => $id, "username" => $account['username'], "password" => md5($account['password']), "status" => 0], $id)); $this->db->insert('person', buildBaseParam(["id" => $id, "firstname" => $account['firstname'], "lastname" => $account['lastname']], $id)); $this->db->insert('accountrole', buildBaseParam(["id" => gen_uuid(), "accountid" => $id, "role" => strtolower($account['role'])], $id)); } return true; }
private function initSession(){ // init a session id if we don't already have one if(!isset($_SESSION["uuid"])){ // all our access will be through this uuid $_SESSION["uuid"] = gen_uuid(); } }
function submit_data_to_google($order_data, $content_data, $order_source) { // Формирование данных для аналитики $gaurl = 'https://ssl.google-analytics.com/collect'; // https://developers.google.com/analytics/devguides/collection/protocol/v1/reference#transport $gaid = ''; // Идентификатор GA $gav = '1'; // Версия GA $gasitename = ''; // Название сайта // Список параметров https://developers.google.com/analytics/devguides/collection/protocol/v1/parameters# $cid = gen_uuid(); // Client ID $uid = gen_uuid(); // User ID $cn = ''; // Campaign Name $cs = ''; // Campaign Source $cm = ''; // Campaign Medium // https://developers.google.com/analytics/devguides/collection/protocol/v1/parameters#in $data_transaction = array('v' => $gav, 'tid' => $gaid, 'cid' => $cid, 'uid' => $uid, 'cn' => $cn, 'cs' => $cs, 'cm' => $cm, 't' => 'transaction', 'ti' => '', 'ta' => $gasitename, 'tr' => '', 'ts' => '', 'tt' => ''); $data_item = array('v' => $gav, 'tid' => $gaid, 'cid' => $cid, 'uid' => $uid, 'cn' => $cn, 'cs' => $cs, 'cm' => $cm, 't' => 'item', 'ti' => '', 'ic' => '', 'in' => '', 'ip' => '', 'iq' => '', 'iv' => 'tea'); // Выполнить запрос к GA $result_transaction = execute_request_to_google($data_transaction, $gaurl); $result_item = execute_request_to_google($data_item, $gaurl); // Вернуть результат данных отправленных в аналитику return array('result_transaction' => $result_transaction, 'result_item' => $result_item, 'data_transaction' => $data_transaction, 'data_item' => $data_item); }
public function edit($arg = null) { $account = new stdClass(); if ($arg != null) { $account = $this->Mdl_Accounts->get($arg); $account->isNew = false; } else { $account->isNew = true; $account->id = gen_uuid(); $account->username = ""; $account->firstname = ""; $account->lastname = ""; $account->status = 1; $account->role = "administrator"; } $arrRoles = ["Free user", "Concreteprotector"]; $account->rolesHTML = "<select name='role'>"; foreach ($arrRoles as $role) { $selected = ""; $selected = $role == $account->role ? " selected " : ""; $Role = ucfirst($role); $account->rolesHTML .= "<option {$selected} value='{$role}'>{$Role}</option>"; } $account->rolesHTML .= "</select>"; parent::initView(get_class($this) . '/edit', 'Accounts', 'Edit account information.', $account); parent::loadView(); }
function add_data_header($link) { $access_id = gen_uuid(); $delete_code = gen_uuid(); $sql = "INSERT INTO `impact`.`header_data` (`id`, `access_id`, `delete_code`, `created`) VALUES (NULL, '" . $access_id . "', '" . $delete_code . "', CURRENT_TIMESTAMP)"; $result = $link->query($sql); return array("id" => mysqli_insert_id($link), "access_id" => $access_id, "delete_code" => $delete_code); }
public function edit($id = null) { $record = new stdClass(); $ings = $this->Mdl_Systems->getIngredients(); if ($id != null) { $record = $this->Mdl_Systems->get($id); $record->isNew = false; } else { $record->isNew = true; $record->id = gen_uuid(); $record->name = ""; $record->saleprice = ""; $record->share = "f"; $record->status = true; } $share = ""; $active = ""; if ($record->share == "t") { $share = "checked"; } if ($record->status) { $active = "checked"; } $record->shareHTML = "<input {$share} id='share' type='checkbox' name='_share'><label for='share'> Share</label>"; $record->activeHTML = "<input {$active} id='status' type='checkbox' name='_status'><label for='status'> Active</label>"; /* Colors.... */ $record->ingredientsHTML = ""; foreach ($ings as $ing) { $checked = ""; $extra = ""; $factor = ""; if (!$record->isNew) { foreach ($record->selIngs as $selIng) { if ($selIng->ingredientid == $ing->id) { $checked = "checked"; $extra = $selIng->extra; $factor = $selIng->factor; } } } $record->ingredientsHTML .= "<div class='row ing'>"; $record->ingredientsHTML .= "<div class='col-md-8'>"; $record->ingredientsHTML .= "<input {$checked} id='{$ing->id}' type='checkbox' name='{$ing->id}' value='1'><label for='{$ing->id}'> {$ing->name}</label><br>"; $record->ingredientsHTML .= "</div>"; $record->ingredientsHTML .= "<div class='col-md-2'>"; $record->ingredientsHTML .= "<div class='row item'><div class='col-md-4'><label >{$ing->purchaseprice}</label></div><div class='col-md-8'><input class='_extra' name='{$ing->id}' value='{$extra}'/></div>"; $record->ingredientsHTML .= "</div></div>"; $record->ingredientsHTML .= "<div class='col-md-2'>"; $record->ingredientsHTML .= "<div class='row item'><div class='col-md-4'><label >Units extra</label></div><div class='col-md-8'><input class='_factor' name='{$ing->id}' value='{$factor}'/></div>"; $record->ingredientsHTML .= "</div></div>"; $record->ingredientsHTML .= "</div>"; } parent::initView("Systems/edit", "Systems", 'Edit Systems information.', $record); parent::loadView(); }
protected function renderContent() { if (isset($this->block) && $this->block != null) { $model = new UserAvatarForm(); if (isset($_POST['UserAvatarForm'])) { $model->attributes = $_POST['UserAvatarForm']; $model->image = CUploadedFile::getInstance($model, 'image'); if ($model->validate()) { //Get the User Id to determine the folder $folder = user()->id >= 1000 ? (string) (round(user()->id / 1000) * 1000) : '1000'; $filename = user()->id . '_' . gen_uuid(); if (!(file_exists(AVATAR_FOLDER . DIRECTORY_SEPARATOR . 'root' . DIRECTORY_SEPARATOR . $folder) && AVATAR_FOLDER . DIRECTORY_SEPARATOR . 'root' . DIRECTORY_SEPARATOR . $folder)) { mkdir(AVATAR_FOLDER . DIRECTORY_SEPARATOR . 'root' . DIRECTORY_SEPARATOR . $folder, 0777, true); } if (file_exists(AVATAR_FOLDER . DIRECTORY_SEPARATOR . 'root' . DIRECTORY_SEPARATOR . $folder . DIRECTORY_SEPARATOR . $filename . '.' . strtolower(CFileHelper::getExtension($model->image->name)))) { $filename .= '_' . time(); } $filename = $filename . '.' . strtolower(CFileHelper::getExtension($model->image->name)); $path = $folder . DIRECTORY_SEPARATOR . $filename; if ($model->image->saveAs(AVATAR_FOLDER . DIRECTORY_SEPARATOR . 'root' . DIRECTORY_SEPARATOR . $path)) { //Generate thumbs // GxcHelpers::generateAvatarThumb($filename, $folder, $filename); //So we will start to check the info from the user $current_user = User::model()->findByPk(user()->id); if ($current_user) { if ($current_user->avatar != null && $current_user->avatar != '') { //We will delete the old avatar here $old_avatar_path = $current_user->avatar; $current_user->avatar = $path; if (file_exists(AVATAR_FOLDER . DIRECTORY_SEPARATOR . 'root' . DIRECTORY_SEPARATOR . $old_avatar_path)) { @unlink(AVATAR_FOLDER . DIRECTORY_SEPARATOR . 'root' . DIRECTORY_SEPARATOR . $old_avatar_path); } //Delete old file Sizes $sizes = AvatarSize::getSizes(); foreach ($sizes as $size) { if (file_exists(AVATAR_FOLDER . DIRECTORY_SEPARATOR . $size['id'] . DIRECTORY_SEPARATOR . $old_avatar_path)) { @unlink(AVATAR_FOLDER . DIRECTORY_SEPARATOR . $size['id'] . DIRECTORY_SEPARATOR . $old_avatar_path); } } } else { //$current_user $current_user->avatar = $path; } $current_user->save(); } } else { throw new CHttpException('503', 'Error while uploading!'); } } } $this->render(BlockRenderWidget::setRenderOutput($this), array('model' => $model)); } else { echo ''; } }
public static function alphaId($len = 10) { $hex = md5("statme" . uniqid("", true)); $pack = pack('H*', $hex); $tmp = base64_encode($pack); $uid = preg_replace("#(*UTF8)[^A-Za-z0-9]#", "", $tmp); $len = max(4, min(128, $len)); while (strlen($uid) < $len) { $uid .= gen_uuid(22); } return substr($uid, 0, $len); }
public function edit($id = null) { $color = new stdClass(); if ($id != null) { $color = $this->Mdl_Patterns->get($id); $color->isNew = false; } else { $color->isNew = true; $color->id = gen_uuid(); $color->name = ""; } parent::initView("Patterns/edit", "Patterns", 'Edit pattern information.', $color); parent::loadView(); }
public function store_result($result_data) { $success = TRUE; // Generate unique id from application/helpers/uuid_helper.php $uuid = gen_uuid(); $result_data['resid'] = $uuid; // Transaction $this->db->trans_start(); if (!$this->db->insert('results', $result_data)) { $success = FALSE; } $this->db->trans_complete(); return $success; }
public function edit($id = null) { $color = new stdClass(); if ($id != null) { $color = $this->Mdl_Colors->get($id); $color->isNew = false; } else { $color->isNew = true; $color->id = gen_uuid(); $color->name = ""; } parent::initView(get_class($this) . '/edit', 'Colors', 'Edit color information.', $color); parent::loadView(); }
public function edit($id = null) { $record = new stdClass(); $colors = $this->Mdl_Ingredients->getColors(); $patterns = $this->Mdl_Ingredients->getPatterns(); if ($id != null) { $record = $this->Mdl_Ingredients->get($id); $record->isNew = false; } else { $record->isNew = true; $record->id = gen_uuid(); $record->name = ""; $record->coverage = ""; $record->purchaseprice = ""; } /* Colors.... */ $record->colorsHTML = ""; foreach ($colors as $col) { $checked = ""; if (!$record->isNew) { foreach ($record->selectedColors as $selCol) { if ($selCol->colorid == $col->id) { $checked = "checked"; } } } $record->colorsHTML .= "<input {$checked} id='{$col->id}' type='checkbox' name='{$col->id}' value='1'><label for='{$col->id}'> {$col->name}</label><br>"; } /* Patterns.... */ $record->patternsHTML = ""; foreach ($patterns as $pat) { $checked = ""; if (!$record->isNew) { foreach ($record->selectedPatterns as $selPat) { if ($selPat->patternid == $pat->id) { $checked = "checked"; } } } $record->patternsHTML .= "<input {$checked} id='{$pat->id}' type='checkbox' name='{$pat->id}' value='1'><label for='{$pat->id}'> {$pat->name}</label><br>"; } parent::initView("Ingredients/edit", "Ingredients", 'Edit ingredient information.', $record); parent::loadView(); }
function activate_addon() { $guid_option_name = "lfeguid"; $base_url_option_name = "base_url"; if (!get_option($guid_option_name)) { add_option($guid_option_name, gen_uuid()); } $base_url = 'http://apps.lfe.com'; if (get_option($base_url_option_name)) { update_option($base_url_option_name, $base_url); } else { add_option($base_url_option_name, $base_url); } //file_get_contents wp_remote_get($base_url . '/WidgetEndPoint/Plugin/Install?' . http_build_query(array('uid' => get_option($guid_option_name), 'domain' => get_site_url(), 'type' => 3, 'version' => get_bloginfo('version'), 'pluginVersion' => "1.0.0"))); }
function api_createSession($uid) { include "db_config.php"; mysql_set_charset('UTF8'); $date = date("Y-m-d H:i:s"); //Date Actuel $UUID = gen_uuid(); // génération UUID $conn = mysql_connect($DB_host, $DB_login, $DB_pass); $db = mysql_select_db($DB_select, $conn); if (!$conn) { die('Erreur de connexion: ' . mysql_error()); } $SQL = "INSERT INTO session(UUID,dateSession,uid) VALUES ('{$UUID}', '{$date}',{$uid})"; $reponse = mysql_query($SQL); return $UUID; }
function BuildOCPSoap() { /* Select the right region for your CRM crmna:dynamics.com - North America crmemea:dynamics.com - Europe, the Middle East and Africa crmapac:dynamics.com - Asia Pacific */ $region = 'crmapac:dynamics.com'; $OCPRequest = '<s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope" xmlns:a="http://www.w3.org/2005/08/addressing" xmlns:u="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"> <s:Header> <a:Action s:mustUnderstand="1">http://schemas.xmlsoap.org/ws/2005/02/trust/RST/Issue</a:Action> <a:MessageID>urn:uuid:%s</a:MessageID> <a:ReplyTo> <a:Address>http://www.w3.org/2005/08/addressing/anonymous</a:Address> </a:ReplyTo> <a:To s:mustUnderstand="1">%s</a:To> <o:Security s:mustUnderstand="1" xmlns:o="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"> <u:Timestamp u:Id="_0"> <u:Created>%sZ</u:Created> <u:Expires>%sZ</u:Expires> </u:Timestamp> <o:UsernameToken u:Id="uuid-cdb639e6-f9b0-4c01-b454-0fe244de73af-1"> <o:Username>%s</o:Username> <o:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">%s</o:Password> </o:UsernameToken> </o:Security> </s:Header> <s:Body> <t:RequestSecurityToken xmlns:t="http://schemas.xmlsoap.org/ws/2005/02/trust"> <wsp:AppliesTo xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy"> <a:EndpointReference> <a:Address>' . $region . '</a:Address> </a:EndpointReference> </wsp:AppliesTo> <t:RequestType>http://schemas.xmlsoap.org/ws/2005/02/trust/Issue</t:RequestType> </t:RequestSecurityToken> </s:Body> </s:Envelope>'; $OCPRequest = sprintf($OCPRequest, gen_uuid(), 'https://login.microsoftonline.com/RST2.srf', getCurrentTime(), getNextDayTime(), $this->username, $this->password); return $OCPRequest; }
function gen_uuid($len = 8) { $hex = md5("summerfields_1864" . uniqid("", true)); $pack = pack('H*', $hex); $uid = base64_encode($pack); // max 22 chars $uid = preg_replace("#(*UTF8)[^A-Za-z0-9]#", "", $uid); // mixed case if ($len < 4) { $len = 4; } if ($len > 128) { $len = 128; } // prevent silliness, can remove while (strlen($uid) < $len) { $uid = $uid . gen_uuid(22); } // append until length achieved return substr($uid, 0, $len); }
public static function generate($len = 8) { $hex = md5("a5cc85f1-e89a-4cc6-86a6-5b58db9a774e" . uniqid("", true)); $pack = pack('H*', $hex); $uid = base64_encode($pack); // max 22 chars $uid = preg_replace("#(*UTF8)[^A-Za-z0-9]#", "", $uid); // mixed case if ($len < 4) { $len = 4; } if ($len > 128) { $len = 128; } // prevent silliness, can remove while (strlen($uid) < $len) { $uid = $uid . gen_uuid(22); } // append until length achieved return substr($uid, 0, $len); }
function gen_uuid($len = 8) { $hex = md5("your_random_salt_here_31415" . uniqid("", true)); $pack = pack('H*', $hex); $uid = base64_encode($pack); // max 22 chars $uid = ereg_replace("[^A-Za-z0-9]", "", $uid); // mixed case //$uid = ereg_replace("[^A-Z0-9]", "", strtoupper($uid)); // uppercase only if ($len < 4) { $len = 4; } if ($len > 128) { $len = 128; } // prevent silliness, can remove while (strlen($uid) < $len) { $uid = $uid . gen_uuid(22); } // append until length achieved return substr($uid, 0, $len); }
function save($id, $record) { // Update .... if (!$record['isNew']) { $this->db->update('system', ["name" => $record['name'], "saleprice" => $record['saleprice'], "status" => $record['status'], "share" => $record['share']], "id = '{$id}'"); // Colors // Remove all colors first. $this->db->delete('systemdetail', ['systemid' => $id]); } else { $this->db->insert('system', buildBaseParam(["id" => $id = gen_uuid(), "name" => $record['name'], "saleprice" => $record['saleprice'], "status" => $record['status'], "share" => $record['share']], $this->session->userdata('id'))); } $selIngs = json_decode($record['selIngs']); $arrSelectedIngs = []; foreach ($selIngs as $key => $val) { if ($val->checked) { array_push($arrSelectedIngs, buildBaseParam(['systemid' => $id, 'ingredientid' => $key, 'extra' => $val->extra, 'factor' => $val->factor, 'id' => gen_uuid(), 'status' => 1], $this->session->userdata('id'))); } } // Re-add all colors. if (count($arrSelectedIngs)) { $this->db->insert_batch('systemdetail', $arrSelectedIngs); } }
function save($id, $ingredient) { // Update .... if (!$ingredient['isNew']) { $this->db->update('ingredient', ["name" => $ingredient['name'], "coverage" => $ingredient['coverage'], "purchaseprice" => $ingredient['purchaseprice']], "id = '{$id}'"); } else { $this->db->insert('ingredient', buildBaseParam(["id" => $id = gen_uuid(), "name" => $ingredient['name'], "coverage" => $ingredient['coverage'], "purchaseprice" => $ingredient['purchaseprice']], $this->session->userdata('id'))); } // Colors // Remove all colors first. $this->db->delete('ingredientcolor', ['ingredientid' => $id]); $selColors = json_decode($ingredient['selCols']); $arrSelectedColors = []; foreach ($selColors as $key => $val) { if ($val == 1) { array_push($arrSelectedColors, buildBaseParam(['colorid' => $key, 'ingredientid' => $id, 'id' => gen_uuid()], $this->session->userdata('id'))); } } // Re-add all colors. if (count($arrSelectedColors)) { $this->db->insert_batch('ingredientcolor', $arrSelectedColors); } // Patterns // Remove all patterns first. $this->db->delete('ingredientpattern', ['ingredientid' => $id]); $selPatterns = json_decode($ingredient['selPats']); $arrSelectedPatterns = []; foreach ($selPatterns as $key => $val) { if ($val == 1) { array_push($arrSelectedPatterns, buildBaseParam(['patternid' => $key, 'ingredientid' => $id, 'id' => gen_uuid()], $this->session->userdata('id'))); } } // Re-add all colors. if (count($arrSelectedPatterns)) { $this->db->insert_batch('ingredientpattern', $arrSelectedPatterns); } }
function get_sans_from_csr($csr) { global $random_blurp; global $timeout; //openssl_csr_get_subject doesn't support SAN names. $filename = "/tmp/csr-" . $random_blurp . "-" . gen_uuid() . ".csr.pem"; $write_csr = file_put_contents($filename, $csr); if ($write_csr !== FALSE) { $openssl_csr_output = trim(shell_exec("timeout " . $timeout . " openssl req -noout -text -in " . $filename . " | grep -e 'DNS:' -e 'IP:'")); } unlink($filename); if ($openssl_csr_output) { $sans = array(); $csr_san_dns = explode("DNS:", $openssl_csr_output); $csr_san_ip = explode("IP:", $openssl_csr_output); if (count($csr_san_dns) > 1) { foreach ($csr_san_dns as $key => $value) { if ($value) { $san = trim(str_replace(",", "", str_replace("DNS:", "", $value))); array_push($sans, $san); } } } if (count($csr_san_ip) > 1) { foreach ($csr_san_ip as $key => $value) { if ($value) { $san = trim(str_replace(",", "", str_replace("IP:", "", $value))); array_push($sans, $san); } } } } if (count($sans) >= 1) { return $sans; } }
$countQry = mysql_query("select * from tanda_terima order by no desc") or die(mysql_error()); $arrCountQry = mysql_fetch_array($countQry); $testDetail = json_encode($jsondata[0]->listDetail); $jsondataDetail = json_decode($testDetail); $cekCN = mysql_num_rows(mysql_query("SELECT * FROM invoice_header WHERE no_inv='{$no_inv}'")); if ($cekCN >= 1) { echo "Nomor Invoice {$no_inv} sudah ada di database, silahkan ganti dengan yang lain !"; } else { $sid_header = $id; $sql = "INSERT INTO invoice_header \r\n\t\t\t\t\tVALUES ('{$id}',\r\n\t\t\t\t\t\t\t'{$no_inv}',\r\n\t\t\t\t\t\t\t'{$tanggal}',\r\n\t\t\t\t\t\t\t'{$customer_sid}',\r\n\t\t\t\t\t\t\t'{$customer_nama}',\r\n\t\t\t\t\t\t\t'0',\r\n\t\t\t\t\t\t\t'0',\r\n\t\t\t\t\t\t\t'0',\r\n\t\t\t\t\t\t\t'{$jatuh_tempo}',\r\n\t\t\t\t\t\t\t'BELUM LUNAS',\r\n\t\t\t\t\t\t\t'{$user_id}',\r\n\t\t\t\t\t\t\t'{$user_name}')"; $result = mysql_query($sql); if ($result) { for ($i = 0; $i < count($jsondataDetail); $i++) { $Qry = mysql_query("select * from tanda_terima where sid = '" . $jsondata[0]->listDetail[$i]->sid . "' ") or die(mysql_error()); $arQ = mysql_fetch_array($Qry); $idDetail = gen_uuid(); mysql_query("INSERT INTO invoice_detail \r\n\t\t\t\t\tVALUES ('{$idDetail}',\r\n\t\t\t\t\t\t\t'{$no_inv}',\r\n\t\t\t\t\t\t\t'{$arQ['sid']}',\r\n\t\t\t\t\t\t\t'{$arQ['no_cn']}',\r\n\t\t\t\t\t\t\t'{$arQ['grand_total']}')"); mysql_query("UPDATE tanda_terima\r\n\t\t\t\t\t\t\tSET is_sudah_invoice = 1\r\n\t\t\t\t\t\t\twhere sid = '" . $jsondata[0]->listDetail[$i]->sid . "' "); } $hitungTotal = mysql_query("SELECT SUM(tarif) as total FROM invoice_detail WHERE no_inv='{$no_inv}'"); $hitungTotalArr = mysql_fetch_array($hitungTotal); $total_inv = $hitungTotalArr['total']; mysql_query("UPDATE invoice_header\r\n\t\t\t\t\t\t\tSET total='{$total_inv}', sisa='{$total_inv}'\r\n\t\t\t\t\t\t\tWHERE no_inv='{$no_inv}'"); } else { echo "Exception Error SQL Save"; } } } else { if ($_GET['sch_inv'] != null) { $sch = mysql_query("select * from invoice_header where no_inv = '" . $_GET['sch_inv'] . "' "); $count = mysql_num_rows($sch);
function get_cookie_saved() { $device = get_device(); $is_new = false; if (empty($device)) { if (isset($_GET['device'])) { $device = $_GET['device']; $is_new = new_user_mem($device, COOKIE_TIMEOUT_NEW); omp_trace('device in params: ' . $device); } else { $device = gen_uuid(); $is_new = new_user($device, time() + COOKIE_TIMEOUT_NEW); omp_trace('device new: ' . $device); } } else { $is_new = new_user($device); omp_trace('device in cookies: ' . $device); } $browser = isset($_COOKIE[COOKIE_DEVICE_SAVED]) ? $_COOKIE[COOKIE_DEVICE_SAVED] : null; $device_saved = null; if (is_first_hit($device) === false) { if ($browser) { $device_saved = json_decode(base64_decode($browser), true); $error = json_last_error(); if ($error === JSON_ERROR_NONE) { $device_saved[0] = empty($device_saved[0]) ? false : true; return array($is_new, $device, $device_saved); } else { $browser = null; } } } $useragent = $_SERVER['HTTP_USER_AGENT']; $browser_o = get_browser_mem($useragent); $device_name = get_device_mem($useragent); $is_mobile = empty($browser_o->ismobiledevice) ? false : true; if (!$is_mobile) { $is_mobile = is_mobile($useragent); } $device_saved = array($is_mobile, $browser_o->browser, $browser_o->platform, $device_name); $device_saved_encode = base64_encode(json_encode($device_saved)); setcookie(COOKIE_DEVICE_SAVED, $device_saved_encode, time() + COOKIE_TIMEOUT, '/', COOKIE_DOMAIN); return array($is_new, $device, $device_saved); }
<?php include 'config_service.php'; include 'gen_uuid_service.php'; session_start(); if (isset($_POST['simpan_po_detail'])) { $id = gen_uuid(); $po = $_POST['po']; $barang = $_POST['barang']; $qty = $_POST['qty']; $diskon = $_POST['diskon']; $strQry = "INSERT INTO po_detail VALUES ('{$id}','{$po}','{$barang}','{$qty}', '{$diskon}')"; // echo ">>>".$strQry; $exQuery = mysql_query($strQry) or die(mysql_error()); if ($exQuery) { echo "<script> alert('Berhasil Menambahkan Detail PO ! '); window.location.href='../form/halaman_utama.php?page=order_detail&po_id={$po}';</script>"; } else { echo "<script> alert('Gagal Membuat PO, silahkan ulangi! '); window.history.back();</script>"; } }
return sprintf('%04x%04x-%04x-%04x-%04x-%04x%04x%04x', mt_rand(0, 0xffff), mt_rand(0, 0xffff), mt_rand(0, 0xffff), mt_rand(0, 0xfff) | 0x4000, mt_rand(0, 0x3fff) | 0x8000, mt_rand(0, 0xffff), mt_rand(0, 0xffff), mt_rand(0, 0xffff)); } header('Content-Type: application/json; charset=utf-8'); $article = urldecode($_POST["article"]); $articleJSON = json_decode("{}"); $articleJSON->id = "article_" . gen_uuid(); $articleJSON->type = "article"; $articleJSON->selectedSentence = json_decode("{}"); $articleJSON->paragraphs = json_decode("[]"); $paragraphs = preg_split('/(?>\\r\\n|\\n|\\r)/', $article); foreach ($paragraphs as $paragraph) { $paragraphJSON = json_decode("{}"); $paragraphJSON->id = "paragraph_" . gen_uuid(); $paragraphJSON->type = "paragraph"; $paragraphJSON->sentences = json_decode("[]"); $sentences = preg_split('/(?<!\\w\\.\\w.)(?<![A-Z][a-z]\\.)(?<=\\.|\\?)\\s/', $paragraph); foreach ($sentences as $sentence) { $sentenceJSON = json_decode("{}"); $sentenceJSON->id = "sentence_" . gen_uuid(); $sentenceJSON->type = "sentence"; $sentenceJSON->displayed = "original"; $sentenceJSON->source = json_decode("{}"); $sentenceJSON->source->original = $sentence; $translatedSentence = translate($sentence); $sentenceJSON->source->machine = $translatedSentence; $sentenceJSON->source->manual = $translatedSentence; array_push($paragraphJSON->sentences, $sentenceJSON); } array_push($articleJSON->paragraphs, $paragraphJSON); } echo json_encode($articleJSON);
function test_heartbleed($ip, $port) { global $current_folder; $exitstatus = 0; $output = 0; $cmdexitstatus = 0; $cmdoutput = 0; $result = 0; $uuid = gen_uuid(); $tmpfile = "/tmp/" . $uuid . ".txt"; # check if python2 is available exec("command -v python2 >/dev/null 2>&1", $cmdoutput, $cmdexitstatus); if ($cmdexitstatus != 1) { exec("timeout 15 python2 " . getcwd() . "/inc/heartbleed.py " . escapeshellcmd($ip) . " --json \"" . $tmpfile . "\" --threads 1 --port " . escapeshellcmd($port) . " --silent", $output, $exitstatus); if (file_exists($tmpfile)) { $json_data = json_decode(file_get_contents($tmpfile), true); foreach ($json_data as $key => $value) { if ($value['status'] == true) { $result = "vulnerable"; } else { $result = "not_vulnerable"; } } unlink($tmpfile); } } else { $result = "python2error"; } return $result; }
public function getRemoteFile(&$resource, $model, &$process, &$message, $path, $ext, $changeresname = true) { if (count($this->allow_types) > 0) { if (!in_array(strtolower($ext), $this->allow_types)) { $message = t('cms', 'File extension is not allowed!'); $process = false; return false; } } $ch = curl_init($path); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); curl_setopt($ch, CURLOPT_BINARYTRANSFER, 1); $rawdata = curl_exec($ch); curl_close($ch); if (!$rawdata) { $process = false; $message = t('cms', 'Error while getting Remote File. Try again later.'); return false; } $filename = gen_uuid(); // folder for uploaded files $folder = date('Y') . DIRECTORY_SEPARATOR . date('m') . DIRECTORY_SEPARATOR; if (!(file_exists(self::RESOURCES_FOLDER . DIRECTORY_SEPARATOR . $folder) && is_dir(self::RESOURCES_FOLDER . DIRECTORY_SEPARATOR . $folder))) { mkdir(self::RESOURCES_FOLDER . DIRECTORY_SEPARATOR . $folder, 0777, true); } //Check if File exists, so Rename the Filename again; while (file_exists(self::RESOURCES_FOLDER . DIRECTORY_SEPARATOR . $folder . DIRECTORY_SEPARATOR . $filename . '.' . strtolower($ext))) { $filename .= rand(10, 99); } $filename = $filename . '.' . $ext; $path = $folder . $filename; $fullpath = self::RESOURCES_FOLDER . DIRECTORY_SEPARATOR . $path; $fp = fopen($fullpath, 'x'); fwrite($fp, $rawdata); fclose($fp); $resource->where = $model->where; $resource->resource_path = $path; if ($changeresname) { $resource->resource_name = $filename; } //Resource::generateThumb($filename,$folder,$filename); $process = true; return true; }
<?php require __DIR__ . '/../../../init.php'; redirect_authed($user); $error = array(); if (isset($_POST['email'])) { $email = $_POST['email']; $email_err = validate_email($email); if (strlen($email_err) > 0) { $error['email'] = $email_err; } if (count($error) == 0) { $uuid = $user->set_token(gen_uuid(), $email); if (!is_production()) { die("<a href='http://localhost:8080/auth/confirm.php?token={$uuid}'>login</a>"); } send_login_mail($email, $uuid); redirect('/auth/confirm.php'); } } echo html(title('Homespot - Sign In/Up'), navigation($user->is_authed()) . content(h1("Sign In/Up") . p('This website uses cookies to check if you are authenticated or not.') . p('By signing in or up you permit us to do so.') . form('post', input_err($error, 'email') . input('email') . submit())));
function createNewPasswordLostToken() { global $dbh; global $config; $uuid = gen_uuid(); $user_name = $_POST['reset_user']; $sth = $dbh->prepare("UPDATE `invoice_users` SET user_password_reset_token=:token, user_password_reset_date=NOW() WHERE user_login=:user;"); $sth->bindParam(':token', $uuid, PDO::PARAM_STR); $sth->bindParam(':user', $user_name, PDO::PARAM_STR); $sth->execute(); $sth = $dbh->prepare("SELECT user_email FROM `invoice_users` WHERE user_login=:user;"); $sth->bindParam(':user', $user_name, PDO::PARAM_STR); $sth->execute(); $data = $sth->fetch(); sendMail($data['user_email'], 'Wachtwoord reset D3 Control Panel', "Hallo,<br />\n<br />\nJe hebt een wachtwoord reset aangevraagd. Je reset token is: '{$uuid}' (zonder '').<br />\nVul deze in bij het invul veld en vervolgens voer je je nieuwe wachtwoord in.<br>\n<br />\nHeb je de pagina niet meer open staan? Vraag dan opnieuw een wachtwoord aan, je ontvangt dan een nieuwe token. Deze is dan niet meer bruikbaar.<br />\n<b>LET OP: Je code is 24 uur geldig.</b><br />\n<br />\nGroet,<br />\nSem"); return true; }
include 'config_service.php'; include 'gen_uuid_service.php'; session_start(); if ($_POST['data'] != null) { $test = json_encode($_POST['data']); $jsondata = json_decode($test); $id = gen_uuid(); $no_inv = strtoupper($jsondata[0]->no_inv); $tanggal = $jsondata[0]->tanggal; $tgl = substr($tanggal, 0, 2); $bln = substr($tanggal, 3, 2); $thn = substr($tanggal, 6, 4); $hasil = "{$thn}-{$bln}-{$tgl}"; $nilai_bayar = $jsondata[0]->nilai_bayar; $user_id = $_SESSION['user_sid']; $user_name = $_SESSION['username']; $result = mysql_query("UPDATE invoice_header\n\t\t\t\t\tSET cicilan=cicilan+'{$nilai_bayar}', sisa=sisa-'{$nilai_bayar}'\n\t\t\t\t\tWHERE no_inv='{$no_inv}'"); if ($result) { $cekHeader = mysql_query("SELECT * FROM invoice_header WHERE no_inv='{$no_inv}'"); $headerArr = mysql_fetch_array($cekHeader); if ($headerArr['sisa'] <= 0) { mysql_query("UPDATE invoice_header\n\t\t\t\t\t\tSET keterangan='LUNAS'\n\t\t\t\t\t\tWHERE no_inv='{$no_inv}'"); } $idBayar = gen_uuid(); mysql_query("INSERT INTO invoice_pembayaran \n\t\t\t\tVALUES ('{$idBayar}',\n\t\t\t\t\t\t'{$no_inv}',\n\t\t\t\t\t\t'{$tanggal}',\n\t\t\t\t\t\t'{$nilai_bayar}',\t\t\t\t\t\t\n\t\t\t\t\t\t'{$user_id}',\n\t\t\t\t\t\t'{$user_name}')"); //echo "<script>alert('Berhasil');</script>"; } else { echo "<script>alert('Exception Error SQL Save');</script>"; } }