This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function get_ip_address() | |
{ | |
if (isset($_SERVER)) { | |
if (isset($_SERVER["HTTP_X_FORWARDED_FOR"]) && ip2long($_SERVER["HTTP_X_FORWARDED_FOR"]) !== false) { | |
$ipadres = $_SERVER["HTTP_X_FORWARDED_FOR"]; | |
} elseif (isset($_SERVER["HTTP_CLIENT_IP"]) && ip2long($_SERVER["HTTP_CLIENT_IP"]) !== false) { | |
$ipadres = $_SERVER["HTTP_CLIENT_IP"]; | |
} else { | |
$ipadres = $_SERVER["REMOTE_ADDR"]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
#Updated by Vahid Mahmoudian | |
#http://vhdm.ir | |
#http://persiangd.berlios.de | |
#Copyright (C) 2007 Milad Rastian (miladmovie[_at_]gmail) | |
#thanks to Bagram Siadat (info[_at_]gnudownload[_dot_]org) (bug fix and new developer) | |
#tahanks to Ramin Farmani (bug fix) | |
# | |
#This program is free software; you can redistribute it and/or |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* 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 3 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Day j Day of the Month, No Leading Zeros 1 - 31 | |
Day d Day of the Month, 2 Digits, Leading Zeros 01 - 31 | |
Day D Day of the Week, First 3 Letters Mon - Sun | |
Day l (lowercase 'L') Day of the Week Sunday - Saturday | |
Day N Numeric Day of the Week 1 (Monday) - 7 (Sunday) | |
Day w Numeric Day of the Week 0 (Sunday) - 6 (Saturday) | |
Day S English Suffix For Day of the Month st, nd, rd or th | |
Day z Day of the Year 0 - 365 | |
Week W Numeric Week of the Year (Weeks Start on Mon.) 1 - 52 | |
Month M Textual Representation of a Month, Three Letters Jan - Dec |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
require_once("pcalendar.php"); | |
$datex = new jDateTime(true, true, 'Asia/Tehran'); | |
echo $datex->date('Y-m-d',time()); | |
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<? | |
// Let me start off by saying I do not take full credit for this! | |
// I needed a way to get my traffic's country for Adverts... | |
// for some reason, json_decode wasn't working, so this is an alternative. | |
// json_decoder function from PHP.net | |
// file_get_contents_curl basic data retrieval function | |
// how to use: | |
// include('country.php'); | |
// $userCountry=getTheCountry(); | |
// output is 2 character country code, US, CA, etc... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function random_string($len=20){ | |
$randstr = ''; | |
srand((double)microtime()*1000000); | |
for($i=0;$i<$len;$i++){ | |
$n = rand(48,120); | |
while (($n >= 58 && $n <= 64) || ($n >= 91 && $n <= 96)){ | |
$n = rand(48,120); | |
} | |
$randstr .= chr($n); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function human_size ($size) { | |
if ($size <= 1024) return $size.' Bytes'; | |
else if ($size <= (1024*1024)) return sprintf('%d KB',(int)($size/1024)); | |
else if ($size <= (1024*1024*1024)) return sprintf('%.2f MB',($size/(1024*1024))); | |
else return sprintf('%.2f Gb',($size/(1024*1024*1024))); | |
} | |
echo human_size(32768); | |
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
error_reporting(0); | |
function toHex($N) { | |
if ($N==NULL) return "00"; | |
if ($N==0) return "00"; | |
$N=max(0,$N); | |
$N=min($N,255); | |
$N=round($N); | |
$string = "0123456789ABCDEF"; | |
$val = (($N-$N%16)/16); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Insert into database | |
mysql_query("INSERT INTO my_table (`column1`, `column2`) VALUES ('one', 'two')"); | |
// Next Get what the auto incremented number was that was inserted | |
$id = mysql_insert_id(); | |
// Display it... | |
echo $id; | |
?> |
OlderNewer