Выкладываем по желанию - фрагменты и/или полные приложения.
Edited by Elkaz, 19 February 2008 - 07:18 PM.
Posted 19 February 2008 - 05:10 PM
Edited by Elkaz, 19 February 2008 - 07:18 PM.
Posted 19 February 2008 - 07:15 PM
Posted 21 February 2008 - 02:30 PM
<?php
$folder = 'music'; # папка, где находится наша музыка
$result_folder = 'result'; # папку, в которую мы будем выводить исправленные файлы
$ext = '.mp3'; # расширение файлов
$dir = opendir($folder);
$new = 1;
while ($file = readdir($dir) ){
if ( $file != "." and $file != ".." ){
rename($folder."/".$file."", $result_folder."/".$new.$ext);
$new++;
}
}
?>
Posted 21 February 2008 - 03:27 PM
Posted 21 February 2008 - 06:57 PM
<?php
//*** Аннаграммы ***//
// Powered by Elkaz © 2008 //
function aff ($word){
$len = strlen ($word);
$Arr = array();
for ($i = 0; $i < $len; $i++){
$Arr[] = $word[$i];
}
shuffle ($Arr);
$str = '';
for ($j = 0; $j < count ($Arr); $j++){
$str.= $Arr[$j];
}
return $str;
}
$word = $_GET['word'];
$word = preg_replace("/[^a-zа-я0-9\s]/i", "", $word);
echo 'Разгадайте слово: '.aff($word).'<br /><font color=#ffffff>'.$word.'</font>';
?>
$host = $_GET['host'];
$timeout = 0.5;
$err = '';
$ports = array();
$ports = array(21, 23, 25, 53, 79, 80, 110, 111, 119, 139, 443, 513);
echo 'Scanning host: '.$host.' with timeout '.$timeout.' sec.';
echo '<pre>';
$o = $c = 0;
for ($i = 0; $i < count ($ports); $i++){
if (@fsockopen ($host, $ports[$i], $err, $err, $timeout)){ flush(); echo 'Port <b><font color=green>'.$ports[$i].'</font></b> - opened<br />'; $o++; }
else { flush(); echo 'Port <b><font color=red>'.$ports[$i].'</font></b> - closed<br />'; $c++; }
}
echo 'Total open ports: '.$o.'<br />';
echo 'Total close ports: '.$c.'<br />';
echo '</pre>';
Posted 21 February 2008 - 08:08 PM
/**
* Sends GET or POST request.
* Examples:
* sendToHost('www.google.com','get','/search','q=phl');
* sendToHost('www.example.com','post','/some_script.cgi',
* 'param=First+Param&second=Second+param');
*
* @param string $_host FQDN hostname.
* @param string $_path The /path/to/file.html part.
* @param string $_data Request parameters, without leading '?' mark.
* @param int $_port Port of the remote service.
* @param string $_method GET or POST, case-insensitive.
* @param string $_useragent If empty will send MSIE, if false no agent is sent.
* @return string result of request.
*/
public static function sendRequest(
$_host, $_path, $_data, $_port = 80, $_method = 'GET', $_useragent = '')
{
$_method = strtoupper($_method);
if (in_array($_method, array('GET', 'POST')) == false) {
$_method = 'GET';
}
$fp = fsockopen($_host, $_port);
if ($_method == 'GET') {
$_path .= '?' . $_data;
}
fputs($fp, $_method . ' ' . $_path . ' ' . 'HTTP/1.1' . "\r\n");
fputs($fp, 'Host: ' . $_host . "\r\n");
fputs($fp, 'Content-type: application/x-www-form- urlencoded' . "\r\n");
fputs($fp, 'Content-length: ' . strlen($_data) . "\r\n");
if ($_useragent) {
if (strlen($_useragent) == 0) {
fputs($fp, 'User-Agent: MSIE' . "\r\n");
}
else {
fputs($fp, 'User-Agent: ' . $_useragent . "\r\n");
}
}
fputs($fp, 'Connection: close' . "\r\n\r\n");
if ($_method == 'POST') {
fputs($fp, $_data);
}
$buf = '';
while (!feof($fp)) {
$buf .= fgets($fp, 128);
}
fclose($fp);
return $buf;
}
Posted 21 February 2008 - 09:21 PM
Edited by Elkaz, 21 February 2008 - 09:22 PM.
Posted 21 February 2008 - 09:33 PM
Edited by Ilg, 22 February 2008 - 06:17 AM.
Posted 22 February 2008 - 06:58 AM
Posted 22 February 2008 - 07:20 AM
Posted 22 February 2008 - 08:04 AM
Posted 22 February 2008 - 08:05 AM
Posted 22 February 2008 - 08:45 AM
Posted 22 February 2008 - 09:00 AM
Posted 22 February 2008 - 11:24 PM
function clean ($var, $number = false, $sql = false){
if ($number == true) return (int) $var;
else {
$var = trim ($var);
$var = htmlspecialchars ($var);
if ($sql == true) $var = mysql_real_escape_string($var);
}
return $var;
}
$a = "or 1=1\*";
$b = "<script>alert();</script>";
$c = "<b <script>alert();</script></b>";
$a = clean($a, true);
$b = clean($b, false, true);
$c = clean($c, false, true);
Edited by Ilg, 25 February 2008 - 08:33 PM.
Posted 23 February 2008 - 05:48 PM
public function getRemoteIP($_single = true)
{
$ip = array($_SERVER['REMOTE_ADDR']);
if (isset($_SERVER['HTTP_X_FORWARDED_FOR'])) {
if (isset($_SERVER['HTTP_X_REAL_IP'])) {
array_unshift($ip, $_SERVER['HTTP_X_REAL_IP']);
}
array_unshift($ip, $_SERVER['HTTP_X_FORWARDED_FOR']);
}
$ip = array_values(array_unique($ip));
if (isset($ip[0]) == false) {
$ip[0] = '0.0.0.0';
}
if ($_single) {
return $ip[0];
}
return $ip;
}
Edited by Elkaz, 25 February 2008 - 08:33 PM.
Posted 24 February 2008 - 10:38 PM
function execTime() {
static $start = 0;
if (!$start) {
$start = microtime(true);
} else {
printf('%.8f', microtime(true) - $start);
}
}
execTime();
// Some code...
execTime();
Edited by Elkaz, 25 February 2008 - 08:33 PM.
Posted 25 February 2008 - 10:14 AM
Edited by Elkaz, 25 February 2008 - 08:36 PM.
Posted 28 February 2008 - 07:56 PM
function remain($ts1, $ts2, $week = true, $day = true, $hour = true, $min = true, $sec = true) {
$diff = abs ($ts1-$ts2);
#$y = floor($diff / (60 * 60 * 24 * 365)); $diff -= $y * 60 * 60 * 24 * 365;
#$m = floor($diff / (60 * 60 * 24 * 30)); $diff -= $m * 60 * 60 * 24 * 30;
$d = $h = $i = $s = 0;
if ($week == true) $w = floor ($diff / (60 * 60 * 24 * 7)); $diff -= $w * 60 * 60 * 24 * 7;
if ($day == true) $d = floor($diff / (60 * 60 * 24)); $diff -= $d * 60 * 60 * 24;
if ($hour == true) $h = floor($diff / (60 * 60)); $diff -= $h * 60 * 60;
if ($min == true) $i = floor($diff / 60); $diff -= $i * 60;
if ($sec == true) $s = floor($diff);
return $w.' недель '.$d.' дн. '.$h.' ч. '.$i.' мин. '.$s.' сек.';
}
$time1 = time();
$time2 = strtotime ("25 May 2008");
$a = remain ($time1, $time2);
echo "Буду в Москве через ".$a;
Posted 29 February 2008 - 07:09 AM
SELECT
CONCAT(table_schema,'.',table_name),CONCAT(ROUND(table_rows/1000000,2),'M') rows,
CONCAT(ROUND(data_length/(1024*1024*1024),2),'G') DATA,
CONCAT(ROUND(index_length/(1024*1024*1024),2),'G') idx,
CONCAT(ROUND((data_length+index_length)/(1024*1024*1024),2),'G') total_size,
ROUND(index_length/data_length,2) idxfrac FROM information_schema.TABLES
ORDER BY data_length+index_length DESC
members, guests, anonymous users