how to get php info ?
<pre>
phpinfo();
</pre>
Friday, October 19, 2012
Get datetime with php
how to get datetime with php?
$datetime = date('Y-m-d H:i:s');
echo $datetime;
$datetime = date('Y-m-d H:i:s');
echo $datetime;
Get user IP with PHP
How to get user ip with php?
Example:
$userIp = $_SERVER['REMOTE_ADDR'];
echo $userIp;
Example:
$userIp = $_SERVER['REMOTE_ADDR'];
echo $userIp;
php generate random number
How to generate randum number with php
$rand = rand(1, 1000); //generate rand number from 1 to 1000
echo $rand;
$rand = rand(1, 1000); //generate rand number from 1 to 1000
echo $rand;
php BAN system
php BAN system
How to create easy ip ban system with PHP?
system for ban user ip
CREATE TABLE `bans` (
`id` INT( 11 ) NOT NULL AUTO_INCREMENT PRIMARY KEY ,
`ip` CHAR( 15 ) NOT NULL ,
) ENGINE = MYISAM
example template:
<div>
<form action="" method="post">
Ban IP: <input type="text" name="ip" value="***.***.***.***" /> <br />
<input type="submit" name="ban" value="ban this ip" />
</form>
</div>
php code:
<?php
if(isset($_POST['ban'])){
mysql_query("
INSERT INTO
users (ip)
VALUES
('" . $_POST['ip'] . "')
");
}
?>
function checkUserBan(){
$checkUserBan_sql = "
SELECT
*
FROM
bans
";
$checkUserBan_res = mysql_query($checkUserBan_sql);
$banIp = array();
while($checkBans = mysql_fetch_array($checkUserBan_res)){
$banIp[] = $checkBans['ip'];
}
if(in_array($_SERVER['REMOTE_ADDR'], $banIp)){
Header('Location: /bans.php');
exit;
}
}
paste function "checkUserBan();" at the top of every file on your site without bans.php
How to create easy ip ban system with PHP?
system for ban user ip
CREATE TABLE `bans` (
`id` INT( 11 ) NOT NULL AUTO_INCREMENT PRIMARY KEY ,
`ip` CHAR( 15 ) NOT NULL ,
) ENGINE = MYISAM
example template:
<div>
<form action="" method="post">
Ban IP: <input type="text" name="ip" value="***.***.***.***" /> <br />
<input type="submit" name="ban" value="ban this ip" />
</form>
</div>
php code:
<?php
if(isset($_POST['ban'])){
mysql_query("
INSERT INTO
users (ip)
VALUES
('" . $_POST['ip'] . "')
");
}
?>
function checkUserBan(){
$checkUserBan_sql = "
SELECT
*
FROM
bans
";
$checkUserBan_res = mysql_query($checkUserBan_sql);
$banIp = array();
while($checkBans = mysql_fetch_array($checkUserBan_res)){
$banIp[] = $checkBans['ip'];
}
if(in_array($_SERVER['REMOTE_ADDR'], $banIp)){
Header('Location: /bans.php');
exit;
}
}
paste function "checkUserBan();" at the top of every file on your site without bans.php
PHP Get image size and type - width, height, type.
Get image size and type - width, height, type.
<?php
list($width, $height, $type) = getimagesize('/path/to/your/image/image.jpg');
echo $widht . ' - ' . $height . ' - ' . $type;
?>
<?php
list($width, $height, $type) = getimagesize('/path/to/your/image/image.jpg');
echo $widht . ' - ' . $height . ' - ' . $type;
?>
jQuery add or remove html class
<style>
.hidden{
display: none;
}
</style>
<div id="example">
example text
</div>
<input type="button" name="button" value="add class hidden" id="addClass" />
<script type="text/javascript">
$('#addClass').click(function() {
$('#example').addClass('hidden');
});
</script>
OR remove
<style>
.hidden{
display: none;
}
</style>
<div id="example" class="hidden">
example text
</div>
<input type="button" name="button" value="add class hidden" id="addClass" /><script type="text/javascript">
$('#addClass').click(function() {
$('#example').removeClass('hidden');
});
</script>
.hidden{
display: none;
}
</style>
<div id="example">
example text
</div>
<input type="button" name="button" value="add class hidden" id="addClass" />
<script type="text/javascript">
$('#addClass').click(function() {
$('#example').addClass('hidden');
});
</script>
OR remove
<style>
.hidden{
display: none;
}
</style>
<div id="example" class="hidden">
example text
</div>
<input type="button" name="button" value="add class hidden" id="addClass" /><script type="text/javascript">
$('#addClass').click(function() {
$('#example').removeClass('hidden');
});
</script>
Subscribe to:
Posts (Atom)