$data = backup_config_section($_POST['backuparea']); $name = "{$_POST['backuparea']}-{$name}"; } } } //unlock($lockbckp); /* * Backup RRD Data */ if ($_POST['backuparea'] !== "rrddata" && !$_POST['donotbackuprrd']) { $rrd_data_xml = rrd_data_xml(); $closing_tag = "</" . $g['xml_rootobj'] . ">"; $data = str_replace($closing_tag, $rrd_data_xml . $closing_tag, $data); } if ($_POST['encrypt']) { $data = encrypt_data($data, $_POST['encrypt_password']); tagfile_reformat($data, $data, "config.xml"); } $size = strlen($data); header("Content-Type: application/octet-stream"); header("Content-Disposition: attachment; filename={$name}"); header("Content-Length: {$size}"); if (isset($_SERVER['HTTPS'])) { header('Pragma: '); header('Cache-Control: '); } else { header("Pragma: private"); header("Cache-Control: private, must-revalidate"); } echo $data; exit;
private static function encrypt($text) { return encrypt_data($text, self::SALT); }
debug_print('!exists! continue', __FILE__, __LINE__, __FUNCTION__, __CLASS__, __METHOD__); continue; } $need_tx .= hextobin($new_data['tx_hash']); } while ($binary_data); if (!$need_tx) { exit; } // получился список нужных нам тр-ий, теперь его пошлем тому ноду, у которого они есть $data = $db->query(__FILE__, __LINE__, __FUNCTION__, __CLASS__, __METHOD__, "\n\t\t\tSELECT `host`,\n\t\t\t\t\t\t `node_public_key`\n\t\t\tFROM `" . DB_PREFIX . "miners_data`\n\t\t\tWHERE `user_id` = {$new_data['user_id']}\n\t\t\t", 'fetch_array'); debug_print($data, __FILE__, __LINE__, __FUNCTION__, __CLASS__, __METHOD__); $host = $data['host']; $node_public_key = $data['node_public_key']; debug_print($new_data, __FILE__, __LINE__, __FUNCTION__, __CLASS__, __METHOD__); // шифруем данные. ключ $key будем использовать для расшифровки ответа $encrypted_data = encrypt_data($need_tx, $node_public_key, $db, $my_key); // user_id получателя (нужно для пулов) $encrypted_data = dec_binary($new_data['user_id'], 5) . $encrypted_data; debug_print('$encrypted_data=' . bin2hex($encrypted_data), __FILE__, __LINE__, __FUNCTION__, __CLASS__, __METHOD__); $url = "{$host}/get_tx.php"; debug_print($url, __FILE__, __LINE__, __FUNCTION__, __CLASS__, __METHOD__); // загружаем сами тр-ии $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10); curl_setopt($ch, CURLOPT_TIMEOUT, 30); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, 'data=' . urlencode($encrypted_data)); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); $encrypted_tx_set = curl_exec($ch); curl_close($ch);
/** * @Author: Prabhakar Gupta * @Date: 2016-01-31 13:02:57 * @Last Modified by: Prabhakar Gupta * @Last Modified time: 2016-02-14 23:11:21 */ require_once 'inc/connection.inc.php'; require_once 'inc/login_functions.inc.php'; require_once 'inc/function.inc.php'; if (isLoggedin()) { header("Location: index.php"); } if (isset($_POST['submit'])) { $entered_email = clean_string($_POST['email']); $entered_pass = encrypt_data(clean_string($_POST['pass'])); $query = "SELECT `user_id`,`name`,`army`,`money`,`land` FROM `users` WHERE `email_id`='{$entered_email}' AND `password`='{$entered_pass}' LIMIT 1"; $query_row = mysqli_fetch_assoc(mysqli_query($connection, $query)); if (isset($query_row['user_id'])) { $_SESSION['user_id'] = (int) $query_row['user_id']; $_SESSION['name'] = clean_string($query_row['name']); $_SESSION['army'] = (int) $query_row['army']; $_SESSION['money'] = (int) $query_row['money']; $_SESSION['land'] = (int) $query_row['land']; header("Location: index.php"); } else { $error = true; $message = "Something's wrong!<br><strong>Incorrect Email ID - Password combination</strong>"; } } ?>
* @Author: Prabhakar Gupta * @Date: 2016-01-31 13:02:57 * @Last Modified by: Prabhakar Gupta * @Last Modified time: 2016-02-14 23:11:14 */ require_once 'inc/connection.inc.php'; require_once 'inc/login_functions.inc.php'; require_once 'inc/function.inc.php'; if (isLoggedin()) { header("Location: index.php"); } if (isset($_POST['submit'])) { $entered_name = clean_string($_POST['name'], false); $entered_email = clean_string($_POST['email']); $entered_pass = encrypt_data(clean_string($_POST['pass'])); $entered_conf_pass = encrypt_data(clean_string($_POST['confpass'])); $entered_college = clean_string($_POST['college'], false); if ($entered_pass != $entered_conf_pass) { $error = true; $message = "You had one job!<br><strong>You did not enter same password twice</strong>"; } else { $query = "SELECT `name` FROM `users` WHERE `email_id`='{$entered_email}' LIMIT 1"; $query_row = mysqli_fetch_assoc(mysqli_query($connection, $query)); if (isset($query_row['user_id'])) { $error = true; $message = "I remember you " . $query_row['name'] . "!<br><strong>This Email ID has already been used</strong>"; } else { $query = "INSERT INTO `users` (`name`,`email_id`,`college`,`password`) VALUES ('{$entered_name}','{$entered_email}','{$entered_college}','{$entered_pass}')"; if (mysqli_query($connection, $query)) { header("Location: login.php"); } else {
function removeObjFilm() { global $filmTable; /* verifica se existe alguma informacao no corpo da mensagem */ $request = Slim::getInstance()->request(); $json = readRequestBody($request); if (!$json) { $response["status"] = 0; echo json_encode($response); return; } /* lendo dados do json */ $appID = $json->appID; $crypt_data = $json->data; $iv = $json->iv; $json = json_decode(decrypt_data($appID, $crypt_data, $iv)); $id = $json->idFilme; $response["status"] = 1; $dbh = getConnection(); $sql = "delete from {$filmTable} where idFilme = :id"; $stmt = $dbh->prepare($sql); $stmt->bindParam(":id", $id); $stmt->execute(); closeConnection($dbh); $json = json_encode($response); $data = encrypt_data($appID, $json); echo json_encode($data); return; }
function getFriendsRequest($appID, $data, $iv) { global $friendTable; $json = json_decode(decrypt_data($appID, $data, $iv)); $id1 = $json->idusuario_a; $response["status"] = 0; $dbh = getConnection(); $sql = "SELECT idusuario, nome, email, addressLat, addressLong, imagePath\n\t\t\t\tfrom usuario, (SELECT idusuario_b AS friend FROM {$friendTable}\n\t\t\t\t\tWHERE idusuario_a = :id1 and status = 0 UNION SELECT\n\t\t\t\t\t\tidusuario_a AS friend FROM {$friendTable} WHERE\n\t\t\t\t\t\t\tidusuario_b = :id1 and status = 0) as tmp WHERE\n\t\t\t\t\t\t\t\t\t\t\t\t\tidusuario = tmp.friend"; $stmt = $dbh->prepare($sql); $stmt->bindParam(":id1", $id1); $stmt->execute(); /* get user information as a associative array */ $tmp = $stmt->fetchAll(PDO::FETCH_ASSOC); $response["users"] = storeElements("user", $tmp); if ($response["users"]) { $response["status"] = 1; } closeConnection($dbh); $json = json_encode($response); $data = encrypt_data($appID, $json); echo json_encode($data); }
function addUserObj() { global $patrimonio; /* verifica se existe alguma informacao no corpo da mensagem */ $request = Slim::getInstance()->request(); $json = readRequestBody($request); if (!$json) { $response["status"] = 0; echo json_encode($response); return; } /* lendo dados do json */ $appID = $json->appID; $crypt_data = $json->data; $iv = $json->iv; $json = json_decode(decrypt_data($appID, $crypt_data, $iv)); $userId = $json->userId; $objId = $json->objId; $objType = $json->objType; /* the objType doesn't exist */ if (!isset($patrimonio[$objType])) { $response["status"] = 0; echo json_encode($response); return; } $response["status"] = 1; $dbh = getConnection(); $obj = $patrimonio[$objType][0]; $possui = $patrimonio[$objType][1]; try { /* if the ids exist in their tables and are not linked, add a new row */ $sql = "insert into {$possui} select idusuario, id{$obj} from\n\t\t\t\t\tusuario, obj{$obj} where idusuario = :userID and\n\t\t\t\t\t\tid{$obj} = :objID and (select count(*) from {$possui} where\n\t\t\t\t\t\t\tfk_idUser = :userID and fk_id{$obj} = :objID) = 0"; $stmt = $dbh->prepare($sql); $stmt->bindParam(":userID", $userId); $stmt->bindParam(":objID", $objId); $stmt->execute(); } catch (PDOException $e) { /* couldn't insert */ $response["status"] = 0; } closeConnection($dbh); $json = json_encode($response); $data = encrypt_data($appID, $json); echo json_encode($data); return; }
function spam_key() { return base64_encode(encrypt_data(time(), $GLOBALS['_spam_key'])); }
function m_curl($urls, $_data, $db, $type = 'data', $timeout = 10, $answer = false, $post = true, $remote_node_host = '') { //создаем набор дескрипторов cURL $mh = curl_multi_init(); // при $remote_node_host будет всего 1 url - ip из локальной сети for ($i = 0; $i < sizeof($urls); $i++) { debug_print('$urls[' . $i . ']: ' . print_r_hex($urls[$i]), __FILE__, __LINE__, __FUNCTION__, __CLASS__, __METHOD__); if ($db) { // т.к. на приеме может быть пул, то нужно дописать user_id, чьим нодовским ключем шифруем $data = encrypt_data($_data, $urls[$i]['node_public_key'], $db); $data = dec_binary($urls[$i]['user_id'], 5) . $data; } else { $data = $_data; } if ($remote_node_host) { $data = ParseData::encode_length_plus_data($remote_node_host) . $data; } // создаем ресурс cURL $ch[$i] = curl_init(); curl_setopt($ch[$i], CURLOPT_URL, $urls[$i]['url']); //curl_setopt($ch[$i], CURLOPT_FAILONERROR, 1); curl_setopt($ch[$i], CURLOPT_CONNECTTIMEOUT, 10); // timeout in seconds curl_setopt($ch[$i], CURLOPT_TIMEOUT, $timeout); if ($post) { curl_setopt($ch[$i], CURLOPT_POST, 1); curl_setopt($ch[$i], CURLOPT_POSTFIELDS, $type . '=' . urlencode($data)); } if ($answer) { curl_setopt($ch[$i], CURLOPT_RETURNTRANSFER, 1); } //$params[] = 'data='.urlencode($data); //curl_setopt($ch[$i], CURLOPT_POSTFIELDS, $params); //добавляем X дескрипторов curl_multi_add_handle($mh, $ch[$i]); } $active = null; //запускаем дескрипторы do { debug_print('curl_multi_exec', __FILE__, __LINE__, __FUNCTION__, __CLASS__, __METHOD__); $mrc = curl_multi_exec($mh, $active); } while ($mrc == CURLM_CALL_MULTI_PERFORM); while ($active && $mrc == CURLM_OK) { if (curl_multi_select($mh) == -1) { usleep(100); } do { $mrc = curl_multi_exec($mh, $active); } while ($mrc == CURLM_CALL_MULTI_PERFORM); } $return = array(); if ($answer) { for ($i = 0; $i < sizeof($urls); $i++) { $return[$urls[$i]['user_id']] = curl_multi_getcontent($ch[$i]); } } for ($i = 0; $i < sizeof($urls); $i++) { // закрываем все дескрипторы curl_multi_remove_handle($mh, $ch[$i]); } curl_multi_close($mh); return $return; }
function changeEmprestimoStatus() { global $loanTable; /* verifica se existe alguma informacao no corpo da mensagem */ $request = Slim::getInstance()->request(); $json = readRequestBody($request); if (!$json) { $response["status"] = 0; echo json_encode($response); return; } /* lendo dados do json */ $appID = $json->appID; $crypt_data = $json->data; $iv = $json->iv; $json = json_decode(decrypt_data($appID, $crypt_data, $iv)); $idEmp = $json->idemprestimo; $status = $json->status; $response["status"] = 1; $dbh = getConnection(); $sql = "update {$loanTable} set status = :status where idemprestimo = :idEmp"; try { $stmt = $dbh->prepare($sql); $stmt->bindParam(":idEmp", $idEmp); $stmt->bindParam(":status", $status); $stmt->execute(); } catch (PDOException $e) { $response["status"] = 0; } closeConnection($dbh); $json = json_encode($response); $data = encrypt_data($appID, $json); echo json_encode($data); return; }
/** * Set a custom profile field for a member. * * @param MEMBER The member. * @param AUTO_LINK The field being set. * @param mixed The value of the field. For a trans-type field, this can be either a lang-ID to be copied (from forum DB), or an actual string. * @param ?ID_TEXT The field type (NULL: look it up). * @param boolean Whether to defer the change, by returning a result change rather than doing it right away. * @return ?array Mapping change (NULL: none / can't defer). */ function ocf_set_custom_field($member_id, $field, $value, $type = NULL, $defer = false) { if (is_null($type)) { $type = $GLOBALS['FORUM_DB']->query_value('f_custom_fields', 'cf_type', array('id' => $field)); } ocf_get_custom_field_mappings($member_id); // This will do an auto-repair if CPF storage row is missing global $ANY_FIELD_ENCRYPTED; if ($ANY_FIELD_ENCRYPTED === NULL) { $ANY_FIELD_ENCRYPTED = !is_null($GLOBALS['FORUM_DB']->query_value_null_ok('f_custom_fields', 'cf_encrypted', array('cf_encrypted' => 1))); } if ($ANY_FIELD_ENCRYPTED) { $encrypted = $GLOBALS['FORUM_DB']->query_value('f_custom_fields', 'cf_encrypted', array('id' => $field)); if ($encrypted) { require_code('encryption'); $current = $GLOBALS['FORUM_DB']->query_value('f_member_custom_fields', 'field_' . strval(intval($field)), array('mf_member_id' => $member_id)); if (remove_magic_encryption_marker($value) == remove_magic_encryption_marker($current) && is_data_encrypted($current)) { return NULL; } $value = encrypt_data($value); } } else { $encrypted = false; } require_code('fields'); $ob = get_fields_hook($type); list(, , $storage_type) = $ob->get_field_value_row_bits(array('id' => $field, 'cf_default' => '', 'cf_type' => $type)); if (strpos($storage_type, '_trans') !== false) { if (is_integer($value)) { $value = get_translated_text($value, $GLOBALS['FORUM_DB']); } $current = $GLOBALS['FORUM_DB']->query_value('f_member_custom_fields', 'field_' . strval(intval($field)), array('mf_member_id' => $member_id)); if (is_null($current)) { if ($type == 'posting_field') { require_code('attachments2'); $current = insert_lang_comcode_attachments(3, $value, 'null', strval($member_id), $GLOBALS['FORUM_DB']); } else { $current = insert_lang_comcode($value, 3, $GLOBALS['FORUM_DB']); } $GLOBALS['FORUM_DB']->query_update('f_member_custom_fields', array('field_' . strval(intval($field)) => $current), array('mf_member_id' => $member_id), '', 1); } else { if ($type == 'posting_field') { require_code('attachments2'); require_code('attachments3'); update_lang_comcode_attachments($current, $value, 'null', strval($member_id), $GLOBALS['FORUM_DB'], false, $member_id); } else { lang_remap_comcode($current, $value, $GLOBALS['FORUM_DB']); } } } else { $change = array('field_' . strval(intval($field)) => $value); if (!$defer) { $GLOBALS['FORUM_DB']->query_update('f_member_custom_fields', $change, array('mf_member_id' => $member_id), '', 1); } return $change; } return NULL; }
<?php /** * @Author: Prabhakar Gupta * @Date: 2016-02-21 15:22:42 * @Last Modified by: Prabhakar Gupta * @Last Modified time: 2016-02-21 15:31:53 */ require_once '../inc/connection.inc.php'; require_once '../inc/function.inc.php'; $name = clean_string($_GET['name']); $email = clean_string($_GET['email']); $send_password = clean_string($_GET['pass']); $password = encrypt_data(clean_string($_GET['pass'])); $phone = clean_string($_GET['phone']); $college = clean_string($_GET['college']); $email_valid = (bool) isValidEmail($email); $success = false; $duplicate = false; $moksha_id = 0; if ($email_valid && !empty($name) && !empty($password) && !empty($phone) && !empty($college)) { $query = "INSERT INTO `users` (`name`,`email`,`password`,`phone`,`college`) VALUES ('{$name}','{$email}','{$password}','{$phone}','{$college}')"; if (mysqli_query($connection, $query)) { $success = true; $moksha_id = (int) mysqli_insert_id($connection); $mok_id = "MOK-" . $moksha_id . ""; $name = ucwords($name); $sql = "UPDATE `users` SET `mok_id`='{$mok_id}'WHERE `email`='{$email}'"; mysqli_query($connection, $sql); $to = "{$email}"; $subject = "Registration and Entry Procedure | Moksha'16";
function getCloseUsers($appID, $data, $iv) { global $friendTable; $json = json_decode(decrypt_data($appID, $data, $iv)); $response["status"] = 0; $id1 = $json->idusuario; $userLat = $json->addressLat; $userLong = $json->addressLong; $dbh = getConnection(); $sql = "SELECT idusuario, nome, email, addressLat, addressLong, imagePath\n\t\t\t\tfrom usuario, (SELECT idusuario_b AS friend FROM {$friendTable}\n\t\t\t\t\tWHERE idusuario_a = :id1 UNION SELECT idusuario_a AS friend\n\t\t\t\t\t\tFROM {$friendTable} WHERE idusuario_b = :id1) as tmp WHERE\n\t\t\t\t\t\t\tidusuario = tmp.friend"; $stmt = $dbh->prepare($sql); $stmt->bindParam(":id1", $id1); $stmt->execute(); /* get user information as a associative array */ $elements = $stmt->fetchAll(PDO::FETCH_ASSOC); $type = "user"; if (count($elements) != 0) { $arr = array(); $i = 0; $coordUser = coordenadasEsfericas($userLat, $userLong); foreach ($elements as $elem) { $arr[$i] = array(); $arr[$i][$type] = array(); /* verifica proximidade */ $friendLat = $elements[$i]["addressLat"]; $friendLong = $elements[$i]["addressLong"]; $coordFriend = coordenadasEsfericas($friendLat, $friendLong); if (!distBetweenUsers($coordUser, $coordFriend)) { continue; } echo $elements[$i]['idusuario']; foreach ($elements[$i] as $key => $value) { $arr[$i][$type][$key] = $value ? $value : null; } $i++; } } if ($i == 0) { $arr = null; } $response["users"] = $arr; if ($response["users"]) { $response["status"] = 1; } closeConnection($dbh); $json = json_encode($response); $data = encrypt_data($appID, $json); echo json_encode($data); return; }