PHP - Integration

Fermé
Utilisateur anonyme - 22 mars 2009 à 14:56
 Utilisateur anonyme - 23 mars 2009 à 17:12
Bonjour, je réalise actuellement un site web pour ma newsletter j'ai utiliser le script phpmynewsletter mes je rencontre certain problème

Je voudrais que se soi comme sa

Adresse électronique
Inscription
Désinscription
OK

Mes c'est comme sa et je n'arrive pas a le changer

Adresse électronique
OK
inscription
désinscription


Voila mon code php :





<?php
// you can include this form in any page of
// your website as follow:
//
// in this file, provide correct values for:
// $path_to_pmnl
// $list_id newsletter id
// then in your page (need to be a php page)
// add this line :
// include("path/to/this/page/form.php");
// NOTA: your page need to use UTF8 encoding
// put
// <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
// in your html header


//$list_id = 1;
$list_id = "";

//path to phpMyNewsletter base directory
$path_to_pmnl="./";

// newsletter id, leave this empty if you want to list available
// newsletter.




////////////////////// DO NOT MODIFY /////////////////////

if(file_exists("./".$path_to_pmnl."include/config.php")){
include("./".$path_to_pmnl."include/config.php");
include("./".$path_to_pmnl."include/db/db_".$db_type.".inc.php");
}
include("./".$path_to_pmnl."include/lib/libconfig.php");
include("./".$path_to_pmnl."include/interface.php");
include("./".$path_to_pmnl."include/lib/libnewsletter.php");
include("./".$path_to_pmnl."admin/include/function.php");


if(file_exists("./".$path_to_pmnl."include/config.php")){
print newsletter_list($list_id, true, $display_archive);
} else {
include "./".$path_to_pmnl."include/lang/english.php";
echo error_msg(translate("NEWSLETTER_NOT_YET"));
}

?>
A voir également:

4 réponses

NookZ Messages postés 2138 Date d'inscription jeudi 29 janvier 2009 Statut Membre Dernière intervention 7 mars 2013 514
23 mars 2009 à 09:40
Les changements sont à effecteur dans un des fichiers inclus. Sûrement un de ces trois là :
include("./".$path_to_pmnl."include/interface.php");
include("./".$path_to_pmnl."include/lib/libnewsletter.php");
include("./".$path_to_pmnl."admin/include/function.php");
0
Utilisateur anonyme
23 mars 2009 à 12:12
Bah j'ai essayer quelque truc mes le problème c'est que moi et le php on a un gros ,souci :)
Tu peux m'expliquer plus en détaille ?

Yoann
0
NookZ Messages postés 2138 Date d'inscription jeudi 29 janvier 2009 Statut Membre Dernière intervention 7 mars 2013 514
23 mars 2009 à 12:15
Il faut d'abord que tu regarde dans les fichiers :
interface.php
libnewsletter.php
si tu vois un bout de code qui ressemblerait à la formation du contenu de la newsletter. Donc l'endroit où ce type de format est défini
Adresse électronique
OK
inscription
désinscription
0
Utilisateur anonyme
23 mars 2009 à 17:12
Je ne trouve rien :-o je suis vraiment une merde tu voi un truc toi ??

-----


libnewsletter.php


<?
//16/05/2002 <gregory.kokanosky@free.fr>
// phpMyNewsletter v0.8.x

// a class for managing Newsletter

if (!defined( "_NEWSLETTER_LIB" ))
{
define("_NEWSLETTER_LIB", 1);


function validEmailAddress($email){
// regx to test for valid e-mail adres
$regex = '^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]{2,})+$';
if (eregi($regex, $email)) return true;
else return false;

}

class Newsletter {

var $list_id;
var $name; //name of the newsletter

var $from;
var $from_name;

var $subscription_subject;
var $subscription_body;
var $welcome_subject;
var $welcome_body;
var $quit_subject;
var $quit_body;

var $subject;
var $header;
var $footer;

var $db_host;
var $db_login;
var $db_pass;
var $db_name;


function getConfig($host, $login, $pass, $database, $list_id , $list_table){
$this->list_id = $list_id;
$db= new Db();
$db->DbConnect($host, $login, $pass, $database);
$db->DbQuery("SELECT * FROM $list_table WHERE list_id='$list_id'");
$conf = $db->DbNextRow();

$this->db_host =$host;
$this->db_login=$login;
$this->db_pass =$pass;
$this->db_name =$database;

$this->name= $conf[1];
$this->from= $conf[2];
$this->from_name = $conf[3];
$this->subject= $conf[4];
$this->header = $conf[5];
$this->footer = $conf[6];
$this->subscription_subject = $conf[7];
$this->subscription_body = $conf[8];
$this->welcome_subject = $conf[9];
$this->welcome_body = $conf[10];
$this->quit_subject = $conf[11];
$this->quit_body = $conf[12];
}


function getAddress($mail_table, $begin='', $limit='')
{
$Addr = array();
$db= new Db();
$db->DbConnect($this->db_host, $this->db_login, $this->db_pass, $this->db_name);
$sql = "SELECT email FROM $mail_table WHERE list_id='$this->list_id'";
$db->DbQuery($sql ,$begin, $limit, 1);
for($i=0; $i<$db->DbNumRows(); $i++){
$addr = $db->DbNextRow();
$Addr[$i]=$addr[0];
}
return $Addr;
}



function saveConfig($db_host, $db_login, $db_pass, $db_name, $list_id, $table_listsconfig, $newsletter_name, $from, $from_name, $subject, $header, $footer, $subscription_subject, $subscription_body, $welcome_subject, $welcome_body, $quit_subject, $quit_body){

$db= new Db();
$db->DbConnect($db_host, $db_login, $db_pass, $db_name);
if(!get_magic_quotes_gpc()){
$newsletter_name = escape_string($newsletter_name);
$from = escape_string($from);
$from_name = escape_string($from_name);
$subject = escape_string($subject);
$header = escape_string($header);
$footer = escape_string($footer);
$subscription_subject = escape_string($subscription_subject);
$subscription_body = escape_string($subscription_body);
$welcome_subject = escape_string($welcome_subject);
$welcome_body = escape_string($welcome_body);
$quit_subject = escape_string($quit_subject);
$quit_body =escape_string($quit_body);
}

$sql ="UPDATE $table_listsconfig SET newsletter_name=\"$newsletter_name\", from_addr=\"$from\", from_name=\"$from_name\", subject=\"$subject\", header=\"$header\" , footer=\"$footer\" , subscription_subject=\"$subscription_subject\", subscription_body=\"$subscription_body\", welcome_subject=\"$welcome_subject\", welcome_body=\"$welcome_body\", quit_subject=\"$quit_subject\", quit_body=\"$quit_body\" WHERE list_id='$list_id'";


$db->DbQuery($sql);
if($db->DbError()) return 0;
else return 1;

}






function getSubscribersNumbers($table_email){
$db= new Db();
$db->DbConnect($this->db_host, $this->db_login, $this->db_pass, $this->db_name);
$db->DbQuery("SELECT COUNT(*) FROM $table_email WHERE list_id='$this->list_id'");
$num = $db->DbNextRow();
return $num[0];
}




function deleteArchive($table_archives, $msg_id){
$db= new Db();
$db->DbConnect($this->db_host, $this->db_login, $this->db_pass, $this->db_name);
$db->DbQuery("DELETE FROM $table_archives WHERE id='$msg_id'");
if($db->DbError()) return 0;
else return 1;
}


function getArchivesSelectList($table_archives, $msg_id='', $form_name='archive_form2'){
$db= new Db();
$db->DbConnect($this->db_host, $this->db_login, $this->db_pass, $this->db_name);
$sql = "SELECT id, date, subject FROM $table_archives WHERE list_id='$this->list_id' ORDER BY date DESC";
$db->DbQuery($sql);
if($db->DbNumRows() == 0) return -1;
else {
echo "<select name=\"msg_id\" onchange=\"document.$form_name.submit()\">\n";
while($archives = $db->DBNextRow())
{

echo "<option value=\"$archives[0]\" ";
if ($msg_id==$archives[0]) echo "selected='selected'";
echo ">".stripslashes(htmlspecialchars($archives[2]))." </option>\n";
}
echo "</select>";

}

}


function getArchiveMsg($table_archives, $msg_id)
{
if( empty($offset)) $offset=0;
$db= new Db();
$db->DbConnect($this->db_host, $this->db_login, $this->db_pass, $this->db_name);
$sql = "SELECT date, type, subject, message FROM $table_archives WHERE id='$msg_id'";
$db->DbQuery($sql);
if($db->DbNumRows() == 0) return -1;
else{
$archive = $db->DbNextRow();
echo "<div class='subsection' >";
$subject = htmlspecialchars($archive[2]);
$subject = stripslashes($subject);
$date = $archive[0];
echo "<div class='archivetitle'>".$subject." - ".$date."</div>";
//echo translate("ARCHIVE_SUBJECT").": ".$subject."<br />\n";
//echo translate("ARCHIVE_DATE").": ".$archive[0]."<br />\n";
//echo translate("ARCHIVE_FORMAT").": ".$archive[1]."<br /><br />\n";
echo "<div class='subcontent'>";

if($archive[1] != "html"){
$body = str_replace("<","<", $archive[3]);
$body = str_replace(">",">", $body);

$body = nl2br(stripslashes($body));
} else {
$body = stripslashes( $archive[3] );
}
echo "\t".$body;

echo "</div></div>\n";
echo "<br />";
}

}



}
}


?>


-------------------------------

interface.php

<?


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"));


}
?>




Merci de ton aide :-)
0