Example #1
0
function postForm($url)
{
    if (getHttpStatusCode($url) == 200) {
        $md5 = new MD5();
        ?>
		<meta charset="utf-8">
		跳转中,请稍等。。。
		<form name="loginform" method="POST" action='<?php 
        echo $url;
        ?>
' class="aui login-form-container">                                     
		    <input name="os_username" id="os_username" value="<?php 
        echo $_SESSION["email"];
        ?>
" type="hidden">      
		    <input name="os_password" id="os_password" value="<?php 
        echo $md5->secret2string($_SESSION["password"]);
        ?>
" type="password" style="display:none;">                 
		    <input id="loginButton" class="aui-button aui-style aui-button-primary" name="login" value="登录" type="submit" style="display:none;">                                                         
		    <input name="os_destination" value="" type="hidden">                                      
		</form>
		<?php 
    } else {
        header("Location: 404page.php");
    }
}
 /**
  * Compares a given hash with a clean text password by figuring out the
  * algorithm that has been used and then calling the appropriate sub-class
  *
  * @see cryptography.MD5#compare()
  * @see cryptography.SHA1#compare()
  * @see cryptography.PBKDF2#compare()
  *
  * @param string $input
  *  the cleartext password
  * @param string $hash
  *  the hash the password should be checked against
  * @param boolean $isHash
  * @return boolean
  *  the result of the comparison
  */
 public static function compare($input, $hash, $isHash = false)
 {
     $version = substr($hash, 0, 8);
     if ($isHash == true) {
         return $input == $hash;
     } elseif ($version == 'PBKDF2v1') {
         // salted PBKDF2
         return PBKDF2::compare($input, $hash);
     } elseif (strlen($hash) == 40) {
         // legacy, unsalted SHA1
         return SHA1::compare($input, $hash);
     } elseif (strlen($hash) == 32) {
         // legacy, unsalted MD5
         return MD5::compare($input, $hash);
     } else {
         // the hash provided doesn't make any sense
         return false;
     }
 }
Example #3
0
print "Created GUID 3: " . GUID::create() . "<br/><br/>\n";
/**
* Test ROT13 encoding.
*/
$rot13enc = ROT13::encode($input);
$rot13dec = ROT13::decode($rot13enc);
//
print "ROT13 encoded in UTF-8: " . $rot13enc . "<br/>\n";
print "ROT13 decoded in UTF-8: " . $rot13dec . "<br/><br/>\n";
/**
* Test MD5 with one official test vector and custom input.
* Vectors from: http://www.febooti.com/products/filetweak/members/hash-and-crc/test-vectors/
*/
$md5 = MD5::compute($input);
$md5tv = MD5::compute("");
$md5hmac = MD5::computeHMAC("1234567890123456", $input);
//
print "MD5 from otv is ok: " . bool_str(Base16::encode($md5tv) == "d41d8cd98f00b204e9800998ecf8427e") . "<br/>\n";
print "MD5 HMAC in UTF-8: " . Base16::encode($md5hmac) . "<br/>\n";
print "MD5 in UTF-8: " . Base16::encode($md5) . "<br/><br/>\n";
/**
* Test RIPEMD-160 with one official test vector and custom input.
* Vectors from: http://www.febooti.com/products/filetweak/members/hash-and-crc/test-vectors/
*/
$rmd160 = RMD160::compute($input);
$rmd160tv = RMD160::compute("");
$rmd160hmac = RMD160::computeHMAC("1234567890123456", $input);
//
print "RIPEMD-160 from otv is ok: " . bool_str(Base16::encode($rmd160tv) == "9c1185a5c5e9fc54612808977ee8f548b2258d31") . "<br/>\n";
print "RIPEMD-160 HMAC in UTF-8: " . Base16::encode($rmd160hmac) . "<br/>\n";
print "RIPEMD-160 in UTF-8: " . Base16::encode($rmd160) . "<br/><br/>\n";
            $lUDA->deletar($lUDA->listar());
            $javaScript .= Aviso::criar("Arquivo removido com sucesso!");
        } catch (Exception $e) {
            $javaScript .= Aviso::criar($e->getMessage());
        }
    }
}
$lUDA = new ListaUploadDownloadArquivos();
$lTUDA->createRepeticao("repetir->UploadDownloadArquivos");
if (!empty($_GET['busca'])) {
    $lUDA->condicoes('', "%" . $_GET['busca'] . "%", 'empresa', 'LIKE');
}
$lTUDA->condicao("condicaoBusca", !empty($_SESSION['nivel']));
$lTUDA->trocar("linkCadastrar.UploadDownloadArquivo", "?p=" . $_GET['p'] . "&a=cadastrarUploadDownloadArquivo");
$lUDA->condicoes($a);
$m = new MD5();
while ($uDA = $lUDA->listar("ASC", ListaUploadDownloadArquivos::ARQUIVO)) {
    $lTUDA->repetir();
    $lTUDA->enterRepeticao()->condicao("condicaoRemover", !empty($_SESSION['nivel']));
    $bgColor = $lUDA->getParametros() % 2 == 0 ? '#FFFFFF' : '#EAEAEA';
    $lTUDA->enterRepeticao()->trocar("bgColorEmpresa", $bgColor);
    $lTUDA->enterRepeticao()->trocar("id.UploadDownloadArquivo", $uDA->getId());
    $lTUDA->enterRepeticao()->trocar("nome.Arquivo.UploadDownloadArquivo", $uDA->getArquivo()->nome . "." . $uDA->getArquivo()->extensao);
    $lTUDA->enterRepeticao()->trocar("url.Arquivo.UploadDownloadArquivo", Sistema::$caminhoURL . 'lib.conf/abrirArquivo.php?caminho=' . $m->criptografar(Sistema::$caminhoURL . Sistema::$caminhoDataUploadsDownloads . $uDA->getArquivo()->getNome()));
    $lTUDA->enterRepeticao()->trocar("linkVisualizar.UploadDownloadArquivo", "?p=" . $_GET['p'] . "&a=listarUploadDownloadArquivos&arquivo=" . $uDA->getId());
    $lTUDA->enterRepeticao()->trocar("linkAlterar.UploadDownloadArquivo", "?p=" . $_GET['p'] . "&a=alterarUploadDownloadArquivo&arquivo=" . $uDA->getId());
    $lTUDA->enterRepeticao()->condicao("condicaoVisualizar", $uDA->tipo == 1);
}
$lTUDA->trocar("linkVoltar.UploadDownloadArquivo", "?p=" . $_GET['p'] . "&a=uploadsdownloads");
$botoes = $lTUDA->cutParte('botoes');
$includePagina = $lTUDA->concluir();
 /**
  * Uses `SHA1` or `MD5` to create a hash based on some input
  * This function is currently very basic, but would allow
  * future expansion. Salting the hash comes to mind.
  *
  * @param string $input
  *  the string to be hashed
  * @param string $algorithm
  *  This function supports 'md5', 'sha1' and 'pbkdf2'. Any
  *  other algorithm will default to 'pbkdf2'.
  * @return string
  *  the hashed string
  */
 public static function hash($input, $algorithm = 'sha1')
 {
     switch ($algorithm) {
         case 'sha1':
             return SHA1::hash($input);
         case 'md5':
             return MD5::hash($input);
         case 'pbkdf2':
         default:
             return Crytography::hash($input, $algorithm);
     }
 }
Example #6
0
<?php

exit;
include 'includes.php';
importar('Utils.Imagens.Image');
importar('Utils.MD5');
$m = new MD5();
$caminho = $m->descriptografar($_GET['caminho']);
$arq = new Arquivos($caminho);
$arq->open();
header('Expires: 0');
header('Pragma: no-cache');
if (strtoupper($arq->extensao) == "JPEG" || strtoupper($arq->extensao) == "JPG" || strtoupper($arq->extensao) == "PNG" || strtoupper($arq->extensao) == "GIF" || strtoupper($arq->extensao) == "BMP") {
    header("Content-type: image/" . $arq->extensao);
    $he = number_format($_GET['h']);
    if ($he < $_GET['h']) {
        $he++;
    }
    if (file_exists(dirname($arq->url) . "/" . $he . "/" . basename($arq->url))) {
        $img = new Image(new Arquivos(dirname($arq->url) . "/" . $he . "/" . $arq->nome . "." . $arq->extensao));
    } else {
        $img = new Image($arq);
        if (($_GET['w'] < $img->largura || $_GET['h'] < $img->altura) && (!empty($_GET['w']) && !empty($_GET['h']))) {
            $img->redimensionar($_GET['w'], $_GET['h']);
        }
    }
    /*/marca d'agua
    	
    	$logoAlo = new Imagem(new Arquivos(caminhoDiretorio."lib.img/LOGOALO.gif"));
    	$logoAloW = (15*$_GET['w'])/100;
    	$logoAloH = (15*$_GET['h'])/100;
Example #7
0
            $lM->deletar($lM->listar());
            $javaScript .= Aviso::criar("Música removida com sucesso!");
        } catch (Exception $e) {
            $javaScript .= Aviso::criar($e->getMessage());
        }
    }
}
$lM = new ListaMusicas();
$lTM->createRepeticao("repetir->Musicas");
if (!empty($_GET['busca'])) {
    $lM->condicoes('', "%" . $_GET['busca'] . "%", 'empresa', 'LIKE');
}
$lTM->condicao("condicaoBusca", !empty($_SESSION['nivel']));
$lTM->trocar("linkCadastrar.Musica", "?p=" . $_GET['p'] . "&a=cadastrarMusica");
$lM->condicoes($a);
$m5 = new MD5();
while ($m = $lM->listar("ASC", ListaMusicas::MUSICA)) {
    $lTM->repetir();
    $lTM->enterRepeticao()->condicao("condicaoRemover", !empty($_SESSION['nivel']));
    $bgColor = $lM->getParametros() % 2 == 0 ? '#FFFFFF' : '#EAEAEA';
    $lTM->enterRepeticao()->trocar("bgColorEmpresa", $bgColor);
    $lTM->enterRepeticao()->trocar("id.Musica", $m->getId());
    $lTM->enterRepeticao()->trocar("titulo.Musica", $m->titulo);
    $lTM->enterRepeticao()->trocar("nome.Musica.Musica", $m->getMusica()->nome . "." . $m->getMusica()->extensao);
    $lTM->enterRepeticao()->trocar("url.Musica.Musica", Sistema::$caminhoURL . 'lib.conf/abrirArquivo.php?caminho=' . $m5->criptografar(Sistema::$caminhoURL . Sistema::$caminhoDataDiscografia . $m->getMusica()->getNome()));
    $lTM->enterRepeticao()->trocar("linkVisualizar.Musica", "?p=" . $_GET['p'] . "&a=listarMusicas&musica=" . $m->getId());
    $lTM->enterRepeticao()->trocar("linkAlterar.Musica", "?p=" . $_GET['p'] . "&a=alterarMusica&musica=" . $m->getId());
    $lTM->enterRepeticao()->condicao("condicaoVisualizar", $m->tipo == 1);
}
$lTM->trocar("linkVoltar.Musica", "?p=" . $_GET['p'] . "&a=discografia");
$botoes = $lTM->cutParte('botoes');
 /**
  * Returns a checksum for a given input string
  *
  * @param   string data
  * @return  security.checksum.Checksum
  */
 protected function checksumOf($data)
 {
     return MD5::fromString($data)->getValue();
 }
Example #9
0
function processLogin()
{
    /*if(isset($_GET["username"]) and $_GET["username"]=="guest"){
    		$_SESSION["username"]="******";
    		$_SESSION["email"]="CY0000";
    		header("Location:home.php");
    	}*/
    if (isset($_POST["email"]) and isset($_POST["password"])) {
        require_once "class.db.Utils.php";
        require_once "class.LDAP.php";
        require_once "class.MD5.php";
        require_once "class.db.Log.php";
        $ldap = new LDAP();
        $md5 = new MD5();
        $email = $_POST["email"];
        if ($email != "") {
            if (!strpos($email, "@cyou-inc.com")) {
                $email = $email . '@cyou-inc.com';
            }
            if ($_POST["password"] != "") {
                $usermsg = "";
                $usermsg = $ldap->login($email, $_POST["password"]);
                if ($usermsg) {
                    $email = substr($_POST["email"], 0, strpos($_POST["email"], "@"));
                    $username = $usermsg["username"];
                    $employee_id = $usermsg["employee_id"];
                    $department = $usermsg["department"];
                    $db = new UserDB();
                    $user = $db->hasUser($_POST["email"]);
                    //如果数据库里修改了用户名则使用修改后的,否则使用num值
                    if ($user) {
                        $username = $user["username"];
                    } else {
                        $db->insertLDAP(array("email" => $_POST["email"], "username" => $username, "employee_id" => $employee_id, "department" => $department));
                    }
                    //保存session
                    $_SESSION["username"] = $username;
                    $_SESSION["email"] = $email;
                    $_SESSION["password"] = $md5->string2secret($_POST["password"]);
                    //保存cookie
                    setcookie("email", $_SESSION["email"], time() + 3600 * 24 * 7);
                    setcookie("username", $_SESSION["username"], time() + 3600 * 24 * 7);
                    setcookie("password", $_SESSION["password"], time() + 3600 * 24 * 7);
                    //记录登陆日志
                    $data['event'] = 'login';
                    $data['page'] = 'login.php';
                    $data['description'] = 'login success';
                    $data['username'] = $_SESSION["email"];
                    $data['ip'] = getIP();
                    $db = new LogDB();
                    $db->insertLog($data);
                    header("Location: home.php");
                } else {
                    displayLoginForm("您输入的帐号或密码有误,请重试");
                }
            } else {
                displayLoginForm("密码不能为空");
            }
        } else {
            displayLoginForm("帐号不能为空");
        }
    } else {
        displayLoginForm("登陆失败,请稍后重试");
    }
}
Example #10
0
<?php

importar("LojaVirtual.Pedidos.Lista.ListaPedidos");
importar("TemTudoAqui.Usuarios.Lista.ListaPessoas");
$tituloPagina = 'Pedidos > Pedidos > Alterar';
$iTAPE = new IFAdmin(new Arquivos(Sistema::$adminLayoutCaminhoDiretorio . "/SistemaPedidos/imprimirPedido.html"));
$lP = new ListaPedidos();
$lP->condicoes('', $_GET['pedido'], ListaPedidos::ID);
$m = new MD5();
if ($lP->getTotal() > 0) {
    $p = $lP->listar();
    //
    $iTAPE->trocar('id.Pedido', $p->getId());
    $iTAPE->trocar('tipoPagamento.Pedido', $p->getTipoPagamento());
    $iTAPE->trocar('status.Pedido', $p->getStatus()->getStatus());
    $iTAPE->trocar("data.Pedido", $p->getData()->mostrar("H:i  d/m/Y"));
    $iTAPE->trocar('moeda', 'R$');
    $iTAPE->createRepeticao("repetir->Itens.Pedido");
    while ($i = $p->getItem()->listar()) {
        $iTAPE->repetir();
        $iTAPE->enterRepeticao()->trocar('id.Item.Pedido', $i->getId());
        $iTAPE->enterRepeticao()->trocar('nome.Item.Pedido', $i);
        if ($i->unidade > 0) {
            $iTAPE->enterRepeticao()->trocar('unidade.Item.Pedido', $i->unidade);
            $iTAPE->enterRepeticao()->trocar('tipoUnidade.Item.Pedido', $i->tipoUnidade);
        }
        $iTAPE->enterRepeticao()->trocar('descricao.Item.Pedido', $i->descricao);
        $iTAPE->enterRepeticao()->trocar('valor.Item.Pedido', $i->valor->moeda());
        $iTAPE->enterRepeticao()->trocar('quantidade.Item.Pedido', $i->quantidade);
        $iTAPE->enterRepeticao()->trocar('subTotal.Item.Pedido', $i->getSubTotal()->moeda());
        if ($img = $i->getImagens()->listar()) {