Viewing file: subscribers.php (9.33 KB) -rw-rw-rw- Select action/file-type: (+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) |
<?
echo "
<script language='javascript' type='text/javascript'>
function Submitform()
{
if (document.sub.add_addr.value=='') alert(\"".translate("EMAIL_ADDRESS_NOT_VALID").".\");
else
{
if ( ((document.sub.add_addr.value.indexOf('@',1))==-1)||(document.sub.add_addr.value.indexOf('.',1))==-1 )
alert(\"".translate("EMAIL_ADDRESS_NOT_VALID")."\");
else document.sub.submit();
}
}
</script>";
//include("include/REF_sub.php");
/** ADD **/
if($op=="add"){
$add_addr = (empty($_POST['add_addr']) ? "" : $_POST['add_addr']);
if(!empty($add_addr)){
$add_r=add_subscriber($conf->db_host, $conf->db_login, $conf->db_pass, $conf->db_name, $conf->table_email,$list_id,$add_addr);
if($add_r==0)
echo "<div align='center' class='error'>".translate("ERROR_ADDING_SUBSCRIBER"," <b>$add_addr</b>").".</div>";
else if($add_r==-1)
echo "<div align='center' class='error'>".translate("ERROR_ALREADY_SUBSCRIBER", "<b>$add_addr</b>").".</div>";
else
echo "<div align='center' class='success'>".translate("SUBSCRIBER_ADDED", "<b>$add_addr</b>").".</div>";
}
else
echo "<div align='center' class='error'>".translate("ERROR_SUPPLY_VALID_EMAIL")."</div>";
}
/** DELETE **/
if($op=="del"){
$del_addr = (empty($_POST['del_addr']) ? "" : $_POST['del_addr']);
$deleted =delete_subscriber($conf->db_host, $conf->db_login, $conf->db_pass, $conf->db_name, $conf->table_email,$list_id,$del_addr);
if( $deleted)
echo success_msg(translate("SUBSCRIBER_DELETED"));
else
echo error_msg(translate("ERROR_DELETING_SUBSCRIBER","<i>$del_addr</i>"));
}
if($op=="import"){
$import_file = (!empty($_FILES['import_file']) ? $_FILES['import_file'] : "");
if (!empty($import_file) && $import_file != "none" &&
$import_file['size'] > 0 && is_uploaded_file($import_file['tmp_name'])) {
$tmp_subdir_writable = 1;
$open_basedir = @ini_get('open_basedir');
if (!empty($open_basedir)) {
$tmp_subdir = (DIRECTORY_SEPARATOR == "/" ? "./import/" : ".\\import\\");
if(! is_writable($tmp_subdir)){
$tmp_subdir_writable = 0;
} else {
$local_filename = $tmp_subdir.basename($import_file['tmp_name']);
move_uploaded_file($import_file['tmp_name'], $local_filename);
$liste = fread(fopen($local_filename, "r"), filesize($local_filename));
unlink($local_filename);
}
} else {
$liste = fread(fopen($import_file['tmp_name'], "r"), filesize($import_file['tmp_name']));
}
if($tmp_subdir_writable){
$liste=ereg_replace("\n|\r|\n\r","\n",$liste);
$liste = explode( "\n",$liste);
for($i=0; $i<sizeof($liste); $i++){
/* Ajouter un nouvel enregistrement dans la table */
$liste[$i]=trim($liste[$i]);
if(!empty($liste[$i])){
$added=add_subscriber($conf->db_host, $conf->db_login, $conf->db_pass, $conf->db_name, $conf->table_email,$list_id,$liste[$i]);
if($added==-1)
echo "<div align='center' class='error'>".translate("ERROR_ALREADY_SUBSCRIBER", "<b>$liste[$i]</b>").".<br/ > </div>";
elseif($added==1)
echo "<div align='center' class='successimport'>".translate("SUBSCRIBER_ADDED", "<b>$liste[$i]</b>").".</div>";
elseif($added==-2)
echo "<div align='center' class='error'>".translate("ERROR_SQL", DbError())."<br></div>";
}
elseif ($i == 0){ //protection against trailing empty line
echo "<div align='center' class='error'>".translate("ERROR_NO_EMAIL_IN_FILE")."<br></div>";
}
}
echo "<br />";
} else {
echo "<div align='center' class='error'>".translate("ERROR_IMPORT_TMPDIR_NOT_WRITABLE")." !<br></div>";
}
}
else
echo "<div align='center' class='error'>".translate("ERROR_IMPORT_FILE_MISSING")." !<br></div>";
}
$subscribers=get_subscribers($conf->db_host, $conf->db_login, $conf->db_pass, $conf->db_name, $conf->table_email,$list_id);
echo "<div class='subsection'>";
echo "<div class='subtitle'>".translate("SUBSCRIBER_ADD_TITLE")."</div>";
echo "<div class='subcontent'>";
echo "<form method='post' name='sub' class='form-light' action=''>
<input type='hidden' name='op' value='add' />
<input type='hidden' name='action' value='manage' />
<input type='hidden' name='page' value='subscribers' />
<input type='hidden' name='list_id' value='$list_id' />
<input type='text' name='add_addr' value='' maxlength='250' size='30' />
<input type='button' value='".translate("SUBSCRIBER_ADD_BTN")."' onclick='Submitform()' />
</form>";
echo "</div>";
echo "</div> <br /> <br />";
/** IMPORT **/
echo "<div class='subsection'>";
echo "<div class='subtitle'>".translate("SUBSCRIBER_IMPORT_TITLE")."</div>";
echo "<div class='subcontent'>";
echo "<form action=''
method='post' enctype='multipart/form-data' name='importform' class='form-light'>
<script language='javascript' type='text/javascript'>
function Soumettre()
{
document.importform.import_file.value=document.importform.insert_file.value;
document.importform.submit();
}
</script>
<input type='file' name='import_file' />
<input type='submit' value='".translate("SUBSCRIBER_IMPORT_BTN")."' />
<input type='hidden' name='op' value='import' />
<input type='hidden' name='page' value='subscribers' />
<input type='hidden' name='list_id' value='$list_id' />";
echo "<div class='info_left'>".translate("SUBSCRIBER_IMPORT_HELP")."</div></form>";
echo "</div>";
echo "</div> <br /> <br />";
if(sizeof($subscribers)){
echo "<div class='subsection'>";
echo "<div class='subtitle'>".translate("SUBSCRIBER_DELETE_TITLE")."</div>";
echo "<div class='subcontent'>";
echo "\t<form action='index.php' method='post' class='form-light'>\n";
echo "\t\t<input type='hidden' name='op' value='del' />\n";
echo "\t\t<input type='hidden' name='action' value='manage' />\n";
echo "\t\t<input type='hidden' name='page' value='subscribers' />\n";
echo "\t\t<input type='hidden' name='list_id' value='$list_id' />\n";
echo "\t\t<select name='del_addr'>\n";
for($i=0; $i<sizeof($subscribers); $i++){
echo "\t\t\t<option value='".$subscribers[$i]."' ";
echo ">".$subscribers[$i]."</option>\n";
}
echo "\t\t</select>\n";
echo "\t\t<input type='submit' value='".translate("SUBSCRIBER_DELETE_BTN")."' />\n";
echo "\t</form>\n";
echo "</div>";
echo "</div> <br /> <br />";
}
/** EXPORT **/
if(sizeof($subscribers)){
echo "<div class='subsection'>";
echo "<div class='subtitle'>".translate("SUBSCRIBER_EXPORT_TITLE")."</div>";
echo "<div class='subcontent'>";
echo "<form action='export.php' method='post' class='form-light'>";
if(sizeof($subscribers))
{
echo "<input type='hidden' name='op' value='export' />
<input type='hidden' name='action' value='manage' />
<input type='hidden' name='page' value='subscribers' />
<input type='hidden' name='list_id' value='$list_id' />
<input type='hidden' name='db_pass' value='".$conf->db_pass."' />
<input type='hidden' name='db_login' value='".$conf->db_login."' />
<input type='hidden' name='db_host' value='".$conf->db_host."' />
<input type='hidden' name='db_name' value='".$conf->db_name."' />
<input type='hidden' name='table_email' value='".$conf->table_email."' />
<input type='hidden' name='db_type' value='".$db_type."' />
<div align='center'><input type='submit' name='Submit' value='".translate("SUBSCRIBER_EXPORT_BTN")."' /></div>";
}
else
echo info_msg("NO_SUBSCRIBER")."<br />\n";
echo "</form>";
echo "</div>";
echo "</div> <br /> <br />";
}
if($op=="del_temp"){
$del_tmpaddr = (empty($_POST['del_tmpaddr']) ? "" : $_POST['del_tmpaddr']);
$deleted_temp =delete_subscriber($conf->db_host, $conf->db_login, $conf->db_pass, $conf->db_name, $conf->table_temp,$list_id,$del_tmpaddr);
if( $deleted_temp )
echo success_msg(translate("SUBSCRIBER_TEMP_DELETED"));
else
echo error_msg(translate("ERROR_DELETING_TEMP","<i>$del_tmpaddr</i>"));
}
$tmp_subscribers=get_subscribers($conf->db_host, $conf->db_login, $conf->db_pass, $conf->db_name, $conf->table_temp,$list_id);
if(sizeof($tmp_subscribers)){
echo "<div class='subsection'>";
echo "<div class='subtitle'>".translate("SUBSCRIBER_TEMP_TITLE")."</div>";
echo "<div class='subcontent'>";
echo "\t<form action='index.php' method='post' class='form-light'>\n";
echo "\t\t<input type='hidden' name='op' value='del_temp'>\n";
echo "\t\t<input type='hidden' name='action' value='manage'>\n";
echo "\t\t<input type='hidden' name='page' value='subscribers'>\n";
echo "\t\t<input type='hidden' name='list_id' value='$list_id'>\n";
echo "\t\t<select name='del_tmpaddr'>\n";
for($i=0; $i<sizeof($tmp_subscribers); $i++){
echo "\t\t\t<option value='".$tmp_subscribers[$i]."' ";
echo ">".$tmp_subscribers[$i]."</option>\n";
}
echo "\t\t</select>\n";
echo "\t\t<input type='submit' value='".translate("SUBSCRIBER_TEMP_BTN")."'>\n";
echo "\t</form>\n";
echo "</div>";
echo "</div> <br /> <br />";
}
?>
|