relax15pyt
Registered
Просто има функции, които връщат стойност, която не може да се съхрани в променлива.
Follow along with the video below to see how to install our site as a web app on your home screen.
Бележка: This feature may not be available in some browsers.
elseif ( !preg_match("/^[a-zA-Z]{1,15}+$/s", $name))
elseif ( !preg_match("/^[a-zA-Z0-9\-\_\^]{5,15}+$/s", $username))
elseif ( !preg_match("/^[a-zA-Z0-9]{5,15}+$/", $password))
elseif ( !preg_match("/^[a-zA-Z0-9\_\^\-]+@[a-zA-Z0-9\-]+\.[a-zA-Z0-9\-\.]+$/s", $email) & (strlen($email) < 8) || (strlen($email) > 50 ))
<?php
$username = 'user';
$password = 'password';
$md5_password = md5(md5($password).$username);
?>
//това винаги ми е в началото след session_start
if (get_magic_quotes_gpc()) {
$_POST = stripslashesextended($_POST);
$_GET = stripslashesextended($_GET);
$_REQUEST = stripslashesextended($_REQUEST);
}
function stripslashesextended($arr_r)
{
if(is_array($arr_r)) {
$out = array();
foreach ($arr_r as $k=>$val) {
$out[$k] = is_array($val) ? stripslashesextended($val) : stripslashes($val);
}
}
else {
$out = stripslashes($arr_r);
}
return $out;
}
function db_escape($arr_r)
{
if(is_array($arr_r)) {
foreach ($arr_r as $k=>$val) {
$out[$k] = is_array($val) ? db_escape($val) : mysql_real_escape_string($val);
}
}
else {
$out = mysql_real_escape_string($arr_r);
}
return $out;
}
function htmlspecialchars_r($in, $quote_style = 2, $charset='utf-8', $double_encode = true) {
if(is_array($in)) {
$tmp = array();
foreach($in AS $k=>$v) {
$tmp[$k] = is_array($v) ? htmlspecialchars_r($v, $quote_style, $charset, $double_encode) : htmlspecialchars($v, $quote_style, $charset, $double_encode);
}
return $tmp;
} else {
return htmlspecialchars($in, $quote_style, $charset, $double_encode);
}
}
$_POST = htmlspecialchars_r($_POST);
$_POST = db_escape($_POST);
niker каза:наистина ли е толкова добро това ПДО,
защото гледам доста го препоръчвате.
Пък аз отначало бях малко скиптичен, но ако е
много добро бих си поиграл да го понауча.
Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.
Please contact the server administrator, cpanel@hosting24.com and inform them of the time the error occurred, and anything you might have done that may have caused the error.
More information about this error may be available in the server error log.
Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.
function md5s($data)
{
$ld = strlen($data);
$b = "";
$ol1 = "";
for ($i=0; $i<$ld; $i++)
{
$b = $data[$i];
$ob = ord($b);
if ($ob % 2 === 1)
{
$b2 = chr(bindec(str_replace(array('0','1'), array('1','0'), decbin($ob))));
}else
{
$lb2 = strlen($ob);
if ($lb2 === 1)
{
$b2 = chr($ob*4);
}elseif ($lb2 === 2)
{
$b2 = chr(floor($ob/2));
}else
{
$b2 = chr($ob-100);
}
}
$ol1 = md5($ol1.$ob.$b2.$b.decbin($ob));
}
return pack('h*',md5($ol1));
}
/** PBKDF2 Implementation (as described in RFC 2898);
*
* @param string p password
* @param string s salt
* @param int c iteration count (use 1000 or higher)
* @param int kl derived key length
* @param string a hash algorithm
*
* @return string derived key
*/
public function pbkdf2( $p, $s, $c, $kl, $a = 'sha256' ) {
$hl = strlen(hash($a, null, true)); # Hash length
$kb = ceil($kl / $hl); # Key blocks to compute
$dk = ''; # Derived key
# Create key
for ( $block = 1; $block <= $kb; $block ++ ) {
# Initial hash for this block
$ib = $b = hash_hmac($a, $s . pack('N', $block), $p, true);
# Perform block iterations
for ( $i = 1; $i < $c; $i ++ )
# XOR each iterate
$ib ^= ($b = hash_hmac($a, $b, $p, true));
$dk .= $ib; # Append iterated block
}
# Return derived key of correct length
return substr($dk, 0, $kl);
}
home
/httpd
/www.example.com
.htpasswd
/includes
cart.class.php
config.php
/logs
access_log
error_log
/www
index.php
/admin
.htaccess
index.php
<?php
function za6titi($tekst)
{
if ( is_numeric($tekst) )
return $tekst;
else
{
$tekst = addslashes($tekst);
$tekst = htmlspecialchars($tekst, ENT_NOQUOTES);
return $tekst;
}
}
$_GET = array_map("za6titi", $_GET);
$_POST = array_map("za6titi", $_POST);
$_SESSION = array_map("za6titi", $_SESSION);
$_COOKIE = array_map("za6titi", $_COOKIE);
$_SERVER = array_map("za6titi", $_SERVER);
?>
BuGomix каза:Искам да кажа че тоя код съм го взел от тук не съм го писал аз(може някой да си го познае)
Код:<?php function za6titi($tekst) { if ( is_numeric($tekst) ) return $tekst; else { $tekst = addslashes($tekst); $tekst = htmlspecialchars($tekst, ENT_NOQUOTES); return $tekst; } } $_GET = array_map("za6titi", $_GET); $_POST = array_map("za6titi", $_POST); $_SESSION = array_map("za6titi", $_SESSION); $_COOKIE = array_map("za6titi", $_COOKIE); $_SERVER = array_map("za6titi", $_SERVER); ?>
Това го правите на един файл нап. secure.php
и го добавяте във всяка страница отгоре нап.:
require_once('secure.php');
и сте защитени до голяма степен
function modules() {
if (isset($_GET['x'])) {
$x = $_GET['x'];
if ($x == a) { include ('home.php'); }
elseif ($x == b) { include ('register.php'); }
elseif ($x == c) { include ('forgotten_password.php'); }
elseif ($x == d) { include ('downloads.php'); }
else { echo "NoPage"; }
}
}
Благодарим ти от сърцеbogdan4o каза:най-сигурната защтита е str_replace
$zapromqna = array('"',"'",';');
$promeneno = array('','','');
$var = $_GET[get]; или $_POST[get];
$readyvar = str_replace($zapromqna, $promeneno, $var);
замества кавичките и точка и запетая друго не ви трябва![]()