Viewing file: index.php (9.8 KB) -rw-rw-rw- Select action/file-type: (+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) |
<?
if(!file_exists("../include/config.php"))
{
header("Location:../install.php");
exit;
}
include("../include/config.php");
include("../include/lib/libconfig.php");
include("../include/db/db_".$db_type.".inc.php");
include("../include/interface.php");
include("../include/lib/libnewsletter.php");
//admin specific functions
include("include/function.php");
$conf = new config();
$op = (empty($_GET['op']) ? "" : $_GET['op']);
$op = (empty($_POST['op']) ? $op : $_POST['op']);
$list_id = (empty($_GET['list_id']) ? "" : $_GET['list_id']);
$list_id = (empty($_POST['list_id']) ? $list_id : $_POST['list_id']);
$action = (empty($_GET['action']) ? "" : $_GET['action']);
$action = (empty($_POST['action']) ? $action : $_POST['action']);
$page = (empty($_GET['page']) ? "subscribers" : $_GET['page']);
$page = (empty($_POST['page']) ? $page : $_POST['page']);
$error_list=false;
if($op=="saveGlobalconfig") {
$smtp_host = (isset($_POST['smtp_host']) ? $_POST['smtp_host'] : '');
$smtp_auth = (isset($_POST['smtp_auth']) ? $_POST['smtp_auth'] : 0);
$smtp_login = (isset($_POST['smtp_login']) ? $_POST['smtp_login'] : '');
$smtp_pass = (isset($_POST['smtp_pass']) ? $_POST['smtp_pass'] : '');
$mod_sub = (isset($_POST['mod_sub']) ? $_POST['mod_sub'] : 0);
if($conf->saveConfig($_POST['db_host'], $_POST['db_login'] ,$_POST['db_pass'],
$_POST['db_name'], $_POST['table_config'],
$_POST['admin_pass'], 50 , $_POST['base_url'],
$_POST['path'], $_POST['language'], $_POST['table_email'],
$_POST['table_temp'], $_POST['table_listsconfig'],
$_POST['table_archives'], $_POST['sending_method'],
$smtp_host, $smtp_auth, $smtp_login,
$smtp_pass,$_POST['sending_limit'], $_POST['validation_period'],
$_POST['sub_validation'], $_POST['unsub_validation'],
$_POST['admin_email'], $_POST['admin_name'], $_POST['mod_sub'],
$_POST['table_sub'], $_POST['charset']
))
$configSaved=true;
else $configSaved=false;
if($_POST['file']==1){
$configFile = saveConfigFile($_POST['db_host'], $_POST['db_login'], $_POST['db_pass'], $_POST['db_name'], $_POST['table_config']);
$forceUpdate = 1;
include("../include/config.php");
unset($forceUpdate);
}
}
$r = $conf->getConfig($hostname,$login,$pass,$database, $table_global_config);
if ( $r != 'SUCCESS'){
include("../include/lang/english.php");
echo "<div class='error'>".translate($r)."<br>";
echo "</div>";
exit;
}
if(empty($conf->language)) $conf->language="english";
include("../include/lang/".$conf->language.".php");
/*** LOGIN CHECK ***/
$form_pass = (empty($_POST['form_pass']) ? "" : $_POST['form_pass']);
if(!isset($form_pass) || $form_pass== "") $form_pass = (empty($_GET['form_pass']) ? "" : $_GET['form_pass']);
if(!checkAdminAccess($conf->admin_pass, $form_pass)){
if(!empty($_POST['form']) && $_POST['form']) header("Location:login.php?error=1");
else header("Location:login.php");
exit;
}
/* deleting a newsletter*/
if($action =="delete" && $page =="newsletterconf"){
$deleted = deleteNewsletter($conf->db_host, $conf->db_login, $conf->db_pass,$conf->db_name,
$conf->table_listsconfig, $conf->table_archives,
$conf->table_email, $conf->table_temp, $list_id);
}
$newsletter = new Newsletter();
/* saving the configuration */
if($op=="SaveConfig"){
$save = $newsletter->saveConfig($conf->db_host, $conf->db_login, $conf->db_pass,
$conf->db_name, $_POST['list_id'], $conf->table_listsconfig,
$_POST['newsletter_name'], $_POST['from'],
$_POST['from_name'], $_POST['subject'],
$_POST['header'], $_POST['footer'],
$_POST['subscription_subject'],
$_POST['subscription_body'],$_POST['welcome_subject'],
$_POST['welcome_body'],
$_POST['quit_subject'], $_POST['quit_body']);
}
/* adding a new newsletter */
if($op=="createConfig"){
$new_id=createNewsletter($conf->db_host, $conf->db_login, $conf->db_pass,
$conf->db_name, $conf->table_listsconfig, $_POST['newsletter_name'],
$_POST['from'], $_POST['from_name'],
$_POST['subject'], $_POST['header'], $_POST['footer'],
$_POST['subscription_subject'], $_POST['subscription_body'],
$_POST['welcome_subject'], $_POST['welcome_body'],
$_POST['quit_subject'], $_POST['quit_body']);
if($new_id>0) $list_id=$new_id;
}
$list_name=-1;
if(!empty($list_id)){
$list_name=get_newsletter_name($conf->db_host, $conf->db_login, $conf->db_pass, $conf->db_name, $conf->table_listsconfig,$list_id);
if($list_name==-1) unset($list_id);
}
$list = list_newsletter($conf->db_host, $conf->db_login, $conf->db_pass,
$conf->db_name, $conf->table_listsconfig);
if(empty($list_id)) $list_id=get_first_newsletter_id($conf->db_host, $conf->db_login,
$conf->db_pass,
$conf->db_name, $conf->table_listsconfig);
//no newsletter available, so let's configure the first one !
if(sizeof($list) == 0 && $page != "config") {
$page = "newsletterconf";
$action = "create";
}
$list_total_subscribers = get_newsletter_total_subscribers($conf->db_host, $conf->db_login, $conf->db_pass, $conf->db_name, $conf->table_email,$list_id);
include("include/pageheader.inc.php");
if(!flushTempTable($conf->db_host, $conf->db_login,
$conf->db_pass, $conf->db_name,
$conf->table_temp, $conf->validation_period)){
echo error_msg(translate("ERROR_FLUSHING_TEMP_TABLE",$conf->table_temp));
}
else echo "<br /> ";
switch($page){
/* archives section */
case "archives":
require 'include/archives.php';
break;
/* phpmynewsletter global configuration section */
case "config":
require 'include/globalconf.php';
break;
/* write a new message and send it*/
case "compose":
require('include/compose.php');
break;
/* managing newsletter */
/* TODO: this section really need refactoring */
case "newsletterconf":
if(!sizeof($list)) {
$action = "create";
}
if(sizeof($list)){
echo " <script language='javascript' type='text/javascript'>
function deleteNews() {
var is_confirmed = confirm(\"".translate("NEWSLETTER_DELETE_WARNING")." ?\");
if (is_confirmed) {
document.newsletter_list.action.value = 'delete';
document.newsletter_list.list_id.value=document.selected_newsletter.list_id.value;
document.newsletter_list .submit();
}
return is_confirmed;
}
</script>";
echo " <script language='javascript' type='text/javascript'>
function createNews() {
document.newsletter_list.elements['action'].value = 'create';
document.newsletter_list.submit();
}
</script>";
if($action!="create"){
echo "<div class='subsection'>";
echo "<div class='subtitle'>".translate("NEWSLETTER_ACTION")."</div>";
echo "<div class='subcontent'>";
echo "\t<form action='index.php' method='post' name='newsletter_list' class='form-light'>\n";
echo "\t\t<input type='button' value=\"".translate("NEWSLETTER_NEW")."\" onclick='createNews()' /><br/> <br />\n";
if($action != "delete") echo "\t\t<input type='button' value=\"".translate("NEWSLETTER_DEL", htmlspecialchars($list_name))."\" onclick='deleteNews()' />\n";
echo "\t\t<input type='hidden' name='page' value='newsletterconf' />";
echo "\t\t<input type='hidden' name='action' value='' />";
echo "\t\t<input type='hidden' name='list_id' value='' />";
echo "\t</form>\n";
echo "</div>";
echo "</div> <br /> <br />";
}
}
if($action=="create"){
echo "<div class='subsection'>";
echo "<div class='subtitle'>".translate("NEWSLETTER_CREATE")."</div>";
echo "<div class='subcontent'>";
echo "<form action='' method='post' class='form-light'>";
echo "<input type='hidden' name='op' value='createConfig' />";
require "include/newsletters_config.php";
echo "</div>";
echo "</div> <br /> <br />";
}
if(isset($list_id) && !empty($list_id)){
if($action=="delete"){
if($deleted) {
echo "<div class='success'>".translate("NEWSLETTER_DELETED").".</div>";
} else {
echo "<div class='error'>".translate("ERROR_DELETING_NEWSLETTER").".</div>";
}
}
if(empty($action)){
if($op=="SaveConfig"){
if($save) echo "<div align='center' class='success'>".translate("NEWSLETTER_SETTINGS_SAVED")."</div>";
else echo "<div align='center' class='error'>".translate("ERROR_SAVING_SETTINGS", "<br />".DbError())."</div>";
}
if($op=="createConfig") {
if($new_id){
echo "<div class='success'>".translate("NEWSLETTER_SETTINGS_CREATED").".</div>";
} else {
echo "<div class='error'>".translate("ERROR_SAVING_SETTINGS"," : <br />".DbError())."</div>";
}
}
echo "<div class='subsection'>";
echo "<div class='subtitle'>".translate("NEWSLETTER_SETTINGS")."</div>";
echo "<div class='subcontent'>";
echo "<form action='' method='post' class='form-light'>";
echo "<input type='hidden' name='op' value='SaveConfig' />";
echo "<input type='hidden' name='list_id' value='$list_id' />\n";
$newsletter->getConfig($conf->db_host, $conf->db_login, $conf->db_pass,
$conf->db_name, $list_id,$conf->table_listsconfig);
require "include/newsletters_config.php";
echo "</div>";
echo "</div> <br /> <br />";
}
}
break;
/* Add/delete subscribers section*/
case "subscribers":
default:
require("include/subscribers.php");
break;
}
include("include/pagefooter.inc.php");
?>
|