function Categories($act = 'getlist', $val = '', $adminPanel = 'NULL') { global $db, $smarty, $conf; $categories = new categories(); switch ($act) { case 'getlist': $output = $categories->build_list($val); break; case 'getlistcollapsed': $output = $categories->build_list($val, "collapsed"); break; case 'getsubcat': $output = $categories->browse_by_id($val); break; case 'getParent': $output = $categories->getParent($val); break; case 'add': $output = $categories->add_new($val['parent'], $val["name"], $val["desc"], $val["icon"], $val["strip"]); break; case 'update': $output = $categories->update($val['id'], $val['parent'], $val["name"], $val["desc"], $val["icon"], $val["strip"]); break; case 'delete': $output = $categories->deleteCat($val['catFrom'], $val['catTo'], $val["cat_action"]); break; case 'getOne': $output = $categories->getOne($val); break; case 'html': if ($adminPanel === true) { $categories->HtmlTree = array("header" => "<ul class='unstyled'>", "BodyUnselected" => '<li> [prefix] <a href="' . $conf['baseurl'] . '/admincp/categories/?catid=[id]&tokenAdmin=' . $_COOKIE['tokenAdmin'] . '"> [name] </a> </li>', "BodySelected" => '<li> [prefix] <a href="' . $conf['baseurl'] . '/admincp/categories/?catid=[id]&tokenAdmin=' . $_COOKIE['tokenAdmin'] . '"><strong><font color="#000000">[name]</font></strong></a> </li>', "footer" => '</ul>'); } else { $categories->HtmlTree = array("header" => "<ul class='nav nav-tabs nav-stacked'>", "BodyUnselected" => '<li> <a href="' . $conf['baseurl'] . '/' . $this->makeUrl(array('page' => 'torrents', 'cat' => 'categorie', 'catid' => '[id]')) . '"> [name] </a> </li>', "BodySelected" => '<li> <a href="' . $conf['baseurl'] . '/' . $this->makeUrl(array('page' => 'torrents', 'cat' => 'categorie', 'catid' => '[id]')) . '"><strong><font color="#000000">[name]</font></strong></a> </li>', "footer" => '</ul>'); } $output = $categories->html_output($val); break; } return $output; }
<?php /* Deletes the user with the userId that is passed Should be used by admin to controll users and by users themselves to eliminate their account. */ // header('Content-Type: application/json'); require '../class.categories.inc'; // GET The info from POST called by Ajax method $nameCat = $_POST['nameCat']; $category = new categories(); $category->nameCat = $nameCat; //Calls method to store users onto the database and Returns 1 if the the user was stored and 0 if the user could not be stored $catDelete = $category->deleteCat($category); $returnDelete = array('success' => false); //Assign values to array that will be returned with success true if the user was stored and false if not (user already exists) if ($catDelete != 0) { $returnDelete['success'] = true; delete_all('../../categories/' . $category->nameCat); } // Function used to delete folders with images inside of them function delete_all($item) { if (is_dir($item)) { array_map('delete_all', array_diff(glob("{$item}/{,.}*", GLOB_BRACE), array("{$item}/.", "{$item}/.."))); rmdir($item); } else { unlink($item); } } //Return for jason to work with