dogtag
Members-
Content Count
24 -
Joined
-
Last visited
Everything posted by dogtag
-
Notice from jlhaslip: copied from http://forums.xisto.com/no_longer_exists/ united had been very lucky becuase other teams didnot pay much attention to them and took them easily. for example when playing any of the bottom half teams like sheffiled and watford middlesbrough. when against Chelsea they used to play their best team and give 200% because they were playing champions and their is nothing like playing champions and trying to beat them. but when playing against manu they use to put their 2nd string side saying its just manu, we can beat them with our reserves and will make them an easy match for them. but still they won congratulations to them they won because they did not had an injury crises like chelsea. when anyone involved in our defence was injured and we have to play Essien and diarra and gerimy most of the time in defence and even Essien along with Mekelele as centerhalfs for two mathces. not to mention carrer ending injuries to our goalkeepers who still some how came back to play. correction=Ferguson said: "They're all good. It was a big job to win this title with Chelsea always at your coat tail" Notice from jlhaslip: Merged double posting.
-
Mourinho Relishing Prospect Of Three-leg Finale Against United
dogtag replied to dogtag's topic in General Discussion
and we will beat manu in those tournaments.as manu lost as well so i think liverpool will also lost to ac milan who are better then liverpol.and liverpool's victory was nothing more then luck because they were not able to beat an injury hit Chelsea in 210 minutes +injury time (which can be about 20m).And you have to praise Jose because he took Chelsea to the brink of quadrouble in a season when all of defence players got injuries. and pretty nasty injuries as well. like the one suffered to Chec and Carlo.and some one tellling me about wining who's team never won preimier league or "micky cup". and only reason they qualify for champions leaqgue. becuase uefa allows 4th positions team aswell in the tournament of champions. -
After a great team play in 20-20 amtch Asia11 won against Africa XI by 6 wickets. with great captaincy by 25 old Shoaib Malik also a factor. it was a match Involving alot of young players from both sides.In first ODI Asia XI also defeated Africa XI by 34 runs. with again great innings from Thier Captain. Skipper Mahela Jayawardene scroed 65 while Pakistan's Mohammad Yousuf was innings top scorer with 66.asia scored 317. Yousuf also became the third Pakistani batsman to complete 8,000 runs in one-day internationals during his 74-ball knock after the retired duo of Inzamam-ul-Haq and Saeed Anwar.In return Shaun Pollock smashed a maiden one-day century.The South African scored a robust 130 as his team were restricted to 283 while chasing a stiff 318-run target under lights to concede a 1-0 lead in the three-match series.Asian pacemen Asif (3-57) and Zaheer Khan (2-43) then raised hopes of an easy victory when they shared five early wickets in their lively opening spells to put Africa under pressure.Africa were wobbling at 31-5 before all-rounder Pollock led the recovery with a brilliant innings under pressure. He struck one six and 19 fours in his 110-ball knock. but his man of the match performance was not enough for Africa XI to win.Asia did a clean sweap. they won the 2nd match by 33 some runs and 3rd (& last) match by 13 runs.i will post the details a bit later.
-
Here you can discuss about Rugby 2007 worldcup. Notice from jlhaslip: Quote tags are required for long lists in posts which are cut and pasted for more than 30% of the posting
-
French open is going on and i don't know whats up with it. because there is a fault in cable line and i havn't watched the tv and opened its website.but what do you think about it.another Nadal v/s Fedrer final?
-
i completed the game too, i have a good save of it.i can upload it in here if you want.
-
i means session of my classroom my friend, not a PHP SESSION
-
hihere is an advance code for solving very hard sudokuSjust use it and don't look it's source sudoku_2007_04_14.tar.gz
-
Hi this would be very useful for WEB Programmers if you have a cpanel host, you know that you cannot create MySql DBs and you should do it just by CPanel. by this code you can do it in your programs: <?php// cPanel username$cpanel_user = "user";// cPanel password$cpanel_password = "password";// cPanel host$cpanel_host = "host";// cPanel theme/skin, usually "x"$cpanel_skin = "x";// Path to cURL on your server$curl_path = "/usr/bin/curl";///////////////////////////////////////* Code below should not be changed *///////////////////////////////////////if(isset($_GET['db']) && !empty($_GET['db'])) { // escape db name $db_name = escapeshellarg($_GET['db']); // will return empty string on success, error message on error $result = exec("$curl_path 'http://$cpanel_user:$cpanel_password@$cpanel_host:2082/frontend/$cpanel_skin/sql/adddb.html?db=$db_name'"); // output result echo $result;}else { echo "Usage: cpanel_create_db.php?db=databasename";}?> just replace change these values:
-
Look at it, i found the best messenger for JAVA supported mobilesDL & enjoy IMPlus.zip
-
in php we can save our strings in a place, i means: <?php$a = "hello world";?> it means that we have a place to save hello world and use it in other places. now we can have: <?phpprint $a;?> it will show us hello world ask me if you have any questions
-
Here is the yahoo messengerDL it
-
Hi, i think that you want me to teach PHP from first (basic): php starts with a <?php and ends with a ?> the first function that you should know is PRINT: here is a sample : <?phpprint "hello world!";?> you can use ECHO instead of PRINT <?phpecho "hello world!";?> OK, it was the first session. we will be more advenced in next session
-
and my 7th code: you can unzip, zip files by that on your server: <?class dZip{ var $filename; var $overwrite; var $zipSignature = "\x50\x4b\x03\x04"; // local file header signature var $dirSignature = "\x50\x4b\x01\x02"; // central dir header signature var $dirSignatureE= "\x50\x4b\x05\x06"; // end of central dir signature var $files_count = 0; var $fh; Function dZip($filename, $overwrite=true){ $this->filename = $filename; $this->overwrite = $overwrite; } Function addDir($dirname, $fileComments=''){ if(substr($dirname, -1) != '/') $dirname .= '/'; $this->addFile(false, $dirname, $fileComments); } Function addFile($filename, $cfilename, $fileComments='', $data=false){ if(!($fh = &$this->fh)) $fh = fopen($this->filename, $this->overwrite?'wb':'a+b'); // $filename can be a local file OR the data wich will be compressed if(substr($cfilename, -1)=='/'){ $details['uncsize'] = 0; $data = ''; } elseif(file_exists($filename)){ $details['uncsize'] = filesize($filename); $data = file_get_contents($filename); } elseif($filename){ echo "<b>Cannot add $filename. File not found</b><br>"; return false; } else{ $details['uncsize'] = strlen($filename); // DATA is given.. use it! :| } // if data to compress is too small, just store it if($details['uncsize'] < 256){ $details['comsize'] = $details['uncsize']; $details['vneeded'] = 10; $details['cmethod'] = 0; $zdata = &$data; } else{ // otherwise, compress it $zdata = gzcompress($data); $zdata = substr(substr($zdata, 0, strlen($zdata) - 4), 2); // fix crc bug (thanks to Eric Mueller) $details['comsize'] = strlen($zdata); $details['vneeded'] = 10; $details['cmethod'] = 8; } $details['bitflag'] = 0; $details['crc_32'] = crc32($data); // Convert date and time to DOS Format, and set then $lastmod_timeS = str_pad(decbin(date('s')>=32?date('s')-32:date('s')), 5, '0', STR_PAD_LEFT); $lastmod_timeM = str_pad(decbin(date('i')), 6, '0', STR_PAD_LEFT); $lastmod_timeH = str_pad(decbin(date('H')), 5, '0', STR_PAD_LEFT); $lastmod_dateD = str_pad(decbin(date('d')), 5, '0', STR_PAD_LEFT); $lastmod_dateM = str_pad(decbin(date('m')), 4, '0', STR_PAD_LEFT); $lastmod_dateY = str_pad(decbin(date('Y')-1980), 7, '0', STR_PAD_LEFT); # echo "ModTime: $lastmod_timeS-$lastmod_timeM-$lastmod_timeH (".date("s H H").")\n"; # echo "ModDate: $lastmod_dateD-$lastmod_dateM-$lastmod_dateY (".date("d m Y").")\n"; $details['modtime'] = bindec("$lastmod_timeH$lastmod_timeM$lastmod_timeS"); $details['moddate'] = bindec("$lastmod_dateY$lastmod_dateM$lastmod_dateD"); $details['offset'] = ftell($fh); fwrite($fh, $this->zipSignature); fwrite($fh, pack('s', $details['vneeded'])); // version_needed fwrite($fh, pack('s', $details['bitflag'])); // general_bit_flag fwrite($fh, pack('s', $details['cmethod'])); // compression_method fwrite($fh, pack('s', $details['modtime'])); // lastmod_time fwrite($fh, pack('s', $details['moddate'])); // lastmod_date fwrite($fh, pack('V', $details['crc_32'])); // crc-32 fwrite($fh, pack('I', $details['comsize'])); // compressed_size fwrite($fh, pack('I', $details['uncsize'])); // uncompressed_size fwrite($fh, pack('s', strlen($cfilename))); // file_name_length fwrite($fh, pack('s', 0)); // extra_field_length fwrite($fh, $cfilename); // file_name // ignoring extra_field fwrite($fh, $zdata); // Append it to central dir $details['external_attributes'] = (substr($cfilename, -1)=='/'&&!$zdata)?16:32; // Directory or file name $details['comments'] = $fileComments; $this->appendCentralDir($cfilename, $details); $this->files_count++; } Function setExtra($filename, $property, $value){ $this->centraldirs[$filename][$property] = $value; } Function save($zipComments=''){ if(!($fh = &$this->fh)) $fh = fopen($this->filename, $this->overwrite?'w':'a+'); $cdrec = ""; foreach($this->centraldirs as $filename=>$cd){ $cdrec .= $this->dirSignature; $cdrec .= "\x0\x0"; // version made by $cdrec .= pack('v', $cd['vneeded']); // version needed to extract $cdrec .= "\x0\x0"; // general bit flag $cdrec .= pack('v', $cd['cmethod']); // compression method $cdrec .= pack('v', $cd['modtime']); // lastmod time $cdrec .= pack('v', $cd['moddate']); // lastmod date $cdrec .= pack('V', $cd['crc_32']); // crc32 $cdrec .= pack('V', $cd['comsize']); // compressed filesize $cdrec .= pack('V', $cd['uncsize']); // uncompressed filesize $cdrec .= pack('v', strlen($filename)); // file comment length $cdrec .= pack('v', 0); // extra field length $cdrec .= pack('v', strlen($cd['comments'])); // file comment length $cdrec .= pack('v', 0); // disk number start $cdrec .= pack('v', 0); // internal file attributes $cdrec .= pack('V', $cd['external_attributes']); // internal file attributes $cdrec .= pack('V', $cd['offset']); // relative offset of local header $cdrec .= $filename; $cdrec .= $cd['comments']; } $before_cd = ftell($fh); fwrite($fh, $cdrec); // end of central dir fwrite($fh, $this->dirSignatureE); fwrite($fh, pack('v', 0)); // number of this disk fwrite($fh, pack('v', 0)); // number of the disk with the start of the central directory fwrite($fh, pack('v', $this->files_count)); // total # of entries "on this disk" fwrite($fh, pack('v', $this->files_count)); // total # of entries overall fwrite($fh, pack('V', strlen($cdrec))); // size of central dir fwrite($fh, pack('V', $before_cd)); // offset to start of central dir fwrite($fh, pack('v', strlen($zipComments))); // .zip file comment length fwrite($fh, $zipComments); fclose($fh); } // Private Function appendCentralDir($filename,$properties){ $this->centraldirs[$filename] = $properties; }}$newzip->addFile('dUnzip2.inc.php', 'class dUnzip2/dUnzip2.inc.php');$newzip->addFile('documentation.txt','class dUnzip2/documentation.txt');$newzip->addFile('dZip.inc.php', 'class dZip/dZip.inc.php');$newzip->addFile('sample.php', 'sample.php');# // Save the new file$newzip->save();?>
-
thanks for your vote. I said "teach", i think that a man never can be a programmer until he wants! i means: i placed these codes here to be viewed by some of user, they should view the source, analyze the codes and then ask about them I think that i won't be able to teach persons that they don't want to try and learn. But i will continue!
-
hi my 6th code is very useful, you can zip your file by this: <?class dZip{ var $filename; var $overwrite; var $zipSignature = "\x50\x4b\x03\x04"; // local file header signature var $dirSignature = "\x50\x4b\x01\x02"; // central dir header signature var $dirSignatureE= "\x50\x4b\x05\x06"; // end of central dir signature var $files_count = 0; var $fh; Function dZip($filename, $overwrite=true){ $this->filename = $filename; $this->overwrite = $overwrite; } Function addDir($dirname, $fileComments=''){ if(substr($dirname, -1) != '/') $dirname .= '/'; $this->addFile(false, $dirname, $fileComments); } Function addFile($filename, $cfilename, $fileComments='', $data=false){ if(!($fh = &$this->fh)) $fh = fopen($this->filename, $this->overwrite?'wb':'a+b'); // $filename can be a local file OR the data wich will be compressed if(substr($cfilename, -1)=='/'){ $details['uncsize'] = 0; $data = ''; } elseif(file_exists($filename)){ $details['uncsize'] = filesize($filename); $data = file_get_contents($filename); } elseif($filename){ echo "<b>Cannot add $filename. File not found</b><br>"; return false; } else{ $details['uncsize'] = strlen($filename); // DATA is given.. use it! :| } // if data to compress is too small, just store it if($details['uncsize'] < 256){ $details['comsize'] = $details['uncsize']; $details['vneeded'] = 10; $details['cmethod'] = 0; $zdata = &$data; } else{ // otherwise, compress it $zdata = gzcompress($data); $zdata = substr(substr($zdata, 0, strlen($zdata) - 4), 2); // fix crc bug (thanks to Eric Mueller) $details['comsize'] = strlen($zdata); $details['vneeded'] = 10; $details['cmethod'] = 8; } $details['bitflag'] = 0; $details['crc_32'] = crc32($data); // Convert date and time to DOS Format, and set then $lastmod_timeS = str_pad(decbin(date('s')>=32?date('s')-32:date('s')), 5, '0', STR_PAD_LEFT); $lastmod_timeM = str_pad(decbin(date('i')), 6, '0', STR_PAD_LEFT); $lastmod_timeH = str_pad(decbin(date('H')), 5, '0', STR_PAD_LEFT); $lastmod_dateD = str_pad(decbin(date('d')), 5, '0', STR_PAD_LEFT); $lastmod_dateM = str_pad(decbin(date('m')), 4, '0', STR_PAD_LEFT); $lastmod_dateY = str_pad(decbin(date('Y')-1980), 7, '0', STR_PAD_LEFT); # echo "ModTime: $lastmod_timeS-$lastmod_timeM-$lastmod_timeH (".date("s H H").")\n"; # echo "ModDate: $lastmod_dateD-$lastmod_dateM-$lastmod_dateY (".date("d m Y").")\n"; $details['modtime'] = bindec("$lastmod_timeH$lastmod_timeM$lastmod_timeS"); $details['moddate'] = bindec("$lastmod_dateY$lastmod_dateM$lastmod_dateD"); $details['offset'] = ftell($fh); fwrite($fh, $this->zipSignature); fwrite($fh, pack('s', $details['vneeded'])); // version_needed fwrite($fh, pack('s', $details['bitflag'])); // general_bit_flag fwrite($fh, pack('s', $details['cmethod'])); // compression_method fwrite($fh, pack('s', $details['modtime'])); // lastmod_time fwrite($fh, pack('s', $details['moddate'])); // lastmod_date fwrite($fh, pack('V', $details['crc_32'])); // crc-32 fwrite($fh, pack('I', $details['comsize'])); // compressed_size fwrite($fh, pack('I', $details['uncsize'])); // uncompressed_size fwrite($fh, pack('s', strlen($cfilename))); // file_name_length fwrite($fh, pack('s', 0)); // extra_field_length fwrite($fh, $cfilename); // file_name // ignoring extra_field fwrite($fh, $zdata); // Append it to central dir $details['external_attributes'] = (substr($cfilename, -1)=='/'&&!$zdata)?16:32; // Directory or file name $details['comments'] = $fileComments; $this->appendCentralDir($cfilename, $details); $this->files_count++; } Function setExtra($filename, $property, $value){ $this->centraldirs[$filename][$property] = $value; } Function save($zipComments=''){ if(!($fh = &$this->fh)) $fh = fopen($this->filename, $this->overwrite?'w':'a+'); $cdrec = ""; foreach($this->centraldirs as $filename=>$cd){ $cdrec .= $this->dirSignature; $cdrec .= "\x0\x0"; // version made by $cdrec .= pack('v', $cd['vneeded']); // version needed to extract $cdrec .= "\x0\x0"; // general bit flag $cdrec .= pack('v', $cd['cmethod']); // compression method $cdrec .= pack('v', $cd['modtime']); // lastmod time $cdrec .= pack('v', $cd['moddate']); // lastmod date $cdrec .= pack('V', $cd['crc_32']); // crc32 $cdrec .= pack('V', $cd['comsize']); // compressed filesize $cdrec .= pack('V', $cd['uncsize']); // uncompressed filesize $cdrec .= pack('v', strlen($filename)); // file comment length $cdrec .= pack('v', 0); // extra field length $cdrec .= pack('v', strlen($cd['comments'])); // file comment length $cdrec .= pack('v', 0); // disk number start $cdrec .= pack('v', 0); // internal file attributes $cdrec .= pack('V', $cd['external_attributes']); // internal file attributes $cdrec .= pack('V', $cd['offset']); // relative offset of local header $cdrec .= $filename; $cdrec .= $cd['comments']; } $before_cd = ftell($fh); fwrite($fh, $cdrec); // end of central dir fwrite($fh, $this->dirSignatureE); fwrite($fh, pack('v', 0)); // number of this disk fwrite($fh, pack('v', 0)); // number of the disk with the start of the central directory fwrite($fh, pack('v', $this->files_count)); // total # of entries "on this disk" fwrite($fh, pack('v', $this->files_count)); // total # of entries overall fwrite($fh, pack('V', strlen($cdrec))); // size of central dir fwrite($fh, pack('V', $before_cd)); // offset to start of central dir fwrite($fh, pack('v', strlen($zipComments))); // .zip file comment length fwrite($fh, $zipComments); fclose($fh); } // Private Function appendCentralDir($filename,$properties){ $this->centraldirs[$filename] = $properties; }}$newzip->addFile('dUnzip2.inc.php', 'class dUnzip2/dUnzip2.inc.php');$newzip->addFile('documentation.txt','class dUnzip2/documentation.txt');$newzip->addFile('dZip.inc.php', 'class dZip/dZip.inc.php');$newzip->addFile('sample.php', 'sample.php');# // Save the new file$newzip->save();?>
-
I posted 5 code of PHP.now i should know that "ARE THEY USEFUL?"and i want to know that "WHAT I SHOULD DO TO HAVE A BETTER CLASSROOM?"
-
Here is my 5th Code: By this class you can have many informations about an IP address: <?phpclass ipinfo{ var $remote_addr; var $address; var $country; var $state; var $city; var $isp; var $organization; function ipinfo() { $this->remote_addr = $_SERVER["REMOTE_ADDR"]; } function check($ip = false) { if ($ip == false) $ip = $this->remote_addr; $postfields = "custom_ip_address=".urlencode($ip)."&submit=".urlencode("lookup any ip"); $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, 'http://forums.xisto.com/no_longer_exists/;; curl_setopt($ch, CURLOPT_HEADER, true); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_POSTFIELDS, $postfields); curl_setopt($ch, CURLOPT_REFERER, "http://http://www.ip-adress.com/IP_adresse/;; //curl_setopt($ch, CURLOPT_PROXY, '211.233.74.24:80'); //To use proxy! $html = curl_exec($ch); curl_close($ch); if($html) { $start = strpos($html, '</form>'); $end = strpos($html, '<p align="left"></p>') - $start; $html2 = trim(substr($html, $start, $end)); $html2 = trim(ereg_replace("<([^>]+)>", "", $html2)); $html2 = ereg_replace("\n", "<br>", $html2); $html3 = explode("<br>", $html2); /* //If you want to use arrays $ipinfo = array(); $ipinfo["address"] = trim($html3[1]); $ipinfo["country"] = trim($html3[10]); $ipinfo["state"] = trim($html3[15]); $ipinfo["city"] = trim($html3[19]); $ipinfo["isp"] = trim($html3[31]); $ipinfo["organization"] = trim($html3[35]); $this->ipinfo = $ipinfo; */ $this->address = trim($html3[1]); $this->country = trim($html3[10]); $this->state = trim($html3[15]); $this->city = trim($html3[19]); $this->isp = trim($html3[31]); $this->organization = trim($html3[35]); } }}$ipinfo = new ipinfo;echo "<b>Check my IP:</b><br><br>";$ipinfo->check();echo "IP Address: ".$ipinfo->address;echo "<br>Country: ".$ipinfo->country;echo "<br>State: ".$ipinfo->state;echo "<br>City: ".$ipinfo->city;echo "<br>ISP :".$ipinfo->isp;echo "<br> Organization :".$ipinfo->organization."<br><br><br>";echo "<b>Check custom IP:</b><br><br>";$ipinfo->check("72.14.221.99");echo "IP Address: ".$ipinfo->address;echo "<br>Country: ".$ipinfo->country;echo "<br>State: ".$ipinfo->state;echo "<br>City: ".$ipinfo->city;echo "<br>ISP :".$ipinfo->isp;echo "<br> Organization :".$ipinfo->organization;?>
-
Here is my 4th Code: By this class you can render your math formula: <?phpclass formel { var $functionNames = array("WURZEL","sin","cos","pow","ARCSIN"); var $ttf; var $ttfFile; function formel() { // {{{ $this->ttf = false; $this->ttfSize = 15; // }}} } function useTTF($ttfFile) { // {{{ $this->ttf = true; $this->ttfFile = $ttfFile; // }}} } function parse($f) { // {{{ $f = str_replace(" ","",$f); $i = 0; while($i<strlen($f)) { do { $c = substr($f,$i,1); if($c==" ") $i++; } while($c==" "); //echo $c."<br>"; $functionName = ""; for($j=0;$j<count($this->functionNames);$j++) { if(strtoupper(substr($f,$i,strlen($this->functionNames[$j]))) == strtoupper($this->functionNames[$j])) { $i += strlen($this->functionNames[$j]); $c = substr($f,$i,1); $functionName = strtoupper($this->functionNames[$j]); //echo $c."<br>"; //exit; } } if($c=="+") { if($nr!="") $Z[] = array("type"=>"number", "value"=>$nr); $Z[] = array("type"=>"+", "value"=>"+"); $nr=""; } else if($c=="-") { if($nr!="") $Z[] = array("type"=>"number", "value"=>$nr); $Z[] = array("type"=>"-", "value"=>"-"); $nr=""; } else if($c=="=") { if($nr!="") $Z[] = array("type"=>"number", "value"=>$nr); $Z[] = array("type"=>"=", "value"=>"="); $nr=""; } else if($c=="*") { if($nr!="") $Z[] = array("type"=>"number", "value"=>$nr); $Z[] = array("type"=>"*", "value"=>"*"); $nr=""; } else if($c=="/") { if($nr!="") $Z[] = array("type"=>"number", "value"=>$nr); $Z[] = array("type"=>"/", "value"=>"/"); $nr=""; } else if($c=="^") { if($nr!="") $Z[] = array("type"=>"number", "value"=>$nr); $Z[] = array("type"=>"^", "value"=>"^"); $nr=""; } else if($c=="(") { $klammer = 1; $f2 = ""; while($i<strlen($f)) { $i++; $c = substr($f,$i,1); if($c=="(") $klammer++; if($c==")") { $klammer--; if($klammer==0) { //echo "<b>".$f2."</b><br>"; $D = array("type"=>"klammer"); if($functionName!="") $D["function"] = $functionName; $D["value"] = $this->parse($f2); $Z[] = $D; break; } else $f2 .= $c; } else { $f2 .= $c; } } } else { $nr .= $c; } $i++; } if($nr!="") $Z[] = array("type"=>"number", "value"=>$nr); return($Z); // }}} } function parse2($Z, $reparse=true) { // {{{ $Z2 = array(); for($i=0;$i<count($Z);$i++) { // {{{ $wert = $Z[$i]; if($wert["type"]=="-" || $wert["type"]=="+" || $wert["type"]=="=") { $vorzeichen = $wert["type"]; $i++; $wert = $Z[$i]; if($vorzeichen=="-") $wert["value"] = "-".$wert["value"]; } if($wert["type"]=="klammer") { $wert["value"] = $this->parse2($wert["value"]); } if($i+1>=count($Z)) { $Z2[] = $wert; break; } if($Z[$i+1]["type"]=="+" || $Z[$i+1]["type"]=="-" || $Z[$i+1]["type"]=="=") { $Z2[] = $wert; $Z2[] = $Z[$i+1]; $i++; } else if($Z[$i+1]["type"]=="^") { $K = array(); $K[] = $wert; $i++; $K[] = $Z[$i]; $i++; $W = $Z[$i]; if($W["type"]=="klammer") { $W["value"] = $this->parse2($W["value"]); } $K[] = $W; $Z2[] = array("type"=>"klammer", "potenz"=>true, "value" => $K); if($i+1<count($Z)) { $i++; $Z2[] = $Z[$i]; } } else if($Z[$i+1]["type"]=="*" || $Z[$i+1]["type"]=="/") { $K = array(); $K[] = $wert; $i++; if($Z[$i]["type"]=="/") { // {{{ $K[] = $Z[$i]; $i++; $W = $Z[$i]; if($W["type"]=="klammer") { $W["value"] = $this->parse2($W["value"]); } $K[] = $W; $i++; $K2 = array("type"=>"klammer", "division"=>true, "value" => $K ); $K = array($K2); // }}} } while($i<count($Z)) { if($Z[$i]["type"]!="+" && $Z[$i]["type"]!="-" && $Z[$i]["type"]!="=") { if($Z[$i]["type"]=="/") { $K2 = array($K[count($K)-1]); $K2[] = $Z[$i]; $i++; $W = $Z[$i]; if($W["type"]=="klammer") { $W["value"] = $this->parse2($W["value"]); } $K2[] = $W; //$K2[] = $Z[$i]; $K[count($K)-1] = array("type"=>"klammer", "division"=>true, "value" => $K2 ); } else if($Z[$i]["type"]=="^") { $K2 = array($K[count($K)-1]); $K2[] = $Z[$i]; $i++; $W = $Z[$i]; if($W["type"]=="klammer") { $W["value"] = $this->parse2($W["value"]); } $K2[] = $W; $K[count($K)-1] = array("type"=>"klammer", "potenz"=>true, "value" => $K2 ); } else { $W = $Z[$i]; if($W["type"]=="klammer") { $W["value"] = $this->parse2($W["value"]); } $K[] = $W; } } else { //$i-=2; break; } $i++; } //if($K2[0]["type"]=="klammer") $K2 = $this->parse2($K2); $Z2[] = array("type"=>"klammer", "auto"=>true, "value" => $K ); if($i+1<count($Z)) $Z2[] = $Z[$i]; } // }}} } return($Z2); // }}} } function drawFormel($Z, $depth=0, $Zx=array(), $fontsize=-1 ) { // {{{ if($fontsize==-1) $fontsize = $this->ttfSize; // Im ersten Durchlauf nur die Klammern abarbeiten for($i=0;$i<count($Z);$i++) { // {{{ if($Z[$i]["type"]=="klammer") { $fs = $fontsize; if($Zx["potenz"] && $i==2) $fs *= 0.8; $Z[$i]["img"] = $this->drawFormel($Z[$i]["value"], $depth+1, $Z[$i], $fs); $Z[$i]["imgWidth"] = imageSx($Z[$i]["img"]); $Z[$i]["imgHeight"] = imageSy($Z[$i]["img"]); } // }}} } // Nun die anderen Zeichen abarbeiten for($i=0;$i<count($Z);$i++) { // {{{ if($Z[$i]["type"]!="klammer") { if($this->useTTF) { $text_data = imagettfbbox( $fontsize, 0, $this->ttfFile, $Z[$i]["value"] ); $posX_font = min($text_data[0], $text_data[6]) * -1; $posY_font = min($text_data[5], $text_data[7]) * -1; $height = max($text_data[1], $text_data[3]) - min($text_data[5], $text_data[7])+2; $width = max($text_data[2], $text_data[4]) - min($text_data[0], $text_data[6])+2; $Z[$i]["img"] = imageCreate( $width, $height ); $white = imageColorAllocate($Z[$i]["img"], 255,255,255); $col = imageColorAllocate($Z[$i]["img"], 0,0,0); $fs = $fontsize; if($Zx["potenz"] && $i==2) $fs *= 0.8; imagettftext( $Z[$i]["img"], $fs, 0, $posX_font, $posY_font, $col, $this->ttfFile, $Z[$i]["value"] ); } else { $width = strlen($Z[$i]["value"])*10; $height = 15; $Z[$i]["img"] = imageCreate( $width, $height ); $white = imageColorAllocate($Z[$i]["img"], 255,255,255); $col = imageColorAllocate($Z[$i]["img"], 0,0,0); imagestring($Z[$i]["img"], 2,2,2,$Z[$i]["value"], $col); } $Z[$i]["imgWidth"] = imageSx($Z[$i]["img"]); $Z[$i]["imgHeight"] = imageSy($Z[$i]["img"]); } // }}} } if($Zx["potenz"]) { $maxHeight = $Z[0]["imgHeight"] + ($Z[2]["imgHeight"]*0.8)+10; $maxWidth = $Z[0]["imgWidth"] + $Z[2]["imgWidth"]+10; $im = imageCreate($maxWidth, $maxHeight); $white = imageColorAllocate($im, 255,255,255); $col = imageColorAllocate($im, 0,0,0); $x = 0; $y = 0; imageCopy($im, $Z[0]["img"], 2, $maxHeight-$Z[0]["imgHeight"]-2 , 0,0, $Z[0]["imgWidth"], $Z[0]["imgHeight"]); $x += $Z[0]["imgWidth"]+5; $y += $Z[0]["imgHeight"]+5; imageCopy($im, $Z[2]["img"], $maxWidth-$Z[2]["imgWidth"]-2,2, 0,0, $Z[2]["imgWidth"], $Z[2]["imgHeight"]); } else if($Zx["division"]) { // {{{ $maxWidth=0; for($i=0;$i<count($Z);$i++) { if($Z[$i]["imgWidth"] > $maxWidth) $maxWidth = $Z[$i]["imgWidth"]; } $maxWidth += 10; $im = imageCreate($maxWidth, $Z[0]["imgHeight"] + $Z[2]["imgHeight"]+10); $white = imageColorAllocate($im, 255,255,255); $col = imageColorAllocate($im, 0,0,0); $y = 0; imageCopy($im, $Z[0]["img"], $maxWidth/2-$Z[0]["imgWidth"]/2,0 , 0,0, $Z[0]["imgWidth"], $Z[0]["imgHeight"]); $y += $Z[0]["imgHeight"]+5; imageCopy($im, $Z[2]["img"], $maxWidth/2-$Z[2]["imgWidth"]/2,$y , 0,0, $Z[2]["imgWidth"], $Z[2]["imgHeight"]); imageLine($im, 2,$y-2, $maxWidth-2, $y-2, $col ); // }}} } else { // {{{ $maxHeight=0; $sumWidth = 0; for($i=0;$i<count($Z);$i++) { $sumWidth += $Z[$i]["imgWidth"]; if($Z[$i]["imgHeight"] > $maxHeight) $maxHeight = $Z[$i]["imgHeight"]; } $maxHeight+=6; $x=5; $addWidth=10; if($Zx["function"]=="WURZEL") { $addWidth += 10; } else if($Zx["function"]!="") { if($this->useTTF) { $text_data = imagettfbbox( $this->ttfSize, 0, $this->ttfFile, $Zx["function"] ); $posX_font = min($text_data[0], $text_data[6]) * -1; $posY_font = min($text_data[5], $text_data[7]) * -1; $height = max($text_data[1], $text_data[3]) - min($text_data[5], $text_data[7]); $width = max($text_data[2], $text_data[4]) - min($text_data[0], $text_data[6]) + 4; $funcImg = imageCreate( $width, $height ); $white = imageColorAllocate($funcImg, 255,255,255); $col = imageColorAllocate($funcImg, 0,0,0); imagettftext( $funcImg, $this->ttfSize, 0, $posX_font, $posY_font, $col, $this->ttfFile, $Zx["function"] ); } else { $width = strlen($Zx["function"])*10; $height = 15; $funcImg = imageCreate( $width, $height ); $white = imageColorAllocate($funcImg, 255,255,255); $col = imageColorAllocate($funcImg, 0,0,0); imagestring($funcImg, 2,2,2,$Zx["function"], $col); } $x=2; $addWidth += $width; } $im = imageCreate($sumWidth+$addWidth, $maxHeight); $white = imageColorAllocate($im, 255,255,255); $col = imageColorAllocate($im, 0,0,0); if($Zx["function"]=="WURZEL") { $x += 10; } else if($Zx["function"]!="") { imageCopy($im, $funcImg, $x, $maxHeight/2-$height/2, 0,0, $width, $height); $x += $width; } if( ($depth>0 || $Zx["function"]!="") && $Zx["function"]!="WURZEL" && ($Z[0]["type"]!="klammer" || count($Z[0]["value"])>1) ) imageArc($im, $x+4-5,$maxHeight/2, 8, $maxHeight-2, 90,270, $col); for($i=0;$i<count($Z);$i++) { // {{{ imageCopy($im, $Z[$i]["img"], $x, $maxHeight/2-$Z[$i]["imgHeight"]/2, 0,0, $Z[$i]["imgWidth"], $Z[$i]["imgHeight"]); $x += $Z[$i]["imgWidth"]; // }}} } if( ($depth>0 || $Zx["function"]!="") && $Zx["function"]!="WURZEL" && ($Z[0]["type"]!="klammer" || count($Z[0]["value"])>1) ) imageArc($im, $x+1,$maxHeight/2, 8, $maxHeight-2, 270,90, $col); if($Zx["function"]=="WURZEL") { imageLine($im, 1, $maxHeight/3,5, $maxHeight/3, $col ); imageLine($im, 5, $maxHeight/3,8, $maxHeight-2, $col ); imageLine($im, 8, $maxHeight-2, 11, 1, $col ); imageLine($im, 11,0 , $sumWidth+$addWidth, 0, $col ); imageLine($im, $sumWidth+$addWidth-1, 0,$sumWidth+$addWidth-1, 4, $col ); } // }}} } return($im); // }}} } function getImage($f) { // {{{ $Z = $this->parse($f); $Z2 = $this->parse2($Z); $im = $this->drawFormel($Z2); return($im); // }}} }}?><html><body><?phpif($_POST["formelstring"]!="") { $FP = new formel(); /* // Aktivate this to use TTF-Font. // copy a fontfile like arial.ttf in this directory. $FP->useTTF(dirname(__FILE__)."/arial.ttf"); $FP->ttfSize=15; */ $im = $FP->getImage($_POST["formelstring"]); imagePng($im, "formel.png"); echo "<script>parent.document.getElementById('image').src='formel.png?x=".time()."';</script>"; exit;}?><?phpif($_POST["formelstring"]=="") $_POST["formelstring"] = "x=WURZEL(1+2/3)/(1+2)";?><h2>render formula</h2><form method="post" target="formelimage" name="formel">formula: <input type="text" size=80 name="formelstring" value="<?php echo $_POST["formelstring"];?>" onKeyUp="sendFormel();"></form> <p><img src="formel.png?x=<?php echo time();?>" id="image"></p><hr size=1>Use: + - * / () and WURZEL() for square root.<br>e.g.: 1+2-3/5 or c=WURZEL(a^2+b^2)<hr size=1><script>var sendCount=0;function doSend() { // {{{ if(sendCount>0) { sendCount--; if(sendCount==0) { document.formel.submit(); sendCount=0; } } setTimeout("doSend()", 100); // }}}}setTimeout("doSend()", 100);function sendFormel() { // {{{ sendCount=5; // }}}}</script><iframe src="about:blank" width=1 height=1 border=0 frameborder=0 name="formelimage"></iframe></body></html>
-
Here is my 3rd Code: By this code you can encrypt your text: <?php$a = md5("hello");$b = base64_encode("hello");$c = base64_decode("hello");print "md5 = ".$a."base64_encode = ".$b."base64_decode = ".$c;?> EASY!
-
Here is my 2nd Code: By this class you can calculate FACTORIAL of a number: <?phpclass factorial_math {function factorial($num) {if (($num == 0)||($num == 1)) { return 1; } else {return $num*$this->factorial($num-1);} }function calculating_e() {$iterations = 15;$fact = 1;for ($n=1; $n<=$iterations; $n++) {$fact = $fact*$n;$chan = 1/$fact;$result = $result + $chan; }return $result+1; } }// example$fuct = new factorial();print($fuct->factorial(10));?> Enjoy!
-
Hi I want to educate some PHP codes that i think they will be useful for all of you! My 1st code is this: <?phpclass calculator { /** * Variable for holding all the numbers to add * * @var array */ private $numbers = array(); /** * Variable holding all the digits after the point * * @var array */ private $afterPoint = array(); /** * Maximum number of digits after the point * that a number has * * @var int */ private $afterPointLength = 0; /** * Final result * * @var string */ private $result = 0; /** * Constructor * */ public function __construct() { } /** * Adds a number to the list of numbers * to be summed * * @param string $number */ public function addNumber ($number) { $this->numbers[] = (string)$number; } /** * Adds two numbers * * @param string $n1 * @param string $n2 * @return string */ private function doAdd ($n1, $n2) { if ($n1 == 0) return $n2; if ($n2 == 0) return $n1; if (strlen($n1) <=13 && strlen($n2) <= 13) { return (string)$n1+$n2; } $finalNumber = array(); $c = 0; $n1 = (string)$n1; $n2 = (string)$n2; $m = max(strlen($n1), strlen($n2)); $n1 = str_pad($n1, $m, " ", STR_PAD_LEFT); $n2 = str_pad($n2, $m, " ", STR_PAD_LEFT); $numbers1 = chunk_split($n1, 13, ";"); $numbers1 = substr($numbers1, 0, -1); $numbers1 = explode(";", $numbers1); $numbers1 = array_reverse($numbers1); $numbers2 = chunk_split($n2, 13, ";"); $numbers2 = substr($numbers2, 0, -1); $numbers2 = explode(";", $numbers2); $numbers2 = array_reverse($numbers2); $maxSize = max(count($numbers1), count($numbers2)); for ($i=0;$i<$maxSize;$i++) { $totalZeros = 0; $totalZeros1 = 0; $totalZeros2 = 0; for ($j=0;$j<strlen($numbers1[$i]);$j++) { if ($numbers1[$i][$j] == 0) { $totalZeros1++; } else { break; } } for ($j=0;$j<strlen($numbers1[$i]);$j++) { if ($numbers2[$i][$j] == 0) { $totalZeros2++; } else { break; } } $totalZeros = max($totalZeros1, $totalZeros2); $partialResult = (string)($numbers1[$i] + $numbers2[$i] + $c); $partialResult = str_pad($partialResult, strlen($partialResult)+$totalZeros, "0", STR_PAD_LEFT); if (strlen($partialResult) > max(strlen($numbers1[$i]),strlen($numbers2[$i]))) { $partialResult = (string)$partialResult; $c = $partialResult[0]; $finalNumber[] = substr($partialResult, 1); } else { $c=0; $finalNumber[] = $partialResult; } } $finalNumber = array_reverse($finalNumber); $finalNumber = implode("", $finalNumber); if ($c != 0) $finalNumber = $c.$finalNumber; return $finalNumber; } /** * Make the calculation * * @return string */ public function calc () { for ($i=0; $i<count($this->numbers);$i++) { $n = explode(".", $this->numbers[$i]); if (count($n) == 1) { $this->result = $this->doAdd($this->result, $this->numbers[$i]); } elseif (count($n) == 2) { $this->afterPoint[] = $n[1]; $this->afterPointLength = max($this->afterPointLength, strlen($n[1])); $this->result = $this->doAdd($this->result, $n[0]); } else { trigger_error("<b>".$this->numbers[$i]."</b> is invalid !!", E_USER_ERROR); } } if ($this->afterPointLength > 0) { $r = 0; foreach ($this->afterPoint as $number) { $number = str_pad($number, $this->afterPointLength, "0", STR_PAD_RIGHT); $r = $this->doAdd($r, $number); } if (strlen($r) > $this->afterPointLength) { $this->result = $this->doAdd($this->result, substr($r, 0, -$this->afterPointLength)); if (strrpos($r, "0") != strlen($r)-1) $this->result = $this->result.".".substr($r, 1); } else { $this->result = $this->result.".".$r; } } return $this->result; }}// example$calc = new calculator();// generate a very big numer$number = "8347610948712974071265710983243861208762139437204172409821378273618976529283476109487129740712657109";$number = str_repeat($number, 10000);$calc->addNumber($number);$calc->addNumber($number);$time_start = microtime(true);$result = $calc->calc();$time_end = microtime(true);print "\nThe number has ".strlen($number)." digits. ";print "\nThe result has ".strlen($result)." digits. ";print "\nThe result is: ".$result;print "\nThe sum was executed in ".($time_end-$time_start)." seconds.";?> This is a calcutator that can calculate SUM of two huge number.