Credo che il problema risieda nel fatto che i due server abbiamo 2 differenti versioni di php installato ma non essendo un esperto non so proprio cosa dovrei cambiare...
Provandolo su altervista funziona PERFETTAMENTE mentre su un server "amatoriale" riscontra diversi problemi.
Alcuni parse error sembravano dati da "<?" che ho corretto in "<?php".. fatto questo ottengo la visualizzazione corretta dello script ma non l'esecuzione: IMPLORO IL VOSTRO AIUTO!
acctmgr.php
codice:
<?php
require "config.php";
require "smtp.php";
?>
<HTML>
<HEAD>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"><style type="text/css">
<!--
body {
background-color: #333333;
}
-->
</style></HEAD>
<BODY>
<?php
if ($submit){
// Get all accounts out of accounts.scp and put them into $accounts
if (($account=="")||($email=="")){
die("A field was left empty");
} else {
if(eregi("^[a-z0-9\._-]+@+[a-z0-9\._-]+\.+[a-z]{2,3}$", $email)){
} else {
die("Email is in an invalid format");
}
}
$account = strtolower($account); // lowercase entered account
$account = str_replace(" ","",$account); // remove spaces
$i=0; // counter for reading file lines
$token = array("a","b","c","d","e","f","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","0","1","2","3","4","5","6","7","8","9");
$password= $token[rand(0, 35)] . $token[rand(0, 35)] . $token[rand(0, 35)] . $token[rand(0, 35)] . $token[rand(0, 35)] . $token[rand(0, 35)]; // generate password
$emails = array("root@127.0.0.1");
// read existing accounts into $accounts
$fd = file ($sphereaccu);
while ($i<=count($fd)){
if (stristr($fd[$i], "[")){
$fd[$i]=trim($fd[$i]);
$fd[$i]=strtolower($fd[$i]);
array_push ($accounts, $fd[$i]);
}
$i++;
}
// read existing emails into $emails
$i=0;
while ($i<=count($fd)){
if (stristr($fd[$i], "EMAIL=")){
$fd[$i]=trim($fd[$i]);
$fd[$i]=strtolower($fd[$i]);
array_push ($emails, $fd[$i]);
}
$i++;
}
// read accounts awaiting to be activated into $accounts
$fd = file ($sphereacct);
$i=0;
while ($i<=count($fd)){
if (stristr($fd[$i], "[")){
$fd[$i]=trim($fd[$i]);
$fd[$i]=strtolower($fd[$i]);
array_push ($accounts, $fd[$i]);
}
$i++;
}
// read more emails into $emails
//$fd = file ($sphereacct);
$i=0; // reset counter for next file
while ($i<=count($fd)){
if (stristr($fd[$i], "EMAIL=")){
$fd[$i]=trim($fd[$i]);
$fd[$i]=strtolower($fd[$i]);
array_push ($emails, $fd[$i]);
}
$i++;
}
// look for entered account name
$b=0;
$result="ok";
while ($b<=count($accounts)){
$account2="[" . $account . "]";
if ($accounts[$b]==$account2){
echo "$error_account
";
print_form();
$b=count($accounts)+1;
$result="no";
}else{
$b++;
}
}
// check emails :)
$b=0;
while ($b<=count($emails)){
$email2="email=" . $email . "";
if ($emails[$b]==$email2){
echo "$error_email
";
print_form();
$b=count($emails)+1;
$result="no";
}else{
$b++;
}
}
if ($result=="ok"){
$fd = fopen ($sphereacct, "a+");
fwrite ($fd,"\n[" . $account . "]\n");
fwrite ($fd,"PASSWORD=" . $password . "\n");
fwrite ($fd,"EMAIL=" . $email . "\n");
fwrite ($fd,"\n");
$smtp=new smtp_client();
$smtp->email("noreply@somewhere.com", $email, $email, $header[0], "Your $shardname Account!", $email_body);
$smtp->send();
print_sucess();
?>
<?php
}
}else{
print_form();
}
?>
</BODY>
</HTML>
config.php
codice:
<?php
$shardname = "Paradoxis";
$shardweb = "http://paradoxis.shorturl.com";
$sphereaccu = "G:\\hosts\\nsh_age1999\\services\\sphere\\accounts\\sphereaccu.scp";
$sphereacct = "G:\\hosts\\nsh_age1999\\services\\sphere\\accounts\\sphereacct.scp";
// Location of your smtp server (ask your ISP)
$smtp_server = "";
$accounts = array("[eof]","[admin]","[add]","[update]","[unused]","[.]"); // array of known accounts
$error_account = "Sorry, this account exists or is illegally named.";
$error_email = "Sorry, this email is in use on this shard.";
$email_body="Thanks for joining $shardname!\n\n Account: $account \n Password: $password\n\n Please visit the website ($shardweb) to get the required files and information on how to connect (new player page).
\n\n\n If you have received this message in error, it means someone is using this email address to register; Please disregard this message and accept our apologies.";
// ADVANCED OPTIONS, SEE DOCUMENTATION
function print_sucess(){
?>
Account created!
Your account has been created and the password has been sent to the email address you provided. You may want to head over to the downloads area and pick up the required files while waiting for your account to be activated.
Notes:
<UL>
<LI>Accounts are updated every 5 minutes, so if you cannot log in, try back again in 5 minutes.</LI>
<LI>All Accounts not used in 30 days/unused accounts are deleted periodically so login to your account as soon as you can after you receive your login information.</LI>
<LI>Thank you for joining our shard.</LI>
<?php
}
function print_form(){
?>
<TABLE>
<TR><TD><FORM NAME="signup" METHOD="POST" ACTION="acctmgr.php">
<FONT>Account Name:</FONT></TD><TD><INPUT TYPE="text" NAME="account"></TD></TR>
<TR><TD><FONT>Email:</FONT></TD><TD><INPUT TYPE="text" NAME="email"></TD></TR>
<TR><TD><INPUT TYPE="submit" NAME="submit" VALUE="Create"></TD><TD></TD></TR>
<TR><TD></FORM></TD><TD></TD></TR>
</TABLE>
<FONT COLOR="red">Your email is required for verification purposes only and will not be used for anything else.</FONT>
If there are spaces in your account name, they will be removed so "john smith" would become "johnsmith"
<?php
}
?>
smtp.php
codice:
<?php
// smtp_client class -------------------------------------------------------
// use:
// $smtp=smtp_client();
// $smtp->email($from, $to[0], $to_name[0], $header[0], $subject[0], $body[0]);
// $smtp->email($from, $to[1], $to_name[1], $header[1], $subject[1], $body[1]);
// $smtp->send();
class smtp_client {
var $connection;
var $server;
var $elog_fp;
var $log_file='./smtp_client.log';
var $do_log=false;
// default constructor
function smtp_client() {
$this->server=$smtp_server;
$this->connection = fsockopen($this->server, 25);
if ($this->connection <= 0) return 0;
$this->elog(fgets($this->connection, 1024));
$this->elog("HELO xyz\r\n", 1);
fputs($this->connection,"HELO xyz\r\n");
$this->elog(fgets($this->connection, 1024));
}
function email($from_mail, $to_mail, $to_name, $header, $subject, $body) {
if ($this->connection <= 0) return 0;
$this->elog("MAIL FROM:$from_mail", 1);
fputs($this->connection,"MAIL FROM:$from_mail\r\n");
$this->elog(fgets($this->connection, 1024));
$this->elog("RCPT TO:$to_mail", 1);
fputs($this->connection, "RCPT TO:$to_mail\r\n");
$this->elog(fgets($this->connection, 1024));
$this->elog("DATA", 1);
fputs($this->connection, "DATA\r\n");
$this->elog(fgets($this->connection, 1024));
$this->elog("Subject: $subject", 1);
$this->elog("To: $to_name", 1);
fputs($this->connection,"Subject: $subject\r\n");
fputs($this->connection,"To: $to_name\r\n");
if ($header) {
$this->elog($header, 1);
fputs($this->connection, "$header\r\n");
}
$this->elog("", 1);
$this->elog($body, 1);
$this->elog(".", 1);
fputs($this->connection,"\r\n");
fputs($this->connection,"$body \r\n");
fputs($this->connection,".\r\n");
$this->elog(fgets($this->connection, 1024));
return 1;
}
function send() {
if ($this->connection) {
fputs($this->connection, "QUIT\r\n");
fclose($this->connection);
$this->connection=0;
}
}
function close() { $this->send(); }
function elog($text, $mode=0) {
if (!$this->do_log) return;
// open file
if (!$this->elog_fp) {
if (!($this->elog_fp=fopen($this->log_file, 'a'))) return;
fwrite($this->elog_fp, "\n-------------------------------------------\n");
fwrite($this->elog_fp, " Sent " . date("Y-m-d H:i:s") . "\n");
fwrite($this->elog_fp, "-------------------------------------------\n");
}
}
}
?>
Ringrazio anticipatamente ogni aiuto