Commit 54485a1e authored by Benjamin Sonntag's avatar Benjamin Sonntag

PHP7.0 compatibility,

parent 53e14f29
<?php <?php
mysql_connect("localhost","user","password"); $db = mysqli_connect("localhost","user","password");
mysql_select_db("database"); mysqli_select_db($db,"database");
$csrf_key="random long string of characters (seriously, change me, pwgen 40 1 is good ;) )"; $csrf_key="random long string of characters (seriously, change me, pwgen 40 1 is good ;) )";
......
...@@ -41,7 +41,7 @@ if ($found==6 && $_POST["url"]=="") { ...@@ -41,7 +41,7 @@ if ($found==6 && $_POST["url"]=="") {
} }
if (count($error)==0) { if (count($error)==0) {
// Does it exist? // Does it exist?
$already=@mysql_fetch_assoc(mysql_query("SELECT * FROM accounts WHERE id='".$id."';")); $already=@mysqli_fetch_assoc(mysqli_query($db,"SELECT * FROM accounts WHERE id='".$id."';"));
if (!$already) { if (!$already) {
$error[]=sprintf(_("This account doesn't exist, or have been permanently destroyed. <a href=\"%s\">Click here to create a new account with this login</a>."),"create.php"); $error[]=sprintf(_("This account doesn't exist, or have been permanently destroyed. <a href=\"%s\">Click here to create a new account with this login</a>."),"create.php");
} }
......
...@@ -47,19 +47,19 @@ if ($found==6 && $_POST["url"]=="") { ...@@ -47,19 +47,19 @@ if ($found==6 && $_POST["url"]=="") {
if (count($error)==0) { if (count($error)==0) {
sleep(5); // Let create some artificial waiting for the one who want to create many accounts ... sleep(5); // Let create some artificial waiting for the one who want to create many accounts ...
// Try to create the account. // Try to create the account.
$already=@mysql_fetch_assoc(mysql_query("SELECT id FROM accounts WHERE jabberid='".addslashes($_POST["login"]."@".$domain)."';")); $already=@mysqli_fetch_assoc(mysqli_query($db, "SELECT id FROM accounts WHERE jabberid='".addslashes($_POST["login"]."@".$domain)."';"));
if ($already) { if ($already) {
$error[]=_("This account already exist, or is disabled. You can't create that login now, please find another one!"); $error[]=_("This account already exist, or is disabled. You can't create that login now, please find another one!");
} }
if (count($error)==0) { if (count($error)==0) {
mysql_query("INSERT INTO accounts SET jabberid='".addslashes($_POST["login"]."@".$domain)."', createdate=NOW(), email='".hashmail(trim($_POST["email"]))."', ack=0;"); mysqli_query($db, "INSERT INTO accounts SET jabberid='".addslashes($_POST["login"]."@".$domain)."', createdate=NOW(), email='".hashmail(trim($_POST["email"]))."', ack=0;");
// Connect to the telnet console of prosody. // Connect to the telnet console of prosody.
$f=fsockopen("localhost",5582,$errno,$errstr,5); $f=fsockopen("localhost",5582,$errno,$errstr,5);
if (!$f) { if (!$f) {
$error[]=_("Can't connect to jabber server"); $error[]=_("Can't connect to jabber server");
mysql_query("DELETE FROM accounts WHERE jabberid='".addslashes($_POST["login"]."@".$domain)."';"); mysqli_query($db, "DELETE FROM accounts WHERE jabberid='".addslashes($_POST["login"]."@".$domain)."';");
} else { } else {
for($i=0;$i<$pass_line_count_telnet;$i++) { for($i=0;$i<$pass_line_count_telnet;$i++) {
$s=fgets($f,1024); $s=fgets($f,1024);
...@@ -69,7 +69,7 @@ if ($found==6 && $_POST["url"]=="") { ...@@ -69,7 +69,7 @@ if ($found==6 && $_POST["url"]=="") {
$s=fgets($f,1024); $s=fgets($f,1024);
if ($debug) echo ":".$s.":<br>"; if ($debug) echo ":".$s.":<br>";
if (trim($s)=="| OK: User created") { if (trim($s)=="| OK: User created") {
mysql_query("UPDATE accounts SET ack=1 WHERE jabberid='".addslashes($_POST["login"]."@".$domain)."';"); mysqli_query($db, "UPDATE accounts SET ack=1 WHERE jabberid='".addslashes($_POST["login"]."@".$domain)."';");
$info[]=_("Your account has been created successfully. You can use it immediately."); $info[]=_("Your account has been created successfully. You can use it immediately.");
unset($_POST); unset($_POST);
unset($_REQUEST); unset($_REQUEST);
...@@ -77,7 +77,7 @@ if ($found==6 && $_POST["url"]=="") { ...@@ -77,7 +77,7 @@ if ($found==6 && $_POST["url"]=="") {
exit(); exit();
} else { } else {
if ($debug) { $s=fgets($f,1024); echo ":".$s.":<br>"; } if ($debug) { $s=fgets($f,1024); echo ":".$s.":<br>"; }
mysql_query("DELETE FROM accounts WHERE jabberid='".addslashes($_POST["login"]."@".$domain)."';"); mysqli_query($db, "DELETE FROM accounts WHERE jabberid='".addslashes($_POST["login"]."@".$domain)."';");
$error[]=_("An error occurred trying to create your account, please try again later"); $error[]=_("An error occurred trying to create your account, please try again later");
// TODO : send an email to us ;) // TODO : send an email to us ;)
} }
......
...@@ -43,7 +43,7 @@ if ($found==5 && $_POST["url"]=="") { ...@@ -43,7 +43,7 @@ if ($found==5 && $_POST["url"]=="") {
if (count($error)==0) { if (count($error)==0) {
sleep(5); // Let create some artificial waiting for the one who want to restore many accounts ... sleep(5); // Let create some artificial waiting for the one who want to restore many accounts ...
// Does it exist? // Does it exist?
$already=@mysql_fetch_assoc(mysql_query("SELECT * FROM accounts WHERE jabberid='".addslashes($_POST["login"]."@jabber.lqdn.fr")."';")); $already=@mysqli_fetch_assoc(mysqli_query($db, "SELECT * FROM accounts WHERE jabberid='".addslashes($_POST["login"]."@jabber.lqdn.fr")."';"));
if (!$already) { if (!$already) {
$error[]=sprintf(_("This account doesn't exist, or have been permanently destroyed. <a href=\"%s\">Click here to create a new account with this login</a>."),"create.php"); $error[]=sprintf(_("This account doesn't exist, or have been permanently destroyed. <a href=\"%s\">Click here to create a new account with this login</a>."),"create.php");
} }
...@@ -86,7 +86,7 @@ if (isset($_GET["id"]) && isset($_GET["key"])) { ...@@ -86,7 +86,7 @@ if (isset($_GET["id"]) && isset($_GET["key"])) {
} }
if (count($error)==0) { if (count($error)==0) {
// Does it exist? // Does it exist?
$already=@mysql_fetch_assoc(mysql_query("SELECT * FROM accounts WHERE id='".$id."';")); $already=@mysqli_fetch_assoc(mysqli_query($db, "SELECT * FROM accounts WHERE id='".$id."';"));
if (!$already) { if (!$already) {
$error[]=sprintf(_("This account doesn't exist, or have been permanently destroyed. <a href=\"%s\">Click here to create a new account with this login</a>."),"create.php"); $error[]=sprintf(_("This account doesn't exist, or have been permanently destroyed. <a href=\"%s\">Click here to create a new account with this login</a>."),"create.php");
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment