<form name=”frmImageResize” action=”” method=”post” enctype=”multipart/form-data”> <input type=”file” name=”myImage” /> <input type=”submit” name=”submit” value=”Submit” /> </form> <?php if(isset($_POST["submit"])) { if(is_array($_FILES)) { $file = $_FILES['myImage']['tmp_name']; $source_properties = getimagesize($file); $image_type = $source_properties[2]; if($image_type == IMAGETYPE_JPEG) { $image_resource_id = imagecreatefromjpeg($file); $target_layer = fn_resize($image_resource_id,$source_properties[0],$source_properties[1]); imagejpeg($target_layer,$_FILES['myImage']['name'] . “_thump.jpg”); } elseif($image_type == IMAGETYPE_GIF) { $image_resource_id = imagecreatefromgif($file); $target_layer = fn_resize($image_resource_id,$source_properties[0],$source_properties[1]); imagegif($target_layer,$_FILES['myImage']['name'] . […]
Category: Web
XML Parser
<?php $xmlDocument = ‘ <?xml version=”1.0″?> <toys> <toy code=”10001″> <name>Ben 10 Watch</name> <type>Battery Toys</type> </toy> <toy code=”10002″> <name>Angry Birds Gun</name> <type>Mechanical Toys</type> </toy> </toys>’; $line_number = 0; function onStart($parser,$name,$attributes) { global $line_number; if($line_number != xml_get_current_line_number($parser)) { $line_number = xml_get_current_line_number($parser) . “: “; $output = “<br/>” . $line_number . ” \t<” . $name . “>”; } […]
XML Reader
<?php $xmlDocument = ‘ <?xml version=”1.0″?> <toys> <toy code=”10001″> <name>Ben 10 Watch</name> <type>Battery Toys</type> </toy> <toy code=”10002″> <name>Angry Birds Gun</name> <type>Mechanical Toys</type> </toy> </toys>’; $xml = new XMLReader(); $xml->XML($xmlDocument); while( $xml->read() ) { if($xml->name == “toy”) { print “ID:” . $xml->getAttribute(“code”) . “<br/>”; print $xml->readInnerXML() . “<br/>”; $xml->next(); } } ?>
session_encode() & session_decode()
<?php session_start(); $_SESSION["product_code"] = “2222″; $_SESSION["logged_in"] = “yes”; $enc_session = session_encode(); print “<b>Encoded Session Data:<br/></b>”; print $enc_session . “<br/><br/>”; // Changing session values $_SESSION['product_code'] = “2000″; $_SESSION["logged_in"] = “no”; // printing $_SESSION print “<b>SESSION Array:<br/></b>”; print “<pre>”; print_r($_SESSION); print “</pre>”; session_decode($enc_session); // printing Reloaded $_SESSION print “<b>Reloaded SESSION Array:<br/></b>”; print “<pre>”; print_r($_SESSION); print “</pre>”; ?>
array_diff()
Php’de array’ler arasında farkı, ortak olmayan elemanları listeler. <?php $array1 = array(“a” => “green”, “red”, “blue”, “red”); $array2 = array(“b” => “green”, “yellow”, “red”); $result = array_diff($array1, $array2); print_r($result); ?>
array_intersect()
Php’de array’ler arasında kesişen, ortak olan elemanları listeler. <?php $array1 = array(“a” => “green”, “red”, “blue”); $array2 = array(“b” => “green”, “yellow”, “red”); $result = array_intersect($array1, $array2); print_r($result); ?>
Div Autoload ve Refresh
<script src=”https://code.jquery.com/jquery-2.1.1.min.js” type=”text/javascript”></script> <script> $(document).ready(function(){ setInterval(function(){ $(“#screen”).load(‘banners.php’) }, 2000); }); </script> <?php $bg_array = array(“#CEED9D”,”#ECED9D”,”#EDCF9D”,”#EC9CA7″,”#ED9DD0″,”#EE9DE2″,”#D69DEC”,”#9E9CEC”); $bg = array_rand($bg_array,1); ?> <div class=”banner” style=”background-color:<?php echo $bg_array[$bg];?>;” > <div class=”txt-title”>jQuery DIV Auto Load Refresh</div> <div class=”txt-subtitle”>This Banner auto loads and refreshes every 2 seconds.</div> </div>
Parola Zorluk Seviyesi Kontrolü
<div name=”frmCheckPassword” id=”frmCheckPassword”> <label>Check Username:</label> <input type=”password” name=”password” id=”password” class=”demoInputBox” onKeyUp=”checkPasswordStrength();” /><div id=”password-strength-status”></div> </div> function checkPasswordStrength() { var number = /([0-9])/; var alphabets = /([a-zA-Z])/; var special_characters = /([~,!,@,#,$,%,^,&,*,-,_,+,=,?,>,<])/; if($(‘#password’).val().length<6) { $(‘#password-strength-status’).removeClass(); $(‘#password-strength-status’).addClass(‘weak-password’); $(‘#password-strength-status’).html(“Weak (should be atleast 6 characters.)”); } else { if($(‘#password’).val().match(number) && $(‘#password’).val().match(alphabets) && $(‘#password’).val().match(special_characters)) { $(‘#password-strength-status’).removeClass(); $(‘#password-strength-status’).addClass(‘strong-password’); $(‘#password-strength-status’).html(“Strong”); } else { $(‘#password-strength-status’).removeClass(); […]
Check-Uncheck All Butonu Yapma
<div id=”divCheckAll”> <input type=”checkbox” name=”checkall” id=”checkall” onClick=”check_uncheck_checkbox(this.checked);” />Check All</div> <div id=”divCheckboxList”> <div class=”divCheckboxItem”><input type=”checkbox” name=”language” id=”language1″ value=”English” />English</div> <div class=”divCheckboxItem”><input type=”checkbox” name=”language” id=”language2″ value=”French” />French</div> <div class=”divCheckboxItem”><input type=”checkbox” name=”language” id=”language3″ value=”German” />German</div> <div class=”divCheckboxItem”><input type=”checkbox” name=”language” id=”language4″ value=”Latin” />Latin</div> </div> function check_uncheck_checkbox(isChecked) { if(isChecked) { $(‘input[name="language"]‘).each(function() { this.checked = true; }); } else { $(‘input[name="language"]‘).each(function() […]
TC Kimlik No Kontrol Class’ı
<?php class TCKimlik{ private $tcKimlikNo; public function __construct($tcKimlikNo){ if((int)log($tcKimlikNo,10)!=10){ return false; } $this->tcKimlikNo = $tcKimlikNo; } function strtoupperTR($str){ $str = str_replace(array(‘i’, ‘ı’, ‘ü’, ‘ğ’, ‘ş’, ‘ö’, ‘ç’), array(‘İ’, ‘I’, ‘Ü’, ‘Ğ’, ‘Ş’, ‘Ö’, ‘Ç’), $str); return strtoupper($str); } public function validate(){ $oddSum = 0; $evenSum = 0; if(substr($this->tcKimlikNo,0,1)==0){ return false; } for($i=0;$i<=8;$i++){ if($i%2==0){ $oddSum += […]