OSDN Git Service

ereg_replaceをpreg_replaceに変更
[nucleus-jp/nucleus-plugins.git] / trunk / NP_MultipleCategories / multiplecategories / index.php
index 2962aef..3527272 100644 (file)
   *   + sato(na) ( http://wa.otesei.com/) 2006-05-01
   */
 
-       // if your 'plugin' directory is not in the default location,
-       // edit this variable to point to your site directory
-       // (where config.php is)
-       $strRel = '../../../';
+    // if your 'plugin' directory is not in the default location,
+    // edit this variable to point to your site directory
+    // (where config.php is)
+    $strRel = '../../../';
 
-       include($strRel . 'config.php');
-       if (!$member->isLoggedIn())
-               doError('You\'re not logged in.');
+    include($strRel . 'config.php');
+    if (!$member->isLoggedIn())
+        doError('You\'re not logged in.');
 
-       include($DIR_LIBS . 'PLUGINADMIN.php');
+    include($DIR_LIBS . 'PLUGINADMIN.php');
 
-       // create the admin area page
-       $oPluginAdmin = new PluginAdmin('MultipleCategories');
-       
+    // create the admin area page
+    $oPluginAdmin = new PluginAdmin('MultipleCategories');
+    
 // ------------------------------------------------------------------
 
 class NpMCategories_ADMIN {
 
-       function NpMCategories_ADMIN() {
-               global $oPluginAdmin;
-               
-               $this->plug =& $oPluginAdmin->plugin;
-               $this->plugname = $this->plug->getName();
-               $this->url = $this->plug->getAdminURL();
-               $this->table = sql_table('plug_multiple_categories_sub');
+    function NpMCategories_ADMIN() {
+        global $oPluginAdmin;
+        
+        $this->plug =& $oPluginAdmin->plugin;
+        $this->plugname = $this->plug->getName();
+        $this->url = $this->plug->getAdminURL();
+        $this->table = sql_table('plug_multiple_categories_sub');
 
 //modify start+++++++++
-               $this->version = $this->plug->checkMSCVersion();
-
-               // include language file for this plugin 
-               $language = ereg_replace( '[\\|/]', '', getLanguageName()); 
-               if (file_exists($this->plug->getDirectory().'language/'.$language.'.php')) 
-                       include_once($this->plug->getDirectory().'language/'.$language.'.php'); 
-               else 
-                       include_once($this->plug->getDirectory().'language/'.'english.php');
+        $this->version = $this->plug->checkMSCVersion();
+
+        // include language file for this plugin 
+//             $language = ereg_replace( '[\\|/]', '', getLanguageName()); 
+        $language = preg_replace( '![\\|/]!', '', getLanguageName()); 
+        if (file_exists($this->plug->getDirectory().'language/'.$language.'.php')) 
+            include_once($this->plug->getDirectory().'language/'.$language.'.php'); 
+        else 
+            include_once($this->plug->getDirectory().'language/'.'english.php');
 //modify end+++++++++
 
-       }
+    }
 
 //-------------------
 
-       function action_overview($msg='') {
-               global $member, $oPluginAdmin;
-               global $manager; //<sato(na)0.5j />
-               
-               $member->isAdmin() or $this->disallow();
-
-               $oPluginAdmin->start();
-               
-               echo '<p><a href="index.php?action=pluginlist">('._PLUGS_BACK.')</a></p>';
-               echo '<h2>' .$this->plugname. '</h2>'."\n";
-               if ($msg) echo "<p>"._MESSAGE.": $msg</p>";
-               echo '<p>[<a href="index.php?action=pluginoptions&amp;plugid='.$this->plug->getID().'">'._MC_EDIT_PLUGIN_OPTIONS.'</a>]</p>';
-               
+    function action_overview($msg='') {
+        global $member, $oPluginAdmin;
+        global $manager; //<sato(na)0.5j />
+        
+        $member->isAdmin() or $this->disallow();
+
+        $oPluginAdmin->start();
+        
+        echo '<p><a href="index.php?action=pluginlist">('._PLUGS_BACK.')</a></p>';
+        echo '<h2>' .$this->plugname. '</h2>'."\n";
+        if ($msg) echo "<p>"._MESSAGE.": $msg</p>";
+        echo '<p>[<a href="index.php?action=pluginoptions&amp;plugid='.$this->plug->getID().'">'._MC_EDIT_PLUGIN_OPTIONS.'</a>]</p>';
+        
 //modify start+++++++++
-               if($this->version == 2){
-                       echo '<blockquote style="color: red;border:1px solid red;padding:0.5em;"><b>Upgarde Information:</b><br />';
-                       echo _MC_SCAT_TABLE_UPDATE_INFO;
+        if($this->version == 2){
+            echo '<blockquote style="color: red;border:1px solid red;padding:0.5em;"><b>Upgarde Information:</b><br />';
+            echo _MC_SCAT_TABLE_UPDATE_INFO;
 ?>
-                       <form method="post" action="<?php echo $this->url ?>index.php"><div>
-                               <input type="hidden" name="action" value="tableUpgrade" />
+            <form method="post" action="<?php echo $this->url ?>index.php"><div>
+                <input type="hidden" name="action" value="tableUpgrade" />
 <?php
-       //<sato(na)0.5j>
-       $manager->addTicketHidden();
-       //</sato(na)0.5j>
+    //<sato(na)0.5j>
+    $manager->addTicketHidden();
+    //</sato(na)0.5j>
 ?>
-                               <input type="submit" tabindex="10" value="upgrade table" />
-                       </div></form>
+                <input type="submit" tabindex="10" value="upgrade table" />
+            </div></form>
 <?php
-                       echo '</blockquote>';
-               }
-               
-               $res = sql_query('SELECT bnumber, bname FROM '.sql_table('blog'));
-               while ($o = mysql_fetch_object($res)) {
-                       echo '<h3 style="padding-left: 0px">' . htmlspecialchars($o->bname) . '</h3>';
+            echo '</blockquote>';
+        }
+        
+        $res = sql_query('SELECT bnumber, bname FROM '.sql_table('blog'));
+        while ($o = mysql_fetch_object($res)) {
+            echo '<h3 style="padding-left: 0px">' . htmlspecialchars($o->bname) . '</h3>';
 ?>
 <table>
-       <thead>
-               <tr><th><?php echo _LISTS_NAME ?></th><th><?php echo _LISTS_DESC ?></th><th><?php echo _MC_SUB_CATEGORIES ?></th><th><?php echo _LISTS_ACTIONS ?></th></tr>
-       </thead>
-       <tbody>
+    <thead>
+        <tr><th><?php echo _LISTS_NAME ?></th><th><?php echo _LISTS_DESC ?></th><th><?php echo _MC_SUB_CATEGORIES ?></th><th><?php echo _LISTS_ACTIONS ?></th></tr>
+    </thead>
+    <tbody>
 <?php
-                       $cats = $this->plug->_getCategories($o->bnumber);
-                       foreach ($cats as $cat) {
-                               $snum = quickQuery("SELECT count(*) as result FROM ".$this->table." WHERE catid=".intval($cat['catid']));//<sato(na)0.5j />
-                               $snum = intval($snum);
+            $cats = $this->plug->_getCategories($o->bnumber);
+            foreach ($cats as $cat) {
+                $snum = quickQuery("SELECT count(*) as result FROM ".$this->table." WHERE catid=".intval($cat['catid']));//<sato(na)0.5j />
+                $snum = intval($snum);
 ?>
-               <tr onmouseover='focusRow(this);' onmouseout='blurRow(this);'>
-                       <td>
-                               <?php echo htmlspecialchars($cat['name']) ?></td>
-                       <td><?php echo htmlspecialchars($cat['cdesc']) ?></td>
-                       <td><?php echo $snum ?></td>
-                       <td><a href="<?php echo $this->url ?>index.php?action=scatoverview&amp;catid=<?php echo intval($cat['catid']) ?>" tabindex="50"><?php echo _MC_EDIT_SUB_CATEGORIES ?></a></td>
-               </tr>
+        <tr onmouseover='focusRow(this);' onmouseout='blurRow(this);'>
+            <td>
+                <?php echo htmlspecialchars($cat['name']) ?></td>
+            <td><?php echo htmlspecialchars($cat['cdesc']) ?></td>
+            <td><?php echo $snum ?></td>
+            <td><a href="<?php echo $this->url ?>index.php?action=scatoverview&amp;catid=<?php echo intval($cat['catid']) ?>" tabindex="50"><?php echo _MC_EDIT_SUB_CATEGORIES ?></a></td>
+        </tr>
 <?php
-                       }
+            }
 ?>
-       </tbody>
+    </tbody>
 </table>
 <?php
-               }
-               
-               $oPluginAdmin->end();
-       
-       }
+        }
+        
+        $oPluginAdmin->end();
+    
+    }
 
 //-----
 
-       function action_scatoverview($msg = '') {
-               global $member, $oPluginAdmin;
-               global $manager; //<sato(na)0.5j />
-               
-               $member->isAdmin() or $this->disallow();
-               
-               $catid = intRequestVar('catid');
-               $catname = $this->plug->_getCatNameFromID($catid);
-               
-               $oPluginAdmin->start();
+    function action_scatoverview($msg = '') {
+        global $member, $oPluginAdmin;
+        global $manager; //<sato(na)0.5j />
+        
+        $member->isAdmin() or $this->disallow();
+        
+        $catid = intRequestVar('catid');
+        $catname = $this->plug->_getCatNameFromID($catid);
+        
+        $oPluginAdmin->start();
 
 ?>
 <p><a href="<?php echo $this->url ?>index.php?action=overview">(Go Back)</a></p>
 
 <h2><?php 
-               echo _MC_EDIT_SUB_CATEGORIES_OF." '".htmlspecialchars($catname)."'</h2>\n";
+        echo _MC_EDIT_SUB_CATEGORIES_OF." '".htmlspecialchars($catname)."'</h2>\n";
 
-               if ($msg) echo "<p>"._MESSAGE.": $msg</p>";
+        if ($msg) echo "<p>"._MESSAGE.": $msg</p>";
 
-               $defines = $this->plug->_getDefinedScats($catid);
-               if (count($defines) > 0) {
+        $defines = $this->plug->_getDefinedScats($catid);
+        if (count($defines) > 0) {
 
 //modify start+++++++++
-                       if($this->version > 2){
-                               echo $this->listupSubcategories($catid, $subcatid);
-                               echo $this->showOrderMenu($catid, $subcatid);
-                       }else{
+            if($this->version > 2){
+                echo $this->listupSubcategories($catid, $subcatid);
+                echo $this->showOrderMenu($catid, $subcatid);
+            }else{
 //modify end+++++++++
 
 ?>
 
-       <table>
-       <thead>
-               <tr><th><?php echo _LISTS_NAME ?></th><th><?php echo _LISTS_DESC ?></th><th colspan='2'><?php echo _LISTS_ACTIONS ?></th></tr>
-       </thead>
-       <tbody>
+    <table>
+    <thead>
+        <tr><th><?php echo _LISTS_NAME ?></th><th><?php echo _LISTS_DESC ?></th><th colspan='2'><?php echo _LISTS_ACTIONS ?></th></tr>
+    </thead>
+    <tbody>
 <?php
-                       foreach ($defines as $scat) {
+            foreach ($defines as $scat) {
 ?>
-               <tr onmouseover='focusRow(this);' onmouseout='blurRow(this);'>
-                       <td><?php echo htmlspecialchars($scat['sname']) ?></td>
-                       <td><?php echo htmlspecialchars($scat['sdesc']) ?></td>
-                       <td><a href="<?php echo $this->url ?>index.php?action=scatedit&amp;catid=<?php echo $catid ?>&amp;scatid=<?php echo $scat['scatid'] ?>" tabindex="50"><?php echo _LISTS_EDIT ?></a></td>
-                       <td><a href="<?php echo $this->url ?>index.php?action=scatdelete&amp;catid=<?php echo $catid ?>&amp;scatid=<?php echo $scat['scatid'] ?>" tabindex="50"><?php echo _LISTS_DELETE ?></a></td>
-               </tr>
+        <tr onmouseover='focusRow(this);' onmouseout='blurRow(this);'>
+            <td><?php echo htmlspecialchars($scat['sname']) ?></td>
+            <td><?php echo htmlspecialchars($scat['sdesc']) ?></td>
+            <td><a href="<?php echo $this->url ?>index.php?action=scatedit&amp;catid=<?php echo $catid ?>&amp;scatid=<?php echo $scat['scatid'] ?>" tabindex="50"><?php echo _LISTS_EDIT ?></a></td>
+            <td><a href="<?php echo $this->url ?>index.php?action=scatdelete&amp;catid=<?php echo $catid ?>&amp;scatid=<?php echo $scat['scatid'] ?>" tabindex="50"><?php echo _LISTS_DELETE ?></a></td>
+        </tr>
 <?php
-                       }
+            }
 ?>
-       </tbody>
-       </table>
+    </tbody>
+    </table>
 <?php
 //modify start+++++++++
-                       }
+            }
 //modify end+++++++++
-               } //end of if(count($defines) > 0)
-               
-               echo "\n\n".'<h3>'._MC_CREATE_NEW_SUB_CATEGORY.'</h3>'."\n\n";
-               
+        } //end of if(count($defines) > 0)
+        
+        echo "\n\n".'<h3>'._MC_CREATE_NEW_SUB_CATEGORY.'</h3>'."\n\n";
+        
 ?>
-       <form method="post" action="<?php echo $this->url ?>index.php"><div>
-       
-               <input name="action" value="scatnew" type="hidden" />
+    <form method="post" action="<?php echo $this->url ?>index.php"><div>
+    
+        <input name="action" value="scatnew" type="hidden" />
 <?php
-       //<sato(na)0.5j>
-       $manager->addTicketHidden();
-       //</sato(na)0.5j>
+    //<sato(na)0.5j>
+    $manager->addTicketHidden();
+    //</sato(na)0.5j>
 ?>
-               <input name="catid" value="<?php echo $catid ?>" type="hidden" />
-               <table><tr>
-                       <td><?php echo _MC_SCAT_NAME ?></td>
-                       <td><input name="sname" tabindex="10010" maxlength="20" size="20" /></td>
-               </tr><tr>
-                       <td><?php echo _MC_SCAT_DESC ?></td>
-                       <td><input name="sdesc" tabindex="10020" size="60" maxlength="200" /></td>
-               </tr><tr>
+        <input name="catid" value="<?php echo $catid ?>" type="hidden" />
+        <table><tr>
+            <td><?php echo _MC_SCAT_NAME ?></td>
+            <td><input name="sname" tabindex="10010" maxlength="20" size="20" /></td>
+        </tr><tr>
+            <td><?php echo _MC_SCAT_DESC ?></td>
+            <td><input name="sdesc" tabindex="10020" size="60" maxlength="200" /></td>
+        </tr><tr>
 <?php
-                       if($this->version > 2){
+            if($this->version > 2){
 ?>
-                       <td><?php echo _MC_SCAT_PARENT_NAME ?></td>
-                       <td>
+            <td><?php echo _MC_SCAT_PARENT_NAME ?></td>
+            <td>
 <?php
-                               $subcategoryList = $this->getCategoryList($catid);
-                               echo $this->printCategoryList($catid, $subcategoryList, 1, 0);
+                $subcategoryList = $this->getCategoryList($catid);
+                echo $this->printCategoryList($catid, $subcategoryList, 1, 0);
 ?>
-       </td>
-               </tr><tr>
+    </td>
+        </tr><tr>
 <?php
-                       }
+            }
 ?>
-                       <td><?php echo _MC_SCAT_CREATE ?></td>
-                       <td><input type="submit" tabindex="10030" value="<?php echo _MC_SCAT_CREATE ?>" onclick="return checkSubmit();" /></td>
-               </tr></table>
-               
-       </div></form>
+            <td><?php echo _MC_SCAT_CREATE ?></td>
+            <td><input type="submit" tabindex="10030" value="<?php echo _MC_SCAT_CREATE ?>" onclick="return checkSubmit();" /></td>
+        </tr></table>
+        
+    </div></form>
 <?php
-               
-               $oPluginAdmin->end();
-       
-       }
-       
-       function action_scatedit($msg = '') {//-----
-               global $member, $oPluginAdmin;
-               global $manager; //<sato(na)0.5j />
-               
-               $member->isAdmin() or $this->disallow();
-
-               $scatid = intRequestVar('scatid');
-               $catid = intRequestVar('catid');
-               
-               $res = sql_query("SELECT * FROM ".$this->table." WHERE scatid=$scatid and catid=$catid");
-               if ($o = mysql_fetch_object($res)) {
-
-                       $oPluginAdmin->start();
+        
+        $oPluginAdmin->end();
+    
+    }
+    
+    function action_scatedit($msg = '') {//-----
+        global $member, $oPluginAdmin;
+        global $manager; //<sato(na)0.5j />
+        
+        $member->isAdmin() or $this->disallow();
+
+        $scatid = intRequestVar('scatid');
+        $catid = intRequestVar('catid');
+        
+        $res = sql_query("SELECT * FROM ".$this->table." WHERE scatid=$scatid and catid=$catid");
+        if ($o = mysql_fetch_object($res)) {
+
+            $oPluginAdmin->start();
 
 ?>
 <p><a href="<?php echo $this->url ?>index.php?action=scatoverview&amp;catid=<?php echo $catid ?>">(Go Back to OVERVIEW)</a></p>
 
 <h2><?php 
-                       echo _MC_SCAT_EDIT;
-                       echo  " '".htmlspecialchars($o->sname)."'</h2>\n";
+            echo _MC_SCAT_EDIT;
+            echo  " '".htmlspecialchars($o->sname)."'</h2>\n";
 
-                       if ($msg) echo "<p>"._MESSAGE.": $msg</p>";
+            if ($msg) echo "<p>"._MESSAGE.": $msg</p>";
 
 ?>
 <script language=javascript src=<?php echo $this->url ?>orderlist.js></script>
 <form method="post" action="<?php echo $this->url ?>index.php?action=scatedit&catid=<?php echo $catid; ?>&scatid=<?php echo $scatid; ?>">
-       <input type="hidden" name="action" value="scatupdate" />
+    <input type="hidden" name="action" value="scatupdate" />
 <?php
-       //<sato(na)0.5j>
-       $manager->addTicketHidden();
-       //</sato(na)0.5j>
+    //<sato(na)0.5j>
+    $manager->addTicketHidden();
+    //</sato(na)0.5j>
 ?>
-       <input type="hidden" name="scatid" value="<?php echo $scatid; ?>" />
-       <input type="hidden" name="catid" value="<?php echo $catid; ?>" />
-
-       <div>
-               
-       <table><tr>
-               <td><?php echo _MC_SCAT_NAME ?></td>
-               <td><input name="sname" tabindex="10010" maxlength="20" size="20" value="<?php echo htmlspecialchars($o->sname) ?>" /></td>
-       </tr><tr>
-               <td><?php echo _MC_SCAT_DESC ?></td>
-               <td><input name="sdesc" tabindex="10020" size="60" maxlength="200" value="<?php echo htmlspecialchars($o->sdesc) ?>" /></td>
-       </tr><tr>
+    <input type="hidden" name="scatid" value="<?php echo $scatid; ?>" />
+    <input type="hidden" name="catid" value="<?php echo $catid; ?>" />
+
+    <div>
+        
+    <table><tr>
+        <td><?php echo _MC_SCAT_NAME ?></td>
+        <td><input name="sname" tabindex="10010" maxlength="20" size="20" value="<?php echo htmlspecialchars($o->sname) ?>" /></td>
+    </tr><tr>
+        <td><?php echo _MC_SCAT_DESC ?></td>
+        <td><input name="sdesc" tabindex="10020" size="60" maxlength="200" value="<?php echo htmlspecialchars($o->sdesc) ?>" /></td>
+    </tr><tr>
 <?php
-                       if($this->version > 2){
+            if($this->version > 2){
 ?>
-                       <td><?php echo _MC_SCAT_PARENT_NAME . '<br />' . _MC_SCAT_PARENT_NAME_DESC ?></td><!-- <sato(na)0.402j /> -->
-                       <td>
+            <td><?php echo _MC_SCAT_PARENT_NAME . '<br />' . _MC_SCAT_PARENT_NAME_DESC ?></td><!-- <sato(na)0.402j /> -->
+            <td>
 <?php
-                               $pid = quickQuery('SELECT parentid as result FROM '.$this->table.' WHERE scatid='.$scatid);
-                               //<sato(na)0.402j>
-                               //$subcategoryList = $this->getCategoryList($catid, $pid);
-                               //echo $this->printCategoryList($catid, $subcategoryList, 1);
-                               echo $this->printCategoryListUD($catid, $pid);
-                               //</sato(na)0.402j>
+                $pid = quickQuery('SELECT parentid as result FROM '.$this->table.' WHERE scatid='.$scatid);
+                //<sato(na)0.402j>
+                //$subcategoryList = $this->getCategoryList($catid, $pid);
+                //echo $this->printCategoryList($catid, $subcategoryList, 1);
+                echo $this->printCategoryListUD($catid, $pid);
+                //</sato(na)0.402j>
 ?>
-       </td>
-               </tr><tr>
+    </td>
+        </tr><tr>
 <?php
-                       }
+            }
 ?>
-               <td><?php echo _MC_SCAT_UPDATE ?></td>
-               <td><input type="submit" tabindex="10030" value="<?php echo _MC_SCAT_UPDATE ?>" onclick="return checkSubmit();" /></td>
-       </tr></table>
-               
-       </div>
+        <td><?php echo _MC_SCAT_UPDATE ?></td>
+        <td><input type="submit" tabindex="10030" value="<?php echo _MC_SCAT_UPDATE ?>" onclick="return checkSubmit();" /></td>
+    </tr></table>
+        
+    </div>
 </form>
 <?php
-                       if($this->version > 2) echo $this->showOrderMenu($catid, $scatid);
-
-                       $oPluginAdmin->end();
-
-               } else $this->error(_MC_SCAT_MISSING);
-       }//-----
-
-       function action_scatnew() {
-               global $member;
-               
-               $member->isAdmin() or $this->disallow();
-               
-               $sname = postVar('sname');
-               if (!trim($sname)){
-                       $this->action_scatoverview(_MC_SCAT_ERROR_NAME);
-               } else{
-                       $newid = $this->createSubcat($sname);
-
-                       $array = array(
-                               'catid'=>postVar('catid'),
-                               'sdesc'=>postVar('sdesc')
-                       );
-                       if($this->version > 2)
-                               $array['parentid'] = postVar('parentid');
-                       
-                       $this->updateSubcat($newid,$array);
-
-                       $this->action_scatoverview();
-               }
-       }
-       
-       function action_scatupdate() {
-               global $member;
-               
-               $scatid = intRequestVar('scatid');
-
-               $member->isAdmin() or $this->disallow();
-               
-               $sname = postVar('sname');
-               if (!trim($sname)) {
-                       $this->action_scatoverview("Error! Input a name.");
-               } else {
-               
-                       $this->addToScat($scatid);
-               
-                       $this->action_scatedit(_MC_SCAT_DATA_UPDATE);
-               }
-       
-       }       
+            if($this->version > 2) echo $this->showOrderMenu($catid, $scatid);
+
+            $oPluginAdmin->end();
+
+        } else $this->error(_MC_SCAT_MISSING);
+    }//-----
+
+    function action_scatnew() {
+        global $member;
+        
+        $member->isAdmin() or $this->disallow();
+        
+        $sname = postVar('sname');
+        if (!trim($sname)){
+            $this->action_scatoverview(_MC_SCAT_ERROR_NAME);
+        } else{
+            $newid = $this->createSubcat($sname);
+
+            $array = array(
+                'catid'=>postVar('catid'),
+                'sdesc'=>postVar('sdesc')
+            );
+            if($this->version > 2)
+                $array['parentid'] = postVar('parentid');
+            
+            $this->updateSubcat($newid,$array);
+
+            $this->action_scatoverview();
+        }
+    }
+    
+    function action_scatupdate() {
+        global $member;
+        
+        $scatid = intRequestVar('scatid');
+
+        $member->isAdmin() or $this->disallow();
+        
+        $sname = postVar('sname');
+        if (!trim($sname)) {
+            $this->action_scatoverview("Error! Input a name.");
+        } else {
+        
+            $this->addToScat($scatid);
+        
+            $this->action_scatedit(_MC_SCAT_DATA_UPDATE);
+        }
+    
+    }   
 
 //modify start+++++++++
-       function action_tableUpgrade() {
-               if($this->version == 2){
-                       $q = "ALTER TABLE `".$this->table."` ADD `parentid` INT( 11 ) DEFAULT '0' NOT NULL AFTER `scatid` , ADD `ordid` INT( 11 ) DEFAULT '100' NOT NULL AFTER `parentid` ;";
-               }elseif($this->version == 3){
-                       $q = "ALTER TABLE `".$this->table."` ADD `ordid` INT( 11 ) DEFAULT '100' NOT NULL AFTER `parentid` ;";
-               }
-               if($q)  sql_query($q);
-               
-               $this->version = 4;
-
-               $this->action_overview('<blockquote style="color: red;border:1px solid red;padding:0.5em;"><b>'._MC_SCAT_TABLE_UPDATE.'</b></blockquote>');
-       }
-
-       function action_scatOrder() {
-               global $member;
-               
-               $scatid = intRequestVar('scatid');
-
-               $member->isAdmin() or $this->disallow();
-               
-               $order = array();
-               $order = explode(",", requestVar('orderList'));
-
-               $x=1;
-               foreach($order as $o){
-                       $o = trim(rtrim($o));
-                       $query = 'UPDATE '.$this->table.' SET ordid='.intval($x).' WHERE scatid='.intval($o); //<sato(na)0.5j />ultrarich
-                       sql_query($query);
-                       $x++;
-               }
-
-               if(requestVar('redirect') == 'scatoverview'){
-                       $this->action_scatoverview(_MC_SCAT_ORDER_UPDATE);
-               }else{
-                       $this->action_scatedit(_MC_SCAT_ORDER_UPDATE);
-               }
-       
-       }       
+    function action_tableUpgrade() {
+        if($this->version == 2){
+            $q = "ALTER TABLE `".$this->table."` ADD `parentid` INT( 11 ) DEFAULT '0' NOT NULL AFTER `scatid` , ADD `ordid` INT( 11 ) DEFAULT '100' NOT NULL AFTER `parentid` ;";
+        }elseif($this->version == 3){
+            $q = "ALTER TABLE `".$this->table."` ADD `ordid` INT( 11 ) DEFAULT '100' NOT NULL AFTER `parentid` ;";
+        }
+        if($q)  sql_query($q);
+        
+        $this->version = 4;
+
+        $this->action_overview('<blockquote style="color: red;border:1px solid red;padding:0.5em;"><b>'._MC_SCAT_TABLE_UPDATE.'</b></blockquote>');
+    }
+
+    function action_scatOrder() {
+        global $member;
+        
+        $scatid = intRequestVar('scatid');
+
+        $member->isAdmin() or $this->disallow();
+        
+        $order = array();
+        $order = explode(",", requestVar('orderList'));
+
+        $x=1;
+        foreach($order as $o){
+            $o = trim(rtrim($o));
+            $query = 'UPDATE '.$this->table.' SET ordid='.intval($x).' WHERE scatid='.intval($o); //<sato(na)0.5j />ultrarich
+            sql_query($query);
+            $x++;
+        }
+
+        if(requestVar('redirect') == 'scatoverview'){
+            $this->action_scatoverview(_MC_SCAT_ORDER_UPDATE);
+        }else{
+            $this->action_scatedit(_MC_SCAT_ORDER_UPDATE);
+        }
+    
+    }   
 //modify end+++++++++
 
-       function action_scatdelete() {
-               global $member, $oPluginAdmin;
-               global $manager; //<sato(na)0.5j />
-               
-               $member->isAdmin() or $this->disallow();
-               
-               $scatid = intRequestVar('scatid');
-               $catid = intRequestVar('catid');
+    function action_scatdelete() {
+        global $member, $oPluginAdmin;
+        global $manager; //<sato(na)0.5j />
+        
+        $member->isAdmin() or $this->disallow();
+        
+        $scatid = intRequestVar('scatid');
+        $catid = intRequestVar('catid');
 //modify start+++++++++
-               if($this->version > 2){
-                       $sname = $this->plug->_getScatNameFromID($scatid);
-                       $sdesc = $this->plug->_getScatDescFromID($scatid);
-                       if($sdesc) $sdesc = ' ('.$sdesc.')';
-
-               
-                       $modChildren = $this->_getDefinedScatsFromScat($scatid);
-                       $pid = quickQuery('SELECT parentid as result FROM '.$this->table.' WHERE scatid='.intval($scatid)); //<sato(na)0.5j />ultrarich
-                       $pid = intval($pid); //<sato(na)0.5j />ultrarich
-                       $pname = ($pid)? 
-                               $this->plug->_getScatNameFromID($pid).' ('._MC_SUB_CATEGORIES.')':
-                               quickQuery('SELECT cname as result FROM '.sql_table('category').' WHERE catid='.intval($catid)).' (' . _EBLOG_CAT_TITLE . ')';
-               }
+        if($this->version > 2){
+            $sname = $this->plug->_getScatNameFromID($scatid);
+            $sdesc = $this->plug->_getScatDescFromID($scatid);
+            if($sdesc) $sdesc = ' ('.$sdesc.')';
+
+        
+            $modChildren = $this->_getDefinedScatsFromScat($scatid);
+            $pid = quickQuery('SELECT parentid as result FROM '.$this->table.' WHERE scatid='.intval($scatid)); //<sato(na)0.5j />ultrarich
+            $pid = intval($pid); //<sato(na)0.5j />ultrarich
+            $pname = ($pid)? 
+                $this->plug->_getScatNameFromID($pid).' ('._MC_SUB_CATEGORIES.')':
+                quickQuery('SELECT cname as result FROM '.sql_table('category').' WHERE catid='.intval($catid)).' (' . _EBLOG_CAT_TITLE . ')';
+        }
 //modify end+++++++++
-               
-               $oPluginAdmin->start();
-               ?>
-                       <h2><?php echo _DELETE_CONFIRM?></h2>
-                       
-                       <p><?php echo _MC_CONFIRMTXT_SCAT ?><b>
+        
+        $oPluginAdmin->start();
+        ?>
+            <h2><?php echo _DELETE_CONFIRM?></h2>
+            
+            <p><?php echo _MC_CONFIRMTXT_SCAT ?><b>
 <?php
-                       echo htmlspecialchars($sname.$sdesc, ENT_QUOTES); //<sato(na)0.5j />
+            echo htmlspecialchars($sname.$sdesc, ENT_QUOTES); //<sato(na)0.5j />
 ?>
-                       </b></p>
-                       
+            </b></p>
+            
 <?php
-               if($modChildren){
-                       $modList = $pid.'-';
-                       echo '<blockquote style="color: red;border:1px solid red;padding:1em;"><b>Note:</b><br />';
-                       echo _MC_SCAT_DELETE_NOTE_LIST;
-                       echo '<ul>';
-                       for($i=0;$i<count($modChildren);$i++){
-                               echo '<li>'.htmlspecialchars($modChildren[$i]['sname'], ENT_QUOTES)."</li>\n"; //<sato(na)0.5j />
-                               $modList .= intval($modChildren[$i]['scatid']).'/'; //<sato(na)0.5j />ultrarich
-                       }
-                       echo '</ul>';
-                       echo _MC_SCAT_DELETE_NOTE_PARENT.'<ul><li>'.htmlspecialchars($pname, ENT_QUOTES).'</li></ul>'; //<sato(na)0.5j />
-                       echo '</blockquote>';
-                       $extraInput = '<input type="hidden" name="modlist" value="'.substr($modList, 0, -1).'" />'."\n";
-               }
+        if($modChildren){
+            $modList = $pid.'-';
+            echo '<blockquote style="color: red;border:1px solid red;padding:1em;"><b>Note:</b><br />';
+            echo _MC_SCAT_DELETE_NOTE_LIST;
+            echo '<ul>';
+            for($i=0;$i<count($modChildren);$i++){
+                echo '<li>'.htmlspecialchars($modChildren[$i]['sname'], ENT_QUOTES)."</li>\n"; //<sato(na)0.5j />
+                $modList .= intval($modChildren[$i]['scatid']).'/'; //<sato(na)0.5j />ultrarich
+            }
+            echo '</ul>';
+            echo _MC_SCAT_DELETE_NOTE_PARENT.'<ul><li>'.htmlspecialchars($pname, ENT_QUOTES).'</li></ul>'; //<sato(na)0.5j />
+            echo '</blockquote>';
+            $extraInput = '<input type="hidden" name="modlist" value="'.substr($modList, 0, -1).'" />'."\n";
+        }
 ?>
-       
-                       
-                       <form method="post" action="<?php echo $this->url ?>index.php"><div>
-                               <input type="hidden" name="action" value="scatdeleteconfirm" />
+    
+            
+            <form method="post" action="<?php echo $this->url ?>index.php"><div>
+                <input type="hidden" name="action" value="scatdeleteconfirm" />
 <?php
-       //<sato(na)0.5j>
-       $manager->addTicketHidden();
-       //</sato(na)0.5j>
+    //<sato(na)0.5j>
+    $manager->addTicketHidden();
+    //</sato(na)0.5j>
 ?>
-                               <input type="hidden" name="scatid" value="<?php echo $scatid ?>" />
-                               <input type="hidden" name="catid" value="<?php echo $catid ?>" />
-                               <?php echo $extraInput ?>
-                               <input type="submit" tabindex="10" value="<?php echo _DELETE_CONFIRM_BTN ?>" />
-                       </div></form>
-               <?php
-               
-               $oPluginAdmin->end();
-       }       
-       
-       function action_scatdeleteconfirm() {
-               global $member, $manager;
-               
-               $scatid = intRequestVar('scatid');
-               $catid  = intRequestVar('catid');
-               
-               $member->isAdmin() or $this->disallow();
-               
+                <input type="hidden" name="scatid" value="<?php echo $scatid ?>" />
+                <input type="hidden" name="catid" value="<?php echo $catid ?>" />
+                <?php echo $extraInput ?>
+                <input type="submit" tabindex="10" value="<?php echo _DELETE_CONFIRM_BTN ?>" />
+            </div></form>
+        <?php
+        
+        $oPluginAdmin->end();
+    }   
+    
+    function action_scatdeleteconfirm() {
+        global $member, $manager;
+        
+        $scatid = intRequestVar('scatid');
+        $catid  = intRequestVar('catid');
+        
+        $member->isAdmin() or $this->disallow();
+        
 //modify start+++++++++
-               $modList = requestVar('modlist');
-               if($modList){
-                       list($parent, $children) = explode("-", $modList);
-                       $children = explode("/", $children);
-                       for($i=0;$i<count($children);$i++){
-                               $c = trim(rtrim($children[$i]));
-                               $query = 'UPDATE '.$this->table.' SET parentid='.intval($parent).' WHERE scatid='.intval($c); //<sato(na)0.5j />ultrarich
-                               sql_query($query);
-                       }
-               }
+        $modList = requestVar('modlist');
+        if($modList){
+            list($parent, $children) = explode("-", $modList);
+            $children = explode("/", $children);
+            for($i=0;$i<count($children);$i++){
+                $c = trim(rtrim($children[$i]));
+                $query = 'UPDATE '.$this->table.' SET parentid='.intval($parent).' WHERE scatid='.intval($c); //<sato(na)0.5j />ultrarich
+                sql_query($query);
+            }
+        }
 //modify end+++++++++
 
-               $this->deleteSubcat($scatid);
-               
-               $this->action_scatoverview("Sub category has been deleted.");
-       }
-       
-       function addToScat($nowid) {
-               if($this->version >= 3)
-                       $datanames = array('catid','sname','sdesc','parentid');
-               else
-                       $datanames = array('catid','sname','sdesc');
-               foreach ($datanames as $val) {
-                       $scat[$val] = postVar($val);
-               }
-               $this->updateSubcat($nowid,$scat);
-       }
-
-       function createSubcat($name) {
-               sql_query('INSERT INTO '.$this->table.' SET sname="'. addslashes($name) .'"');
-               $newid = mysql_insert_id();
-               global $manager;
-               $manager->notify(
-                                                'PostAddSubcat',
-                                                array(
-                                                          'subcatid' => $newid
-                                                         )
-                                               );
-               return $newid;
-       }
-
-       //<sato(na)0.402j>
-       //printCategoryList for update
-       function printCategoryListUD($catid, $parentid) {
-               $catName = quickQuery('SELECT cname as result FROM '.sql_table('category').' WHERE catid='.intval($catid));
-               $catName = htmlspecialchars($catName, ENT_QUOTES); //<sato(na)0.5j />
-               $text .= "<select size='10' name='parentid'>\n";
-               $text    .= "<option value='0'>&nbsp;$catName&nbsp;</option>\n";
-               foreach ($this->plug->_setSubOrder() as $val) { //$val : _getSubOrder intval($row_scat->scatid)
-                       $query = 'SELECT * FROM '.$this->table.' WHERE scatid=' . intval($val);
-                       $res   = sql_query($query);
-                       $row   = mysql_fetch_array($res);
-                       if ($row['catid'] == $catid){
-                               $levelstr = '';
-                               for ($i=0; $i<$this->getDepth($val, 0); $i++) $levelstr .= "&hellip;&hellip;";
-                               $selected = ($parentid == $val) ? " selected='selected'" : '';
-                               $text    .= "<option value='".$val."'".$selected.">&nbsp;".$levelstr."&hellip;&nbsp;".
-                                           //<sato(na)0.5j>
-                                           htmlspecialchars($row['sname'], ENT_QUOTES).
-                                           " <sup>".
-                                           htmlspecialchars($row['sdesc'], ENT_QUOTES).
-                                           "</sup>&nbsp;</option>\n";
-                                           //</sato(na)0.5j>
-                       }
-               }
-               $text .= "</select>\n";
-               return $text;
-       }
-       function getDepth($scatid, $level) {
-               $parentid = quickQuery('SELECT parentid as result FROM '.$this->table.' WHERE scatid='.$scatid);
-               return ($parentid == 0) ? $level : $this->getDepth($parentid, $level + 1);
-       }
-       function descendantCheck($parentid, $checkid){
-               $res = sql_query("SELECT scatid FROM ".$this->table." WHERE parentid=".intval($parentid)); //<sato(na)0.5j />
-               while ($o = mysql_fetch_object($res)) {
-                       if ($o->scatid == $checkid) {
-                               return TRUE;
-                       } else {
-                               if ($this->descendantCheck($o->scatid, $checkid)) return TRUE;
-                       }
-               }
-               return FALSE;
-       }
-       //</sato(na)0.402j>
-
-       function updateSubcat($id, $scat) {
-               
-               //<sato(na)0.402j>
-               $old_parentid = quickQuery('SELECT parentid as result FROM '.$this->table.' WHERE scatid='.$id);
-               if ($id == $scat['parentid']) $branch = 'Self'; else $branch = ($this->descendantCheck($id, $scat['parentid']) ? 'Descendant' : 'Other');
-               
-               switch ($branch){
-                       case 'Self':
-                               //cancel
-                               $scat['parentid'] = $old_parentid;
-                               //echo '----------------------------------------Self';
-                       break;
-                       case 'Descendant':
-                               //Succession
-                               //echo '----------------------------------------Descendant';
-                               $query = 'UPDATE '.$this->table.' SET parentid='.intval($old_parentid).' WHERE parentid='.intval($id); //<sato(na)0.5j />
-                               sql_query($query);
-                       break;
-                       case 'Other':
-                               //Nothing is done.
-                               //echo '----------------------------------------Other';
-               }
-               //</sato(na)0.402j>
-               
-               $query = 'UPDATE '.$this->table.' SET ';
-               foreach ($scat as $k => $v) {
-                       $query .= $k.'="'.addslashes($v).'",';
-               }
-               $query = substr($query,0,-1);
-               $query .= ' WHERE scatid='.intval($id); //<sato(na)0.5j />
-               sql_query($query);
-       }
-       
-       function deleteSubcat($id) {
-               $id = intval($id); //<sato(na)0.5j />
-               sql_query('DELETE FROM '.$this->table.' WHERE scatid=' . $id);
-               global $manager;
-               $manager->notify(
-                                                'PostDeleteSubcat',
-                                                array(
-                                                          'subcatid' => $id
-                                                         )
-                                               );
-
-               $res = sql_query("SELECT categories, subcategories, item_id FROM ". sql_table("plug_multiple_categories") ." WHERE subcategories REGEXP '(^|,)$id(,|$)'");
-               $dell = array();
-               $up = array();
-
-               while ($o = mysql_fetch_object($res)) {
-                       $o->subcategories = preg_replace("/^(?:(.*),)?$catid(?:,(.*))?$/","$1,$2",$o->subcategories);
-                       if (!$o->categories && (!$o->subcategories || $o->subcategories == ',')) {
-                               $del[] = intval($o->item_id); //<sato(na)0.5j />ultrarich
-                       } else {
-                               $o->subcategories = preg_replace("/(^,+|(?<=,),+|,+$)/","",$o->subcategories);
-                               $up[] = "UPDATE ". sql_table("plug_multiple_categories") ." SET categories='".addslashes($o->categories)."', subcategories='".addslashes($o->subcategories)."' WHERE item_id=".$o->item_id;
-                       }
-               }
-               
-               if (count($del) > 0) {
-                       sql_query("DELETE FROM ". sql_table("plug_multiple_categories") . " WHERE item_id in (".implode(",",$del).")");
-               }
-               if (count($up) > 0) {
-                       foreach ($up as $v) {
-                               sql_query($v);
-                       }
-               }
-       }
-       
-
-       function action($action) {
-               //<sato(na)0.5j>
-               global $manager;
-               $methodName         = 'action_' . $action;
-               $this->action       = strtolower($action);
-               $aActionsNotToCheck = array(
-                       'overview',
-                       'scatoverview',
-                       'scatedit',
-                       'scatdelete',
-               );
-               if (!in_array($this->action, $aActionsNotToCheck)) {
-                       if (!$manager->checkTicket()) $this->error(_ERROR_BADTICKET);
-               }
-               //</sato(na)0.5j>
-               
-               if (method_exists($this, $methodName)) {
-                       call_user_func(array(&$this, $methodName));
-               } else {
-                       $this->error(_BADACTION . " ($action)");
-               }
-       }
-
-       function disallow() {
-               global $HTTP_SERVER_VARS;
-               ACTIONLOG::add(WARNING, _ACTIONLOG_DISALLOWED . $HTTP_SERVER_VARS['REQUEST_URI']);
-               $this->error(_ERROR_DISALLOWED);
-       }
-
-       function error($msg) {
-               global $oPluginAdmin;
-               
-               $oPluginAdmin->start();
-               $dir=$oPluginAdmin->plugin->getAdminURL();
-               ?>
-               <h2>Error!</h2>
-               <?php           echo $msg;
-               echo "<br />";
-               echo "<a href='".$dir."index.php' onclick='history.back()'>"._BACK."</a>";
-               
-               $oPluginAdmin->end();
-               exit;
-       }
+        $this->deleteSubcat($scatid);
+        
+        $this->action_scatoverview("Sub category has been deleted.");
+    }
+    
+    function addToScat($nowid) {
+        if($this->version >= 3)
+            $datanames = array('catid','sname','sdesc','parentid');
+        else
+            $datanames = array('catid','sname','sdesc');
+        foreach ($datanames as $val) {
+            $scat[$val] = postVar($val);
+        }
+        $this->updateSubcat($nowid,$scat);
+    }
+
+    function createSubcat($name) {
+        sql_query('INSERT INTO '.$this->table.' SET sname="'. addslashes($name) .'"');
+        $newid = mysql_insert_id();
+        global $manager;
+        $manager->notify(
+                         'PostAddSubcat',
+                         array(
+                               'subcatid' => $newid
+                              )
+                        );
+        return $newid;
+    }
+
+    //<sato(na)0.402j>
+    //printCategoryList for update
+    function printCategoryListUD($catid, $parentid) {
+        $catName = quickQuery('SELECT cname as result FROM '.sql_table('category').' WHERE catid='.intval($catid));
+        $catName = htmlspecialchars($catName, ENT_QUOTES); //<sato(na)0.5j />
+        $text .= "<select size='10' name='parentid'>\n";
+        $text    .= "<option value='0'>&nbsp;$catName&nbsp;</option>\n";
+        foreach ($this->plug->_setSubOrder() as $val) { //$val : _getSubOrder intval($row_scat->scatid)
+            $query = 'SELECT * FROM '.$this->table.' WHERE scatid=' . intval($val);
+            $res   = sql_query($query);
+            $row   = mysql_fetch_array($res);
+            if ($row['catid'] == $catid){
+                $levelstr = '';
+                for ($i=0; $i<$this->getDepth($val, 0); $i++) $levelstr .= "&hellip;&hellip;";
+                $selected = ($parentid == $val) ? " selected='selected'" : '';
+                $text    .= "<option value='".$val."'".$selected.">&nbsp;".$levelstr."&hellip;&nbsp;".
+                            //<sato(na)0.5j>
+                            htmlspecialchars($row['sname'], ENT_QUOTES).
+                            " <sup>".
+                            htmlspecialchars($row['sdesc'], ENT_QUOTES).
+                            "</sup>&nbsp;</option>\n";
+                            //</sato(na)0.5j>
+            }
+        }
+        $text .= "</select>\n";
+        return $text;
+    }
+    function getDepth($scatid, $level) {
+        $parentid = quickQuery('SELECT parentid as result FROM '.$this->table.' WHERE scatid='.$scatid);
+        return ($parentid == 0) ? $level : $this->getDepth($parentid, $level + 1);
+    }
+    function descendantCheck($parentid, $checkid){
+        $res = sql_query("SELECT scatid FROM ".$this->table." WHERE parentid=".intval($parentid)); //<sato(na)0.5j />
+        while ($o = mysql_fetch_object($res)) {
+            if ($o->scatid == $checkid) {
+                return TRUE;
+            } else {
+                if ($this->descendantCheck($o->scatid, $checkid)) return TRUE;
+            }
+        }
+        return FALSE;
+    }
+    //</sato(na)0.402j>
+
+    function updateSubcat($id, $scat) {
+        
+        //<sato(na)0.402j>
+        $old_parentid = quickQuery('SELECT parentid as result FROM '.$this->table.' WHERE scatid='.$id);
+        if ($id == $scat['parentid']) $branch = 'Self'; else $branch = ($this->descendantCheck($id, $scat['parentid']) ? 'Descendant' : 'Other');
+        
+        switch ($branch){
+            case 'Self':
+                //cancel
+                $scat['parentid'] = $old_parentid;
+                //echo '----------------------------------------Self';
+            break;
+            case 'Descendant':
+                //Succession
+                //echo '----------------------------------------Descendant';
+                $query = 'UPDATE '.$this->table.' SET parentid='.intval($old_parentid).' WHERE parentid='.intval($id); //<sato(na)0.5j />
+                sql_query($query);
+            break;
+            case 'Other':
+                //Nothing is done.
+                //echo '----------------------------------------Other';
+        }
+        //</sato(na)0.402j>
+        
+        $query = 'UPDATE '.$this->table.' SET ';
+        foreach ($scat as $k => $v) {
+            $query .= $k.'="'.addslashes($v).'",';
+        }
+        $query = substr($query,0,-1);
+        $query .= ' WHERE scatid='.intval($id); //<sato(na)0.5j />
+        sql_query($query);
+    }
+    
+    function deleteSubcat($id) {
+        $id = intval($id); //<sato(na)0.5j />
+        sql_query('DELETE FROM '.$this->table.' WHERE scatid=' . $id);
+        global $manager;
+        $manager->notify(
+                         'PostDeleteSubcat',
+                         array(
+                               'subcatid' => $id
+                              )
+                        );
+
+        $res = sql_query("SELECT categories, subcategories, item_id FROM ". sql_table("plug_multiple_categories") ." WHERE subcategories REGEXP '(^|,)$id(,|$)'");
+        $dell = array();
+        $up = array();
+
+        while ($o = mysql_fetch_object($res)) {
+            $o->subcategories = preg_replace("/^(?:(.*),)?$catid(?:,(.*))?$/","$1,$2",$o->subcategories);
+            if (!$o->categories && (!$o->subcategories || $o->subcategories == ',')) {
+                $del[] = intval($o->item_id); //<sato(na)0.5j />ultrarich
+            } else {
+                $o->subcategories = preg_replace("/(^,+|(?<=,),+|,+$)/","",$o->subcategories);
+                $up[] = "UPDATE ". sql_table("plug_multiple_categories") ." SET categories='".addslashes($o->categories)."', subcategories='".addslashes($o->subcategories)."' WHERE item_id=".$o->item_id;
+            }
+        }
+        
+        if (count($del) > 0) {
+            sql_query("DELETE FROM ". sql_table("plug_multiple_categories") . " WHERE item_id in (".implode(",",$del).")");
+        }
+        if (count($up) > 0) {
+            foreach ($up as $v) {
+                sql_query($v);
+            }
+        }
+    }
+    
+
+    function action($action) {
+        //<sato(na)0.5j>
+        global $manager;
+        $methodName         = 'action_' . $action;
+        $this->action       = strtolower($action);
+        $aActionsNotToCheck = array(
+            'overview',
+            'scatoverview',
+            'scatedit',
+            'scatdelete',
+        );
+        if (!in_array($this->action, $aActionsNotToCheck)) {
+            if (!$manager->checkTicket()) $this->error(_ERROR_BADTICKET);
+        }
+        //</sato(na)0.5j>
+        
+        if (method_exists($this, $methodName)) {
+            call_user_func(array(&$this, $methodName));
+        } else {
+            $this->error(_BADACTION . " ($action)");
+        }
+    }
+
+    function disallow() {
+        global $HTTP_SERVER_VARS;
+        ACTIONLOG::add(WARNING, _ACTIONLOG_DISALLOWED . $HTTP_SERVER_VARS['REQUEST_URI']);
+        $this->error(_ERROR_DISALLOWED);
+    }
+
+    function error($msg) {
+        global $oPluginAdmin;
+        
+        $oPluginAdmin->start();
+        $dir=$oPluginAdmin->plugin->getAdminURL();
+        ?>
+        <h2>Error!</h2>
+        <?php       echo $msg;
+        echo "<br />";
+        echo "<a href='".$dir."index.php' onclick='history.back()'>"._BACK."</a>";
+        
+        $oPluginAdmin->end();
+        exit;
+    }
 
 //modify start+++++++++
     /* START OF UNLIMITED DEPTH SUBCATEGORY HELPER FUNCTIONS */
@@ -670,58 +671,58 @@ class NpMCategories_ADMIN {
 
     }
     
-       function showOrderMenu($catid, $subcatid=0){//<sato(na)0.402j />
-               global $manager; //<sato(na)0.5j />
-               $text = "<h3>"._MC_MODIFY_CHILDREN_ORDER."</h3>\n";
-               if ($sorder = $this->subcatOrd($catid, $subcatid)){
-                       $text .= "<table style='width:auto;'>\n";
-                       $text .= "<script language=javascript src={$this->url}orderlist.js></script>\n";
-                       $text .= "<form method='post' name='ordform' onsubmit=\"submitCatOrder();\">\n";
-                       $text .= "<input type='hidden' name='action' value='scatOrder'>\n";
-                       $text .= "<input type='hidden' name='ticket' value='".$manager->_generateTicket()."'>\n"; //<sato(na)0.5j />
-                       $text .= "<input type='hidden' name='redirect' value='".getVar('action')."'>\n";
-                       $text .= "<input type=hidden name=orderList value=''>\n";
-                       //<sato(na)0.402j>
-                       global $CONF;
-                       $actionUrl = htmlspecialchars($CONF['ActionURL'], ENT_QUOTES).
-                               '?action=plugin&amp;name=MultipleCategories&amp;catid='.intval($catid).'&amp;subcatid='.intval($subcatid); //<sato(na)0.5j />
-                       echo '<script language="javascript" src="'.$actionUrl.'"></script>';
-                       $text .= '
+    function showOrderMenu($catid, $subcatid=0){//<sato(na)0.402j />
+        global $manager; //<sato(na)0.5j />
+        $text = "<h3>"._MC_MODIFY_CHILDREN_ORDER."</h3>\n";
+        if ($sorder = $this->subcatOrd($catid, $subcatid)){
+            $text .= "<table style='width:auto;'>\n";
+            $text .= "<script language=javascript src={$this->url}orderlist.js></script>\n";
+            $text .= "<form method='post' name='ordform' onsubmit=\"submitCatOrder();\">\n";
+            $text .= "<input type='hidden' name='action' value='scatOrder'>\n";
+            $text .= "<input type='hidden' name='ticket' value='".$manager->_generateTicket()."'>\n"; //<sato(na)0.5j />
+            $text .= "<input type='hidden' name='redirect' value='".getVar('action')."'>\n";
+            $text .= "<input type=hidden name=orderList value=''>\n";
+            //<sato(na)0.402j>
+            global $CONF;
+            $actionUrl = htmlspecialchars($CONF['ActionURL'], ENT_QUOTES).
+                '?action=plugin&amp;name=MultipleCategories&amp;catid='.intval($catid).'&amp;subcatid='.intval($subcatid); //<sato(na)0.5j />
+            echo '<script language="javascript" src="'.$actionUrl.'"></script>';
+            $text .= '
 <tr><td class="main" style="border:0px;padding:0px;">
 <table style="width:auto; margin:0; padding:0;">
-       <tr><td style="border:0px;padding:0px;" colspan="6">'._MC_SHOW_ORDER_MENU_KEY.'</td>
-       <tr><td style="border:0px;padding:0px;">
-               <table>
-                       <tr>
-                               <td style="border:0px; padding:0px 3px;">ID</td>
-                               <td style="border:0px; padding:0px 3px;">
-                                       <img src=plugins/multiplecategories/images/up.gif alt="Move Up" onClick="orderKey(\'id\', \'ASC\')"><br />
-                                       <img src=plugins/multiplecategories/images/down.gif alt="Move Down" onClick="orderKey(\'id\', \'DESC\')">
-                               </td>
-                               <td style="border:0px; padding:0px 3px;">[ '._MC_SHOW_ORDER_MENU_SNAME.' ]</td>
-                               <td style="border:0px; padding:0px 3px;">
-                                       <img src=plugins/multiplecategories/images/up.gif alt="Move Up" onClick="orderKey(\'sname\', \'ASC\')"><br />
-                                       <img src=plugins/multiplecategories/images/down.gif alt="Move Down" onClick="orderKey(\'sname\', \'DESC\')">
-                               </td>
-                               <td style="border:0px; padding:0px 3px;">'._MC_SHOW_ORDER_MENU_SDESC.'</td>
-                               <td style="border:0px; padding:0px 3px;">
-                                       <img src=plugins/multiplecategories/images/up.gif alt="Move Up" onClick="orderKey(\'sdesc\', \'ASC\')"><br />
-                                       <img src=plugins/multiplecategories/images/down.gif alt="Move Down" onClick="orderKey(\'sdesc\', \'DESC\')">
-                               </td>
-                       </tr>
-               </table>
-       </td></tr>
+    <tr><td style="border:0px;padding:0px;" colspan="6">'._MC_SHOW_ORDER_MENU_KEY.'</td>
+    <tr><td style="border:0px;padding:0px;">
+        <table>
+            <tr>
+                <td style="border:0px; padding:0px 3px;">ID</td>
+                <td style="border:0px; padding:0px 3px;">
+                    <img src=plugins/multiplecategories/images/up.gif alt="Move Up" onClick="orderKey(\'id\', \'ASC\')"><br />
+                    <img src=plugins/multiplecategories/images/down.gif alt="Move Down" onClick="orderKey(\'id\', \'DESC\')">
+                </td>
+                <td style="border:0px; padding:0px 3px;">[ '._MC_SHOW_ORDER_MENU_SNAME.' ]</td>
+                <td style="border:0px; padding:0px 3px;">
+                    <img src=plugins/multiplecategories/images/up.gif alt="Move Up" onClick="orderKey(\'sname\', \'ASC\')"><br />
+                    <img src=plugins/multiplecategories/images/down.gif alt="Move Down" onClick="orderKey(\'sname\', \'DESC\')">
+                </td>
+                <td style="border:0px; padding:0px 3px;">'._MC_SHOW_ORDER_MENU_SDESC.'</td>
+                <td style="border:0px; padding:0px 3px;">
+                    <img src=plugins/multiplecategories/images/up.gif alt="Move Up" onClick="orderKey(\'sdesc\', \'ASC\')"><br />
+                    <img src=plugins/multiplecategories/images/down.gif alt="Move Down" onClick="orderKey(\'sdesc\', \'DESC\')">
+                </td>
+            </tr>
+        </table>
+    </td></tr>
 </table>
 </td></tr>';
-                       //</sato(na)0.402j>
-                       $text .= $sorder;
-                       $text .= "<tr><td class='main' style='border:0px;padding:0px;'><input type='submit' value='"._MC_SUBMIT_CHILDREN_ORDER."'></td></form></tr>\n";
-                       $text .= "</table>\n";
-               } else {
-                       $text .= _MC_NO_CHILDREN_ORDER;
-               }
-               return $text;
-       }
+            //</sato(na)0.402j>
+            $text .= $sorder;
+            $text .= "<tr><td class='main' style='border:0px;padding:0px;'><input type='submit' value='"._MC_SUBMIT_CHILDREN_ORDER."'></td></form></tr>\n";
+            $text .= "</table>\n";
+        } else {
+            $text .= _MC_NO_CHILDREN_ORDER;
+        }
+        return $text;
+    }
     function getCategoryList($catid, $selected = 0) {//$selected : parentid
         /** Returns a list of the gallery categories **/
         $queryString  = "SELECT * FROM ".$this->table;
@@ -823,7 +824,7 @@ class NpMCategories_ADMIN {
                     $text .= "&hellip;&hellip;";
                 }
                 $text .= "&hellip;&nbsp;".htmlspecialchars($category["title"], ENT_QUOTES).
-                       " <sup>".htmlspecialchars($category["description"], ENT_QUOTES)."</sup>&nbsp;</option>\n"; //<sato(na)0.5j />
+                    " <sup>".htmlspecialchars($category["description"], ENT_QUOTES)."</sup>&nbsp;</option>\n"; //<sato(na)0.5j />
                 $text .= $this->walkCategoryList($category["children"], $catid, $type, $selectedCategory, $level+1);
             }
         } elseif ($type == 2) {
@@ -872,10 +873,10 @@ class NpMCategories_ADMIN {
                 else { $group = ''; }
                 if ($selectedCategory == $category["id"]) {
                     $text .= "<strong>".htmlspecialchars($category["title"], ENT_QUOTES).
-                       " <sup>".htmlspecialchars($category["description"], ENT_QUOTES)."</sup>"."</strong> $group</td>\n";
+                        " <sup>".htmlspecialchars($category["description"], ENT_QUOTES)."</sup>"."</strong> $group</td>\n";
                 } else {
                     $text .= htmlspecialchars($category["title"], ENT_QUOTES).
-                       " <sup>".htmlspecialchars($category["description"], ENT_QUOTES)."</sup>"." $group</td>\n";
+                        " <sup>".htmlspecialchars($category["description"], ENT_QUOTES)."</sup>"." $group</td>\n";
                 }
                 $subcatid = $category["id"];
                 if ($type == 2) {
@@ -913,7 +914,7 @@ class NpMCategories_ADMIN {
         $q .= ($this->version >= 4) ? ' order by ordid, scatid ASC': ' order by scatid ASC';
         $result = sql_query($q);
         if(mysql_num_rows($result) < 2){
-               return FALSE;
+            return FALSE;
         }
         $text .= "<tr><td class=main style='border:0px;padding:0px;'><select name=order multiple size=15>";
         //<sato(na)0.402j>
@@ -933,27 +934,27 @@ class NpMCategories_ADMIN {
         return $text;
     }
 
-       function _getDefinedScatsFromScat($id){
-               $aResult = array();     
-               $query = 'SELECT * FROM '.sql_table('plug_multiple_categories_sub').' WHERE parentid=' . intval($id);
-               $res = sql_query($query);       
-               while ($a = mysql_fetch_assoc($res)){
-                       array_push($aResult,$a);
-               
-               return $aResult;
-       }
+    function _getDefinedScatsFromScat($id){
+        $aResult = array(); 
+        $query = 'SELECT * FROM '.sql_table('plug_multiple_categories_sub').' WHERE parentid=' . intval($id);
+        $res = sql_query($query);   
+        while ($a = mysql_fetch_assoc($res)){
+            array_push($aResult,$a);
+        } 
+        return $aResult;
+    }
 //modify end+++++++++
 
 
 } // NpMCategories_ADMIN end
-       
+    
 // ------------------------------------------------------------------
 
 $myAdmin = new NpMCategories_ADMIN();
 if (requestVar('action')) {
-       $myAdmin->action(requestVar('action'));
+    $myAdmin->action(requestVar('action'));
 } else {
-       $myAdmin->action('overview');
+    $myAdmin->action('overview');
 }
 
 ?>
\ No newline at end of file