Sofro diariamente deletando spam no meu guestbook. Encontrei um script muito parecido com captcha. Inclui no guestbook, mas não esta funcionando. O que acresentei esta em negrito. <?php
require_once(dirname(__FILE__) . '/config.php');
$bd = mysql_connect($mysql['server'], $mysql['name'], $mysql['pass']);
mysql_select_db($mysql['db'],$bd);
$kvgbcookie = $HTTP_COOKIE_VARS['kvgbcookie'];
if($a == "add") {
add();
kvgbcopyright();
}
elseif($a == "addsave") {
addsave();
kvgbcopyright();
}
elseif($a == "login") {
login();
kvgbcopyright();
}
elseif($a == "dologin") {
dologin();
}
elseif($a == "delete") {
delete();
kvgbcopyright();
}
else {
gbindex();
kvgbcopyright();
}
function gbindex() {
global $offset, $kvgbcookie, $PHP_SELF, $scripturl, $gburl, $HTTP_GET_VARS;
$offset = $HTTP_GET_VARS['offset'];
$resultado=mysql_query("SELECT count(*) FROM kv_guestbook");
$linha=mysql_fetch_row($resultado);
$gbtotal=$linha[0];
if($offset == "") {
$offset = 0;
}
$stop = $offset + 10;
$query = "SELECT * FROM kv_guestbook ORDER BY id DESC LIMIT $offset,$stop";
$result = mysql_query($query) or DIE(mysql_error());
print("
<link rel=\"stylesheet\" href=\"$scripturl/style.css\" type=\"text/css\">
<table cellspacing=\"1\" cellpadding=\"3\" width=\"100%\" border=\"0\">
<tr>
<td class=\"otherpages\" width=\"25%\">Páginas:
<a href=\"$PHP_SELF?offset=0\">1</a>
");
if($gbtotal >= "10") {
print(" | <a href=\"$PHP_SELF?offset=10\">2</a>");
if($gbtotal >= "20") {
print(" | <a href=\"$PHP_SELF?offset=20\">3</a>");
if($gbtotal >= "30") {
print(" | <a href=\"$PHP_SELF?offset=30\">4</a>");
if($gbtotal >= "40") {
print(" | <a href=\"$PHP_SELF?offset=40\">5</a>");
}
}
}
}
print("
</td>
<td align=\"left\" class=\"addentry\"><a href=\"$PHP_SELF?a=add\">Registrar Visita</td>
</tr>
<tr>
<td align=\"center\" class=\"gbheader\"><b>Visitantes</b></td><td align=\"center\" class=\"gbheader\"><b>Comentários</b></td>
</tr>
");
while($entry = mysql_fetch_object($result)) {
print("
<tr>
<td class=\"gbt1\" valign=\"top\">
<div class=\"mainname\">Nome: $entry->name</div>
<div class=\"smallleft\">
Localidade: $entry->location <br>
");
if($entry->email != "") {
print("Email: <a href=\"mailto:$entry->email\">$entry->email</a> <br> \n");
}
if($entry->url != "") {
print("Homepage: <a href=\"$entry->url\">$entry->url</a> <br> \n");
}
/*
if($kvgbcookie) {
print("
IP: $entry->ip<br>
<a href=\"$gburl?a=delete&id=$entry->id\">Deletar</a>
");
}
*/
print("
</div>
</td>
<td class=\"gbt2\" valign=\"top\">
<div class=\"smallleft\">
data: $entry->date </div><hr size=2 width=60% align=center><div class=\"post\">$entry->post</div>
</td>
</tr>
");
}
print("
</table>
");
}
function add() {
global $PHP_SELF;
print("
<center>
<form action=\"$PHP_SELF\" method=\"post\">
<input type=\"hidden\" name=\"a\" value=\"addsave\">
<table width=\"100%\" cellpadding=\"0\" cellspacing=\"0\">
<tr>
<td align=\"right\">Nome:</td><td><input type=\"text\" name=\"name\" size=\"25\"></td>
</tr>
<tr>
<td align=\"right\">Email:</td><td><input type=\"text\" name=\"email\" size=\"25\"></td>
</tr>
<tr>
<td align=\"right\">URL:</td><td><input type=\"text\" name=\"url\" value=\"http://\" size=\"25\"></td>
</tr>
<tr>
<td align=\"right\">Localidade:</td>
<td>
<select name=\"location\">
<option value=\"0\" SELECTED>-------- selecione --------</option>
<OPTION VALUE=\"United States\">United States</OPTION>
<OPTION VALUE=\"Afghanistan\">Afghanistan</OPTION>
<OPTION VALUE=\"Albania\">Albania</OPTION>
<OPTION VALUE=\"Algeria\">Algeria</OPTION>
<OPTION VALUE=\"American Samoa\">American Samoa</OPTION>
<OPTION VALUE=\"Andorra\">Andorra</OPTION>
<OPTION VALUE=\"Angola\">Angola</OPTION>
<OPTION VALUE=\"Anguilla\">Anguilla</OPTION>
<OPTION VALUE=\"Antarctica\">Antarctica</OPTION>
<OPTION VALUE=\"Antigua And Barbuda\">Antigua And Barbuda</OPTION>
<OPTION VALUE=\"Argentina\">Argentina</OPTION>
<OPTION VALUE=\"Armenia\">Armenia</OPTION>
<OPTION VALUE=\"Aruba\">Aruba</OPTION>
<OPTION VALUE=\"Australia\">Australia</OPTION>
<OPTION VALUE=\"Austria\">Austria</OPTION>
<OPTION VALUE=\"Azerbaijan\">Azerbaijan</OPTION>
<OPTION VALUE=\"Bahamas\">Bahamas</OPTION>
<OPTION VALUE=\"Bahrain\">Bahrain</OPTION>
<OPTION VALUE=\"Bangladesh\">Bangladesh</OPTION>
<OPTION VALUE=\"Barbados\">Barbados</OPTION>
<OPTION VALUE=\"Belarus\">Belarus</OPTION>
<OPTION VALUE=\"Belgium\">Belgium</OPTION>
<OPTION VALUE=\"Belize\">Belize</OPTION>
<OPTION VALUE=\"Benin\">Benin</OPTION>
<OPTION VALUE=\"Bermuda\">Bermuda</OPTION>
<OPTION VALUE=\"Bhutan\">Bhutan</OPTION>
<OPTION VALUE=\"Bolivia\">Bolivia</OPTION>
<OPTION VALUE=\"Bosnia And Herzegowina\">Bosnia And Herzegowina</OPTION>
<OPTION VALUE=\"Botswana\">Botswana</OPTION>
<OPTION VALUE=\"Bouvet Island\">Bouvet Island</OPTION>
<OPTION VALUE=\"Brazil\">Brazil</OPTION>
<OPTION VALUE=\"British Indian Ocean Territory\">British Indian Ocean Territory</OPTION>
<OPTION VALUE=\"Brunei Darussalam\">Brunei Darussalam</OPTION>
<OPTION VALUE=\"Bulgaria\">Bulgaria</OPTION>
<OPTION VALUE=\"Burkina Faso\">Burkina Faso</OPTION>
<OPTION VALUE=\"Burundi\">Burundi</OPTION>
<OPTION VALUE=\"Cambodia\">Cambodia</OPTION>
<OPTION VALUE=\"Cameroon\">Cameroon</OPTION>
<OPTION VALUE=\"Canada\">Canada</OPTION>
<OPTION VALUE=\"Cape Verde\">Cape Verde</OPTION>
<OPTION VALUE=\"Cayman Islands\">Cayman Islands</OPTION>
<OPTION VALUE=\"Central African Republic\">Central African Republic</OPTION>
<OPTION VALUE=\"Chad\">Chad</OPTION>
<OPTION VALUE=\"Chile\">Chile</OPTION>
<OPTION VALUE=\"China\">China</OPTION>
<OPTION VALUE=\"Christmas Island\">Christmas Island</OPTION>
<OPTION VALUE=\"Cocos (Keeling) Islands\">Cocos (Keeling) Islands</OPTION>
<OPTION VALUE=\"Colombia\">Colombia</OPTION>
<OPTION VALUE=\"Comoros\">Comoros</OPTION>
<OPTION VALUE=\"Congo\">Congo</OPTION>
<OPTION VALUE=\"Cook Islands\">Cook Islands</OPTION>
<OPTION VALUE=\"Costa Rica\">Costa Rica</OPTION>
<OPTION VALUE=\"Cote D Ivoire\">Cote D Ivoire</OPTION>
<OPTION VALUE=\"Croatia\">Croatia</OPTION>
<OPTION VALUE=\"Cuba\">Cuba</OPTION>
<OPTION VALUE=\"Cyprus\">Cyprus</OPTION>
<OPTION VALUE=\"Czech Republic\">Czech Republic</OPTION>
<OPTION VALUE=\"Denmark\">Denmark</OPTION>
<OPTION VALUE=\"Djibouti\">Djibouti</OPTION>
<OPTION VALUE=\"Dominica\">Dominica</OPTION>
<OPTION VALUE=\"Dominican Republic\">Dominican Republic</OPTION>
<OPTION VALUE=\"East Timor\">East Timor</OPTION>
<OPTION VALUE=\"Ecuador\">Ecuador</OPTION>
<OPTION VALUE=\"Egypt\">Egypt</OPTION>
<OPTION VALUE=\"El Salvador\">El Salvador</OPTION>
<OPTION VALUE=\"Equatorial Guinea\">Equatorial Guinea</OPTION>
<OPTION VALUE=\"Eritrea\">Eritrea</OPTION>
<OPTION VALUE=\"Estonia\">Estonia</OPTION>
<OPTION VALUE=\"Ethiopia\">Ethiopia</OPTION>
<OPTION VALUE=\"Falkland Islands\">Falkland Islands</OPTION>
<OPTION VALUE=\"Faroe Islands\">Faroe Islands</OPTION>
<OPTION VALUE=\"Fiji\">Fiji</OPTION>
<OPTION VALUE=\"Finland\">Finland</OPTION>
<OPTION VALUE=\"France\">France</OPTION>
<OPTION VALUE=\"France, Metropolitan \">France, Metropolitan </OPTION>
<OPTION VALUE=\"French Guiana\">French Guiana</OPTION>
<OPTION VALUE=\"French Polynesia\">French Polynesia</OPTION>
<OPTION VALUE=\"French Southern Territories\">French Southern Territories</OPTION>
<OPTION VALUE=\"Gabon\">Gabon</OPTION>
<OPTION VALUE=\"Gambia\">Gambia</OPTION>
<OPTION VALUE=\"Georgia\">Georgia</OPTION>
<OPTION VALUE=\"Germany\">Germany</OPTION>
<OPTION VALUE=\"Ghana\">Ghana</OPTION>
<OPTION VALUE=\"Gibraltar\">Gibraltar</OPTION>
<OPTION VALUE=\"Greece\">Greece</OPTION>
<OPTION VALUE=\"Greenland\">Greenland</OPTION>
<OPTION VALUE=\"Grenada\">Grenada</OPTION>
<OPTION VALUE=\"Guadeloupe\">Guadeloupe</OPTION>
<OPTION VALUE=\"Guam\">Guam</OPTION>
<OPTION VALUE=\"Guatemala\">Guatemala</OPTION>
<OPTION VALUE=\"Guinea\">Guinea</OPTION>
<OPTION VALUE=\"Guinea-Bissau\">Guinea-Bissau</OPTION>
<OPTION VALUE=\"Guyana\">Guyana</OPTION>
<OPTION VALUE=\"Haiti\">Haiti</OPTION>
<OPTION VALUE=\"Heard And Mc Donald Islands\">Heard And Mc Donald Islands</OPTION>
<OPTION VALUE=\"Honduras\">Honduras</OPTION>
<OPTION VALUE=\"Hong Kong\">Hong Kong</OPTION>
<OPTION VALUE=\"Hungary\">Hungary</OPTION>
<OPTION VALUE=\"Iceland\">Iceland</OPTION>
<OPTION VALUE=\"India\">India</OPTION>
<OPTION VALUE=\"Indonesia\">Indonesia</OPTION>
<OPTION VALUE=\"Iran\">Iran</OPTION>
<OPTION VALUE=\"Iraq\">Iraq</OPTION>
<OPTION VALUE=\"Ireland\">Ireland</OPTION>
<OPTION VALUE=\"Israel\">Israel</OPTION>
<OPTION VALUE=\"Italy\">Italy</OPTION>
<OPTION VALUE=\"Jamaica\">Jamaica</OPTION>
<OPTION VALUE=\"Japan\">Japan</OPTION>
<OPTION VALUE=\"Jordan\">Jordan</OPTION>
<OPTION VALUE=\"Kazakhstan\">Kazakhstan</OPTION>
<OPTION VALUE=\"Kenya\">Kenya</OPTION>
<OPTION VALUE=\"Kiribati\">Kiribati</OPTION>
<OPTION VALUE=\"North Korea\">North Korea</OPTION>
<OPTION VALUE=\"South Korea\">South Korea</OPTION>
<OPTION VALUE=\"Kuwait\">Kuwait</OPTION>
<OPTION VALUE=\"Kyrgyzstan\">Kyrgyzstan</OPTION>
<OPTION VALUE=\"Lao Peoples Republic\">Lao Peoples Republic</OPTION>
<OPTION VALUE=\"Latvia\">Latvia</OPTION>
<OPTION VALUE=\"Lebanon\">Lebanon</OPTION>
<OPTION VALUE=\"Lesotho\">Lesotho</OPTION>
<OPTION VALUE=\"Liberia\">Liberia</OPTION>
<OPTION VALUE=\"Libyan Arab Jamahiriya\">Libyan Arab Jamahiriya</OPTION>
<OPTION VALUE=\"Liechtenstein\">Liechtenstein</OPTION>
<OPTION VALUE=\"Lithuania\">Lithuania</OPTION>
<OPTION VALUE=\"Luxembourg\">Luxembourg</OPTION>
<OPTION VALUE=\"Macau\">Macau</OPTION>
<OPTION VALUE=\"Macedonia\">Macedonia</OPTION>
<OPTION VALUE=\"Madagascar\">Madagascar</OPTION>
<OPTION VALUE=\"Malawi\">Malawi</OPTION>
<OPTION VALUE=\"Malaysia\">Malaysia</OPTION>
<OPTION VALUE=\"Maldives\">Maldives</OPTION>
<OPTION VALUE=\"Mali\">Mali</OPTION>
<OPTION VALUE=\"Malta\">Malta</OPTION>
<OPTION VALUE=\"Marshall Islands\">Marshall Islands</OPTION>
<OPTION VALUE=\"Martinique\">Martinique</OPTION>
<OPTION VALUE=\"Mauritania\">Mauritania</OPTION>
<OPTION VALUE=\"Mauritius\">Mauritius</OPTION>
<OPTION VALUE=\"Mayotte\">Mayotte</OPTION>
<OPTION VALUE=\"Mexico\">Mexico</OPTION>
<OPTION VALUE=\"Micronesia\">Micronesia</OPTION>
<OPTION VALUE=\"Moldova\">Moldova</OPTION>
<OPTION VALUE=\"Monaco\">Monaco</OPTION>
<OPTION VALUE=\"Mongolia\">Mongolia</OPTION>
<OPTION VALUE=\"Montserrat\">Montserrat</OPTION>
<OPTION VALUE=\"Morocco\">Morocco</OPTION>
<OPTION VALUE=\"Mozambique\">Mozambique</OPTION>
<OPTION VALUE=\"Myanmar\">Myanmar</OPTION>
<OPTION VALUE=\"Namibia\">Namibia</OPTION>
<OPTION VALUE=\"Nauru\">Nauru</OPTION>
<OPTION VALUE=\"Nepal\">Nepal</OPTION>
<OPTION VALUE=\"Netherlands\">Netherlands</OPTION>
<OPTION VALUE=\"Netherlands Antilles\">Netherlands Antilles</OPTION>
<OPTION VALUE=\"New Caledonia\">New Caledonia</OPTION>
<OPTION VALUE=\"New Zealand\">New Zealand</OPTION>
<OPTION VALUE=\"Nicaragua\">Nicaragua</OPTION>
<OPTION VALUE=\"Niger\">Niger</OPTION>
<OPTION VALUE=\"Nigeria\">Nigeria</OPTION>
<OPTION VALUE=\"Niue\">Niue</OPTION>
<OPTION VALUE=\"Norfolk Island\">Norfolk Island</OPTION>
<OPTION VALUE=\"Northern Mariana Islands\">Northern Mariana Islands</OPTION>
<OPTION VALUE=\"Norway\">Norway</OPTION>
<OPTION VALUE=\"Oman\">Oman</OPTION>
<OPTION VALUE=\"Pakistan\">Pakistan</OPTION>
<OPTION VALUE=\"Palau\">Palau</OPTION>
<OPTION VALUE=\"Panama\">Panama</OPTION>
<OPTION VALUE=\"Papua New Guinea\">Papua New Guinea</OPTION>
<OPTION VALUE=\"Paraguay\">Paraguay</OPTION>
<OPTION VALUE=\"Peru\">Peru</OPTION>
<OPTION VALUE=\"Philippines\">Philippines</OPTION>
<OPTION VALUE=\"Pitcairn\">Pitcairn</OPTION>
<OPTION VALUE=\"Poland\">Poland</OPTION>
<OPTION VALUE=\"Portugal\">Portugal</OPTION>
<OPTION VALUE=\"Puerto Rico\">Puerto Rico</OPTION>
<OPTION VALUE=\"Qatar\">Qatar</OPTION>
<OPTION VALUE=\"Reunion\">Reunion</OPTION>
<OPTION VALUE=\"Romania\">Romania</OPTION>
<OPTION VALUE=\"Russian Federation\">Russian Federation</OPTION>
<OPTION VALUE=\"Rwanda\">Rwanda</OPTION>
<OPTION VALUE=\"Saint Kitts And Nevis\">Saint Kitts And Nevis</OPTION>
<OPTION VALUE=\"Saint Lucia\">Saint Lucia</OPTION>
<OPTION VALUE=\"Saint Vincent And The Grenadines\">Saint Vincent And The Grenadines</OPTION>
<OPTION VALUE=\"Samoa\">Samoa</OPTION>
<OPTION VALUE=\"San Marino\">San Marino</OPTION>
<OPTION VALUE=\"são Tome And Principe\">são Tome And Principe</OPTION>
<OPTION VALUE=\"Saudi Arabia\">Saudi Arabia</OPTION>
<OPTION VALUE=\"Senegal\">Senegal</OPTION>
<OPTION VALUE=\"Seychelles\">Seychelles</OPTION>
<OPTION VALUE=\"Sierra Leone\">Sierra Leone</OPTION>
<OPTION VALUE=\"Singapore\">Singapore</OPTION>
<OPTION VALUE=\"Slovakia\">Slovakia</OPTION>
<OPTION VALUE=\"Slovenia\">Slovenia</OPTION>
<OPTION VALUE=\"Solomon Islands\">Solomon Islands</OPTION>
<OPTION VALUE=\"Somalia\">Somalia</OPTION>
<OPTION VALUE=\"South Africa\">South Africa</OPTION>
<OPTION VALUE=\"South Georgia\">South Georgia</OPTION>
<OPTION VALUE=\"The South Sandwich Islands\">The South Sandwich Islands</OPTION>
<OPTION VALUE=\"Spain\">Spain</OPTION>
<OPTION VALUE=\"Sri Lanka\">Sri Lanka</OPTION>
<OPTION VALUE=\"St Helena\">St Helena</OPTION>
<OPTION VALUE=\"St Pierre and Miquelon\">St Pierre and Miquelon</OPTION>
<OPTION VALUE=\"Sudan\">Sudan</OPTION>
<OPTION VALUE=\"Suriname\">Suriname</OPTION>
<OPTION VALUE=\"Svalbard And Jan Mayen Islands\">Svalbard And Jan Mayen Islands</OPTION>
<OPTION VALUE=\"Swaziland\">Swaziland</OPTION>
<OPTION VALUE=\"Sweden\">Sweden</OPTION>
<OPTION VALUE=\"Switzerland\">Switzerland</OPTION>
<OPTION VALUE=\"Syrian Arab Republic\">Syrian Arab Republic</OPTION>
<OPTION VALUE=\"Taiwan\">Taiwan</OPTION>
<OPTION VALUE=\"Tajikistan\">Tajikistan</OPTION>
<OPTION VALUE=\"Tanzania\">Tanzania</OPTION>
<OPTION VALUE=\"Thailand\">Thailand</OPTION>
<OPTION VALUE=\"Togo\">Togo</OPTION>
<OPTION VALUE=\"Tokelau\">Tokelau</OPTION>
<OPTION VALUE=\"Tonga\">Tonga</OPTION>
<OPTION VALUE=\"Trinidad And Tobago\">Trinidad And Tobago</OPTION>
<OPTION VALUE=\"Tunisia\">Tunisia</OPTION>
<OPTION VALUE=\"Turkey\">Turkey</OPTION>
<OPTION VALUE=\"Turkmenistan\">Turkmenistan</OPTION>
<OPTION VALUE=\"Turks And Caicos Islands\">Turks And Caicos Islands</OPTION>
<OPTION VALUE=\"Tuvalu\">Tuvalu</OPTION>
<OPTION VALUE=\"Uganda\">Uganda</OPTION>
<OPTION VALUE=\"Ukraine\">Ukraine</OPTION>
<OPTION VALUE=\"United Arab Emirates\">United Arab Emirates</OPTION>
<OPTION VALUE=\"United Kingdom\">United Kingdom</OPTION>
<OPTION VALUE=\"US Minor Outlying Islands\">US Minor Outlying Islands</OPTION>
<OPTION VALUE=\"Uruguay\">Uruguay</OPTION>
<OPTION VALUE=\"Uzbekistan\">Uzbekistan</OPTION>
<OPTION VALUE=\"Vanuatu\">Vanuatu</OPTION>
<OPTION VALUE=\"Vatican City State\">Vatican City State</OPTION>
<OPTION VALUE=\"Venezuela\">Venezuela</OPTION>
<OPTION VALUE=\"Viet Nam\">Viet Nam</OPTION>
<OPTION VALUE=\"Virgin Islands (British)\">Virgin Islands (British)</OPTION>
<OPTION VALUE=\"Virgin Islands (U.S.)\">Virgin Islands (U.S.)</OPTION>
<OPTION VALUE=\"Wallis And Futuna Islands\">Wallis And Futuna Islands</OPTION>
<OPTION VALUE=\"Western Sahara\">Western Sahara</OPTION>
<OPTION VALUE=\"Yemen\">Yemen</OPTION>
<OPTION VALUE=\"Zaire\">Zaire</OPTION>
<OPTION VALUE=\"Zambia\">Zambia</OPTION>
<OPTION VALUE=\"Zimbabwe\">Zimbabwe</OPTION>
<OPTION VALUE=\"Other-Not Shown\">Outro-Não Mostrado</OPTION>
</select>
</td>
</tr>
<tr>
<td align=\"right\">Comentário:</td><td><textarea name=\"post\" rows=\"8\" cols=\"30\"></textarea></td>
</tr><tr>
[b]<tr><td align='right'><img src='freecap.php' id='freecap'></td></tr>
<tr><td align='right'>Código acima:</td><td><input type='text' name='word'></td></tr>[/b]
<td align=\"right\"><input type=\"submit\" value=\"Postar\"></td><td><input type=\"reset\" value=\"Limpar\"></td>
</tr>
</table>
</form></center>
");
}
[b]if(!empty($_SESSION['freecap_word']) && !empty($_POST['word']))
{
if($_POST['word']==$_SESSION['freecap_word'])
{
// process form and then:
header("Location=someone_file.php");
$word_ok = "yes";
} else {
$word_ok = "no";
}
} else {
$word_ok = false;
}
if($word_ok!==false)
{
if($word_ok=="yes")
{
echo "you got the word correct, rock on.<br />";
} else {
echo "sorry, that's not the right word, try again.<br />";
}
}[/b]
function addsave(){
global $HTTP_POST_VARS, $REMOTE_ADDR;
$gb = $HTTP_POST_VARS;
if($gb['name'] == "") {
print("Error: Você deve entrar com seu nome");
exit;
}
$date = date("m-d-y");
$query = "INSERT INTO kv_guestbook (name, email, url, ip, location, post, date) VALUES
('{$gb['name']}', '{$gb['email']}', '{$gb['url']}', '{$REMOTE_ADDR}', '{$gb['location']}', '{$gb['post']}', '$date')";
mysql_query($query) or DIE(mysql_error());
print("<center><font size=\"4\"></font></center><br><br>");
gbindex();
}
function login() {
global $scripturl;
$scripturl .= "/livro.php";
print("
<font size=\"4\">Login</font><br>
<form action=\"$scripturl\" method=\"post\">
<input type=\"hidden\" name=\"a\" value=\"dologin\">
Senha: <input type=\"password\" name=\"gbpass\" size=\"15\"><br>
<input type=\"submit\" value=\"Login\">
</form>
");
}
function dologin() {
global $mysql, $gbpass, $gburl;
$time = time() + 86400*365;
if($gbpass == $mysql['pass']) {
setcookie('kvgbcookie', $mysql['pass'], $time, '/');
}
header("Location: $gburl");
}
function delete() {
global $id, $kvgbcookie, $mysql, $HTTP_GET_VARS;
$id = $HTTP_GET_VARS['id'];
if($kvgbcookie != $mysql['pass']) {
print("Você não esta logado!");
exit;
}
$query = "DELETE FROM kv_guestbook WHERE id='$id'";
mysql_query($query) or DIE(mysql_error());
gbindex();
}
function kvgbcopyright() {
print("");
}
?>
O arquivo word.txt contem cerca de 200 palavras.
abaixo o arquivo freecap.php
<?
session_start();
header ("Content-type: image/png");
// if false, generates quasi-random string (harder for humans to read, though)
$use_dict = true;
// true=transparent background, false=white
$bg_trans = true;
// colour of word
$text_r = rand(50,150);
$text_g = rand(50,150);
$text_b = rand(50,150);
// get word
if($use_dict==true)
{
// load dictionary and choose random word
// keep dictionary in non-web accessible folder, or htaccess it
// or modify so word comes from a database; SELECT word FROM words ORDER BY rand() LIMIT 1
// took 0.11 seconds when 'words' had 10,000 records
$words = file("words.txt");
$word = strtolower($words[rand(0,sizeof($words)-1)]);
// cut off line endings/other possible odd chars
$word = ereg_replace("[^a-z]","",$word);
// might be large file so forget it now
unset($words);
} else {
// modified from code by breakzero at hotmail dot com
// (http://uk.php.net/manual/en/function.rand.php)
// doesn't use easily mistaken chars like ij1lo0
$consonant = 'bcdfghkmnpqrstuvwx2345789';
$vowel = 'aeyu';
$word = "";
$wordlen = rand(5,6);
for($i=0; $i<$wordlen; $i++)
{
// don't allow to start with 'vowel'
if(rand(0,2)==1 && $i!=0)
{
$word .= substr($vowel,rand(1,strlen($vowel))-1,1);
} else {
$word .= substr($consonant,rand(1,strlen($consonant))-1,1);
}
}
}
// save word for comparison
$_SESSION['freecap_word'] = $word;
// modify width depending on maximum possible length of word
// you shouldn't need to use words > 6 chars in length though.
$width = 250;
$height = 60;
$im = ImageCreate($width, $height);
if(!$bg_trans)
{
// blends colours, but is a pain to get nice transparency if true colour
$im2 = ImageCreateTrueColor($width, $height);
} else {
$im2 = ImageCreate($width, $height);
}
// set background colour (can change to any colour not in 50-150 range)
$bg = ImageColorAllocate($im, 255, 255, 255);
// set text colour
$text_color = ImageColorAllocate($im, $text_r, $text_g, $text_b);
// write word in random position, in random font size
$word_start_x = rand(1,30);
$word_start_y = rand(1,3);
$font_size = rand(2,5);
ImageString($im, $font_size, $word_start_x, $word_start_y, $word, $text_color);
// enlarge itself
// (could be acheived by using larger font; for compatibility, leave as is for now)
// randomly scale between 2 and 3 times orig size
$scale = "2.".rand(1,9999);
$scale = floatval($scale);
$width_scaled = $width*$scale;
$height_scaled = $height*$scale;
ImageCopyResampled($im2, $im, 0, 0, 0, 0, $width_scaled, $height_scaled, $width, $height);
// blank original image out
ImageFilledRectangle($im,0,0,$width,$height,$bg);
// randomly morph each character on x-axis
// copies enlarged text back to original image
$morph_factor = 1;
$y_chunk = 1;
for($i=0; $i<=$height_scaled; $i+=$y_chunk)
{
// change amount of y_chunk
$y_chunk = rand(1,3);
for($j=0; $j<=strlen($word); $j++)
{
$orig_x = ($word_start_x+$j*($font_size+4))*$scale;
$morph_x = $orig_x + rand(-$morph_factor,$morph_factor);
ImageCopy($im, $im2, $morph_x, $i, $orig_x, $i, 21, $y_chunk);
}
}
// randomly morph word along y-axis
$word_start_x *= $scale;
$x_chunk = rand(5,10);
$word_pix_size = $word_start_x+(strlen($word)*($font_size+4)*$scale);
for($i=$word_start_x; $i<=$word_pix_size; $i+=$x_chunk)
{
ImageCopy($im2, $im, $i, rand(-1,1), $i, 0, $x_chunk+1, $height);
}
if($bg_trans==true)
{
// make background transparent
ImageColorTransparent($im2,$bg);
}
// tag it (feel free to remove/change (but if it's not essential I'd appreciate you leaving it))
$lt_grey = ImageColorAllocate($im2,128,128,128);
// ensure tag is right-aligned
$tag_str = "";
$tag_width = strlen($tag_str)*6;
// write tag
ImageString($im2, 2, $width-$tag_width, 45, $tag_str, $lt_grey);
// output image
ImagePNG($im2);
// kill GD images (removes from memory)
ImageDestroy($im);
ImageDestroy($im2);
exit();
?> Por favor, me ajudem