Google+

if else ( ) #

   if else (  )

? 1 : 2

PHP
//
if($a $msg = 'a }else{
$msg = 'a>b';
}
//
$msg = (ab';
?>


JS
if (document.all==true) then ie=1 else ie=0;
: var ie=document.all?1:0;

PHP, JavaScript / : if else, , true, false / 09.02.11 / [4]

HTTPS #

   HTTPS

https .

HTTPS (Hypertext Transfer Protocol Secure) HTTP, . , HTTPS, SSL TLS, . HTTP, HTTPS TCP- 443.

PHP - , ...
if (!empty($_SERVER['HTTPS']) && ('on' == $_SERVER['HTTPS'])) {
$uri = 'https://';
} else {
$uri = 'http://';
}
$uri .= $_SERVER['HTTP_HOST'];
header('Location: '.$uri.'/');
exit;

SSL config

DocumentRoot /usr/var/www/site
ServerName site
SSLEngine on
SSLCipherSuite ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP:+eNULL
SSLCertificateFile "conf/ssl.crt/server.crt"
SSLCertificateKeyFile "conf/ssl.key/server.key"

SSLOptions +StdEnvVars

BrowserMatch ".*MSIE.*" nokeepalive ssl-unclean-shutdown downgrade-1.0 force-response-1.0

.htaccess - https
RewriteCond %{SERVER_PORT} !^443$
RewriteRule ^(.*)$ https://%{SERVER_NAME}/$1 [L,R]

PHP, / : https, ssl, redirect / 08.02.11 / [0]

#



, :
function time_stamp($session_time)
{
$time_difference = time() - $session_time;
$seconds = $time_difference;
$minutes = round($time_difference / 60 );
$hours = round($time_difference / 3600 );
$days = round($time_difference / 86400 );
$weeks = round($time_difference / 604800 );
$months = round($time_difference / 2419200 );
$years = round($time_difference / 29030400 );
//
if($seconds <= 60) { echo "$seconds ";}
//
else if($minutes <=60) {
if($minutes==1){ echo " ";}
else {echo "$minutes ";}
}
//
else if($hours <=24)
{
if($hours==1)
{ echo " ";}
else
{ echo "$hours ";}
}
//
else if($days <= 7)
{
if($days==1)
{ echo " ";}
else
{ echo "$days "; }
}
//
else if($weeks <= 4)
{
if($weeks==1)
{ echo " "; }
else
{ echo "$weeks ";}
}
//
else if($months <=12)
{
if($months==1)
{ echo " "; }
else
{ echo "$months "; }
}
//
else
{
if($years==1)
{echo " "; }
else
{echo "$years \ "; }
}
}
$session_time ="1264326122";
//$session_time=time();
echo time_stamp($session_time);
?>

PHP / / 10.01.11 / [0]

CascadeSelect #

  CascadeSelect




cascadeSelect.rar

PHP, JavaScript / : , CascadeSelect / 09.01.11 / [0]

PHP #

  PHP


$path = "/home/user/public/foldername/";
$dir_handle = @opendir($path) or die("Unable to open $path");

while ($file = readdir($dir_handle)) {
if($file == "." || $file == ".." || $file == "index.php" )
continue;
echo "$file
";
}
closedir($dir_handle);



$username = "someuser";
$password = "somepassword";

if ($_POST['txtUsername'] != $username || $_POST['txtPassword'] != $password) {?>

Login













This is the protected page. Your private content goes here.




,
$files = glob('*.php');
print_r($files);
/* - :
Array
(
[0] => phptest.php
[1] => pi.php
[2] => post_output.php
[3] => test.php
)
*/



// a complex array
$myvar = array(
'hello',
42,
array(1,'two'),
'apple'
);

// convert to a string
$string = serialize($myvar);

echo $string;
/* prints
a:4:{i:0;s:5:"hello";i:1;i:42;i:2;a:2:{i:0;i:1;i:1;s:3:"two";}i:3;s:5:"apple";}
*/

// you can reproduce the original variable
$newvar = unserialize($string);

print_r($newvar);
/* prints
Array
(
[0] => hello
[1] => 42
[2] => Array
(
[0] => 1
[1] => two
)

[3] => apple
)
*/

PHP / : , , / 07.01.11 / [0]

PHP #

     PHP
function colorPalette($imageFile, $numColors, $granularity = 5)
{
$granularity = max(1, abs((int)$granularity));
$colors = array();
$size = @getimagesize($imageFile);
if($size === false)
{
user_error("Unable to get image size data");
return false;
}
$img = @imagecreatefromjpeg($imageFile);
if(!$img)
{
user_error("Unable to open image file");
return false;
}
for($x = 0; $x < $size[0]; $x += $granularity)
{
for($y = 0; $y < $size[1]; $y += $granularity)
{
$thisColor = imagecolorat($img, $x, $y);
$rgb = imagecolorsforindex($img, $thisColor);
$red = round(round(($rgb['red'] / 0x33)) * 0x33);
$green = round(round(($rgb['green'] / 0x33)) * 0x33);
$blue = round(round(($rgb['blue'] / 0x33)) * 0x33);
$thisRGB = sprintf('%02X%02X%02X', $red, $green, $blue);
if(array_key_exists($thisRGB, $colors))
{
$colors[$thisRGB]++;
}
else
{
$colors[$thisRGB] = 1;
}
}
}
arsort($colors);
return array_slice(array_keys($colors), 0, $numColors);
}
?>
58.jpg


// :
$palette = colorPalette('58.jpg', 10, 5);
echo "\n";
foreach($palette as $color)
{
echo "\n";
}
echo "
 #$color
\n";
GD


PHP / : palette, , , php, GD, / 21.11.10 / [0]