Frage zum Einbau in mein Script

Hier werden Probleme rund um das Zahlen Captcha behandelt

Moderator: frameguard

Frage zum Einbau in mein Script

Beitragvon ruffneck21 » 17.02.2008, 07:58

Hallo.

Ich bin was PHP angeht ne abslute Null. Kann mir jemand sagen wie ich mein Script ändern muss, damit Captcha bei mir funzt? Ich benutze eine Shoutbox. Hier gibt es 2 PHP-Dateien die wichtig scheinen, allerdings weiß ich nicht in welche der Code rein muss und wie.

shout.php:

<?
/*********************************************************************************************************
This code is part of the ShoutBox software (www.gerd-tentler.de/tools/shoutbox), copyright by
Gerd Tentler. Obtain permission before selling this code or hosting it on a commercial website or
redistributing it over the Internet or in any other medium. In all cases copyright must remain intact.
*********************************************************************************************************/

error_reporting(E_WARNING);
if(function_exists('session_start')) session_start();

//========================================================================================================
// Set variables, if they are not registered globally; needs PHP 4.1.0 or higher
//========================================================================================================

if(isset($_POST['sbID'])) $sbID = $_POST['sbID'];
if(isset($_POST['sbName'])) $sbName = $_POST['sbName'];
if(isset($_POST['sbEMail'])) $sbEMail = $_POST['sbEMail'];
if(isset($_POST['sbText'])) $sbText = $_POST['sbText'];

if(isset($_POST['create'])) $create = $_POST['create'];
if(isset($_REQUEST['delete'])) $delete = $_REQUEST['delete'];
if(isset($_REQUEST['admin'])) $admin = $_REQUEST['admin'];

if(isset($_SERVER['PHP_SELF'])) $PHP_SELF = $_SERVER['PHP_SELF'];
if(isset($_SERVER['HTTP_HOST'])) $HTTP_HOST = $_SERVER['HTTP_HOST'];
if(isset($_SERVER['HTTP_USER_AGENT'])) $HTTP_USER_AGENT = $_SERVER['HTTP_USER_AGENT'];

//========================================================================================================
// Make sure that the following variables are integers, e.g. to avoid possible database problems
//========================================================================================================

$delete = (int) $delete;

//========================================================================================================
// Includes
//========================================================================================================


if($HTTP_HOST == 'localhost' || ereg('^192\.168\.0\.[0-9]+$', $HTTP_HOST)) {
include('config_local.inc.php');
}
else {
include('config_main.inc.php');
}
if(!isset($language)) $language = 'en';
include("languages/lang_$language.inc");
include('smilies.inc');
include('funclib.inc');

//========================================================================================================
// Set session variables (admin login); needs PHP 4.1.0 or higher
//========================================================================================================

if($admin) $_SESSION['sb_admin'] = ($admin == $adminPass) ? $admin : '';

//========================================================================================================
// Functions
//========================================================================================================

function read_data() {
$data = array();
clearstatcache();

if(file_exists('data/shoutbox.txt')) {
$size = filesize('data/shoutbox.txt');

if($size > 0) {
if($fp = fopen('data/shoutbox.txt', 'r')) {
$data = fread($fp, $size);
$data = explode(chr(8) . "\r\n", $data);
for($i = 0; $i < count($data); $i++) $data[$i] = explode(chr(7), $data[$i]);
fclose($fp);
}
}
}
return $data;
}

function write_data($data) {
if($fp = fopen('data/shoutbox.txt', 'w')) {
for($i = 0; $i < count($data); $i++) $data[$i] = join(chr(7), $data[$i]);
fwrite($fp, join(chr(8) . "\r\n", $data));
fclose($fp);
}
}

function delete_entry($id) {
global $db_name, $tbl_name, $fld_id;

$error = '';

if($db_name) {
if(!mysql_query("DELETE FROM $tbl_name WHERE $fld_id='$id'")) $error = mysql_error();
}
else {
$data = read_data();

if(count($data)) foreach($data as $key => $val) {
if($val[0] == $id) {
array_splice($data, $key, 1);
write_data($data);
break;
}
}
}
return $error;
}

function new_entry($name, $email, $text) {
global $db_name, $tbl_name, $fld_id, $fld_timestamp, $fld_name, $fld_email,
$fld_text, $boxEntries;

$error = '';
$tstamp = date('YmdHis');

if($db_name) {
if(!get_magic_quotes_gpc()) {
$name = addslashes($name);
$email = addslashes($email);
$text = addslashes($text);
}

$sql = "INSERT INTO $tbl_name ($fld_timestamp, $fld_name, $fld_email, $fld_text) ";
$sql .= "VALUES ('$tstamp', '$name', '$email', '$text')";

if(!mysql_query($sql)) $error = mysql_error();
else {
$sql = "SELECT $fld_id FROM $tbl_name ORDER BY $fld_timestamp DESC LIMIT $boxEntries, 1";
$result = mysql_query($sql);
if(mysql_num_rows($result)) {
if($id = mysql_result($result, $fld_id)) {
$sql = "DELETE FROM $tbl_name WHERE $fld_id<=$id";
if(!mysql_query($sql)) $error = mysql_error();
}
}
}
}
else {
$data = read_data();
$len = count($data);
$id = $len ? $data[$len-1][0] + 1 : 1;
if($len >= $boxEntries) array_shift($data);
$data[] = array($id, $tstamp, $name, $email, $text);
write_data($data);
}
return $error;
}

function read_entries() {
global $msg, $db_name, $tbl_name, $fld_timestamp, $messageOrder, $boxEntries,
$boxWidth, $wordLength, $adminPass;

if($db_name) {
$sql = "SELECT * FROM $tbl_name ORDER BY $fld_timestamp $messageOrder LIMIT $boxEntries";
$result = mysql_query($sql);
while($row = mysql_fetch_row($result)) $data[] = $row;
}
else {
$data = read_data();
if(strtoupper($messageOrder) != 'ASC') rsort($data);
}

for($i = 0; $i < count($data); $i++) {
$id = $data[$i][0];
$tstamp = timeStamp($data[$i][1]);
$name = $data[$i][2] ? format($data[$i][2], $wordLength, $boxWidth - 22, true) : '???';
$email = strstr($data[$i][3], '@') ? $data[$i][3] : '';
$text = format($data[$i][4], $wordLength, $boxWidth - 22, false);
$bgcolor = ($bgcolor != '#FFFFFF') ? '#FFFFFF' : '#F6F6F6';

if($_SESSION['sb_admin'] && $_SESSION['sb_admin'] == $adminPass) {
?>
<div class="cssShoutRaised" style="float:right" title="<? echo $msg['delete']; ?>"
onMouseDown="this.className='cssShoutPressed'"
onMouseUp="this.className='cssShoutRaised'"
onMouseOut="this.className='cssShoutRaised'"
onClick="confirmDelete(<? echo $id; ?>)">
<img src="delete.gif" width="10" height="10">
</div>
<?
}
?>
<TABLE WIDTH="100%" style="background-image: url(../../bilder/design/bg_shoutbox_2.jpg);">
<TR>
<TD class="cssShoutText"><? if($email) echo '<a href="mailto:' . $email . '">'; ?><b><? echo $name; ?>:</b><? if($email) echo '</a>'; ?><BR>
<SPAN class="cssShoutTime"><? echo $tstamp; ?></SPAN></TD>
</TR><TR>
<TD class="cssShoutText"><? echo $text; ?></TD>
</TR>
</TABLE>
<?
}
}

//========================================================================================================
// Main
//========================================================================================================

if(!$db_name || db_open($db_server, $db_user, $db_pass, $db_name)) {
$error = '';
$table_exists = true;

if($db_name) {
if(!mysql_query("SELECT 1 FROM $tbl_name LIMIT 1")) $table_exists = false;
}

header('Cache-control: private, no-cache, must-revalidate');
header('Expires: Sat, 01 Jan 2000 00:00:00 GMT');
header('Date: Sat, 01 Jan 2000 00:00:00 GMT');
header('Pragma: no-cache');
?>
<html>
<head>
<meta name="robots" content="noindex, nofollow">
<?
if($table_exists) {
?>
<meta http-equiv="refresh" content="<? echo $boxRefresh; ?>; URL=<? echo basename($PHP_SELF); ?>">
<?
}
?>
<title>Output</title>
<?
$messageOrder = strtoupper($messageOrder);
if($messageOrder != 'ASC' && $messageOrder != 'DESC') $messageOrder = 'DESC';

if($messageOrder == 'ASC') {
?>
<script language="JavaScript"> <!--
function autoscroll() {
if(document.documentElement && document.documentElement.offsetHeight)
window.scrollBy(0, document.documentElement.offsetHeight + 1000);
else if(document.body && document.body.offsetHeight)
window.scrollBy(0, document.body.offsetHeight + 1000);
else if(window.innerHeight)
window.scrollBy(0, window.innerHeight + 1000);
else if(document.height)
window.scrollBy(0, document.height + 1000);
}
window.onload = autoscroll;
//--> </script>
<?
}

if($_SESSION['sb_admin'] && $_SESSION['sb_admin'] == $adminPass) {
?>
<script language="JavaScript"> <!--
function confirmDelete(id) {
var check = confirm("<? echo $msg['confirm']; ?>");
if(check) document.location.href = '<? echo $PHP_SELF; ?>?delete=' + id;
}
//--> </script>
<?
}
?>
<link rel="stylesheet" href="shoutbox.css" type="text/css">
</head>
<body style="margin:0px">
<?
if($db_name && !$table_exists) {

if($create == 'yes') {
$sql = "CREATE TABLE $tbl_name ( " .
"$fld_id INT(10) NOT NULL auto_increment, " .
"$fld_timestamp VARCHAR(14) NOT NULL, " .
"$fld_name VARCHAR(20), " .
"$fld_email VARCHAR(75), " .
"$fld_text TEXT NOT NULL, " .
"PRIMARY KEY ($fld_id))";
if(!mysql_query($sql)) $error = mysql_error();
else $table_exists = true;
}
else if($create == 'no') $error = 'Operation cancelled.';
else {
echo '<div class="cssShoutText" style="padding:4px">';
echo '<form name="f1" action="' . $PHP_SELF . '" method="post" style="margin:0px">';
echo "<b>Table $tbl_name doesn't exist. Create it now?</b><br><br>";
echo '<input type="radio" name="create" value="yes" onClick="document.f1.submit()">yes &nbsp; ';
echo '<input type="radio" name="create" value="no" onClick="document.f1.submit()">no';
echo '</form></div>';
}
}
else {

if($admin && $admin != $_SESSION['sb_admin']) $error = $msg['wrongPass'];
else if($_SESSION['sb_admin'] && $_SESSION['sb_admin'] == $adminPass && $delete) {
$error = delete_entry($delete);
}
else if($sbText) {
if(checkSpam($sbID, -1, $sbName, $sbEMail, '', $sbText)) $error = $msg['noSpam'];
else $error = new_entry($sbName, $sbEMail, $sbText);
}

if($error) echo '<div class="cssShoutError">' . $error . '</div>';

read_entries();
}
?>
</body>
</html>
<?
if($db_name) mysql_close();
}
?>







shoutbox.inc.php:

<?

/*
+-------------------------------------------------------------------+
| S H O U T B O X (v3.0) |
| |
| Copyright Gerd Tentler www.gerd-tentler.de/tools |
| Created: Jun. 1, 2004 Last modified: Jan. 22, 2007 |
+-------------------------------------------------------------------+
| This program may be used and hosted free of charge by anyone for |
| personal purpose as long as this copyright notice remains intact. |
| |
| Obtain permission before selling the code for this program or |
| hosting this software on a commercial website or redistributing |
| this software over the Internet or in any other medium. In all |
| cases copyright must remain intact. |
+-------------------------------------------------------------------+
*/
error_reporting(E_WARNING);

//========================================================================================================
// Set variables, if they are not registered globally; needs PHP 4.1.0 or higher
//========================================================================================================

if(isset($_SERVER['HTTP_HOST'])) $HTTP_HOST = $_SERVER['HTTP_HOST'];

//========================================================================================================
// Includes
//========================================================================================================

if($HTTP_HOST == 'localhost' || $HTTP_HOST == '127.0.0.1' || ereg('^192\.168\.0\.[0-9]+$', $HTTP_HOST)) {
include('php/messagebox/config_local.inc.php');
}
else {
include('php/messagebox/config_main.inc.php');
}
if(!isset($language)) $language = 'de';
include("php/messagebox/languages/lang_$language.inc");
include('php/messagebox/smilies.inc');

//========================================================================================================
// Set session variables (message ID); needs PHP 4.1.0 or higher
//========================================================================================================

if($enableIDs && !$_SESSION['msgID']) {
srand((double) microtime() * 1000000);
$_SESSION['msgID'] = md5(uniqid(rand()));
}

//========================================================================================================
// Main
//========================================================================================================

if($boxFolder && !ereg('/$', $boxFolder)) $boxFolder .= '/';
?>
<script language="JavaScript"> <!--
var shout_popup = 0;

function newWindow(url, w, h, x, y, scroll, menu, tool, resizable) {
if(shout_popup && !shout_popup.closed) shout_popup.close();
if(!x && !y) {
x = Math.round((screen.width - w) / 2);
y = Math.round((screen.height - h) / 2);
}
shout_popup = window.open(url, "shout_popup", "width=" + w + ",height=" + h +
",left=" + x + ",top=" + y + ",scrollbars=" + scroll +
",menubar=" + menu + ",toolbar=" + tool + ",resizable=" + resizable);
shout_popup.focus();
}

function refreshBox() {
document.fShout.sbText.value = "";
document.fShout.admin.value = "";
document.fShout.submit();
setTimeout("document.fShout.Refresh.disabled=false", 1000);
}

function shoutIt() {
document.fShout.admin.value = "";
document.fShout.submit();
setTimeout("document.fShout.sbText.value=''", 1000);
setTimeout("document.fShout.Shout.disabled=false", 1000);
}

function login() {
var pass = prompt("<? echo $msg['pass']; ?>", "");
if(pass) {
document.fShout.admin.value = pass;
document.fShout.submit();
}
document.fShout.Admin.disabled = false;
}
//--> </script>
<!--<link rel="stylesheet" href="<? echo $boxFolder; ?>shoutbox.css" type="text/css">-->
<table border="0" cellspacing="0" cellpadding="0">
<form name="fShout" action="<? echo $boxFolder; ?>shout.php" target="ShoutBox" method="post">
<input type="hidden" name="sbID" value="<? echo $_SESSION['msgID']; ?>">
<input type="hidden" name="admin">
<tr valign="top">
<td>
<iframe name="ShoutBox" src="<? echo $boxFolder; ?>shout.php" class="cssShoutBox"
width="<? echo $boxWidth; ?>" height="<? echo $boxHeight; ?>" frameborder="0"></iframe>
</td>
<?
if(strtolower($inputsPosition) != 'side') {
$txtHeight = 50;
?>
</tr><tr>
<?
}
else {
$txtHeight = round($boxHeight * 0.65);
?>
<td width="20">&nbsp;</td>
<?
}
?>







<td STYLE="padding-top: 2px;">
<table border="0" cellspacing="0" cellpadding="0" width="<? echo $boxWidth; ?>"><tr>
<td><input type="text" name="sbName" maxlength="20" class="cssShoutForm" style="width:150px" value="Name" onfocus="if (this.value == 'Name') this.value = '';"></td>
</tr><tr>
<td><input type="text" name="sbText" maxlength="750" class="cssShoutForm" style="width:150px;" value="Message" onfocus="if (this.value == 'Message') this.value = '';"></td>
</tr><tr>
<td><input type="text" name="sbEMail" maxlength="75" class="cssShoutForm" style="width:150px" value="Email" onfocus="if (this.value == 'Email') this.value = '';">

<img src="../../captcha/captcha.php" border="0" title="Sicherheitscode">

<table border="0" cellspacing="0" cellpadding="0" width="100%"><tr>
<td align="left" STYLE="padding-right:2px;"><input type="text" name="sicherheitscode" size="5"></td></tr><tr>
<td align="left" STYLE="padding-right:2px;"><input type="button" name="Shout" value="Shout" class="cssShoutButton" onClick="this.disabled=false; shoutIt()"></td>
<td align="left" STYLE="padding-right:2px;"><input type="button" name="Refresh" value="R" class="cssShoutButton1" onClick="this.disabled=false; refreshBox()"></td>
<td align="left" STYLE="padding-right:2px;"><input type="button" name="Admin" value="©" class="cssShoutButton1" onClick="this.disabled=false; login()"></td>
<td align="right"><input type="button" name="Smilies" value="Smilies" class="cssShoutButton2" onClick="newWindow('<? echo $boxFolder; ?>smilies.php', 126, 300, 0, 0, 1)"></td>

</tr></table>
</td>
</tr></table>
</td>
</tr>
</form>
</table>
ruffneck21
 
Beiträge: 1
Registriert: 17.02.2008, 07:54

Zurück zu Zahlen Captcha

Wer ist online?

Mitglieder in diesem Forum: 0 Mitglieder und 0 Gäste

cron