Hallo,
ich habe folgendes Problem, und zwar habe ich ein Script, dass sol eigentlich eine Email bzw. Invite verschicken, aber jedesmal kommt ein 500 Error nach langem googlen habe ich heraus gefunden, dass es nicht mit dem Neueren PHP Versionen kompatible ist.
Code:
ZitatAlles anzeigen
<?php
if (!eregi("takeinvite.php",$_SERVER['PHP_SELF'])) die ("You cannot include this file");
include("header.php");
include_once("language/mailtexts.php");
global $db, $db_prefix;
function validemail($email) {
return preg_match('/^[\w.-]+@([\w.-]+\.)+[a-z]{2,6}$/is', $email);
}
function mksecret($len = 20) {
$ret = "";
for ($i = 0; $i < $len; $i++)
$ret .= chr(mt_rand(0, 255));
return $ret;
}
$sql=("SELECT COUNT(*) FROM ".$db_prefix."_users")or sql_error();
$res = $db->sql_query($sql) or btsqlerror($sql);
$arr = $db->sql_fetchrow($res);
if ($arr[0] >= $invites1)bterror(""._btsignup_limit_reached."(" . number_format($invites1) . ")"._btsignup_reached."",""._btsignup_limit."");
if($user->invites == 0)bterror(_btsignup_noinvites);
$mess= unesc($_POST['mess']);
if (!$mess) bterror(_btsignup_message);
if (!mkglobal("email"))die();
if (!validemail($email))bterror(_btsignup_invalid_email);
$a = ($db->sql_numrows($db->sql_query("select count(*) from ".$db_prefix."_users where email='$email'"))) or die(mysql_error());
if ($a[0] != 0)bterror(_bterremailexists);
$secret = mksecret();
$editsecret = mksecret();
$username = rand();
if($force_passkey){
do {
$passkey = ", '".RandomAlpha(32)."'";
$sql = "SELECT passkey FROM ".$db_prefix."_users WHERE passkey = '".$passkey."';";
$res = $db->sql_query($sql);
$cnt = $db->sql_numrows($sql);
$db->sql_freeresult($res);
} while ($cnt > 0);
$passkeyrow = ', passkey';
}else{
$passkeyrow = NULL;
$passkey = NULL;
}
$act_key = RandomAlpha(32);
$ret = $db->sql_query("INSERT INTO ".$db_prefix."_users (username, password, email, active, act_key, invited_by, regdate" . $passkeyrow . ") VALUES ('" .$username. "', '". $secret ."', '" .$email ."', '0', '".$act_key."', '". $user->id ."', now() " . $passkey .")")or die(mysql_error());
$id = $db->sql_nextid();
$id2 = $user->id;
$invites = $user->invites -1;
$invitees = $user->invitees;
$invitees2 = "$id $invitees";
$db->sql_query("UPDATE ".$db_prefix."_users SET invites='$invites', invitees='$invitees2' WHERE id = $id2");
$username = $user->name;
$psecret = md5($secret);
$message = ($html ? strip_tags($mess) : $mess);
$replace_markers = Array("**sitename**","**siteurl**","**inviter**","**toemail**","**message**","**newid**","**newsecrt**");
$replace_data = Array ($sitename,$siteurl,$username,$email,$message,$id,$psecret);
$confirm_mail = New eMail();
$confirm_mail->sender = $admin_email;
$confirm_mail->subject = $userinviteconfirmmailsub[$language];
$confirm_mail->body = str_replace($replace_markers,$replace_data,$inviteuser[$language]);
$confirm_mail->Add($email);
$confirm_mail->Send();
header("Refresh: 0; url=user.php?op=profile&id=".$user->id."&type=invite&email=" . urlencode($email));
?>