[geeklog-cvs] Geeklog-1.x/plugins/spamx Import.Admin.class.php, 1.11, 1.12
Dirk Haun
dhaun at qs1489.pair.com
Mon May 28 13:21:34 EDT 2007
Update of /cvsroot/geeklog/Geeklog-1.x/plugins/spamx
In directory qs1489.pair.com:/tmp/cvs-serv82470
Modified Files:
Import.Admin.class.php
Log Message:
Mostly cosmetics ...
Index: Import.Admin.class.php
===================================================================
RCS file: /cvsroot/geeklog/Geeklog-1.x/plugins/spamx/Import.Admin.class.php,v
retrieving revision 1.11
retrieving revision 1.12
diff -C2 -d -r1.11 -r1.12
*** Import.Admin.class.php 8 Feb 2007 01:42:17 -0000 1.11
--- Import.Admin.class.php 28 May 2007 17:21:32 -0000 1.12
***************
*** 7,11 ****
* Updates Sites MT Blacklist via Master MT Blacklist rss feed
*
! * Copyright (C) 2004-2006 by the following authors:
* Author Tom Willett tomw AT pigstye DOT net
* Author Dirk Haun dirk AT haun-online DOT de
--- 7,11 ----
* Updates Sites MT Blacklist via Master MT Blacklist rss feed
*
! * Copyright (C) 2004-2007 by the following authors:
* Author Tom Willett tomw AT pigstye DOT net
* Author Dirk Haun dirk AT haun-online DOT de
***************
*** 19,27 ****
*/
! if (strpos ($_SERVER['PHP_SELF'], 'Import.Admin.class.php') !== false) {
! die ('This file can not be used on its own!');
}
! require_once ($_CONF['path'] . 'plugins/spamx/BaseAdmin.class.php');
class Import extends BaseAdmin {
--- 19,27 ----
*/
! if (strpos($_SERVER['PHP_SELF'], 'Import.Admin.class.php') !== false) {
! die('This file can not be used on its own!');
}
! require_once $_CONF['path'] . 'plugins/spamx/BaseAdmin.class.php';
class Import extends BaseAdmin {
***************
*** 29,40 ****
* Constructor
*/
! function display ()
{
global $_TABLES;
! if (DB_count ($_TABLES['spamx'], 'name', 'MTBlacklist') > 0) {
! $display = $this->_update_blacklist ();
} else {
! $display = $this->_initial_import ();
}
--- 29,40 ----
* Constructor
*/
! function display()
{
global $_TABLES;
! if (DB_count($_TABLES['spamx'], 'name', 'MTBlacklist') > 0) {
! $display = $this->_update_blacklist();
} else {
! $display = $this->_initial_import();
}
***************
*** 42,50 ****
}
! function link ()
{
global $_TABLES, $LANG_SX00;
! if (DB_count ($_TABLES['spamx'], 'name', 'MTBlacklist') > 0) {
$display = $LANG_SX00['uMTlist'];
} else {
--- 42,50 ----
}
! function link()
{
global $_TABLES, $LANG_SX00;
! if (DB_count($_TABLES['spamx'], 'name', 'MTBlacklist') > 0) {
$display = $LANG_SX00['uMTlist'];
} else {
***************
*** 58,71 ****
* Update MT Blacklist from RSS feed
*/
! function _update_blacklist ()
{
global $_CONF, $_TABLES, $LANG_SX00, $_SPX_CONF;
! require_once($_CONF['path'] . 'plugins/spamx/magpierss/rss_fetch.inc');
! require_once($_CONF['path'] . 'plugins/spamx/magpierss/rss_utils.inc');
$rss = fetch_rss($_SPX_CONF['rss_url']);
if ($rss === false) {
! if (strpos ($_SPX_CONF['rss_url'], 'jayallen.org') === false) {
return '<p>An error occured when updating MT Blacklist</p>';
} else {
--- 58,71 ----
* Update MT Blacklist from RSS feed
*/
! function _update_blacklist()
{
global $_CONF, $_TABLES, $LANG_SX00, $_SPX_CONF;
! require_once $_CONF['path'] . 'plugins/spamx/magpierss/rss_fetch.inc';
! require_once $_CONF['path'] . 'plugins/spamx/magpierss/rss_utils.inc';
$rss = fetch_rss($_SPX_CONF['rss_url']);
if ($rss === false) {
! if (strpos($_SPX_CONF['rss_url'], 'jayallen.org') === false) {
return '<p>An error occured when updating MT Blacklist</p>';
} else {
***************
*** 79,83 ****
$to_delete = array();
! foreach($rss->items as $item) {
// time this entry was published (currently unused)
// $published_time = parse_w3cdtf( $item['dc']['date'] );
--- 79,83 ----
$to_delete = array();
! foreach ($rss->items as $item) {
// time this entry was published (currently unused)
// $published_time = parse_w3cdtf( $item['dc']['date'] );
***************
*** 86,103 ****
// is this an addition or a deletion?
if (strpos($subject, 'addition') !== false) {
// save it to database
! $result = DB_query('SELECT * FROM ' . $_TABLES['spamx'] . ' WHERE name="MTBlacklist" AND value="' . $entry . '"');
$nrows = DB_numRows($result);
if ($nrows < 1) {
! $result = DB_query('INSERT INTO ' . $_TABLES['spamx'] . ' VALUES ("MTBlacklist","' . $entry . '")');
$to_add[] = $entry;
}
} else if (strpos($subject, 'deletion') !== false) {
// delete it from database
! $result = DB_query('SELECT * FROM ' . $_TABLES['spamx'] . ' where name="MTBlacklist" AND value="' . $entry . '"');
$nrows = DB_numRows($result);
if ($nrows >= 1) {
! $result = DB_query('DELETE FROM ' . $_TABLES['spamx'] . ' where name="MTBlacklist" AND value="' . $entry . '"');
$to_delete[] = $entry;
}
--- 86,104 ----
// is this an addition or a deletion?
+ $dbentry = addslashes($entry);
if (strpos($subject, 'addition') !== false) {
// save it to database
! $result = DB_query("SELECT name FROM {$_TABLES['spamx']} WHERE name = 'MTBlacklist' AND value = '$dbentry'");
$nrows = DB_numRows($result);
if ($nrows < 1) {
! DB_query("INSERT INTO {$_TABLES['spamx']} VALUES ('MTBlacklist', '$dbentry')");
$to_add[] = $entry;
}
} else if (strpos($subject, 'deletion') !== false) {
// delete it from database
! $result = DB_query("SELECT name FROM {$_TABLES['spamx']} WHERE name = 'MTBlacklist' AND value = '$dbentry'");
$nrows = DB_numRows($result);
if ($nrows >= 1) {
! DB_query("DELETE FROM {$_TABLES['spamx']} WHERE name = 'MTBlacklist' AND value = '$dbentry'");
$to_delete[] = $entry;
}
***************
*** 121,137 ****
* Initial import of the MT Blacklist
*/
! function _initial_import ()
{
global $_CONF, $_TABLES, $LANG_SX00, $_SPX_CONF;
! if (ini_get ('allow_url_fopen')) {
! $blacklist = file ($_SPX_CONF['mtblacklist_url']);
! $count = $this->_do_import ($blacklist);
if ($count > 0) {
! $display = sprintf ($LANG_SX00['import_success'], $count);
! SPAMX_log ($LANG_SX00['uMTlist'] . $LANG_SX00['uMTlist2']
! . $count . $LANG_SX00['uMTlist3'] . '0'
! . $LANG_SX00['entries']);
} else {
$display = $LANG_SX00['import_failure'];
--- 122,138 ----
* Initial import of the MT Blacklist
*/
! function _initial_import()
{
global $_CONF, $_TABLES, $LANG_SX00, $_SPX_CONF;
! if (ini_get('allow_url_fopen')) {
! $blacklist = file($_SPX_CONF['mtblacklist_url']);
! $count = $this->_do_import($blacklist);
if ($count > 0) {
! $display = sprintf($LANG_SX00['import_success'], $count);
! SPAMX_log($LANG_SX00['uMTlist'] . $LANG_SX00['uMTlist2']
! . $count . $LANG_SX00['uMTlist3'] . '0'
! . $LANG_SX00['entries']);
} else {
$display = $LANG_SX00['import_failure'];
***************
*** 140,173 ****
$fromfile = $_CONF['path_data'] . 'blacklist.txt';
! if (file_exists ($fromfile)) {
! $blacklist = file ($fromfile);
! $count = $this->_do_import ($blacklist);
if ($count > 0) {
! $display = sprintf ($LANG_SX00['import_success'], $count);
! SPAMX_log ($LANG_SX00['uMTlist'] . $LANG_SX00['uMTlist2']
! . $count . $LANG_SX00['uMTlist3'] . '0'
! . $LANG_SX00['entries']);
} else {
$display = $LANG_SX00['import_failure'];
}
} else {
! $display = sprintf ($LANG_SX00['allow_url_fopen'],
! $_CONF['path_data']);
$display .= '<p>'. COM_createLink($_SPX_CONF['mtblacklist_url'],
! $_SPX_CONF['mtblacklist_url']);
}
}
// Import Personal Blacklist for existing users.
$fromfile = $_CONF['path_html'] . 'spamx/blacklist.php';
! if (file_exists ($fromfile)) {
! require_once ($fromfile);
! $count = $this->_do_importp ($SPAMX_BLACKLIST);
$display .= $LANG_SX00['initial_Pimport'];
if ($count > 0) {
! $display .= sprintf ($LANG_SX00['import_success'], $count);
! SPAMX_log ($LANG_SX00['uPlist'] . $LANG_SX00['uMTlist2']
! . $count . $LANG_SX00['uMTlist3'] . '0'
! . $LANG_SX00['entries']);
} else {
$display .= $LANG_SX00['import_failure'];
--- 141,175 ----
$fromfile = $_CONF['path_data'] . 'blacklist.txt';
! if (file_exists($fromfile)) {
! $blacklist = file($fromfile);
! $count = $this->_do_import($blacklist);
if ($count > 0) {
! $display = sprintf($LANG_SX00['import_success'], $count);
! SPAMX_log($LANG_SX00['uMTlist'] . $LANG_SX00['uMTlist2']
! . $count . $LANG_SX00['uMTlist3'] . '0'
! . $LANG_SX00['entries']);
} else {
$display = $LANG_SX00['import_failure'];
}
} else {
! $display = sprintf($LANG_SX00['allow_url_fopen'],
! $_CONF['path_data']);
$display .= '<p>'. COM_createLink($_SPX_CONF['mtblacklist_url'],
! $_SPX_CONF['mtblacklist_url']);
}
}
+
// Import Personal Blacklist for existing users.
$fromfile = $_CONF['path_html'] . 'spamx/blacklist.php';
! if (file_exists($fromfile)) {
! require_once $fromfile;
! $count = $this->_do_importp($SPAMX_BLACKLIST);
$display .= $LANG_SX00['initial_Pimport'];
if ($count > 0) {
! $display .= sprintf($LANG_SX00['import_success'], $count);
! SPAMX_log($LANG_SX00['uPlist'] . $LANG_SX00['uMTlist2']
! . $count . $LANG_SX00['uMTlist3'] . '0'
! . $LANG_SX00['entries']);
} else {
$display .= $LANG_SX00['import_failure'];
***************
*** 184,188 ****
* @return int number of lines imported
*/
! function _do_import ($lines)
{
global $_TABLES;
--- 186,190 ----
* @return int number of lines imported
*/
! function _do_import($lines)
{
global $_TABLES;
***************
*** 190,199 ****
$count = 0;
foreach ($lines as $line) {
! $l = explode ('#', $line);
! $entry = trim ($l[0]);
! if (!empty ($entry)) {
! DB_query ('INSERT INTO ' . $_TABLES['spamx']
! . ' VALUES ("MTBlacklist","' . addslashes ($entry)
! . '")');
$count++;
}
--- 192,199 ----
$count = 0;
foreach ($lines as $line) {
! $l = explode('#', $line);
! $entry = addslashes(trim($l[0]));
! if (!empty($entry)) {
! DB_query("INSERT INTO {$_TABLES['spamx']} VALUE ('MTBlacklist', '$entry')");
$count++;
}
***************
*** 209,213 ****
* @return int number of lines imported
*/
! function _do_importp ($lines)
{
global $_TABLES;
--- 209,213 ----
* @return int number of lines imported
*/
! function _do_importp($lines)
{
global $_TABLES;
***************
*** 215,221 ****
$count = 0;
foreach ($lines as $entry) {
! if (!empty ($entry)) {
! DB_query ('INSERT INTO ' . $_TABLES['spamx']
! . ' VALUES ("Personal","' . $entry . '")');
$count++;
}
--- 215,221 ----
$count = 0;
foreach ($lines as $entry) {
! if (!empty($entry)) {
! $entry = addslashes($entry);
! DB_query("INSERT INTO {$_TABLES['spamx']} VALUES ('Personal', '$entry')");
$count++;
}
More information about the geeklog-cvs
mailing list