112 lines
2.9 KiB
PHP
Executable file
112 lines
2.9 KiB
PHP
Executable file
<?php
|
|
// https://uichi.ortiche.net/index.php/Strutture_dati_di_posta
|
|
// version: 0.2
|
|
require_once('include/Database.php');
|
|
require_once('include/util.php');
|
|
require_once('include/localization.php');
|
|
require_once('include/template.php');
|
|
|
|
$err=$user=$email="";
|
|
$type="-1";
|
|
//$rasplice_url="http://rasplice.contaminati.net/cgi-bin/rasplice.txt";
|
|
$rasplice_url="http://rasplice.contaminati.net/i2rasplice/";
|
|
$indivia24hdomain="@24h.indivia.net";
|
|
$db=Database::getInstance('std');
|
|
|
|
function getSqlNumOfAlias($alias_tab,$alias_nic){
|
|
$sql = "SELECT count(*)
|
|
FROM $alias_tab
|
|
WHERE user = '$alias_nic'
|
|
AND active = 'Y'";
|
|
return $sql;
|
|
}
|
|
|
|
function getSqlCreateAlias($alias_tab, $alias_nic,$alias_dom,$goto_email,$timo){
|
|
$sql = "INSERT INTO $alias_tab (user, domain, active, tipo, goto, modified, md5salt, deleted)
|
|
VALUES ('$alias_nic', '$alias_dom', 'Y', 'alias', '$goto_email', '$timo','','0')";
|
|
|
|
return $sql;
|
|
}
|
|
|
|
function getSqlAliasInfo($goto_email){
|
|
$sql = "SELECT user
|
|
FROM 24h_indivia_net
|
|
WHERE goto = '$goto_email'
|
|
AND active = 'Y'";
|
|
|
|
return $sql;
|
|
}
|
|
|
|
//aliasing..
|
|
if (isset($_POST["ph"]) AND
|
|
$_POST["ph"]=="1" AND
|
|
$_POST['email'] != "") {
|
|
$goto_email_noescape = $_POST['email'];
|
|
$goto_email = $db->escapeString($goto_email_noescape);
|
|
|
|
if (email_check($goto_email)) {
|
|
//solo l'email alias deve non essere presente.
|
|
do {
|
|
$alias_nic = preg_replace('/\s+/', '', get_data($rasplice_url.rand()));
|
|
if($alias_nic===FALSE)
|
|
$alias_nic="email_".rand(10000,99999);
|
|
$alias_dom = substr($indivia24hdomain,1);
|
|
$alias_email = $alias_nic.$indivia24hdomain;
|
|
$alias_dom2lvl = dom($alias_dom);
|
|
$alias_tab = str_replace(".","_",$alias_dom2lvl);
|
|
$res = $db->isThereAlready(getSqlNumOfAlias($alias_tab,$alias_nic));
|
|
} while ($res != FALSE);
|
|
|
|
$timo=time();
|
|
$ret=$db->execQuery(getSqlCreateAlias($alias_tab,$alias_nic,$alias_dom,$goto_email,$timo));
|
|
if ($ret == 1) {
|
|
header("location: index.php?ph=2&email=".$goto_email."&lang=".$lang);
|
|
} else {
|
|
$type=1;
|
|
$err=$msgAliasErr;
|
|
}
|
|
} else {
|
|
$type=1;
|
|
$err=$msgEmailValidErr;
|
|
}
|
|
} elseif (isset($_GET["ph"]) AND
|
|
$_GET['ph'] == 2 AND
|
|
isset($_GET['email'])) {
|
|
|
|
$goto_email_noescape = $_GET['email'];
|
|
$goto_email = $db->escapeString($goto_email_noescape);
|
|
$rows = $db->select(getSqlAliasInfo($goto_email));
|
|
$row = mysqli_fetch_row($rows);
|
|
if ($row[0] != "") {
|
|
$type=2;
|
|
$user=$row[0];
|
|
$email=$goto_email;
|
|
} else {
|
|
$type=1;
|
|
$err=$msgNoEmailFoundErr;
|
|
}
|
|
} else {
|
|
$type=0;
|
|
}
|
|
|
|
if($type>-1) {
|
|
printHead($type);
|
|
printLangSelector();
|
|
printTitle($title);
|
|
switch ($type) {
|
|
case 0:
|
|
printForm($form_goto_email, $lang);
|
|
break;
|
|
case 1:
|
|
printMessage($err);
|
|
break;
|
|
case 2:
|
|
printMessage($msgAliasDonePart1).
|
|
printBold($user.$indivia24hdomain).
|
|
printMessage($msgAliasDonePart2).
|
|
printBold($email);
|
|
break;
|
|
}
|
|
}
|
|
|
|
?>
|