hilfe bei shoutbox :(

Hier werden Probleme rund um das Rechen Captcha behandelt

Moderator: frameguard

hilfe bei shoutbox :(

Beitragvon Octron » 12.10.2008, 09:41

hallo...
will das rechen-captcha in meine shoutbox eintragen aber irgendwas mache ich falsch... wenn ich den code einfüge ist meine seite weg (alles weiß) :(

rechen-captcha.php


<?php
session_start();
unset($_SESSION['rechen_captcha_spam']);
$zahl1 = rand(10,20); //Erste Zahl 10-20
$zahl2 = rand(1,10); //Zweite Zahl 1-10
$operator = rand(1,2); // + oder -

if($operator == "1"){
$operatorzeichen = " + ";
$ergebnis = $zahl1 + $zahl2;
}else{
$operatorzeichen = " - ";
$ergebnis = $zahl1 - $zahl2;
}

function encrypt($string, $key) {
$result = '';
for($i=0; $i<strlen($string); $i++) {
$char = substr($string, $i, 1);
$keychar = substr($key, ($i % strlen($key))-1, 1);
$char = chr(ord($char)+ord($keychar));
$result.=$char;
}
return base64_encode($result);
}

$_SESSION['rechen_captcha_spam'] = encrypt($ergebnis, "29jfkd921"); //Key
$_SESSION['rechen_captcha_spam'] = str_replace("=", "", $_SESSION['rechen_captcha_spam']);

$rechnung = $zahl1.$operatorzeichen.$zahl2." = ?";
$img = imagecreatetruecolor(80,15);
$schriftfarbe = imagecolorallocate($img,13,28,91);
$hintergrund = imagecolorallocate($img,162,162,162);
imagefill($img,0,0,$hintergrund);
imagestring($img, 3, 2, 0, $rechnung, $schriftfarbe);
header("Content-type: image/jpg");
imagepng($img);
imagedestroy($img);
?>




default.php

<?php
JHTML::_('behavior.mootools');
$module_base = JURI::base() . 'modules/mod_shoutbox/';
$document =& JFactory::getDocument();
$document->addScript($module_base . 'js/fatAjax.php?refresh='.$refresh);
$document->addStyleSheet($module_base . 'css/mod_shoutbox.css');
?>

<script type="text/javascript">
var fadefrom = '<?php echo $params->get("fadefrom"); ?>';
var fadeto = '<?php echo $params->get("fadeto"); ?>';
</script>

<div id="shoutbox">
<div id="chatoutput">
<?php $first_time = true; ?>
<?php foreach ($list as $item) : ?>
<?php if ($first_time == true):
$lastID = $item->id; ?>
<div id="lastMessage"><span><?php echo JText::_( 'LAST_MESSAGE'); ?>:</span> <em id="responseTime"><?php echo modShoutboxHelper::time_since($item->time); ?> <?php echo JText::_( 'AGO'); ?></em></div><ul id="outputList">
<?php endif; ?>
<?php if ($maydelete): ?>
<li><a href="?mode=delshout&amp;shoutid=<?php echo $item->id; ?>" title="Delete">x</a> <span title="<?php echo modShoutboxHelper::time_since($item->time); ?>"><?php echo $item->url; ?> : </span><?php echo $item->text; ?></li>
<?php else : ?>
<li><span title="<?php echo modShoutboxHelper::time_since($item->time); ?>"><?php echo $item->url; ?> : </span><?php echo $item->text; ?></li>
<?php endif; ?>
<?php $first_time = false; ?>
<?php endforeach; ?>
</ul>
</div>
<?php if ($params->get('tag')) : ?>
<p><?php echo JText::_( 'GUESTTAG');?></p>
<?php endif; ?>
<?php if ($params->get('post_guest') || $loggedin != 'guest') : ?>
<form id="chatForm" name="chatForm" method="post" action="index.php">
<p>
<?php if($loggedin != 'guest') : /* If they are logged in, then print their nickname */ ?>
<label><?php echo JText::_( 'NAME'); ?> <em><?php echo $user->get('name'); ?></em></label>
<input type="hidden" name="shoutboxname" id="shoutboxname" class="inputbox" value="<?php echo $user->get('name'); ?>" />
<?php else: /* Otherwise allow the user to pick their own name */ ?>
<label for="shoutboxname"><?php echo JText::_( 'NAME'); ?></label>
<input type="text" name="shoutboxname" id="shoutboxname" class="inputbox" value="<?php if (isset($_COOKIE['jalUserName'])) { echo $_COOKIE['jalUserName']; } else { echo ' '; } ?>" />
<?php endif; ?>
<?php if (!$params->get('url')) : ?>
<span style="display: none">
<?php endif; ?>
<label for="shoutboxurl">Url:</label>
<input type="text" name="shoutboxurl" id="shoutboxurl" class="inputbox" value="<?php if (isset($_COOKIE['jalUrl'])) { echo $_COOKIE['jalUrl']; } else { echo 'http://'; } ?>" />
<?php if (!$params->get('url')) : ?>
</span>
<?php endif; ?>

<label for="chatbarText"><?php echo JText::_( 'MESSAGE'); ?></label>
<?php if ($params->get('textarea')) : ?>
<textarea rows="4" cols="16" name="chatbarText" id="chatbarText" class="inputbox" onkeypress="return pressedEnter(this,event);"></textarea>
<?php else: ?>
<input type="text" name="chatbarText" id="chatbarText" class="inputbox" onkeypress="return pressedEnter(this,event);"/>
<?php endif; ?>
<input type="text" name="homepage" id="homepage" class="homepage" />
</p>
<?php
$smilies = '';
$mainframe->triggerEvent('onSmiley_RenderForm', array('document.forms.chatForm.chatbarText', &$smilies) );
echo $smilies;
?>
<input type="hidden" id="jal_lastID" value="<?php echo $lastID + 1; ?>" name="jal_lastID" />
<input type="hidden" name="shout_no_js" value="true" />

<img src="rechen-captcha.php">
<input type="text" name="sicherheitscode" size="5">


<input type="submit" id="submitchat" name="submit" class="button" value="<?php echo JText::_( 'SEND'); ?>" />
</form>
<?php else: ?>
<p><?php echo JText::_( 'REGISTER_ONLY'); ?></p>
<?php endif; ?>
</div>



mod_shoutbox.php

<?php

session_start();
function encrypt($string, $key) {
$result = '';
for($i=0; $i<strlen($string); $i++) {
$char = substr($string, $i, 1);
$keychar = substr($key, ($i % strlen($key))-1, 1);
$char = chr(ord($char)+ord($keychar));
$result.=$char;
}
return base64_encode($result);
}
$sicherheits_eingabe = encrypt($_POST["sicherheitscode"], "29jfkd921");
$sicherheits_eingabe = str_replace("=", "", $sicherheits_eingabe);
if(isset($_SESSION['rechen_captcha_spam']) AND $sicherheits_eingabe == $_SESSION['rechen_captcha_spam']){
unset($_SESSION['rechen_captcha_spam']);


// no direct access
defined('_JEXEC') or die('Restricted access');

// Include the syndicate functions only once
require_once( dirname(__FILE__).DS.'helper.php' );

$shouts = intval($params->get( 'shouts', 10 ));
$refresh = intval($params->get( 'refresh', 1 ));
$tag = $params->get( 'tag' );
$loggedin = modShoutboxHelper::getType();
$user =& JFactory::getUser();
$jal_lastID = isset($_GET['jal_lastID']) ? $_GET['jal_lastID'] : "";
$jalGetChat = isset($_GET['jalGetChat']) ? $_GET['jalGetChat'] : "";
$jalSendChat = isset($_GET['jalSendChat']) ? $_GET['jalSendChat'] : "";

$name = JRequest::getVar( 'n', '', 'post' );
$url = JRequest::getVar( 'u', '', 'post' );
$text = JRequest::getVar( 'c', '', 'post' );
$homepage = JRequest::getVar( 'h', '', 'post' );
$shoutid = JRequest::getInt( 'shoutid', '', 'get' );

$maydelete = $user->authorize('com_content', 'edit', 'content', 'all');

$mode = JRequest::getCmd('mode');
//$ajaxcall = isset($_SERVER["HTTP_X_REQUESTED_WITH"]) ? ($_SERVER["HTTP_X_REQUESTED_WITH"] == "XMLHttpRequest") : false;



switch ($mode) {
case 'addshout':
if(empty($homepage)) {
modShoutboxHelper::addShout($name, $url, $text, $tag);
}
break;
case 'delshout':
modShoutboxHelper::delShout($shoutid);
break;
}

//getList

if($mode == 'getshouts') {
header( "Expires: Mon, 26 Jul 1997 05:00:00 GMT" );
header( "Last-Modified: ".gmdate( "D, d M Y H:i:s" )."GMT" );
header( "Cache-Control: no-cache, must-revalidate" );
header( "Pragma: no-cache" );
header( "Content-Type: text/html; charset=utf-8" );
$loop = '';
$ajaxshouts = modShoutBoxHelper::getAjaxShouts($shouts);
foreach ( $ajaxshouts as $shout ) {
$loop = $shout->id."---".stripslashes($shout->name)."---".stripslashes($shout->text)."---0 minutes ago---".stripslashes($shout->url)."---" . $loop;
// --- is being used to separate the fields in the output
}
if (empty($loop)) {
$loop = "0";
}
echo $loop;
exit;
}

$list = modShoutboxHelper::getShouts($shouts);



if (isset($_POST['shout_no_js'])) {
if ($_POST['shoutboxname'] != '' && $_POST['chatbarText'] != '' && empty($homepage)) {
$name = $_POST['shoutboxname'];
($tag) ? $name = '['.$name.']' : $name;
modShoutboxHelper::jal_addData($name, $_POST['shoutboxurl'], $_POST['chatbarText']);
modShoutboxHelper::deleteOld(); //some database maintenance
header('location: '.$_SERVER['HTTP_REFERER']);
} else echo "You must have a name and a comment";
}


require(JModuleHelper::getLayoutPath('mod_shoutbox'));
?>


<?php
//Add the javascript and css to the head when only the module is displayed
if(JRequest::getCmd( 'view' ) != 'shoutbox') {

}

// Register globals
$jal_lastID = isset($_GET['jal_lastID']) ? $_GET['jal_lastID'] : "";
$jal_user_name = isset($_POST['n']) ? $_POST['n'] : "";
$jal_user_url = isset($_POST['u']) ? $_POST['u'] : "";
$jal_user_text = isset($_POST['c']) ? $_POST['c'] : "";
$jalGetChat = isset($_GET['jalGetChat']) ? $_GET['jalGetChat'] : "";
$jalSendChat = isset($_GET['jalSendChat']) ? $_GET['jalSendChat'] : "";

////////////////////////////////////////////////////////////
// Functions Below are for submitting comments to the database
////////////////////////////////////////////////////////////

// When user submits and javascript fails
if (isset($_POST['shout_no_js'])) {
if ($_POST['shoutboxname'] != '' && $_POST['chatbarText'] != '') {
ShoutboxController::jal_addData($_POST['shoutboxname'], $_POST['shoutboxurl'], $_POST['chatbarText']);
ShoutboxController::deleteOld(); //some database maintenance
header('location: '.$_SERVER['HTTP_REFERER']);
} else echo "You must have a name and a comment";
}
?>



habe jetz erst mal wieder alles gelöscht damit meine seite wieder funktioniert....
es handelt sich um eine shoutbox für joomla....
das ganze modul habe ich mal zum download hochgeladen... ist so vieleicht etwas übersichtlicher und leichter zu verstehen....

http://uploaded.to/?id=chsoer

danke schonmal für die hilfe ;)
Octron
 
Beiträge: 4
Registriert: 12.10.2008, 09:27

Beitragvon Octron » 15.10.2008, 18:13

kann mir den keiner helfen????
Octron
 
Beiträge: 4
Registriert: 12.10.2008, 09:27

Beitragvon Octron » 18.10.2008, 14:09

hmmm.... sieht wohl aus als könnte mir keiner helfen :(
Octron
 
Beiträge: 4
Registriert: 12.10.2008, 09:27

Beitragvon Octron » 23.10.2008, 16:12

schade das mir keiner helfen kann :(
Octron
 
Beiträge: 4
Registriert: 12.10.2008, 09:27


Zurück zu Rechen Captcha

Wer ist online?

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

cron