public function get_code_transfer() { $db = new db_core(); $token = ""; while (true) { $token = $this->getToken_transfer(4, true, false, false) . "-" . $this->getToken_transfer(8, false, true, false); if (!$db->isExists('inversion_proyecto', 'codigo_transfer', $token)) { break; } } $this->returnData(array("code" => $token)); }
<?php @session_start(); @(include_once "db_core.php"); if (isset($_SESSION['token'])) { $db = new db_core(); if ($db->isExists('session_log', 'token', $_SESSION['token'])) { } else { header("location:index.php"); } } else { header("location:index.php"); }
//LEEMOS LAS LIBRERIAS INTERNAS if (is_dir($dir)) { if ($dh = opendir($dir)) { while (($file = readdir($dh)) !== false) { if (!is_dir($dir . $file)) { if (!class_exists(substr($file, 0, -4))) { require_once $dir . $file; } } } closedir($dh); } } //VERIFICAMOS TOKEN DE SEGURIDAD $db = new db_core(); if ($_POST['lib'] != "user" && $_POST['lib'] != "simulacion" && !$db->isExists('session_log', 'token', $_SESSION['token_user'])) { die('ERROR HANDLER - ERROR DE SEGURIDAD: COD 02'); } else { // LEEMOS LA LIBRERIA QUE SE REQUIERE if (isset($_POST['lib']) && $_POST['method'] && class_exists($_POST['lib'])) { $clase = $_POST['lib']; $objeto = new $clase(); $methodo = $_POST['method']; $clases = new reflectionClass($clase); if ($clases->hasMethod($methodo)) { $data = $_SERVER['HTTP_HOST'] == "localhost" || $_SERVER['HTTP_HOST'] == "127.0.0.1" ? json_decode(stripslashes($_POST['data'])) : json_decode($_POST['data']); $objeto->{$methodo}($data); } else { die("ERROR HANDLER - LLAMADA INVALIDA: COD 03"); } } else {
public function isConected() { $db = new db_core(); if (isset($_SESSION['token_user']) && $db->isExists('session_log', 'token', $_SESSION['token_user'])) { $this->returnData(array("status" => 0)); } else { $this->returnData(array("status" => 1)); } }
public function posibleInvertir($opt) { $db = new db_core(); if (isset($_SESSION['token_user']) && $db->isExists('session_log', 'token', $_SESSION['token_user'])) { $consulta = proyectos::get_info($opt->id); if (time() < strtotime($consulta['proyecto']['inicio_date'])) { $this->returnData(array("status" => "noinit")); } elseif (time() > strtotime($consulta['proyecto']['deadline'])) { $this->returnData(array("status" => "finish")); } elseif ($consulta['proyecto']['deadline'] == 1) { $this->returnData(array("status" => "financiado")); } else { $this->returnData(array("status" => "ok")); } } else { $this->returnData(array("status" => "user")); } }
function getToken($table, $campo, $uc = TRUE, $n = TRUE, $sc = TRUE, $largo = 15) { $db = new db_core(); $source = 'abcdefghijklmnopqrstuvwxyz'; if ($uc == 1) { $source .= 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'; } if ($n == 1) { $source .= '1234567890'; } if ($sc == 1) { $source .= '|@#~$%()=^*+[]{}-_'; } $rstr = ""; while (true) { $rstr = ""; $source = str_split($source, 1); for ($i = 1; $i <= $largo; $i++) { mt_srand((double) microtime() * 1000000); $num = mt_rand(1, count($source)); $rstr .= $source[$num - 1]; } if (!$db->isExists($table, $campo, $rstr)) { break; } } return $rstr; }