Viewing file: interface.php (7.73 KB) -rw-rw-rw- Select action/file-type: (+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) |
<?
function getLanguageList($selected , $basedir="./"){
$ret = "";
$langfiles = array();
if ($handle = opendir($basedir."/include/lang/")) {
while (false !== ($file = readdir($handle))) {
if ($file != "." && $file != ".." && eregi("([a-z_]+)[.]php$", $file, $match)) {
array_push( $langfiles , str_replace("_"," ",$match[1]));
}
}
closedir($handle);
}
asort($langfiles);
foreach($langfiles as $value){
$ret.= "\t<option value='$value' ".($selected == $value ? 'selected' : '').">".ucfirst($value)."</option>\n";
}
return $ret;
}
function success_msg($msg)
{
pmnl_msg($msg,"success");
}
function info_msg($msg)
{
pmnl_msg($msg,"info");
}
function error_msg($msg)
{
pmnl_msg($msg,"error");
}
function pmnl_msg($msg, $class, $align='center')
{
echo "<div align=\"$align\" class=\"$class\">$msg</div>";
}
function list_newsletter($host, $login, $pass, $database, $lists_table)
{
$db= new Db();
$db->DbConnect($host, $login, $pass, $database);
$db->DbQuery("SELECT list_id , newsletter_name FROM $lists_table ORDER BY list_id ASC");
$newsletter = array();
for($i=0;$i< $db->DbNumRows();$i++)
$newsletter[$i] = $db->DbNextRow();
return $newsletter;
}
function get_newsletter_name($host, $login, $pass, $database, $lists_table, $list_id)
{
$db= new Db();
$db->DbConnect($host, $login, $pass, $database);
$db->DbQuery("SELECT newsletter_name FROM $lists_table WHERE list_id = '$list_id'");
if($db->DbNumRows()==0) return -1;
$name = $db->DbNextRow();
return $name[0];
}
function get_newsletter_total_subscribers($host, $login, $pass, $database, $email_table, $list_id){
$db= new Db();
$db->DbConnect($host, $login, $pass, $database);
$db->DbQuery("SELECT COUNT( email ) FROM $email_table WHERE list_id ='$list_id'");
$count = $db->DbNextRow();
return $count[0];
}
function get_first_newsletter_id($host, $login, $pass, $database, $lists_table){
$db= new Db();
$db->DbConnect($host, $login, $pass, $database);
$db->DbQuery("SELECT list_id FROM $lists_table LIMIT 1");
if($db->DbNumRows()==0) return '';
$first_id = $db->DbNextRow();
return $first_id[0];
}
function html_header($title='', $css='phpmynewsletter.css'){
header("Content-type: text/html; charset=utf-8");
echo <<<EOT
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link rel="stylesheet" href="$css" type="text/css" />
<title>$title</title>
</head>
<body>
EOT;
}
function html_footer()
{
echo "<br /><div align='center'><a href='http://gregory.kokanosky.free.fr/phpmynewsletter/' target='_blank'><img src='img/button_pmnl.png' alt='logo pmnl' title='powered by phpMyNewsletter' border='0' /></a></div>";
echo "</body></html>";
}
function page_header()
{
echo " <table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" align=\"center\" width=\"90%\">
<tbody>
<tr>
<td rowspan=\"3\" align=\"center\" valign=\"top\" width=\"20\">
<br />
</tr>
<tr>
<td>
</td>
</tr>
<tr>
<td>
<table cellpadding=\"0\" cellspacing=\"0\" border=\"0\" width=\"100%\">
<tbody><tr>
<td bgcolor=\"black\" width=\"1\"><img src=\"img/clear.gif\" width=\"1\" height=\"1\" alt=\"\"></td>
<td bgcolor=\"white\">
<br />";
}
function page_footer()
{
echo " <br />
</td>
<td bgcolor=\"black\" width=\"1\"><img src=\"img/clear.gif\" width=\"1\" height=\"1\" alt=\"\"></td>
</tr>
<tr>
<td colspan=\"3\" bgcolor=\"black\"><img src=\"img/clear.gif\" width=\"1\" height=\"1\" alt=\"\"></td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table><br />";
}
function table_header()
{
echo "<table width=\"70%\" cellspacing=0 border=0 cellpadding=0 align=\"center\">\n";
}
function table_title($title)
{
echo "\t<tr><td width=\"100%\" class=\"titreSection\">$title</td></tr>\n";
echo "\t<tr><td width=\"100%\"><img alt=\"--\" src=\"img/line.gif\" width=\"100%\" height=\"2\"><br /> </td></tr>\n";
}
function table_footer()
{
echo "</table>\n";
}
function newsletter_list($list_id="", $popup=false, $display_archive=true){
global $hostname, $login ,$pass,$database, $table_global_config;
global $lang_array;
$conf = new config();
$r = $conf->getConfig($hostname,$login ,$pass,$database, $table_global_config);
if ( $r != 'SUCCESS'){
include("include/lang/english.php");
echo translate($r);
exit;
}
if( $conf->language != "" && file_exists("include/lang/".$conf->language.".php")){
include("include/lang/".$conf->language.".php");
} else {
include("include/lang/english.php");
}
$list = list_newsletter($conf->db_host, $conf->db_login, $conf->db_pass, $conf->db_name, $conf->table_listsconfig);
if(sizeof($list)){
echo <<<EOT
<script language="JavaScript1.2" type="text/javascript">
function submitform() {
if (document.sub_form.email_addr.value=='')
EOT;
echo"\n alert(\"".translate("EMAIL_ADDRESS_NOT_VALID")."\");\n";
echo <<<EOT
else {
if ( ((document.sub_form.email_addr.value.indexOf('@',1))==-1)||(document.sub_form.email_addr.value.indexOf('.',1))==-1 )
EOT;
echo"\n alert(\"".translate("EMAIL_ADDRESS_NOT_VALID")."\");\n";
echo "
else {";
if($popup){ echo "
window.open(\"\", \"formPopup\", \"toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0,height=200,width=500,toolbar=no\", true);
document.sub_form.target='formPopup';";
}
echo "
document.sub_form.submit();
}
}
}
</script><br />
";
echo "<div class='content'>";
echo "<form action=\"subscription.php\" method=\"post\" name=\"sub_form\"".($popup ? " target=\"formPopup\"" : "")." onsubmit=\"submitform();false;\">
<input type=\"text\" size=\"".($popup ? "15" : "25")."\" name=\"email_addr\" value=\"".translate("EMAIL_ADDRESS")."\" onfocus=\"if (this.value=='".translate("EMAIL_ADDRESS")."') this.value=''\" />
<input type=\"button\" name=\"sub\" value=\" O K \" onclick=\"submitform()\" /><br />\n
<input type=\"radio\" class='radio' name=\"op\" value=\"join" ;
if(!$conf->sub_validation) echo "_direct";
echo "\" checked=\"checked\" /> ".translate("NEWSLETTER_SUBSCRIPTION")."\n";
echo "\t\t<input type=\"radio\" class='radio' name=\"op\" value=\"leave";
if(!$conf->unsub_validation) echo "_direct";
echo "\" /> ".translate("NEWSLETTER_UNSUBSCRIPTION");
if(sizeof($list) > 1 && empty($list_id)){
echo "<br />";
echo translate("AVAILABLE_NEWSLETTER");
echo "\n<select name=\"list_id\">\n";
for($i=0; $i<sizeof($list); $i++){
echo "\t\t\t<option value=\"".$list[$i]['list_id']."\" ";
if(!empty($_GET['list_id'])){
if ($_GET['list_id']==$list[$i]['list_id']) echo "selected ";
}
echo ">".$list[$i]['newsletter_name']."</option>\n";
}
echo "</select>\n";
} else {
$tid = (empty($list_id) ? $list[0]['list_id'] : $list_id);
echo "<input type='hidden' name='list_id' value='$tid'>";
}
echo "<input type='hidden' name='popup' value=\"".($popup ? "_popup" : "")."\">";
echo "\t</form>\n";
if( $display_archive){ echo "<div align=\"center\"><a href=\"archives.php\">".translate("ARCHIVE_BROWSE")."</a></div>"; }
echo "</div>";
} else echo error_msg(translate("NEWSLETTER_NOT_YET"));
}
?>
|