OSDN Git Service

2.0.3 jp10
[nucleus-jp/nucleus-plugins.git] / trunk / NP_TrackBack / trackback / index.php
index 14fb332..ae07874 100644 (file)
@@ -7,12 +7,7 @@
        
        
        // Send out Content-type
-       sendContentType('application/xhtml+xml', 'admin-trackback', _CHARSET);  
-
-       // Compatiblity with Nucleus < = 2.0
-       if (!function_exists('sql_table')) { function sql_table($name) { return 'nucleus_' . $name; } }
-       
-
+       //sendContentType('application/xhtml+xml', 'admin-trackback', _CHARSET);        
 
        $oPluginAdmin = new PluginAdmin('TrackBack');
 
@@ -32,7 +27,9 @@
        if (!in_array($action, $aActionsNotToCheck)) {
                if (!$manager->checkTicket()) doError(_ERROR_BADTICKET);
        }
+
        $oPluginAdmin->start();
+       //$oPluginAdmin->admin->pagehead();
        
 //modify start+++++++++
                $plug =& $oPluginAdmin->plugin;
 
        $mTemplate = new Trackback_Template();
        $mTemplate->set ('CONF', $CONF);
-       $mTemplate->set ('plugid', $plug->getID());\r    $mTemplate->set ('plugindirurl', $oPluginAdmin->plugin->getAdminURL());
+       $mTemplate->set ('plugid', $plug->getID());
+       $mTemplate->set ('plugindirurl', $oPluginAdmin->plugin->getAdminURL());
        $mTemplate->template('templates/menu.html');
        echo $mTemplate->fetch();
 
        $oTemplate = new Trackback_Template();
        $oTemplate->set ('CONF', $CONF);
        $oTemplate->set ('plugindirurl', $oPluginAdmin->plugin->getAdminURL());
+       $oTemplate->set ('ticket', $manager->_generateTicket());
+       $ajaxEnabled = ($oPluginAdmin->plugin->getOption('ajaxEnabled') == 'yes') ? true : false;
+       $oTemplate->set ('ajaxEnabled', $ajaxEnabled);
 
        switch($action) {
 
 //modify start+++++++++
                case 'tableUpgrade':
-                       mysql_query("
+                       sql_query("
                                CREATE TABLE IF NOT EXISTS
                                        ".sql_table('plugin_tb_lookup')."
                                (
                                 CHANGE `blog_name` `blog_name` TEXT NOT NULL,
                                 DROP PRIMARY KEY,
                                 ADD `id` INT( 11 ) NOT NULL AUTO_INCREMENT PRIMARY KEY FIRST ;";
-                       $res = @mysql_query($q);
+                       $res = @sql_query($q);
                        if (!$res){
                                echo 'Could not alter table: ' . mysql_error();
                        }else{
                                $tableVersion = 1;
                                $oTemplate->template('templates/updatetablefinished.html');
                        }
-                       @mysql_query('ALTER TABLE `' . sql_table('plugin_tb') . '` ADD INDEX `tb_id_block_timestamp_idx` ( `tb_id`, `block`, `timestamp` DESC )');
+                       @sql_query('ALTER TABLE `' . sql_table('plugin_tb') . '` ADD INDEX `tb_id_block_timestamp_idx` ( `tb_id`, `block`, `timestamp` DESC )');
                        break;
 //modify end+++++++++
 
                case 'block':
                        $tb = intRequestVar('tb');
 
-                       $res = mysql_query ("
+                       $res = sql_query ("
                                UPDATE
                                        ".sql_table('plugin_tb')."
                                SET
                        $action = requestVar('next');
                        break;
                case 'blocked_clear':
-                       $res = mysql_query ("DELETE FROM ".sql_table('plugin_tb')." WHERE block = 1");
+                       $res = sql_query ("DELETE FROM ".sql_table('plugin_tb')." WHERE block = 1");
                        $action = requestVar('next');
                        break;
                        
                case 'blocked_spamclear':
-                       $res = mysql_query ("DELETE FROM ".sql_table('plugin_tb')." WHERE block = 1 and spam = 1");
+                       $res = sql_query ("DELETE FROM ".sql_table('plugin_tb')." WHERE block = 1 and spam = 1");
                        $action = requestVar('next');
                        break;
 
                case 'unblock':
                        $tb = intRequestVar('tb');
 
-                       $res = mysql_query ("
+                       $res = sql_query ("
                                UPDATE
                                        ".sql_table('plugin_tb')."
                                SET
                case 'delete':
                        $tb = intRequestVar('tb');
 
-                       $res = mysql_query ("
+                       $res = sql_query ("
                                DELETE FROM
                                        ".sql_table('plugin_tb')."
                                WHERE
                        break;
 
                case 'blocked':
-                       $start  = intRequestVar('start') ? intRequestVar('start') : 0;
-                       $amount = intRequestVar('amount') ? intRequestVar('amount') : 25;
-
-                       $rres = mysql_query ("
+               case 'all':     
+                       $rres = sql_query ("
                                SELECT
                                        COUNT(*) AS count
                                FROM
                                        ".sql_table('item')." AS i
                                WHERE
                                        t.tb_id = i.inumber AND
-                                       t.block = 1
-                       ");                             
+                                       t.block = " . (( $action == 'all') ? 0 : 1) );                          
                                                
                        if ($row = mysql_fetch_array($rres))
                                $count = $row['count'];
                        else
                                $count = 0;
-                                       
-                       $rres = mysql_query ("
-                               SELECT
+                       $oTemplate->set('count', $count);
+
+                       if($ajaxEnabled){
+                               if( $action == 'all') 
+                                       $oTemplate->template('templates/all_ajax.html');
+                               else                    
+                                       $oTemplate->template('templates/blocked_ajax.html');
+                       } else {\r                               $start  = intRequestVar('start') ? intRequestVar('start') : 0;
+                               $amount = intRequestVar('amount') ? intRequestVar('amount') : 25;
+
+                               $rres = sql_query ("
+                                       SELECT
                                        i.ititle AS story,
                                        i.inumber AS story_id,
                                        t.id AS id,
                                        t.blog_name AS blog_name,
                                        t.excerpt AS excerpt,
                                        t.url AS url,
-                                       -- UNIX_TIMESTAMP(t.timestamp) AS timestamp,
-                                       t.timestamp AS timestamp,
+                                       UNIX_TIMESTAMP(t.timestamp) AS timestamp,
                                        t.spam AS spam,
                                        t.link AS link
-                               FROM
+                                       FROM
                                        ".sql_table('plugin_tb')." AS t,
                                        ".sql_table('item')." AS i
-                               WHERE
+                                       WHERE
                                        t.tb_id = i.inumber AND
-                                       t.block = 1
-                               ORDER BY
+                                       t.block = " . (( $action == 'all') ? 0 : 1) ."
+                                       ORDER BY
                                        timestamp DESC
-                               LIMIT
-                                       ".$start.",".$amount."
-                       ");                             
-                       
-                       $items = array();
-
-                       while ($rrow = mysql_fetch_array($rres))
-                       {
-                               $rrow['title']          = $oPluginAdmin->plugin->_cut_string($rrow['title'], 50);
-                               $rrow['title']          = $oPluginAdmin->plugin->_strip_controlchar($rrow['title']);
-                               $rrow['title']          = htmlspecialchars($rrow['title']);
-//                             $rrow['title']          = _CHARSET == 'UTF-8' ? $rrow['title'] : $oPluginAdmin->plugin->_utf8_to_entities($rrow['title']);
-
-                               $rrow['blog_name']      = $oPluginAdmin->plugin->_cut_string($rrow['blog_name'], 50);
-                               $rrow['blog_name']      = $oPluginAdmin->plugin->_strip_controlchar($rrow['blog_name']);
-                               $rrow['blog_name']      = htmlspecialchars($rrow['blog_name']);
-//                             $rrow['blog_name']      = _CHARSET == 'UTF-8' ? $rrow['blog_name'] : $oPluginAdmin->plugin->_utf8_to_entities($rrow['blog_name']);
-
-                               $rrow['excerpt']        = $oPluginAdmin->plugin->_cut_string($rrow['excerpt'], 800);
-                               $rrow['excerpt']        = $oPluginAdmin->plugin->_strip_controlchar($rrow['excerpt']);
-                               $rrow['excerpt']        = htmlspecialchars($rrow['excerpt']);
-//                             $rrow['excerpt']        = _CHARSET == 'UTF-8' ? $rrow['excerpt'] : $oPluginAdmin->plugin->_utf8_to_entities($rrow['excerpt']);
-
-                               $rrow['url']            = htmlspecialchars($rrow['url'], ENT_QUOTES);
-                               $rrow['timestamp']              = htmlspecialchars($rrow['timestamp'], ENT_QUOTES);
+                                       LIMIT
+                                       ".$start.",".$amount);                          
                                
-                               $blog = & $manager->getBlog(getBlogIDFromItemID($item['itemid']));
-                               $rrow['story_url'] = $oPluginAdmin->plugin->_createItemLink($rrow['story_id'], $blog);
-                               $rrow['story'] = htmlspecialchars(strip_tags($rrow['story']), ENT_QUOTES);
-
-                               $items[] = $rrow;
-                       }
-                       
-                       $oTemplate->set ('amount', $amount);
-                       $oTemplate->set ('count', $count);
-                       $oTemplate->set ('start', $start);
-                       $oTemplate->set ('items', $items);
-                       $oTemplate->template('templates/blocked.html');                 
-                       break;
-
-               case 'all':
-                       $start  = intRequestVar('start') ? intRequestVar('start') : 0;
-                       $amount = intRequestVar('amount') ? intRequestVar('amount') : 25;
-
-                       $rres = mysql_query ("
-                               SELECT
-                                       COUNT(*) AS count
-                               FROM
-                                       ".sql_table('plugin_tb')." AS t,
-                                       ".sql_table('item')." AS i
-                               WHERE
-                                       t.tb_id = i.inumber AND
-                                       t.block = 0
-                       ");                             
-                                               
-                       if ($row = mysql_fetch_array($rres))
-                               $count = $row['count'];
-                       else
-                               $count = 0;
+                               $items = array();
+                               
+                               while ($rrow = mysql_fetch_array($rres)){
+                                       $rrow['title']          = $oPluginAdmin->plugin->_cut_string($rrow['title'], 50);
+                                       $rrow['title']          = $oPluginAdmin->plugin->_strip_controlchar($rrow['title']);
+                                       $rrow['title']          = htmlspecialchars($rrow['title']);
                                        
-                       $rres = mysql_query ("
-                               SELECT
-                                       i.ititle AS story,
-                                       i.inumber AS story_id,
-                                       t.id AS id,
-                                       t.title AS title,
-                                       t.blog_name AS blog_name,
-                                       t.excerpt AS excerpt,
-                                       t.url AS url,
-                                       UNIX_TIMESTAMP(t.timestamp) AS timestamp
-                               FROM
-                                       ".sql_table('plugin_tb')." AS t,
-                                       ".sql_table('item')." AS i
-                               WHERE
-                                       t.tb_id = i.inumber AND
-                                       t.block = 0
-                               ORDER BY
-                                       timestamp DESC
-                               LIMIT
-                                       ".$start.",".$amount."
-                       ");                             
-                       
-                       $items = array();
-
-                       while ($rrow = mysql_fetch_array($rres))
-                       {
-                               $rrow['title']          = $oPluginAdmin->plugin->_cut_string($rrow['title'], 50);
-                               $rrow['title']          = $oPluginAdmin->plugin->_strip_controlchar($rrow['title']);
-                               $rrow['title']          = htmlspecialchars($rrow['title']);
-//                             $rrow['title']          = _CHARSET == 'UTF-8' ? $rrow['title'] : $oPluginAdmin->plugin->_utf8_to_entities($rrow['title']);
-
-                               $rrow['blog_name']      = $oPluginAdmin->plugin->_cut_string($rrow['blog_name'], 50);
-                               $rrow['blog_name']      = $oPluginAdmin->plugin->_strip_controlchar($rrow['blog_name']);
-                               $rrow['blog_name']      = htmlspecialchars($rrow['blog_name']);
-//                             $rrow['blog_name']      = _CHARSET == 'UTF-8' ? $rrow['blog_name'] : $oPluginAdmin->plugin->_utf8_to_entities($rrow['blog_name']);
-
-                               $rrow['excerpt']        = $oPluginAdmin->plugin->_cut_string($rrow['excerpt'], 800);
-                               $rrow['excerpt']        = $oPluginAdmin->plugin->_strip_controlchar($rrow['excerpt']);
-                               $rrow['excerpt']        = htmlspecialchars($rrow['excerpt']);
-//                             $rrow['excerpt']        = _CHARSET == 'UTF-8' ? $rrow['excerpt'] : $oPluginAdmin->plugin->_utf8_to_entities($rrow['excerpt']);
-
-                               $rrow['url']            = htmlspecialchars($rrow['url'], ENT_QUOTES);
-
-                               $blog = & $manager->getBlog(getBlogIDFromItemID($item['itemid']));
-                               $rrow['story_url'] = $oPluginAdmin->plugin->_createItemLink($rrow['story_id'], $blog);
-                               $rrow['story'] = htmlspecialchars(strip_tags($rrow['story']), ENT_QUOTES);
-
-                               $items[] = $rrow;
+                                       $rrow['blog_name']      = $oPluginAdmin->plugin->_cut_string($rrow['blog_name'], 50);
+                                       $rrow['blog_name']      = $oPluginAdmin->plugin->_strip_controlchar($rrow['blog_name']);
+                                       $rrow['blog_name']      = htmlspecialchars($rrow['blog_name']);
+                                       
+                                       $rrow['excerpt']        = $oPluginAdmin->plugin->_cut_string($rrow['excerpt'], 800);
+                                       $rrow['excerpt']        = $oPluginAdmin->plugin->_strip_controlchar($rrow['excerpt']);
+                                       $rrow['excerpt']        = htmlspecialchars($rrow['excerpt']);
+                                       
+                                       $rrow['url']            = htmlspecialchars($rrow['url'], ENT_QUOTES);
+                                       $rrow['timestamp']              = htmlspecialchars($rrow['timestamp'], ENT_QUOTES);
+                                       
+                                       $blog = & $manager->getBlog(getBlogIDFromItemID($item['itemid']));
+                                       $rrow['story_url'] = $oPluginAdmin->plugin->_createItemLink($rrow['story_id'], $blog);
+                                       $rrow['story'] = htmlspecialchars(strip_tags($rrow['story']), ENT_QUOTES);
+                                       
+                                       $items[] = $rrow;
+                               }
+                               
+                               $oTemplate->set('amount', $amount);
+                               $oTemplate->set('start', $start);
+                               $oTemplate->set('items', $items);
+                               
+                               if( $action == 'all') 
+                                       $oTemplate->template('templates/all.html');
+                               else                    
+                                       $oTemplate->template('templates/blocked.html');
                        }
+                       break;
                        
-                       $oTemplate->set ('amount', $amount);
-                       $oTemplate->set ('count', $count);
-                       $oTemplate->set ('start', $start);
-                       $oTemplate->set ('items', $items);
-                       $oTemplate->template('templates/all.html');                     
-                       break;          
-               
                case 'list':
                        $id     = requestVar('id');
                        $start  = intRequestVar('start') ? intRequestVar('start') : 0;
                        $amount = intRequestVar('amount') ? intRequestVar('amount') : 25;
 
-                       $ires = mysql_query ("
+                       $ires = sql_query ("
                                SELECT
                                        ititle,
                                        inumber
                                $story['id']    = $id;
                                $story['title'] = $irow['ititle'];
 
-                               $rres = mysql_query ("
+                               $rres = sql_query ("
                                        SELECT
                                                COUNT(*) AS count
                                        FROM
                                else
                                        $count = 0;
                                        
-                               $rres = mysql_query ("
+                               $rres = sql_query ("
                                        SELECT
                                                t.id AS id,
                                                t.title AS title,
                                                        
                
                case 'index':
-                       $bres = mysql_query ("
+                       $bres = sql_query ("
                                SELECT
                                        bnumber AS bnumber,
                                        bname AS bname,
                        
                        while ($brow = mysql_fetch_array($bres))
                        {
-                               $ires = mysql_query ("
+                               $ires = sql_query ("
                                        SELECT
                                                i.inumber AS inumber,
                                            i.ititle AS ititle,
        // Create the admin area page
        echo $oTemplate->fetch();
        
-       echo '<hr noshade="noshade" size="1" /><div align="right">Powered by <a href="http://www.famfamfam.com/lab/icons/silk/">Silk icon</a></div>';
+       echo '<div align="right">Powered by <a href="http://www.famfamfam.com/lab/icons/silk/">Silk icon</a></div>';
        $oPluginAdmin->end();   
 
-?>