PHP . SU
Программирование на PHP, MySQL и другие веб-технологии
Страниц (1): [1]
Найдено сообщений: 7
fastattack
Отправлено: 19 Июля, 2011 - 17:44:13 • Тема: как переименовать за несколько действий? • Форум: Прочее
Ответов: 5 Просмотров: 54
vlom пишет: Вечером буде свободен напишу
(Добавление)
в смысле напишу скрипт для переименовывания файлов
вопро, изображения в одной папке???
Могу всё в одну папку сложить. Заранее спасибо.
fastattack
Отправлено: 08 Июля, 2011 - 16:19:36 • Тема: как переименовать за несколько действий? • Форум: Прочее
Ответов: 5 Просмотров: 54
LIME пишет: fastattack можно скрипт написать чтоб выбирал все файлы в папке с картинками и переименовывал ...а в чем сложность собственно ?
Сложность в том что я не знаю как написать такой скрипт.( Если можешь помоги! Вообщем что мне надо то. Скриптик чтоб переименовывал название кртинки и в папке и в html или php файле.
fastattack
Отправлено: 07 Июля, 2011 - 17:43:04 • Тема: как переименовать за несколько действий? • Форум: Прочее
Ответов: 5 Просмотров: 54
У меня есть html страничка в ней таблица с множественными разными названиями картинок. Все картинки на русском языке а новый хостинг не понимает русского. Вопрос: Как можно переименовать разом название картинок и их название в html файле. Ну или хотя бы в несколько действий.
fastattack
Отправлено: 14 Июня, 2011 - 08:11:33 • Тема: Запара с captcha Помогите!) • Форум: Графика в PHP
Ответов: 6 Просмотров: 2707
// Подключаем и летим в папочку captcha на index.php
Я так понимаю вот занос в сессию:
PHP:
скопировать код в буфер обмена
<?PHP
include ( 'kcaptcha.php' ) ;
$captcha = new KCAPTCHA( ) ;
$_SESSION [ 'captcha_keystring' ] = $captcha -> getKeyString ( ) ;
}
?>
И от сюда как ты видешь инклюдится к выше изложенному.php
P.S Например мне она очень понравилась) Хотел бы узнать и ваше мнения)
fastattack
Отправлено: 13 Июня, 2011 - 16:44:11 • Тема: Запара с captcha Помогите!) • Форум: Графика в PHP
Ответов: 6 Просмотров: 2707
Кто такой попов? Какие курсы? Может это тот кто мне отдал этот сайт? Да вроде он не попов.
И у меня вообще небыло там никаких ref. Было только имя, комент и submit. Вот приделал капчу! Скачал её с сайта captcha.ru помоему так назывался.Я конечно только начал изучать php но про курсы попова ничего не слышал. А что хорошие курсы?
Вот моя форма:
PHP:
скопировать код в буфер обмена
<form action="com_ment.php" method="post" name="forma_ept">
<table width="500" border="0" align="center" cellpadding="0" cellspacing="0" class="border">
<tr>
<td height="192" align="left" valign="top"><table width="500" border="0" cellspacing="0" cellpadding="0">
<tr>
<td class="border_top"width="316" height="191"><table width="316" border="0" cellspacing="0" cellpadding="0">
<tr>
<td height="195" align="left" valign="top"><table width="316" border="0" cellspacing="0" cellpadding="0">
<tr>
<td class="dob_com" height="36">Добавить ваш комментарий:</td>
</tr>
<tr>
<td class="text_area"height="159"><textarea name="text" cols="40" rows="9"></textarea></td>
</tr>
</table></td>
</tr>
</table></td>
<td width="184" align="center" valign="top" class="border_left"><table width="184" border="0" cellspacing="0" cellpadding="0">
<tr>
<td class="dob_com" height="38">Введите код:</td>
</tr>
<tr>
<td height="159" align="center"><p><img src="./captcha?
<?PHP echo session_name ( ) ?> =
<?PHP echo session_id ( ) ?> "></p>
<p><input type="text" name="keystring"></p></td>
</tr>
</table></td>
</tr>
</table></td>
</tr>
<tr>
<td height="33" align="left" valign="top"><table width="500" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="315" height="33"> <div class="author_n">Ваше имя:</div> <input name="author" type="text" size="29" maxlength="30" /></td>
<td width="185">
<input name="id" type="hidden" value="<? echo $id ?> " />
<input class="butoon_s" name="sub_com" type="submit" value="Комментировать" />
</td>
</tr>
</table></td>
</tr>
</table><br><br>
</td>
</tr>
</table></td>
</tr>
</form>
А вот часть капчи:
PHP:
скопировать код в буфер обмена
<?PHP
class KCAPTCHA{
// generates keystring and image
function KCAPTCHA( ) {
require ( dirname ( __FILE__ ) . '/kcaptcha_config.php' ) ; $fontsdir_absolute = dirname ( __FILE__ ) . '/' . $fontsdir ; if ( $handle = opendir ( $fontsdir_absolute ) ) { while ( false !== ( $file = readdir ( $handle ) ) ) { $fonts [ ] = $fontsdir_absolute . '/' . $file ;
}
}
}
$alphabet_length = strlen ( $alphabet ) ;
do {
// generating random keystring
while ( true ) {
$this -> keystring = '' ;
for ( $i = 0 ; $i < $length ; $i ++ ) {
$this -> keystring .= $allowed_symbols { mt_rand ( 0
, strlen ( $allowed_symbols ) - 1
) } ; }
if ( ! preg_match ( '/cp|cb|ck|c6|c9|rn|rm|mm|co|do|cl|db|qp|qb|dp|ww/' , $this -> keystring ) ) break ; }
$symbol = 0 ;
$reading_symbol = false ;
// loading font
for ( $i = 0 ; $i < $fontfile_width && $symbol < $alphabet_length ; $i ++ ) {
if ( ! $reading_symbol && ! $transparent ) {
$font_metrics [ $alphabet { $symbol } ] = array ( 'start' => $i ) ; $reading_symbol = true ;
continue ;
}
if ( $reading_symbol && $transparent ) {
$font_metrics [ $alphabet { $symbol } ] [ 'end' ] = $i ;
$reading_symbol = false ;
$symbol ++;
continue ;
}
}
// draw text
$x = 1 ;
if ( $odd == 0) $odd =- 1 ;
for ( $i = 0 ; $i < $length ; $i ++ ) {
$m = $font_metrics [ $this -> keystring { $i } ] ;
$y = ( ( $i % 2) * $fluctuation_amplitude - $fluctuation_amplitude / 2) * $odd
+ ( $height - $fontfile_height ) / 2 ;
if ( $no_spaces ) {
$shift = 0 ;
if ( $i > 0) {
$shift = 10000 ;
for ( $sy = 3 ; $sy < $fontfile_height - 10 ; $sy += 1) {
for ( $sx = $m [ 'start' ] - 1 ; $sx < $m [ 'end' ] ; $sx += 1) {
$opacity = $rgb >> 24 ;
if ( $opacity < 127) {
$left = $sx - $m [ 'start' ] + $x ;
$py = $sy + $y ;
if ( $py > $height ) break ;
for ( $px = min ( $left , $width - 1
) ; $px > $left - 200
&& $px >= 0 ; $px -= 1
) { if ( $color + $opacity < 170 ) { // 170 - threshold
if ( $shift > $left - $px ) {
$shift = $left - $px ;
}
break ;
}
}
break ;
}
}
}
if ( $shift == 10000) {
}
}
} else {
$shift = 1 ;
}
imagecopy ( $img , $font , $x - $shift , $y , $m [ 'start' ] , 1
, $m [ 'end' ] - $m [ 'start' ] , $fontfile_height ) ; $x += $m [ 'end' ] - $m [ 'start' ] - $shift ;
}
} while ( $x >= $width - 10) ; // while not fit in canvas
//noise
for ( $i = 0 ; $i < ( ( $height - 30) * $x ) * $white_noise_density ; $i ++ ) {
}
for ( $i = 0 ; $i < ( ( $height - 30) * $x ) * $black_noise_density ; $i ++ ) {
}
$center = $x / 2 ;
// credits. To remove, see configuration file
$foreground = imagecolorallocate ( $img2 , $foreground_color [ 0
] , $foreground_color [ 1
] , $foreground_color [ 2
] ) ; $background = imagecolorallocate ( $img2 , $background_color [ 0
] , $background_color [ 1
] , $background_color [ 2
] ) ; $credits = empty ( $credits ) ?
$_SERVER [ 'HTTP_HOST' ] : $credits ;
// periods
$rand1 = mt_rand ( 750000
, 1200000
) / 10000000 ; $rand2 = mt_rand ( 750000
, 1200000
) / 10000000 ; $rand3 = mt_rand ( 750000
, 1200000
) / 10000000 ; $rand4 = mt_rand ( 750000
, 1200000
) / 10000000 ; // phases
$rand5 = mt_rand ( 0
, 31415926
) / 10000000 ; $rand6 = mt_rand ( 0
, 31415926
) / 10000000 ; $rand7 = mt_rand ( 0
, 31415926
) / 10000000 ; $rand8 = mt_rand ( 0
, 31415926
) / 10000000 ; // amplitudes
//wave distortion
for ( $x = 0 ; $x < $width ; $x ++ ) {
for ( $y = 0 ; $y < $height ; $y ++ ) {
$sx = $x + ( sin ( $x * $rand1 + $rand5 ) + sin ( $y * $rand3 + $rand6 ) ) * $rand9 - $width / 2
+ $center + 1 ; $sy = $y + ( sin ( $x * $rand2 + $rand7 ) + sin ( $y * $rand4 + $rand8 ) ) * $rand10 ;
if ( $sx < 0 || $sy < 0 || $sx >= $width - 1 || $sy >= $height - 1) {
continue ;
} else {
}
if ( $color == 255 && $color_x == 255 && $color_y == 255 && $color_xy == 255) {
continue ;
} else if ( $color == 0 && $color_x == 0 && $color_y == 0 && $color_xy == 0) {
$newred = $foreground_color [ 0] ;
$newgreen = $foreground_color [ 1] ;
$newblue = $foreground_color [ 2] ;
} else {
$frsx1 = 1- $frsx ;
$frsy1 = 1- $frsy ;
$newcolor = (
$color * $frsx1 * $frsy1 +
$color_x * $frsx * $frsy1 +
$color_y * $frsx1 * $frsy +
$color_xy * $frsx * $frsy ) ;
if ( $newcolor > 255) $newcolor = 255 ;
$newcolor = $newcolor / 255 ;
$newcolor0 = 1- $newcolor ;
$newred = $newcolor0 * $foreground_color [ 0] + $newcolor * $background_color [ 0] ;
$newgreen = $newcolor0 * $foreground_color [ 1] + $newcolor * $background_color [ 1] ;
$newblue = $newcolor0 * $foreground_color [ 2] + $newcolor * $background_color [ 2] ;
}
}
}
header ( 'Expires: Mon, 26 Jul 1997 05:00:00 GMT' ) ; header ( 'Cache-Control: no-store, no-cache, must-revalidate' ) ; header ( 'Cache-Control: post-check=0, pre-check=0' , FALSE ) ; header ( "Content-Type: image/jpeg" ) ; header ( "Content-Type: image/gif" ) ; header ( "Content-Type: image/x-png" ) ; }
}
// returns keystring
function getKeyString( ) {
return $this -> keystring ;
}
}
?>
Что посоветуешь из курсов для написания более хорошего кода? Я начал читать PHP,Mysql,JavaScript Автор: Робин Никсон.
fastattack
Отправлено: 13 Июня, 2011 - 09:31:45 • Тема: Запара с captcha Помогите!) • Форум: Графика в PHP
Ответов: 6 Просмотров: 2707
Всё заработало! Огромное спасибо. И как я просмотрел подключение хз)
сделал так:
PHP:
скопировать код в буфер обмена
}
if ( isset ( $_SESSION [ 'captcha_keystring' ] ) && $_SESSION [ 'captcha_keystring' ] === $_POST [ 'keystring' ] )
{
$date = date ( "Y-m-d H:i" ) ; $result = mysql_query ( "INSERT INTO comments (post,author,text,date) VALUES ('$id ','$author ','$text ','$date ')" , $d_base ) ;
echo "<html><head> <meta http-equiv='Refresh' content='0; URL=view_post.php?id=$id '> </head></html>" ;
} else {
echo "<p class='contentheading_my'>Вы ввели неправельный код с картинки. <br><br><input name='back' type='button' value='Вернутся назад' onclick='javascript:history.back()' onMouseOver='window.status='Back';return true'>" ;
}
}
unset ( $_SESSION [ 'captcha_keystring' ] ) ;
Нормально?)
fastattack
Отправлено: 12 Июня, 2011 - 18:38:57 • Тема: Запара с captcha Помогите!) • Форум: Графика в PHP
Ответов: 6 Просмотров: 2707
Всем доброго время суток! Есть такая проблемма!
Решил прекрутить к своему сайтику капчу. Выбор пал на captcha.ru.
Пришлось повозится немного но вскоре весь код отладил и вроде всё без ошибок. Но после проверки выявилось что данные не попадают в БД.
Вот собственно и сам код. Где напортачил то подскажите люди добрые)
основной фаил:
PHP:
скопировать код в буфер обмена
<?
include ( "block/config.php" ) ;
if ( isset ( $_GET [ 'id' ] ) ) { $id = $_GET [ 'id' ] ; } if ( ! isset ( $id ) ) { $id = 1 ; }
exit ( "<p>Неверный формат запроса! Проверьте URL!" ) ; }
$result = mysql_query ( "SELECT * FROM data WHERE id='$id '" , $d_base ) ;
if ( ! $result )
{
echo "<p>Запрос не прошел. Напишите об этом администратору. <br> <strong>Код ошибки:</strong></p>" ;
}
{
$new_view = $myrow [ "view" ] + 1 ;
$update = mysql_query ( "UPDATE data SET view='$new_view ' WHERE id='$id '" , $d_base ) ;
}
else
{
echo "<p>Информация по запросу не может быть извлечена в таблице нет записей.</p>" ;
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="description" content="<? echo $myrow [ "meta_d" ] ; ?> " />
<meta name="keywords" content="<? echo $myrow [ "meta_k" ] ; ?> " />
<link rel="stylesheet" type="text/css" href="css/template.css"/>
<title><? echo $myrow [ "title" ] ; ?> </title>
<link href="favicon.ico" rel="shortcut icon" type="image/x-icon" />
</head>
<body>
<table width="980" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td height="300" align="left" valign="top" class="hedshot"> </td>
</tr>
<tr>
<td align="left" valign="top"><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<? include ( "block/menu.php" ) ; ?>
</table></td>
<td class="centre_more">
<?
printf ( "<p class='post_title2'>%s </p><p class='post_add'>Автор: %s <br>Дата: %s </p><div id='conteyner_my_top'>%s </div><p class='post_my_view'>Просмотров: %s </p>" , $myrow [ "title" ] , $myrow [ "author" ] , $myrow [ "date" ] , $myrow [ "text" ] , $myrow [ "view" ] ) ;
echo "<p class='post_comments'><br>Коментарии к этой заметке:</p>" ;
$result3 = mysql_query ( "SELECT * FROM comments WHERE post='$id '" , $d_base ) ; {
do
{
printf ( "<div class='ramka_comm'><p class='post_com_obza'>Коментарий добавил(а): <strong>%s </strong> <br> Дата: <strong>%s </strong></p><p class='my_com-fon'>%s </p></div>" , $myrow3 [ 'author' ] , $myrow3 [ 'date' ] , $myrow3 [ 'text' ] ) ; }
}
?>
<br><br><br>
<p class='post_comments2'>Добавить ваш коментарий:</p>
<form action="com_ment.php" method="post">
<p><label class="autor_name">Ваше имя:</label><p><input name="author" type="text" size="30" maxlength="30" /></p></p>
<p><label class='post_comments2'>Текст комментария: <br> <textarea name="text" cols="35" rows="4"></textarea></label></p>
<p>Введите текст с картинки:</p>
<p><input name="keystring" type="text"></p>
<input name="id" type="hidden" value="<? echo $id ?> " />
<p><input name="sub_com" type="submit" value="Комментировать"></p>
</form>
</td>
</tr>
</table></td>
</tr>
<? include ( "block/footer.php" ) ; ?>
</body>
</html>
А вот и файл обработки:
PHP:
скопировать код в буфер обмена
<link rel="stylesheet" type="text/css" href="css/template.css"/>
<?PHP
include ( "block/config.php" ) ;
if ( isset ( $_POST [ 'author' ] ) ) {
$author = $_POST [ 'author' ] ;
}
if ( isset ( $_POST [ 'text' ] ) ) {
$text = $_POST [ 'text' ] ;
}
if ( isset ( $_POST [ 'keystring' ] ) ) {
$keystring = $_POST [ 'keystring' ] ;
}
if ( isset ( $_POST [ 'sub_com' ] ) ) {
$sub_com = $_POST [ 'sub_com' ] ;
}
{
$id = $_POST [ 'id' ] ;
}
{
else { $author = "" ; }
else { $text = "" ; }
{
exit ( "<p class='contentheading_my'>Вы ввели не всю информацию, вернитесь назад и заполните все поля. <br><br><input name='back' type='button' value='Вернутся назад' onclick='javascript:history.back()' onMouseOver='window.status='Back';return true'>" ) ; }
}
if ( isset ( $_SESSION [ 'captcha_keystring' ] ) && $_SESSION [ 'captcha_keystring' ] === $_POST [ 'keystring' ] ) { echo "<html><head>
<meta http-equiv='Refresh' content='0; URL=view_post.php?id=$id '>
</head></html>" ;
} else {
echo "<p class='contentheading_my'>Вы ввели неправельный код с картинки. <br><br><input name='back' type='button' value='Вернутся назад' onclick='javascript:history.back()' onMouseOver='window.status='Back';return true'>" ;
}
}
unset ( $_SESSION [ 'captcha_keystring' ] ) ; ?>
З.Ы
Вроде все проверки проходит а в бд не попадают данные. Что за ***** непонимаю(
Страниц (1): [1]
Powered by ExBB FM 1.0 RC1. InvisionExBB