View file katrinka.ru/admin/test1.php

File size: 1.78Kb
<?php

function test_chars($string)
{

 $ok_char_eng = array ('A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z','a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z');
 $ok_char_rus = explode(":", ":б:в:ч:з:д:е:і:ц:ъ:й:к:л:м:н:о:п:р:т:у:ф:х:ж:и:г:ю:ы:э:я:щ:ш:ь:а:с:Б:В:Ч:З:Д:Е:Ј:Ц:Ъ:Й:К:Л:М:Н:О:П:Р:Т:У:Ф:Х:Ж:И:Г:Ю:Ы:Э:Я:Щ:Ш:Ь:А:С:");
 $ok_char_sym = array ('!','?','.',',','`','"','-','(',')','@','/','|','\\',':','_',';','+','&','%','*','=','<','>','$','[',']','{','}','~','^','#','\'',' ');
 $ok_char_num = array ('0','1','2','3','4','5','6','7','8','9');
# $ok_char_spc = array ('£','€','¥','¤','§','¡','¿');

 $sl=strlen($string);
 print $sl."<br>";
 
 $string=iconv("UTF-8","KOI8-R", $string);
# $sl=strlen($string);

 $string=iconv("KOI8-R","UTF-8", $string);
 $sl=strlen($string);

 print $sl."<br>";
 if ($sl==0) return 0;
 for ($i=0; $i<$sl; $i++) {
  $cok=0;
  if ($string[$i]=='') return 0;
  if (in_array($string[$i], $ok_char_eng)) $cok=1;
  if (in_array($string[$i], $ok_char_rus)) $cok=1;
  if (in_array($string[$i], $ok_char_sym)) $cok=1;
  if (in_array($string[$i], $ok_char_num)) $cok=1;
#  if (in_array($string[$i], $ok_char_spc)) $cok=1;
  print "\"".$string[$i]."\"<br>\n";
  if (!$cok) return 0;
 }
 if ($cok) return 1; else return 0;
}

	$agent=$_SERVER['HTTP_USER_AGENT'];
	$dbhost='dbserv.mgul.ac.ru';
	$dbname='katwap';
	$dbport=5432;
	$dbuser='katrinka';
	$dbpass='angeL';
	if (($conn=pg_connect("host=$dbhost port=$dbport dbname=$dbname user=$dbuser password=$dbpass"))) {
		$res=pg_query($conn,"select login from users where id='549';");
		if (pg_numrows($res)==1) {
			$login=pg_result($res,0,0);
			if (test_chars($login)) print "1"; else print "0";
		}
		pg_close($conn);

	}