/** * Generates an order reference * @result string A reference number */ function calculateReference($bcCodetext) { $tableBuyTemporal = $bcCodetext === 'THIS_IS_A_SESSION' ? Database::get_main_table(TABLE_BUY_SESSION_TEMPORARY) : Database::get_main_table(TABLE_BUY_COURSE_TEMPORAL); $sql = "SELECT MAX(cod) as cod FROM {$tableBuyTemporal}"; $res = Database::query($sql); $row = Database::fetch_assoc($res); $reference = $row['cod'] != '' ? $row['cod'] : '1'; $randomText = randomText(); $reference .= $randomText; return $reference; }
<?php function randomText($length) { $key = ''; $pattern = '1234567890abcdefghijklmnopqrstuvwxyz'; for ($i = 0; $i < $length; $i++) { $key .= $pattern[rand(0, 35)]; } return $key; } function imagecenteredstring($image, $font, $str, $color) { $x = round(imagesx($image) / 2 - strlen($str) * imagefontwidth($font) / 2, 1); $y = round(imagesy($image) / 2 - imagefontheight($font) / 2); imagestring($image, $font, $x, $y, $str, $color); } $str = randomText(4); $_SESSION[$_GET['cid']] = $str; header('Cache-Control: no-store, no-cache, must-revalidate'); header('Pragma: no-cache'); header('Content-type: image/png'); $image = imagecreate(40, 20); $color1 = imagecolorallocate($image, 255, 255, 255); $color2 = imagecolorallocate($image, 0, 0, 0); imagecenteredstring($image, 5, $str, $color2); imagepng($image); die;
<?php session_start(); function randomText($length) { $key = ""; $pattern = "1234567890abcdefghijklmnopqrstuvwxyz"; for ($i = 0; $i < $length; $i++) { $key .= $pattern[rand(0, 35)]; } return $key; } $_SESSION['CaptchaText'] = randomText(5); $Image = imagecreatefromgif("bgcaptcha.gif"); if (!$Image) { $Image = imagecreatetruecolor(150, 30); } $TextColor = imagecolorallocate($Image, 0, 0, 0); imagestring($Image, 4, 2, 0, $_SESSION['CaptchaText'], $TextColor); header("Content-type: image/gif"); imagegif($Image);
$ADODB_COUNTRECS = false; require_once "{$ruta_raiz}/include/db/ConnectionHandler.php"; include "../config.php"; $_SESSION["depeRadicaFormularioWeb"] = $depeRadicaFormularioWeb; // Es radicado en la Dependencia 900 $_SESSION["usuaRecibeWeb"] = $usuaRecibeWeb; // Usuario que Recibe los Documentos Web $_SESSION["secRadicaFormularioWeb"] = $secRadicaFormularioWeb; // Osea que usa la Secuencia sec_tp2_900 $db = new ConnectionHandler($ruta_raiz); $db->conn->SetFetchMode(ADODB_FETCH_ASSOC); //$db->conn->debug = true; include './funciones.php'; include './formulario_sql.php'; //captcha $val_cap = randomText(4); $_SESSION['val_cap'] = $val_cap; //numero de radicado // $numero=substr('000000'.$db->conn->GenID('SECR_TP2_'.$_SESSION['secRadicaFormularioWeb']),-6); $numero = substr('000000' . $db->conn->GenID('SECR_TP2_' . $_SESSION['secRadicaFormularioWeb']), -6); $numeroRadicado = date('Y') . $_SESSION['depeRadicaFormularioWeb'] . $numero . "2"; $_SESSION['numeroRadicado'] = $numeroRadicado; ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Formulario QRDP</title>
<?php session_start(); function randomText($length) { // $pattern = "1234567890abcdefghijklmnopqrstuvwxyz"; $pattern = "23456789aBcDefghjkLmnPQrstuVwxyz"; for ($i = 0; $i < $length; $i++) { $key1 = $pattern[rand(0, 31)]; $key2 = $pattern[rand(0, 31)]; $key3 = $pattern[rand(0, 31)]; $key4 = $pattern[rand(0, 31)]; $key5 = $pattern[rand(0, 31)]; } $key = $key1 . $key2 . $key3 . $key4 . $key5; return $key; } $_SESSION['tmptxt'] = randomText(1); $captcha = imagecreatefromgif("../img/bgcaptcha.gif"); $colText = imagecolorallocate($captcha, 0, 0, 0); imagestring($captcha, 5, 16, 7, $_SESSION['tmptxt'], $colText); //header("Content-type: image/gif"); imagegif($captcha);