PHP,ASP,JAVASCRIPT,MYSQL;HTMLDERSI

Formda alan girilen değer mail adresimi

function emailkontrol(str){
var filter=/^.+@.+\..{2,3}$/
if (filter.test(str))
testresults=true
else {
return false
}
return true
}

21 Ocak 2008 | PHP | No Comments

form alanına sayımı girildi kontrolü

function IsValid(sText)
{ //SAYI MI GİRDİ
//ALT SATIRDAKİ RAKAMLARIN OLDUĞU YERE GİRİLEBİLECEK KARAKTERLERİ YAZ
// ÖRNEK: var ValidChars = “ABCD-*+”;
var ValidChars = “0123456789″;
var Valid=true;
var Char;
for (i = 0; i < sText.length && Valid == true; i++)
{
Char = sText.charAt(i);
if (ValidChars.indexOf(Char) == -1)
{
Valid = false;
}
}
return Valid;
}

21 Ocak 2008 | JAVASCRIPT | No Comments

Dosya boyutunu hesaplama

<?
function file_size($file){
$size=filesize($file);
if($size >= 1073741824){
$size=round($size/1073741824).”Gb”;
}
elseif($size >= 1048576){
$size=round($size/1048576).”Mb”;
}
elseif($size >= 1024){
$size=round($size/1024).”Kb”;
}else{
$size=$size. “b”;
}
echo “File size: <b>$size</b>” ;
}
file_size($file=”index.php”); ?>

21 Ocak 2008 | PHP | No Comments

kelimelerin sansürlenmesi

<?
function censor($message){
$fh = fopen(”badwords.txt”,”r”); //Open the badwords.txt
while($word = fgets($fh,4096)) {
$message = ereg_replace(trim($word),” #*@!”,$message);
}
return $message;
}
?>

21 Ocak 2008 | PHP | No Comments

Metin içinde kaç kelime geçtiğini bulmak

<?
# string içinde kaç adet kelime geçtiğini bulur.
function kelime_say($metin) {
$parcalar = explode(” “, $metin);
$say = count($parcalar);
echo “$say kelime”;
}
$metin =”ahmet mehmet murtaza”;
kelime_say($metin); # çıktı : 3 kelime
?>

21 Ocak 2008 | PHP | No Comments