Login
Nome utente:

Password:

Ricorda



Recupero password

Registrati!
Navigazione
Utenti Online
4 utente(i) online
(2 utente(i) in Tutorial)

Iscritti: 0
Ospiti: 4

altro...
Tutorial :: Sviluppo e Hack

Porting degli utenti xoops su PhpList


Porting degli utenti xoops su PhpList
slyss
Importare automaticamente gli utenti di un sito xoops all'interno del database del famoso tool per mailing-list PhpList.
Profilo Autore: slyss


Presentazione dello script per il porting di utenti xoops sulla piattaforma per mailing-list: phplist.

Inanizitutto è da notare che questo script è adattato per xoops 2.2.x (per esigenze personali) ma è adattabile facilmente a qualunque tipo versione di xoops.

Phplist è un potentissimo strumento per inviare mailing-list. Grazie a phplist si possono creare mailing list con editor WYSWYG e creare invii personalizzati. Si possono inoltre decidere quando inviare mail (scheduler) per non incorrere in segnalazioni spam o cose del genere (molto gravose per mass-mail).

E' lo strumento ideale per amministrare mailing-list di grandi community.

Phplist ha anche un potente strumento di subscribe che però non è pienamente utilizzabile quando si vuole che tutti gli utenti iscritti ad un sito xoops debbano automaticamente ricevere la mailing-list. Quindi ho deciso di creare questo script automatico di porting degli utenti.

Lo script importa tutti gli utenti del sito xoops nel database di phplist. Inoltre controlla eventuali campi aggiornati sul database xoops e li sostituisce con quelli vecchi presenti sul database di phplist.

Con questo script avrò sempre tutti gli utenti aggiornati e, per esempio, potrò inviare newsletter solamente agli utenti uomini, o solamente a utenti di milano, o solamente a utenti con foto, ecc. Insomma potrò personalizzare gli invii a mio piacimento.

Lo script di porting farà dei cicli di 300 utenti per volta per non rischiare, in caso di gran numero di utenti, di mandare in timeout il server o altri problemi vari.

Se lo script dovesse interrompersi per un qualunque motivo, niente paura perchè basterà rifarlo partire e fargli fare un ciclo completo di porting per sistemare tutto.

INIZIAMO:

Createvi una pagina nome_file.php ed copiateci lo script. Inseritelo poi in modules/profile/.



Ecco lo script:

<?php

include '../../mainfile.php';
include 
XOOPS_ROOT_PATH.'/header.php';
//Hack by Stefano Silvestrini - stefanoitalia at gmail dot com
// aka slyss in xoopsitalia.org
// 20/02/2007
//Per favore, se possibile, lasciare i crediti.

global $xoopsUser;

if (!
$xoopsUser)
{
header("Location: http://www.vostrosito.com");
exit();
}


// controllo se sono admin inteso come uid = 1
if ($xoopsUser->getVar('uid') != 1)
{
redirect_header("../../index.php""Solo gli admin hanno accesso a questa area!");
exit();
}


// ---------------------------------------------------

// 

$start = empty( $_GET['start'] ) ? intval$_GET['start'] ) ;
    
$step 300;
    if (
$start == '') {
    
$start 0;
    }

    
// --------- dati collegamento database del sito xoops ----------
$db2_host "indirizzo_database";
$db2_user "nome_utente";
$db2_password "password";
$db2_name "nome_database";
$db2_prefix "prefissotabelle_";
// --------- dati collegamento database del sito xoops ----------

$db2 mysql_connect($db2_host$db2_user$db2_password);

if (
$db2 == FALSE)
die (
"Errore nella connessione.");

mysql_select_db($db2_name$db2)
or die (
"Errore nella selezione del database.");


// query per trovarmi tutti gli utenti del vostro sito xoops
$risultato mysql_query("SELECT s.*, t.* FROM ".$db2_prefix."users s, ".$db2_prefix."user_profile t WHERE (s.uid = t.profileid) AND (s.level = 1) ORDER BY s.uid ASC LIMIT ".$start.",".$step."; ")
or die(
"Query non valida: " mysql_error());
    

$num_righe mysql_num_rows($risultato);
if (
$num_righe != 0) {



while (
$myrow_users_network mysql_fetch_array ($risultato))
{


// campi personalizzati di extended profile da importare nel database di phplist
$uid_find $myrow_users_network['profileid'];
$email_find $myrow_users_network['email'];
$uname_find $myrow_users_network['uname'];
$loginname_find $myrow_users_network['loginname'];
$name_find $myrow_users_network['name'];
$user_avatar_find $myrow_users_network['user_avatar'];
$rank_find $myrow_users_network['rank'];
$bio_find $myrow_users_network['bio'];
$user_intrest_find $myrow_users_network['user_intrest'];
$user_occ_find $myrow_users_network['user_occ'];
$location_sly_find $myrow_users_network['location_sly'];
$years_old_sly_find $myrow_users_network['years_old_sly'];
$specific_location_city_sly_find $myrow_users_network['specific_location_city_sly'];
$field_inserted_sly_find $myrow_users_network['field_inserted_sly'];
$gender_sly_find $myrow_users_network['gender_sly'];



// --------- dati collegamento database di phplist ----------
$db_host "indirizzo_database";
$db_user "nome_utente";
$db_password "password";
$db_name "nome_database";
$db_prefix "prefissotabelle_";
// --------- dati collegamento database di phplist ----------

$db mysql_connect($db_host$db_user$db_password);

if (
$db == FALSE)
die (
"Errore nella connessione.");

mysql_select_db($db_name$db)
or die (
"Errore nella selezione del database.");



// --------- INIZIO CICLO DI INSERIMENTO ---------     
// inizio iscrivo utente alla lista dello Stefano Network Mailing List ---> cioe numero 3

// questo sotto (3) è il numero della mailing-list alla quale gli utenti importati saranno iscritti automaticamente
// quindi andatevi a creare prima una mailing list di base e vedete quale id sarà ad essa assegnata
$mailing_network ;
$date date('Y-m-d H:i:s'); 
$date1 date('Y-m-d'); 

$listuser mysql_query("REPLACE LOW_PRIORITY INTO ".$db_prefix."listuser (`userid`, `listid`, `entered`, `modified`) VALUES (".$uid_find.", '".$mailing_network."', '".$date."', '".$date."'); ")
or die(
"Query non valida: " mysql_error());

// fine iscrivo utente alla lista dello Stefano Network Mailing List ---> cioe numero 3



// inizio inserisco utente parte 1

// mi creo un token univoco per ogni utente... magari potrà servire in futuro
$better_token md5(uniqid(rand(), true));

$user_user mysql_query("REPLACE LOW_PRIORITY INTO ".$db_prefix."user_user (id, email, confirmed, blacklisted, bouncecount, entered, modified, uniqid, htmlemail, subscribepage, rssfrequency, password, passwordchanged, disabled, extradata, foreignkey) VALUES (".$uid_find.", '".$email_find."', 1, 0, 0, '".$date."', '".$date."', '".$better_token."', 1, 'NULL', '', '', '".$date1."', 0, '', ''); ")
or die(
"Query non valida: " mysql_error());

// fine inserisco utente parte 1


// inizio inserisco utente parte 2

$uid_find_ok = (int) $uid_find;

// mi faccio alcuni controllo per evitare che nei campi ci siano asterischi che possano in qualche modo
// bloccarmi lo script automatico
$specific_location_city_sly_find_slash mysql_real_escape_string($specific_location_city_sly_find);
$location_sly_find_slash mysql_real_escape_string($location_sly_find);
$user_occ_find_slash mysql_real_escape_string($user_occ_find);
$user_intrest_find_slash mysql_real_escape_string($user_intrest_find);
$bio_find_slash mysql_real_escape_string($bio_find);
$name_find_slash mysql_real_escape_string($name_find);
$uname_find_slash mysql_real_escape_string($uname_find);


// inserisco gli attributi di extended profile di ogni utente nel database di phplist
// nota: mi sono già creato tramite phplist i vari attributi personalizzati
// esempio 22 è l'id assegnato al campo gender su phplist
// esempio 21 è l'id assegnato al campo years su phplist
// esempio 9 è l'id assegnato al campo rank su phplist
// ecc...
$user_user_attribute mysql_query("REPLACE LOW_PRIORITY INTO ".$db_prefix."user_user_attribute VALUES
(22, "
.$uid_find.", '".$gender_sly_find."'),
(23, "
.$uid_find.", '".$field_inserted_sly_find."'),
(20, "
.$uid_find.", '".$specific_location_city_sly_find_slash."'),
(21, "
.$uid_find.", '".$years_old_sly_find."'),
(19, "
.$uid_find.", '".$location_sly_find_slash."'),
(16, "
.$uid_find.", '".$user_occ_find_slash."'),
(15, "
.$uid_find.", '".$user_intrest_find_slash."'),
(14, "
.$uid_find.", '".$bio_find_slash."'),
(9, "
.$uid_find.", '".$rank_find."'),
(7, "
.$uid_find.", '".$user_avatar_find."'),
(6, "
.$uid_find.", '".$email_find."'),
(5, "
.$uid_find.", '".$name_find_slash."'),
(4, "
.$uid_find.", '".$loginname_find."'),
(3, "
.$uid_find.", '".$uname_find_slash."'),
(2, "
.$uid_find.", '".$uid_find."'); ") or die("Query non valida: " mysql_error());

// fine inserisco utente parte 2
// --------- FINE CICLO DI INSERIMENTO --------- 





// chiudo il while


    
$myrow_attrib mysql_fetch_array ($risultato);
$uid $myrow_attrib['uid'];
$var_uid = (int) $uid;

$start_next $start $step;    


echo 
"<br /><br /><div align='center'><img src='http://www.stefanosnetwork.com/site/uploads/img45da09000337f.gif'>

<br /><br />
Attendere prego... stiamo aggiornando la lista utenti sulla mailing-list!<br /><br />
Aggiornamento record utenti da "
.$start." a ".$start_next."</div>";



// faccio un redirect a questo file dandogli però il nuovo next per fare il ciclo successivo
$url "http://www.vostrosito.com/site/modules/profile/nome_file.php?start=".$start_next;
header("Refresh: 4; URL="$url"");
    



    
}

else 

{
// finito il ciclo esco...
echo "<br /><br /><div align='center'><strong>AGGIORNAMENTO COMPLETATO!</strong><br /><br />La mailing list è pronta per essere usata!<br /><br />
<a href='http://www.vostrosito.com/mailing-list/' target='_top'>Vai alla Mailing List!</a><br /><br />
<a href='http://www.vostrosito.com/index.php' target='_top'>Torna alla Home Page!</a></div>"
;






// --------- dati collegamento database di phplist ----------
$db_host "indirizzo_database";
$db_user "nome_utente";
$db_password "password";
$db_name "nome_database";
$db_prefix "prefissotabelle_";
// --------- dati collegamento database di phplist ----------

$db mysql_connect($db_host$db_user$db_password);

if (
$db == FALSE)
die (
"Errore nella connessione.");

mysql_select_db($db_name$db)
or die (
"Errore nella selezione del database.");



$risultato mysql_query("SELECT * FROM ".$db_prefix."user_user ; ")
or die(
"Query non valida: " mysql_error());

$trovato_users_mailing 0;

while (
$myrow_users_mailing mysql_fetch_array ($risultato))
{


$trovato_users_mailing ++;



// stampo il numero utenti sulla mailing list
echo "<div align='center'><br />Utenti Mailing-List: ".$trovato_users_mailing."<br /></div>";






    
// --------- dati collegamento database del sito xoops ----------
$db2_host "indirizzo_database";
$db2_user "nome_utente";
$db2_password "password";
$db2_name "nome_database";
$db2_prefix "prefissotabelle_";
// --------- dati collegamento database del sito xoops ----------

$db mysql_connect($db_host$db_user$db_password);

if (
$db == FALSE)
die (
"Errore nella connessione.");

mysql_select_db($db_name$db)
or die (
"Errore nella selezione del database.");

$risultato mysql_query("SELECT * FROM ".$db_prefix."users ; ")
or die(
"Query non valida: " mysql_error());

$trovato_users_network 0;

while (
$myrow_users_mailing mysql_fetch_array ($risultato))
{

$trovato_users_network ++;



// stampo numero utenti sul sito xoops
echo "<div align='center'><br />Utenti Network: ".$trovato_users_network."<br /></div>";



}
    
    

include 
XOOPS_ROOT_PATH.'/footer.php';

?>




ed ecco il risultato:







Spero che potrà interessare a qualcuno.

PhpList si preleva da: http://www.phplist.com/

Per discussioni ho aperto questo topic, clicca qui:

vai alla discussione sul forum!

ciao sly
<< Personalizzare la mail di registrazione Nuovo Utente! Visualizzare il gruppo utente >>

API: RSS | RDF | ATOM
Copyright© slyss & Xoops Italia
I commenti sono di proprietà degli autori. Si declina ogni responsibilità sul loro contenuto.

Autore Contenuto
Anonymous
Data di invio: 17/7/2012 3:04  Aggiornato: 17/7/2012 3:04
 Re: Porting degli utenti xoops su PhpList
photographer is finished you can then allow relatives and friends to take snapshots evening dresses evening dresses . The article Deciding on Your Wedding ceremony Day Photographer then gives only a ideas and ideas about the marriage ceremony. pregnancy evening dresses pregnancy evening dresses Should you do not consider them quite helpful beautiful bridal dresses beautiful bridal dresses flower girls dress flower girls dress , online evening dresses online evening dresses flower girl ivory dress flower girl ivory dress look at to look like news about the Deciding upon Your Marriage ceremony Day Photographer, or go to research around the site. Visualizza immagine originale For those who have generally dreamed of getting a winter season marriage ceremony then why don't you believe about possessing a Xmas themed stunning. By opting to own Xmas as your concept you immediately have your color scheme as well as a huge of bulk on the decorations in your venue sorted which consequently helps along with the complete arranging and preparing. Ordinarily reds and greens would be the color palette for Xmas, flower girl dresses cheap flower girl dresses cheap even so wintery

Autore Contenuto
huff01
Data di invio: 5/9/2012 11:26  Aggiornato: 5/9/2012 11:26
Senior
Iscritto: 5/9/2012
Da:
Inviati: 164
 replica omega watches
with the situation, at one and eleven oclock positions audemars piguet watches replica audemars piguet watches replica . Guaranteeing the utmost stage of precision, Emporio Armani watches Emporio Armani watches the Quartz Ronda 1005 motion also guarantees the right dependability and provides the primary capabilities of time, alongside having an indispensable day functionality. replica watches for sale replica watches for sale fake cartier watches fake cartier watches The brand new TAG Heuer Expert Golfing Look at will come accompanied by a strap made out of silicon, to guarantee best versatility for the wrist cheap fake watches cheap fake watches Emporio Armani watches Emporio Armani watches , audemars piguet royal oak offshore replica audemars piguet royal oak offshore replica readily available dependent within the dial Visualizza immagine originale , fake swiss audemars piguet watch fake swiss audemars piguet watch on white or black. Totally fantastic, the brand new TAG Heuer Specialist Golfing Observe could be the ideal wrist accent for qualified golfers or just for folks enthusiastic about interesting patterns Breitling Chrono Matic 49 watches Breitling Chrono Matic 49 watches . TAG-Heuer Qualified Golfing Photos GalleryDue to the fact we don't want the acquisition of the enjoy to become a soreness but a delight, it s an honor for us to supply some

Autore Contenuto
huff01
Data di invio: 12/9/2012 2:47  Aggiornato: 12/9/2012 2:47
Senior
Iscritto: 5/9/2012
Da:
Inviati: 164
 replica chopard watches
replica aigner replica aigner time to look at this information before starting the task is the best way to go as it can prevent problems before they arise replica aigner watches replica aigner watches concord replica concord replica . Stop by our site to find out more hair cutting tips For those looking for Waco hair salons, replica aigner watches replica aigner watches the best bet is usually to take a look around town and see what kind of services are available. This is especially important if one has a wedding or a big event coming up. It is always important to look one's best. Nowadays there also exist an abundance of different hair salons, Visualizza immagine originale all of which can cater towards various different types of people. roger dubuis replica roger dubuis replica replica breitling replica breitling Some might specialize more in looking after older people, whilst others will be targeted towards a much younger crowd. With men, fake rolex sale fake rolex sale generally barber shops are going to offer the basic hair cutting service. Alternative hair styles have always been

Autore Contenuto
huff01
Data di invio: 12/9/2012 3:38  Aggiornato: 12/9/2012 3:38
Senior
Iscritto: 5/9/2012
Da:
Inviati: 164
 replica longines
DessyPantone Style Board Challenge where you can show off your creative talents and win $500 worth of Dessy accessories. 2 replica sarcar replica sarcar . $10 Off & Free Shipping from Beauty: Stock up on wedding makeup with $10 off and free shipping on purchases over $60! 3. Centerpiece Upgrades from 1800Flowers: Just in time for your Thanksgiving decorating needs, 1800Flowers is offering a free centerpiece upgrade. 4. replica breitling replica breitling Hotels from $35/night from Orbitz: Score free nights, upgrades and more just in time for Fall travel replica enicar watches replica enicar watches . 5. welder replica watches welder replica watches 15%Off Shoes from Shoes: Score those wedding shoes with 15% off all styles at Shoes. Use FALL at checkout. 6 Visualizza immagine originale . 10% Off Wedding Favors from My Wedding Favors: If you're ready to start thinking about wedding favors, you can save 10% on your order of $150 or more from replica vacheron constantin watches replica vacheron constantin watches , use coupon code SAVE10 at checkout. As always replica ferrari watches replica ferrari watches alange sohne replica alange sohne replica ,
Sostieni XoopsItalia!
Ultimi Tutorial
Ultime Traduzioni
XOOPS ITALIA © 2002-2012 - Powered by XOOPS