Forum->Flatnux->Inizializzazione Forum | ||||
Welcome Unknown | Register | Help | 383 Users |
User | Message |
Tuesday 08 January 2008 - 22:15 Inizializzazione Forum: Ciao! sto inizializzando una sessione di Forum, poichè volevo installarlo con una serie di Gruppi / Argomenti e Topic in 3 lingue ... lavoraccio a mano ..... ci sono già degli script preconfezzionati oppure qualcuno può darmi qualche indicazione per farmeli ? ... uso la versione flatnux-2007-12-08 Grazie! A tutto c'è una spiegazione, per quanto nascosta e strana essa sia e spesso è la più semplice... inoltre semina Linux che Windows si pianta da solo !! ------------------- Nickname registrato su http://www.mynickname.org | |
Saturday 19 January 2008 - 15:22 Re: Inizializzazione Forum: Ciao a tutti, vorrei condividere con voi lo script che ho creato per la creazione / inizializzazione di un forum. Prerequisiti: - nel database che si utilizza i files descrittori delle tabelle del forum, nell'esempio io ho il forum in 3 lingue e il database nella cartella /misc/fndatabase/ e ho i files: flatforum_en_arguments.php flatforum_en_posts.php flatforum_en_topics.php flatforum_en_user_topics.php flatforum_fr_arguments.php flatforum_fr_posts.php flatforum_fr_topics.php flatforum_fr_user_topics.php flatforum_it_arguments.php flatforum_it_posts.php flatforum_it_topics.php flatforum_it_user_topics.php - un file CVS per esempio generato da Ecel contenete i seguenti dati : "Gruppo";"Argomento";"Descrizione Argomento";"Discussione";"Primo messaggio";"Lingua";"Utente" nell'esempio è misc/admin/Forum-discussioni.csv e contiene le seguenti righe ( in UTF-8 ) : "Gruppo";"Argomento";"Descrizione Argomento";"Discussione";"Primo messaggio";"Lingua";"Utente" "NickNames";"Forma e Stile";"i vari formati artistici che danno stile ai NickNames";"Il formato MSN Plus";"Il nuovo MSN Plus consente di colorare i nickname usando dei semplici TAG. Per esempio è possibile definire un colore di sfondo col tag 'a' e un colore di testo con 'c'. [a=#FF0000][c=#33FF99]NickName[/c=#FF0000][/a=#33FF99] Che colori ho creato ?";"it";"Boymix81" "NickNames";"Form and Style";"the various formats and artistic style to format the nicknames";"The format MSN Plus";"The new MSN Plus allows you to paint the nickname using simple TAG. For example, you can define a background color with tag 'a' and a text color with tag 'c'. [a = # FF0000] [c = # 33FF99] NickName [/ c = # FF0000] [/ a = # 33FF99] What is NickName's color?";"en";"Boymix81" "NickNames";"Forme et style";"les différents formats et le style artistique des nicknames";"Le format MSN Plus";"Par exemple, vous pouvez définir une couleur d'arrière-plan avec le tag 'a' et une couleur de texte avec le tag 'c'. [A = # FF0000] [c = # 33FF99] Pseudo [/ c = # FF0000] [/ a = # 33FF99]";"fr";"Boymix81" - richiamo al codice sottostante. Script: global $fn_datadir, $_FNUSER; $fd = fopen("misc/admin/Forum-discussioni-new.csv", "r"); $firstRow = true; $files_a = array(); $i = 0; $db = new XMLDatabase("fndatabase"); while (!feof($fd)) { $buffer = fgets($fd, 4096); if($firstRow){ // header $firstRow = false; continue; } if(substr($buffer,0,1) == '#'){ // comment; continue; } if(strlen($buffer) == 0){ continue; } $fields = split(";",$buffer); $forum_tmp['group'] = trimDoubleVirg($fields[0]); $forum_tmp['arg'] = trimDoubleVirg($fields[1]); $forum_tmp['arg_desc'] = trimDoubleVirg($fields[2]); $forum_tmp['disc'] = trimDoubleVirg($fields[3]); $forum_tmp['mex'] = trimDoubleVirg($fields[4]); $forum_tmp['lang'] = trimDoubleVirg($fields[5]); $forum_tmp['user'] = trimDoubleVirg($fields[6]); // to use logging user // $forum_tmp['user'] = $_FNUSER; $forumdir = "flatforum" . "_".$forum_tmp['lang']; $table_forum_arguments = new FieldForm("fndatabase", $forumdir . "_arguments", $fn_datadir, $forum_tmp['lang']); $table_forum_threads = new FieldForm("fndatabase", $forumdir . "_posts", $fn_datadir, $forum_tmp['lang']); $forum_topics = new FieldForm("fndatabase", $forumdir . "_topics", $fn_datadir, $forum_tmp['lang']); $newvalues['unirecid'] = ""; $newvalues['subject'] = $forum_tmp['arg']; $newvalues['argumentgroup'] = $forum_tmp['group']; $newvalues['level'] = -1; $newvalues['description'] = $forum_tmp['arg_desc']; //print_r($newvalues); $err = $table_forum_arguments->Verify($newvalues, true); if ($err == "") { //Se non esiste già inserisce / If this argument exist script doesn't insert it. $args = $db->Query("SELECT * FROM ".$forumdir.'_arguments'); // WHERE subject = "'.$newvalues['subject'].'"'); // la where con caratteri UTF8 ( accentati ) non funziona faccio ciclo / // If UTF8 string WHERE condiction doesn't work $find = false; if($args != ""){ foreach ($args as $arg) { if(strcasecmp(utf8_encode($arg['subject']),$newvalues['subject']) == 0){ $find = true; $argument = $arg; break; } } } if (! $find) { $UserValues = $table_forum_arguments->xmltable->InsertRecord($newvalues); $argument = $UserValues; } } else { echo "ERROR:".$err." ".print_r($newvalues); } // la where con caratteri UTF8 ( accentati ) non funziona faccio ciclo / // If UTF8 string WHERE condiction doesn't work $_topics = $db->Query("SELECT * FROM ".$forumdir.'_topics'); $find = false; if($_topics != ""){ foreach ($_topics as $_topic) { if(strcasecmp(utf8_encode($_topic['subject']),$forum_tmp['disc']) == 0){ $find = true; break; } } } if (! $find) { // topic $topic = array (); $topic['subject'] = $forum_tmp['disc']; $topic['user'] = $forum_tmp['user']; $topic['time'] = time(); $topic['read'] = "0"; $topic['argument'] = $argument['unirecid']; $topic['username'] = $_FNUSER; $newtopic = $forum_topics->xmltable->InsertRecord($topic); // posts $firspost['topicid'] = $newtopic['unirecid']; $firspost['subject'] = $forum_tmp['disc']; $firspost['text'] = $forum_tmp['mex']; $firspost['parent'] = ""; $firspost['time'] = time(); $firspost['username'] = $forum_tmp['user']; $table_forum_threads->xmltable->InsertRecord($firspost); } unset($table_forum_arguments); unset($table_forum_threads); unset($forum_topics); } fclose($fd); echo "End Insertings"; Versione funzionante : flatnux-2007-12-08 L'idea è di creare una discussione in ogni lingua con un primo messaggio, potete parametrizzare la lingua e l'utente che lo posta. Se il gruppo o discussione non esiste la crea altrimenti utilizza quello creato. Spero vi sia utile... Saluti By Boymix81. A tutto c'è una spiegazione, per quanto nascosta e strana essa sia e spesso è la più semplice... inoltre semina Linux che Windows si pianta da solo !! ------------------- Nickname registrato su http://www.mynickname.org | |
Saturday 19 January 2008 - 19:50 Re: Inizializzazione Forum: complimenti, veramente notevole ... Vedo che hai imparato ad usare le xmldb nonostante non abbia avuto tempo di documentarle . Riguardo agli accenti nel metodo Query cerco di sistemarlo in qualche modo. Alex | |
[1] |