• 29-04-2008, 19:04:11
    #55
    Üyeliği durduruldu
    umarım başkasının yazdıgı sınıfları yayınlamamızda sorun yoktur.
    verdiginiz metni, bir anahtara göre şifreleyebilen ve daha sonra verdiginiz anahtarla metini tekrar okunabilir hale getirebilen sınıf.

    class.encrypt.php
    <?php  
    // ***************************************************************************** 
    // Copyright 2003-2004 by A J Marston <http://www.tonymarston.net> 
    // Distributed under the GNU General Public Licence 
    // ***************************************************************************** 
    session_start();
    class Encryption { 
    
        var $scramble1;         // 1st string of ASCII characters 
        var $scramble2;         // 2nd string of ASCII characters 
         
        var $errors;            // array of error messages 
        var $adj;               // 1st adjustment value (optional) 
        var $mod;               // 2nd adjustment value (optional) 
         
        // **************************************************************************** 
        // class constructor 
        // **************************************************************************** 
        function encryption () 
        { 
            $this->errors = array(); 
             
            // Each of these two strings must contain the same characters, but in a different order. 
            // Use only printable characters from the ASCII table. 
            // Do not use single quote, double quote or backslash as these have special meanings in PHP. 
            // Each character can only appear once in each string EXCEPT for the first character 
            // which must be duplicated at the end (this gets round a bijou problemette when the 
            // first character of the password is also the first character in $scramble1). 
            $this->scramble1 = '! #$%&()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[]^_`abcdefghijklmnopqrstuvwxyz{|}~!'; 
            $this->scramble2 = 'f^jAE]okIOzU[2&q1{3`h5w_794p@6s8?BgP>dFV=m D<TcS%Ze|r:lGK/uCy.Jx)HiQ!#$~(;Lt-R}Ma,NvW+Ynb*0Xf'; 
    
            if (strlen($this->scramble1) <> strlen($this->scramble2)) { 
                $this->errors[] = '** SCRAMBLE1 is not same length as SCRAMBLE2 **'; 
            } // if 
             
            $this->adj = 1.75;  // this value is added to the rolling fudgefactors 
            $this->mod = 3;     // if divisible by this the adjustment is made negative 
             
        } // constructor 
         
        // **************************************************************************** 
        function decrypt ($key, $source)  
        // decrypt string into its original form 
        { 
            //DebugBreak(); 
            // convert $key into a sequence of numbers 
            $fudgefactor = $this->_convertKey($key); 
            if ($this->errors) return; 
             
            if (empty($source)) { 
                $this->errors[] = 'No value has been supplied for decryption'; 
                return; 
            } // if 
             
            $target = null; 
            $factor2 = 0; 
             
            for ($i = 0; $i < strlen($source); $i++) { 
                // extract a character from $source 
                $char2 = substr($source, $i, 1); 
                 
                // identify its position in $scramble2 
                $num2 = strpos($this->scramble2, $char2); 
                if ($num2 === false) { 
                    $this->errors[] = "Source string contains an invalid character ($char2)"; 
                    return; 
                } // if 
                 
                if ($num2 == 0) { 
                    // use the last occurrence of this letter, not the first 
                    $num2 = strlen($this->scramble1)-1; 
                } // if 
                 
                // get an adjustment value using $fudgefactor 
                $adj     = $this->_applyFudgeFactor($fudgefactor); 
                 
                $factor1 = $factor2 + $adj;                 // accumulate in $factor1 
                $num1    = round($factor1 * -1) + $num2;    // generate offset for $scramble1 
                $num1    = $this->_checkRange($num1);       // check range 
                $factor2 = $factor1 + $num2;                // accumulate in $factor2 
                 
                // extract character from $scramble1 
                $char1 = substr($this->scramble1, $num1, 1); 
                 
                // append to $target string 
                $target .= $char1; 
    
                //echo "char1=$char1, num1=$num1, adj= $adj, factor1= $factor1, num2=$num2, char2=$char2, factor2= $factor2<br />\n"; 
                 
            } // for 
             
            return rtrim($target); 
             
        } // decrypt 
         
        // **************************************************************************** 
        function encrypt ($key, $source, $sourcelen = 0)  
        // encrypt string into a garbled form 
        { 
            //DebugBreak(); 
            // convert $key into a sequence of numbers 
            $fudgefactor = $this->_convertKey($key); 
            if ($this->errors) return; 
    
            if (empty($source)) { 
                $this->errors[] = 'No value has been supplied for encryption'; 
                return; 
            } // if 
             
            // pad $source with spaces up to $sourcelen 
            while (strlen($source) < $sourcelen) { 
                $source .= ' '; 
            } // while 
             
            $target = null; 
            $factor2 = 0; 
             
            for ($i = 0; $i < strlen($source); $i++) { 
                // extract a character from $source 
                $char1 = substr($source, $i, 1); 
                 
                // identify its position in $scramble1 
                $num1 = strpos($this->scramble1, $char1); 
                if ($num1 === false) { 
                    $this->errors[] = "Source string contains an invalid character ($char1)"; 
                    return; 
                } // if 
                 
                // get an adjustment value using $fudgefactor 
                $adj     = $this->_applyFudgeFactor($fudgefactor); 
                 
                $factor1 = $factor2 + $adj;             // accumulate in $factor1 
                $num2    = round($factor1) + $num1;     // generate offset for $scramble2 
                $num2    = $this->_checkRange($num2);   // check range 
                $factor2 = $factor1 + $num2;            // accumulate in $factor2 
                 
                // extract character from $scramble2 
                $char2 = substr($this->scramble2, $num2, 1); 
                 
                // append to $target string 
                $target .= $char2; 
    
                //echo "char1=$char1, num1=$num1, adj= $adj, factor1= $factor1, num2=$num2, char2=$char2, factor2= $factor2<br />\n"; 
                 
            } // for 
             
            return $target; 
             
        } // encrypt 
         
        // **************************************************************************** 
        function getAdjustment ()  
        // return the adjustment value 
        { 
            return $this->adj; 
             
        } // setAdjustment 
         
        // **************************************************************************** 
        function getModulus ()  
        // return the modulus value 
        { 
            return $this->mod; 
             
        } // setModulus 
         
        // **************************************************************************** 
        function setAdjustment ($adj)  
        // set the adjustment value 
        { 
            $this->adj = (float)$adj; 
             
        } // setAdjustment 
         
        // **************************************************************************** 
        function setModulus ($mod)  
        // set the modulus value 
        { 
            $this->mod = (int)abs($mod);    // must be a positive whole number 
             
        } // setModulus 
         
        // **************************************************************************** 
        // private methods 
        // **************************************************************************** 
        function _applyFudgeFactor (&$fudgefactor)  
        // return an adjustment value  based on the contents of $fudgefactor 
        // NOTE: $fudgefactor is passed by reference so that it can be modified 
        { 
            $fudge = array_shift($fudgefactor);     // extract 1st number from array 
            $fudge = $fudge + $this->adj;           // add in adjustment value 
            $fudgefactor[] = $fudge;                // put it back at end of array 
             
            if (!empty($this->mod)) {               // if modifier has been supplied 
                if ($fudge % $this->mod == 0) {     // if it is divisible by modifier 
                    $fudge = $fudge * -1;           // make it negative 
                } // if 
            } // if 
             
            return $fudge; 
             
        } // _applyFudgeFactor 
         
        // **************************************************************************** 
        function _checkRange ($num)  
        // check that $num points to an entry in $this->scramble1 
        { 
            $num = round($num);         // round up to nearest whole number 
             
            // indexing starts at 0, not 1, so subtract 1 from string length 
            $limit = strlen($this->scramble1)-1; 
             
            while ($num > $limit) { 
                $num = $num - $limit;   // value too high, so reduce it 
            } // while 
            while ($num < 0) { 
                $num = $num + $limit;   // value too low, so increase it 
            } // while 
             
            return $num; 
             
        } // _checkRange 
         
        // **************************************************************************** 
        function _convertKey ($key)  
        // convert $key into an array of numbers 
        { 
            if (empty($key)) { 
                $this->errors[] = 'No value has been supplied for the encryption key'; 
                return; 
            } // if 
             
            $array[] = strlen($key);    // first entry in array is length of $key 
             
            $tot = 0; 
            for ($i = 0; $i < strlen($key); $i++) { 
                // extract a character from $key 
                $char = substr($key, $i, 1); 
                 
                // identify its position in $scramble1 
                $num = strpos($this->scramble1, $char); 
                if ($num === false) { 
                    $this->errors[] = "Key contains an invalid character ($char)"; 
                    return; 
                } // if 
                 
                $array[] = $num;        // store in output array 
                $tot = $tot + $num;     // accumulate total for later 
            } // for 
             
            $array[] = $tot;            // insert total as last entry in array 
             
            return $array; 
             
        } // _convertKey 
         
    // **************************************************************************** 
    } // end Encryption 
    // **************************************************************************** 
    ?>
    Kullanım

    <?php
    $metin="Sifrelenmek Istiyorum";
    $mod=10;
    $adj=0.5;
    $key="Anahtar";
    $len=10;
    $crypt=new Encryption();
    $crypt->setAdjustment($adj);
    $crypt->setModulus($mod); 
    $sifrelenmis=$crypt->encrypt($key, $metin, $len);
    echo $sifrelenmis;
    echo "<br>";
    $eskiMetin=$crypt->decrypt($key,$sifrelenmis);
    echo $eskiMetin;
    ?>
  • 29-04-2008, 19:05:21
    #56
    Üyeliği durduruldu
    Class dosyamız
    class paging
    {
    	var $koneksi;
    	var $p;
    	var $page;
    	var $q;
    	var $query;
    	var $next;
    	var $prev;
    	var $number;
    
    	function paging($baris=5, $langkah=5, $prev="[ileri]", $next="[geri]", $number="[%%number%%]")
    	{
    		$this->next=$next;
    		$this->prev=$prev;
    		$this->number=$number;
    		$this->p["baris"]=$baris;
    		$this->p["langkah"]=$langkah;
    		$_SERVER["QUERY_STRING"]=preg_replace("/&page=[0-9]*/","",$_SERVER["QUERY_STRING"]);
    		if (empty($_GET["page"])) {
    			$this->page=1;
    		} else {
    			$this->page=$_GET["page"];
    		}
    	}
    
    	function db($host,$username,$password,$dbname)
    	{
    		$this->koneksi=mysql_pconnect($host, $username, $password) or die("Connection Error");
    		mysql_select_db($dbname);
    		return $this->koneksi;
    	}
    
    	function query($query)
    	{
    		$kondisi=false;
    		// only select
    		if (!preg_match("/^[\s]*select*/i",$query)) {
    			$query="select ".$query;
    		}
    
    		$querytemp = mysql_query($query);
    		$this->p["count"]= mysql_num_rows($querytemp);
    
    		// total page
    		$this->p["total_page"]=ceil($this->p["count"]/$this->p["baris"]);
    
    		// filter page
    		if  ($this->page<=1)
    			$this->page=1;
    		elseif ($this->page>$this->p["total_page"])
    			$this->page=$this->p["total_page"];
    
    		// awal data yang diambil
    		$this->p["mulai"]=$this->page*$this->p["baris"]-$this->p["baris"];
    
    		$query=$query." limit ".$this->p["mulai"].",".$this->p["baris"];
    
    		$query=mysql_query($query) or die("Query Error");
    		$this->query=$query;
    	}
    	
    	function result()
    	{
    		return $result=mysql_fetch_object($this->query);
    	}
    
    	function result_assoc()
    	{
    		return mysql_fetch_assoc($this->query);
    	}
    
    	function print_no()
    	{
    		$number=$this->p["mulai"]+=1;
    		return $number;
    	}
    	
    	function print_color($color1,$color2)
    	{
    		if (empty($this->p["count_color"]))
    			$this->p["count_color"] = 0;
    		if ( $this->p["count_color"]++ % 2 == 0 ) {
    			return $color=$color1;
    		} else {
    			return $color=$color2;
    		}
    	}
    
    	function print_info()
    	{
    		$page=array();
    		$page["start"]=$this->p["mulai"]+1;
    		$page["end"]=$this->p["mulai"]+$this->p["baris"];
    		$page["total"]=$this->p["count"];
    		$page["total_pages"]=$this->p["total_page"];
    			if ($page["end"] > $page["total"]) {
    				$page["end"]=$page["total"];
    			}
    			if (empty($this->p["count"])) {
    				$page["start"]=0;
    			}
    
    		return $page;
    	}
    
    	function print_link()
    	{
    		//generate template
    		function number($i,$number)
    		{
    			return ereg_replace("^(.*)%%number%%(.*)$","\\1$i\\2",$number);
    		}
    		$print_link = false;
    
    		if ($this->p["count"]>$this->p["baris"]) {
    
    			// print prev
    			if ($this->page>1)
    			$print_link .= "<a href=\"".$_SERVER["PHP_SELF"]."?".$_SERVER["QUERY_STRING"]."&page=".($this->page-1)."\">".$this->prev."</a>\n";
    
    			// set number
    			$this->p["bawah"]=$this->page-$this->p["langkah"];
    				if ($this->p["bawah"]<1) $this->p["bawah"]=1;
    
    			$this->p["atas"]=$this->page+$this->p["langkah"];
    				if ($this->p["atas"]>$this->p["total_page"]) $this->p["atas"]=$this->p["total_page"];
    
    			// print start
    			if ($this->page<>1)
    			{
    				for ($i=$this->p["bawah"];$i<=$this->page-1;$i++)
    					$print_link .="<a href=\"".$_SERVER["PHP_SELF"]."?".$_SERVER["QUERY_STRING"]."&page=$i\">".number($i,$this->number)."</a>\n";
    			}
    			// print active
    			if ($this->p["total_page"]>1)
    				$print_link .= "<b>".number($this->page,$this->number)."</b>\n";
    
    			// print end
    			for ($i=$this->page+1;$i<=$this->p["atas"];$i++)
    			$print_link .= "<a href=\"".$_SERVER["PHP_SELF"]."?".$_SERVER["QUERY_STRING"]."&page=$i\">".number($i,$this->number)."</a>\n";
    
    			// print next
    			if ($this->page<$this->p["total_page"])
    			$print_link .= "<a href=\"".$_SERVER["PHP_SELF"]."?".$_SERVER["QUERY_STRING"]."&page=".($this->page+1)."\">".$this->next."</a>\n";
    
    			return $print_link;
    		}
    	}
    }
    ?>
    Kullanım Şekli

    <?
    require("paging_class.php");
    $paging=new paging(5,5);
    $paging->db("localhost","username","password","dbname");
    $paging->query("Select * FROM paging ORDER BY MY_FIELD ASC");
    
    $page=$paging->print_info();
    	echo "Data $page[start] - $page[end] of $page[total] [Total $page[total_pages] Pages]<hr>\n";
    
    while ($result=$paging->result_assoc()) {
    	echo $paging->print_no()." : ";
    	echo "$result[MY_FIELD]<br>\n";
    }
    
    echo "<hr>".$paging->print_link();
    ?>
  • 29-04-2008, 19:07:02
    #57
    Üyeliği durduruldu
    <?php
    class msnlistgrab {
        var $mail = 'msn@adresiniz.com' ;
        var $password = 'sifreniz' ;
        var $server ='messenger.hotmail.com';
        var $port = 1863;
        var $version = 'MSNMSGR  6.2' ;
        var $buffer;
        var $socket;
        var $startcom;
        var $error="";
            var $e_mail;
        var $name;
        var $number;
            function msnlistgrab() {
       
        }
        function GetRecords(){
            if ($this->msn_connect($this->server, $this->port))
            {
                return $this->res;
            }
            else
            {
                return $this->error;
            }
        }
       
        function getData() {
            $this->buffer="";
            while (!feof($this->socket)) {
                $this->buffer .= fread($this->socket,1024);
                if (preg_match("/\r/",$this->buffer)) {
                    break;
                }
            }
            $this->checkData($this->buffer);
        }
        function getData2() {;
        //$container="";
        $buffer="";
        while (!feof($this->socket)) {
            if ($this->i>1) {
                if ($this->i==$this->total) {
                    fclose($this->socket);
                    $this->res;
                    break;
                }
            }
            $buffer = fread($this->socket,8192);
            $this->check_buffer($buffer);
        }
        }
       
        function check_buffer($buffer) {
            if (eregi("^SYN",$buffer)) {
                list($junk, $junk, $junk, $this->total) = explode(" ", $buffer);
                //    echo '<h1>Number of Records: '.$this->total.'</h1>';
            }
            $this->grabber($buffer);
        }
       
        function grabber ($buffer)
        {
            $g = preg_split("/[\n]+/", $buffer);
            for ($n=0;$n<count($g);$n++) {
                if (strstr($g[$n], 'LST')) {
                    $this->i++;
                    //list($junk, $email) = explode(" ", $g[$n]);
                    //$this->res[] = $email;
                                          list($LST, $mailx,$namex,$numberx) = explode(" ", $g[$n]);
                                          $this->e_mail[] = $mailx;
                                              $this->name[] = mb_convert_encoding(urldecode($namex),"ISO-8859-9", "auto");
                                              $this->number[] = $numberx;
       
                                              //echo $g[$n]."<br>";
                                          //$this->deleted[] = $veri[1][0];
       
       
                }
            }
       
        }
       
        function checkData($buffer) {
            //              echo $buffer;
            if (preg_match("/lc\=(.+?)/Ui",$buffer,$matches)) {
       
                $this->challenge = "lc=" . $matches[1];
       
            }
       
            if (preg_match("/(XFR 3 NS )([0-9\.\:]+?) (.*) ([0-9\.\:]+?)/is",$buffer,$matches)) {
                $split = explode(":",$matches[2]);
                $this->startcom = 1;
                $this->msn_connect($split[0],$split[1]);
       
            }
       
            if (preg_match("/tpf\=([a-zA-Z0-9]+?)/Ui",$buffer,$matches)) {
       
                $this->nexus_connect($matches[1]);
            }
            /*
            $split = explode("\n",$buffer);
       
            for ($i=0;$i<count($split);$i++) {
       
            $detail = explode(" ",$split[$i]);
       
            if ($detail[0] == "LST") {
            //echo "<div  OnMouseOver=\"style.cursor='hand';showTooltip('show','$detail[1]-$detail[3]')\" OnMouseMove=\"followTooltip('show')\" OnMouseOut=\"showTooltip('hide')\">" . urldecode($detail[2]) . "</div>";
            }
            }
            */
       
       
       
        }
       
        function msn_connect($server, $port) {
            if (IsSet($this->socket)) {
                fclose($this->socket);
            }
       
            $this->socket = fsockopen($server,$port);       //stream_set_timeout($GLOBALS["socket"], 20000);
            if (!$this->socket) {
                return "Could not connect";
            } else {
                $this->startcom++;
                $this->send_command("VER " . $this->startcom . " MSNP8 CVR0",1);
                $this->send_command("CVR " . $this->startcom . " 0x0409 win 4.10 i386 ". $this->version ." MSMSGS " . $this->mail,1);
                $this->send_command("USR " . $this->startcom . " TWN I " . $this->mail,1);
       
            }
        }
       
        function send_command($command)
        {
            $this->startcom++;
            //      echo "<font color=blue> >> $command<br>";
            fwrite($this->socket,$command . "\r\n");
            $this->getData();
       
       
        }
       
       
        function nexus_connect($tpf)
        {
       
            $arr[] = "GET /rdr/pprdr.asp HTTP/1.0\r\n\r\n";
       
            $curl = curl_init();
            curl_setopt($curl, CURLOPT_URL, "https://nexus.passport.com:443/rdr/pprdr.asp");
            curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
            curl_setopt($curl, CURLOPT_VERBOSE, 0);
            curl_setopt($curl, CURLOPT_HEADER,1);
            curl_setopt($curl, CURLOPT_HTTPHEADER, $arr);
            curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, FALSE);
            $data = curl_exec($curl);
            curl_close($curl);
            preg_match("/DALogin=(.+?),/",$data,$matches);
       
            //$data = str_replace("\n","<br>",$data);
            //              echo $data;
       
            //echo "<br><br>";
       
            $split = explode("/",$matches[1]);
            $this->mail = urldecode($this->mail);
            $headers[0] = "GET /$split[1] HTTP/1.1\r\n";
            $headers[1] = "Authorization: Passport1.4 OrgVerb=GET,OrgURL=http%3A%2F%2Fmessenger%2Emsn%2Ecom,sign-in=" . $this->mail . ",pwd=" . $this->password . ", " . trim($this->challenge) . "\r\n";
       
            $curl = curl_init();
            curl_setopt($curl, CURLOPT_URL, "https://" . $split[0] . ":443/". $split[1]);
            curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
            curl_setopt($curl, CURLOPT_VERBOSE, 0);
            curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
            curl_setopt($curl, CURLOPT_HEADER,1);
            curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, FALSE);
       
            $data = curl_exec($curl);
       
            //$data = str_replace("\n","<br>\n",$data);
            //              echo $data;
       
            curl_close($curl);
       
            //echo "</font>";
       
            preg_match("/t=(.+?)'/",$data,$matches);
            $this->send_command("USR " . $this->startcom . " TWN S t=" . trim($matches[1]) . "",2);
            $this->send_command("SYN " . $this->startcom . " 0",2);
                    $this->getData2();
       
       
       
        }
       
    }
    $gm = new msnlistgrab();
    $gm->GetRecords();
       
    echo '<table border="1"><tr><td></td><td>MAİL</td><td>İSİM</td><td>DURUM</td></tr>';
       
    $durum = array (
         "2"=> "Sildi + Sildin",
         "3"=> "Sildi",
         "4"=> "Engelledin + Sildin + Sildi",
         "5"=> "Engelledin + Sildi",
         "10"=> "Sildin",
         "11"=> "Normal",
         "12"=> "Engelledin + Sildin",
         "13"=> "Engelledin",
    );
       
    for($i=0; $i < $gm->total; $i++) {
    $durumx = strtr($gm->number[$i],$durum);
    echo "<tr><td>$i</td><td>".$gm->e_mail[$i]."</td><td>".$gm->name[$i]."</td><td>".$durumx."</td></tr>\n";
    }
    echo '</table>';
    En baştaki

        var $mail = 'msn@adresiniz.com' ;
        var $password = 'sifreniz' ;
    kısmını editlediğinizde çalışacaktır.


    Not: Bu sınıfın çalışabilmesi için CURL kütüphanesinin yüklenmesi gerek.
  • 29-04-2008, 19:10:20
    #58
    Üyeliği durduruldu
    rand_word.class.php

    <?php
    class rand_word
    {
        var $vowels = array('a','e','i','o','u','y');
        var $consonants = array('b','c','d','f','g','h','j','k','l','m','n','p','r','s','t','v','w','z','ch','qu','th','xy','0','1','2','3','4','5','6','7','8','9');
        var $word = '';
    
        function rand_word($length = 5, $lower_case = true, $ucfirst = false, $upper_case = false)
        {
            $done = false;
            $const_or_vowel = 1;
            
            while (!$done)
            {
                switch ($const_or_vowel)
                {
                    case 1:
                        $this->word .= $this->consonants[array_rand($this->consonants)];
                        $const_or_vowel = 2;
                        break;
                    case 2:
                        $this->word .= $this->vowels[array_rand($this->vowels)];
                        $const_or_vowel = 1;
                        break;
                }
                 
                if (strlen($this->word) >= $length)
                {
                    $done = true;
                }
            }
    
            $this->word = substr($this->word, 0, $length);
            $this->word = ($lower_case) ? strtolower($this->word) : $this->word;
            $this->word = ($ucfirst) ? ucfirst(strtolower($this->word)) : $this->word;
            $this->word = ($upper_case) ? strtoupper($this->word) : $this->word;
            
            return $this->word;
        }
    }
    
    ?>
    example.php

    <?php
    
    /***************************************************************************
     *
     *   Author   : Eric Sizemore ( www.secondversion.com & www.phpsociety.com )
     *   Package  : Random Word
     *   Version  : 1.0.0
     *   Copyright: (C) 2006 Eric Sizemore
     *   Site     : www.secondversion.com & www.phpsociety.com
     *   Email    : esizemore05@gmail.com
     *
     *   This program is free software; you can redistribute it and/or modify
     *   it under the terms of the GNU General Public License as published by
     *   the Free Software Foundation; either version 2 of the License, or
     *   (at your option) any later version.
     *
     *   This program is distributed in the hope that it will be useful,
     *   but WITHOUT ANY WARRANTY; without even the implied warranty of
     *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
     *   GNU General Public License for more details.
     *
     ***************************************************************************/
    
    require_once('rand_word.class.php');
    // rand_word() accepts the following parameters
    // length, use lowercase (true/false), ucfirst (true/false), use uppercase (true/false)
    // the below would output something similar to: Maquu
    $word = new rand_word(5, false, true);
    echo $word->word;
    
    ?>
  • 29-04-2008, 19:12:18
    #59
    Üyeliği durduruldu
    Class dosyası

    <?php
    class mdb
    {
      var $RS = 0;
      var $ADODB = 0;
      
      var $RecordsAffected;
      
      var $strProvider = 'Provider=Microsoft.Jet.OLEDB.4.0';
      var $strMode     = 'Mode=ReadWrite';
      var $strPSI      = 'Persist Security Info=False';
      var $strDataSource  = '';
      var $strConn     = '';
      var $strRealPath = '';
      
      var $recordcount = 0;
      var $ok = false;
      
      
      /**
      * Constructor needs path to .mdb file
      *
      * @param string $dsn = path to *.mdb file
      * @return boolean success 
      */
      function mdb( $dsn='Please enter DataSource!' )
      {
        $this->strRealPath = realpath( $dsn );
        if( strlen( $this->strRealPath ) > 0 )
        {
          $this->strDataSource = 'Data Source='.$this->strRealPath;
          $result = true;
        }
        else
        {
          echo "<br>mdb::mdb() File not found $dsn<br>";
          $result = false;
        }
        
        $this->RecordsAffected = new VARIANT();
        
        $this->open();
        
      } // eof constructor mdb()
      
      
      function open( )
      {
        if( strlen( $this->strRealPath ) > 0 )
        {
      
          $this->strConn = 
            $this->strProvider.';'.
            $this->strDataSource.';'.
            $this->strMode.';'.
            $this->strPSI;
            
          $this->ADODB = new COM( 'ADODB.Connection' );
          
          if( $this->ADODB )
          {
            $this->ADODB->open( $this->strConn );
            
            $result = true;
          }
          else
          {
            echo '<br>mdb::open() ERROR with ADODB.Connection<br>'.$this->strConn;
            $result = false;
          }
        }
        
        $this->ok = $result;
        
        return $result;
      } // eof open()
      
      
      /**
      * Execute SQL-Statement
      * @param string $strSQL = sql statement
      * @param boolean $getrecordcount = true when a record count is wanted
      */
      function execute( $strSQL, $getrecordcount = false )
      {
    
        $this->RS = $this->ADODB->execute( $strSQL, &$this->RecordsAffected );
        
        if( $getrecordcount == true )
        {
    
          $this->RS->MoveFirst();
          $this->recordcount = 0;
          
          # brute force loop
          while( $this->RS->EOF == false )
          {
            $this->recordcount++;
            $this->RS->MoveNext();
          }
          $this->RS->MoveFirst();
    
        }
        
            
      } // eof execute()
      
      function eof()
      {
        return $this->RS->EOF;
      } // eof eof()
      
      function movenext( )
      {
        $this->RS->MoveNext();
      } // eof movenext()
      
      function movefirst()
      {
        $this->RS->MoveFirst();
      } // eof movefirst()
      
      function close()
      {
       
        @$this->RS->Close(); // Generates a warning when without "@"
        $this->RS=null;
      
        @$this->ADODB->Close();
        $this->ADODB=null;
      } // eof close()
      
      function fieldvalue( $fieldname )
      {
        return $this->RS->Fields[$fieldname]->value;
      } // eof fieldvalue()
      
      function fieldname( $fieldnumber )
      {
        return $this->RS->Fields[$fieldnumber]->name;
      } // eof fieldname()
      
      function fieldcount( )
      {
        return $this->RS->Fields->Count;
      } // eof fieldcount()  
      
    } // eoc mdb
    ?>
    Kullanım Şekli

    <?php
    #
    # This is some wired example.
    # You cannot use it out of the box.
    #
    # Use your own mdb filename and 
    # your own tablename and 
    # your own fieldnames.
    #
    # You really need a Windows Server and a mdb file on it to have it work!
    # Big chance it does not work with Linux or Unix - but tell me if it does.
    #
    # This example opens the mdb once and then reads it twice.
    # I know about 2 ways to get the values, so I show them all.
    # Maybe there is a speed difference.
    #
    # Works on a Win 2000 server with PHP 4.3.4 and Microsoft-IIS/5.0
    #
    
    include 'class_mdb.php';
    
    $mdb = new mdb('mymdbfile.mdb'); // your own mdb filename required
    $mdb->execute('select * from table'); // your own table in the mdb file
    
    #
    # first example: using fieldnames
    # 
    
    while( !$mdb->eof() )
    {
      echo $mdb->fieldvalue('description'); // using your own fields name
      echo ' = ';
      echo $mdb->fieldvalue( 1 ); // using the fields fieldnumber
      echo '<br>';
      $mdb->movenext();
    }
    
    echo '<br><hr><br>';
    
    #
    # Going back to the first recordset for the second example
    #
    $mdb->movefirst();
    
    #
    # This works, too: Make each Field an object. The values change
    # when the data pointer advances with movenext().
    # 
    $url = $mdb->RS->Fields(1);
    $bez = $mdb->RS->Fields(2);
    $kat = $mdb->RS->Fields(3);
    
    while( !$mdb->eof() )
    {
      # works!
      echo $bez->value;
      echo ' = ';
      echo $url->value;
      echo '<br>';
      $mdb->movenext(); 
    }
    
    $mdb->close(); 
    
    ?>
    ------------------------------------------------------------------------

    Alternatif access'e bağlantı yöntemi

    <?
    $sube = $_POST['sube'];
    $conn = new COM("ADODB.Connection") or die("ADODB başlatılamıyor"); 
    $conn->Open("DRIVER={Microsoft Access Driver (*.mdb)};DBQ=d:\Database2.mdb"); 
    $rs = $conn->Execute("SELECT * FROM MAASKART where SUBENO like '$sube' "); 
    echo "<TABLE border='1'><TR><TH colspan='6'>Veriler</TH><TR>"; 
    echo "<TR>"; 
    echo "<TH>" . $rs->Fields[0]->name . "</TH>"; 
    echo "<TH>" . $rs->Fields[1]->name . "</TH>"; 
    echo "<TH>" . $rs->Fields[2]->name . "</TH>"; 
    echo "<TH>" . $rs->Fields[3]->name . "</TH>"; 
    echo "<TH>" . $rs->Fields[4]->name . "</TH>"; 
    echo "<TH>" . $rs->Fields[5]->name . "</TH>"; 
    echo "</TR>";
    while (!$rs->EOF) 
    { 
    echo "<tr>"; 
    echo "<td>" . $rs->Fields[0]->value . " </td>"; 
    echo "<td>" . $rs->Fields[1]->value . " </td>"; 
    echo "<td>" . $rs->Fields[2]->value . " </td>"; 
    echo "<td>" . $rs->Fields[3]->value . " </td>"; 
    echo "<td>" . $rs->Fields[4]->value . " </td>"; 
    echo "<td>" . $rs->Fields[5]->value . " </td>"; 
    echo "</tr>"; 
    $rs->MoveNext(); 
    }
    echo "</TABLE>";
    $rs->Close(); 
    $conn->Close(); 
    
    $rs = null; 
    $conn = null; 
    ?>
  • 29-04-2008, 19:14:15
    #60
    Üyeliği durduruldu
    Gerçi bir çok css-web 2.0 muaidili var ama özellikle tablolarımızda yuvarlatılmış imajları kullanmayı bir parça otomotize edecek bir sınıfdır.

    <?php
    /*
     * Created on 15.Ara.2006
     *
     * A simple class that creates rounded corner images for tables
     * Coded By Ozgur Kaya
     * ozgurkaya01@hotmail.com
     */
    
    class roundedCorners {
        var $width = 50;
        var $height = 50;
        var $bgcolor = "#FFFFFF";
        var $imagecolor = "#ff0000";
        var $align;
        var $cx;
        var $cy;
        var $image;
        var $type = "jpeg";
        var $transparent = false;
    
        function roundedCorners($width,$height,$align,$bgcolor,$color,$type,$transparent){
            $this->setWidth($width); // sets image width
            $this->setHeight($height); // sets image height
            $this->setAlign($align);  // sets align of image (top-left, top-right, bottom-left, bottom-right)
            $this->setbgColor($bgcolor); // set image background color
            $this->setImageColor($color); // set rounded image color
            $this->setType($type); // set extension for image (jpg,gif,png)
            $this->setTransparent($transparent); // set transparency of the image
        }
    
        function setAlign($align){
            $align = ($align) ? $align : $this->align;
    		if ($this->width == $this->height) {
    			$align_array = array (
    						"tl"=>array($this->width,$this->height),
    						"tr"=>array(0,$this->width),
    						"bl"=>array($this->height,0),
    						"br"=>array(0,0)
    					);
    		}
    		elseif ($this->width > $this->height) {
    			$align_array = array (
    						"tl"=>array($this->width,$this->height),
    						"tr"=>array(0,$this->height),
    						"bl"=>array($this->height*2,0),
    						"br"=>array(0,0)
    					);			
    		}
    		elseif ($this->width < $this->height) {
    			$align_array = array (
    						"tl"=>array($this->width,$this->height),
    						"tr"=>array(0,$this->height),
    						"bl"=>array($this->width,0),
    						"br"=>array(0,0)
    					);			
    		}
            $this->cx = $align_array[$align][0];
            $this->cy = $align_array[$align][1];
        }
    
        function setWidth($width){
            $this->width = ($width) ? $width : $this->width;
        }
    
        function setHeight($height) {
            $this->height = ($height) ? $height : $this->height;
        }
    
        function setBgColor($bgcolor){
            $this->bgcolor = ($bgcolor) ? $bgcolor : $this->bgcolor;
        }
    
        function setImageColor($color) {
            $this->imagecolor = ($color) ? $color : $this->imagecolor;
        }
    
        function setType($type){
            if ($type == "jpg")
                $type = "jpeg";
            $types = array("gif","jpeg","png");
            $type = (in_array($type,$types)) ? $type : "jpeg";
            $this->type = $type;
        }
    
        function setTransparent($transparent){
            if ($transparent) {
                $this->type = "gif";
                $this->transparent = true;
            }
            else
                $this->transparent = false;
        }
    
        function displayImage($type){
            $types = array ("gif"=>"gif","png"=>"png","jpg"=>"jpeg");
            $type = $types[$type];
            header("Content-type: image/png]}");
            imagepng($this->image);
        }
    
        function createRGBValues($color) {
            $color = str_replace("#","",$color);
            $rgb["red"] = hexdec(substr($color,0,2));
            $rgb["green"] = hexdec(substr($color,2,2));
            $rgb["blue"] = hexdec(substr($color,4,2));
            return $rgb;
        }
    
        function createImage() {
            $this->image = imagecreatetruecolor($this->width,$this->height);
    
            //
            $bg_rgb = $this->createRGBValues($this->bgcolor);
            $bg = imagecolorallocate($this->image, $bg_rgb["red"], $bg_rgb["green"], $bg_rgb["blue"]);
            if ($this->transparent)
                $bg = imagecolortransparent($this->image,$bg);
            imagefill($this->image, 0, 0, $bg);
    
            //
            $img_rgb = $this->createRGBValues($this->imagecolor);;
            $col_ellipse = imagecolorallocate($this->image, $img_rgb["red"], $img_rgb["green"], $img_rgb["blue"]);
    
            $w = $this->width * 2;
            $h = $this->height * 2;
            imagefilledellipse($this->image, $this->cx, $this->cy, $w, $h, $col_ellipse);
    
            header("Content-type: image/{$this->type}");  // set header (you can use different types png,jpeg,gif
            switch ($this->type){
                case "gif":
                    imagegif($this->image);
                    break;
                case "png":
                    imagepng($this->image);
                    break;
                case "jpeg":
                    imagejpeg($this->image);
                    break;
            }
        }
    
    }
    ?>
    Kullanımı:

    <?php
    
    $img = new roundedCorners($_GET['w'],$_GET['h'],$_GET['al'],$_GET['bg'],$_GET['cl'],$_GET['type'],$_GET['tr']);
    $img->createImage();
    
    ?>
  • 29-04-2008, 19:14:52
    #61
    Üyeliği durduruldu
    PHP Manual den alıntı küçük ama hoş bir sınıf...

    <?php
    
    class ICQ {
      
     var $crc = array('253889085' => 'offline', '1177883536' => 'online', '1182613274' => 'hidden');
    //CRCs valid as long as the redirect-page does not change
      
     function getCrc($url) {
       $ch = curl_init();
       curl_setopt ($ch, CURLOPT_URL, $url);
       curl_setopt ($ch, CURLOPT_HEADER, 0);
       ob_start();
       curl_exec ($ch);
       curl_close ($ch);
       $cache = ob_get_contents();
    
       ob_end_clean();
       //print($cache);
       return (string)abs(crc32($cache));
     }
      
     function status($number) {
       $check = $this->getCrc( 'http://status.icq.com/online.gif?icq=' . $number . '&img=5');
       if (in_array($check, array_keys($this->crc))) {
         return $this->crc[$check];
       }
       return false;
     }
        
    }
    ?>
    
    Durum:
    
    <?php
     $icq = new ICQ();
     print($icq->status('icq numaranız'));
    ?>
  • 01-05-2008, 00:21:56
    #62
    saolasın yinede