Iterating through Key- Value Pair Array using PHP 
foreach ($array as $key => $value)
{
//code block statements that run inside foreach loop
}




[ view entry ] ( 1221 views )   |  print article
Code to populate mysql with random data (needs some cleaning) 
CREATE TABLE `RandomNumbers_InnoDB` (
`id` int(11) NOT NULL auto_increment,
`random1` varchar(100) default NULL,
`random2` varchar(100) default NULL,
`random3` varchar(100) default NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1

Sample ouput:
http://www.angelcool.net/tutorials/othe ... 00rows.txt


<?php
set_time_limit(0);

function db_link()
{




//@ suppresses the error mysqli_connect returns, and instead we use our die() error
$db_link=mysqli_connect('127.0.0.1','root','');




if($db_link==false)
echo 'Could NOT connect to MySQL, check mysqli_connect settings. ';


//select database
if(@mysqli_select_db($db_link,'test')==false)
echo 'Could NOT select DB, check DB name.';


return $db_link;

}



function String()
{
//Step 1 Generate a token.
$length = 32;
$chars = 'ABCDEFGHIJKLMNPQRSTUVWXYZ123456789'; //ABCDEFGHIJKLMNPQRTWXYZ123456789 123456789abcdefghijklmnopqrstwxzABCDEFGHIJKLMNPQRTWXYZ
$string = '';
for ($i = 0; $i < $length; $i++) {
$pos = rand(0, strlen($chars)-1);
$string .= $chars{$pos}; }

return $string;

}




/*
How many different 4-letter combinations are there in the alphabet?
letters in alphabet = 26

Answer:
26^4 = 456,976
There are 26 choices for the first letter, 26 for the second, 26 for the 3rd and 26 for the 4th. So altogether, there are 26*26*26*26 = 456,976 combinations.

I hope this helps!

http://answers.yahoo.com/question/index ... 851AAkpgEj
*/

$conn=db_link();
echo '<b>'.date(DATE_RFC822).'</b>';

$execution_time=microtime(true);

for($iii=1;$iii<=200;)
{
$start=microtime(true);



/*

//Run this query to find out duplicate tokens
SELECT * FROM BulkTokens INNER JOIN (SELECT Token,COUNT(Token) AS Duplicated FROM BulkTokens
GROUP BY Token HAVING Duplicated > 1) dup ON BulkTokens.Token=dup.Token;


*/

$string1=String(); $string2=String(); $string3=String();

//Step 2 Check if token DOES NOT exist in database (check if it is duplicated, if it is skip this iteration).
// $query="SELECT random1 FROM RandomNumbers_InnoDB WHERE BINARY random1='".$string1."' and random2='".$string2."' and random3='".$string3."'";
// $result=mysqli_query($conn,$query) or die(mysqli_error($conn));
// $query=mysqli_num_rows($result);



//if token exists skip iteration.mysqli_num_rows($query)==0
if(true)//$query==0
{

//If token does not exist add 1 to $iii and assign the token to array.



// and insert it in database.
$query="INSERT INTO RandomNumbers_InnoDB(random1,random2,random3) VALUES('".$string1."','".$string2."','".$string3."');";
mysqli_query($conn,$query) or die(mysqli_error($conn));
echo $iii.'----'.$string1.'----'.$string2.'----'.$string3.' Iteration execution time:'.round((microtime(true)-$start),4).' secs<br>';
$iii++;

}
else
{ echo '====================================================================================================SKIPPED REPEATED RECORD !!';}



}
echo '<br><br><br>Total Execution Time:'.round((microtime(true)-$execution_time),4).'<br><br><br>';

echo '<b>'.date(DATE_RFC822).'</b>';

?>


[ view entry ] ( 1246 views )   |  print article
HOSTS file location 
#Win7
C:\windows\system32\drivers\etc\ or %systemroot%\system32\drivers\etc\


#CentOS
/etc/hosts

[ view entry ] ( 1157 views )   |  print article
Setting up PDFlib extension in PHP 
1.- Download PDFlib-8.0
2.- Look for libpdf_php.so
3.- Copy and paste to extension_dir [ see phpinfo() ]
4.- Add extension in php.ini

extension=libpdf_php.so

5.- Restart httpd and check PDFlib support in phpinfo()
6.- Get a license ($) to remove watermark.

Or try fpdf and fpdi.

[ view entry ] ( 1200 views )   |  print article
PHP Easter Egg 
file.php?=PHPB8B5F2A0-3C92-11d3-A3A9-4C7B08C10000 - PHP Credits
PHPE9568F34-D428-11d2-A769-00AA001ACF42 - PHP Logo
PHPE9568F35-D428-11d2-A769-00AA001ACF42 - Zend Logo
PHPE9568F36-D428-11d2-A769-00AA001ACF42 - Easter Egg

[ view entry ] ( 1223 views )   |  print article
.htaccess notes 
# This will pop-up a user/password dialog box saying Realm =
AuthName "Restricted Area"

# AuthType is normally basic. Not very secure until "Digest" type becomes prevalent
AuthType basic

# If value of AuthUserFile doesn't begin with a slash, it is treated as
# relative to the ServerRoot (not DocumentRoot!)
AuthUserFile "/userhome/blahBlah/.htpasswd"
AuthGroupFile "/userhome/blahBlah/.htgroup"

#Custom icons
AddIcon /icons/binary.gif .bin .exe
AddIcon /icons/text.gif .txt
AddIcon /icons/uuencoded.gif .uu
AddIcon /icons/hand.right.gif README
AddIcon /icons/folder.gif ^^DIRECTORY^^
AddIcon /icons/blank.gif ^^BLANKICON^^
# If no file type matches..
DefaultIcon /icons/unknown.gif

...more to come.

[ view entry ] ( 1749 views )   |  print article
Populating a PDF file with XFDF using PDFTK command. 
pdftk InvoiceTemplate.pdf fill_form InvoiceData.xfdf output - flatten > InvoiceXXXX.pdf


[ view entry ] ( 1781 views )   |  print article
Multiple NAT translations with NVI (NAT Virtual Interface) 
NVI removes the inside & outside terminology. With NVI multiple interfaces can participate in the translation. Before you cannot have translation with two INSIDE interfaces, NVI fixes that. http://www.cisco.com/en/US/docs/ios/12_ ... natvi.html



Basic configuration(no VRF enable):

int fa 0
  ip nat enable
int fa 1
  ip nat enable
int serial 0
  ip nat enable

ip nat source list 50 interface serial 0 overload //translate fa 0 & fa 1 lans out serial 0
ip nat source list 125 interface fa 0 overload //translate fa 1's lan out fa 0
ip nat source static tcp 172.168.50.10 80 interface serial 0 80 //translate web server out serial 0


[ view entry ] ( 1883 views )   |  print article
Router IOS Firewall: Allow only internal hosts to initiate a TCP session. 
InternalHosts<--e1(Router)e0-->RemoteNetworks

access-list 100 permit tcp any any gt 1023 established

interface e0
ip access-group 100 in


"UDP packets don't establish a connection, they're literally fire and forget! A simple permit udp host xx.xx.xx.xx host xx.xx.xx.xx eq xx should be all that's required."

-------------------------------------------------------------
See Cisco document id 26448


Also see:

Reflexive ACLs
ip inspect command.



[ view entry ] ( 1553 views )   |  print article
T1 Crossover Connection 
Connecting two routers back to back using their T1-DSU/CSU ports.

Cards and pin layout:







[ view entry ] ( 1587 views )   |  print article

<<First <Back | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | Next> Last>>


2024 By Angel Cool