Advertisement
plas71k

csp - tools - decoded

Nov 16th, 2012
312
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 26.24 KB | None | 0 0
  1. <?php
  2.  
  3. require("includes/logincheck.php");
  4. require("config.php");
  5. require("includes/settings.php");
  6. require("includes/functions.php");
  7.  
  8. $tool       = "";
  9. $toolselect = "";
  10.  
  11. if (isset($_POST["subimportxml"]) and $_POST["subimportxml"] == "Import users") {
  12.     $cspxmlusers = $_POST["cspxmlusers"];
  13.     $cspxmlusers = str_replace("<auth-config>", "", $cspxmlusers);
  14.     $cspxmlusers = str_replace("</auth-config>", "", $cspxmlusers);
  15.     $cspxmlusers = str_replace("</user-manager>", "", $cspxmlusers);
  16.     $cspxmlusers = str_replace("<user-manager class=\"com.bowman.cardserv.SimpleUserManager\" allow-on-failure=\"true\" log-failures=\"true\">", "", $cspxmlusers);
  17.     $cspxmlusers = str_replace("<user-manager class=\"com.bowman.cardserv.SimpleUserManager\" allow-on-failure=\"false\" log-failures=\"false\">", "", $cspxmlusers);
  18.     $cspxmlusers = str_replace("<user-manager class=\"com.bowman.cardserv.SimpleUserManager\" allow-on-failure=\"true\" log-failures=\"false\">", "", $cspxmlusers);
  19.     $cspxmlusers = str_replace("<user-manager class=\"com.bowman.cardserv.SimpleUserManager\" allow-on-failure=\"false\" log-failures=\"true\">", "", $cspxmlusers);
  20.     $cspxmlusers = str_replace("<user-manager class=\"com.bowman.cardserv.SimpleUserManager\">", "", $cspxmlusers);
  21.     $cspxmlusers = str_replace("display-name", "displayname", $cspxmlusers);
  22.     $cspxmlusers = str_replace("ip-mask", "ipmask", $cspxmlusers);
  23.     $cspxmlusers = str_replace("max-connections", "maxconnections", $cspxmlusers);
  24.     $cspxmlusers = str_replace("map-exclude", "mapexclude", $cspxmlusers);
  25.     $cspxmlusers = str_replace("email-address", "emailaddress", $cspxmlusers);
  26.     $cspxmlusers = str_replace("ecm-rate", "ecmrate", $cspxmlusers);
  27.     $cspxmlusers = str_replace("start-date", "startdate", $cspxmlusers);
  28.     $cspxmlusers = str_replace("expire-date", "expiredate", $cspxmlusers);
  29.    
  30.     $cspuserlines = explode("\n", $cspxmlusers);
  31.    
  32.     $conn = @mysql_connect($dbhost, $dbuser, $dbpass) or die("Error connecting to database");
  33.     mysql_select_db($dbname, $conn);
  34.    
  35.     $i              = 0;
  36.     $x              = 0;
  37.     $y              = 0;
  38.     $e              = 0;
  39.     $userimportlist = "";
  40.     $userexistlist  = "";
  41.     $importresult   = "";
  42.     $impdonecolor   = "#347C2C";
  43.     foreach ($cspuserlines as $i => $value) {
  44.         libxml_use_internal_errors(true);
  45.         $cspusersxml = simplexml_load_string(stripslashes($cspuserlines[$i]));
  46.         if (!$cspusersxml) {
  47.             $y = $y + 1;
  48.         } elseif ($cspusersxml->attributes()->name == "" or $cspusersxml->attributes()->password == "") {
  49.             $y = $y + 1;
  50.         } else {
  51.             $username   = $cspusersxml->attributes()->name;
  52.             $uesql      = mysql_query("SELECT * FROM cmum_udb WHERE name='" . $username . "'");
  53.             $foundusers = mysql_num_rows($uesql);
  54.             if ($foundusers == 0) {
  55.                 $password       = $cspusersxml->attributes()->password;
  56.                 $displayname    = $cspusersxml->attributes()->displayname;
  57.                 $ipmask         = $cspusersxml->attributes()->ipmask;
  58.                 $profiles       = $cspusersxml->attributes()->profiles;
  59.                 $maxconnections = $cspusersxml->attributes()->maxconnections;
  60.                 $admin          = $cspusersxml->attributes()->admin;
  61.                 $enabled        = $cspusersxml->attributes()->enabled;
  62.                 $mapexclude     = $cspusersxml->attributes()->mapexclude;
  63.                 $debug          = $cspusersxml->attributes()->debug;
  64.                 $email          = $cspusersxml->attributes()->emailaddress;
  65.                 $ecmrate        = $cspusersxml->attributes()->ecmrate;
  66.                 $startdate      = $cspusersxml->attributes()->startdate;
  67.                 $expiredate     = $cspusersxml->attributes()->expiredate;
  68.                 $comment        = "";
  69.                 $usrgroup       = "";
  70.                 $improf         = explode(" ", $profiles);
  71.                 foreach ($improf as $profvalue) {
  72.                     $sql  = mysql_query("SELECT * FROM cmum_profiles WHERE value='" . $profvalue . "'");
  73.                     $line = mysql_fetch_array($sql);
  74.                     if ($line["id"] <> "") {
  75.                         $convporf[] = $line["id"];
  76.                     }
  77.                 }
  78.                 if (!isset($convporf)) {
  79.                     $convporf = "N;";
  80.                 } else {
  81.                     $convporf = serialize($convporf);
  82.                 }
  83.                 mysql_query("INSERT INTO cmum_udb (name,password,displayname,ipmask,profiles,maxconnections,admin,enabled,mapexclude,debug,comment,email,usrgroup,ecmrate,startdate,expiredate,added,addedby,changed,changedby) VALUES ('" . $username . "','" . $password . "','" . $displayname . "','" . $ipmask . "','" . $convporf . "','" . $maxconnections . "','" . strtolower($admin) . "','" . strtolower($enabled) . "','" . strtolower($mapexclude) . "','" . strtolower($debug) . "','" . $comment . "','" . $email . "','" . $usrgroup . "','" . $ecmrate . "','" . $startdate . "','" . $expiredate . "','" . date('Y-m-d H:i') . "','" . $_SESSION["loginuser"] . "','','')");
  84.                 $x = $x + 1;
  85.                 unset($convporf);
  86.                 $sql            = "";
  87.                 $uesql          = "";
  88.                 $foundusers     = "";
  89.                 $userimportlist = $userimportlist . $username . "<br>";
  90.             } else {
  91.                 $e             = $e + 1;
  92.                 $userexistlist = $userexistlist . $username . "<br>";
  93.             }
  94.         }
  95.     }
  96.     mysql_close($conn);
  97.     if ($x <> 0 and $e <> 0) {
  98.         $importresult = "<br><br>The following users where imported:<br>" . $userimportlist . "<br>The following users where not imported due to duplicates:<br>" . $userexistlist;
  99.         $impdonecolor = "#FF6600";
  100.     }
  101.     if ($x <> 0 and $e == 0) {
  102.         $importresult = "<br><br>The following users where imported:<br>" . $userimportlist;
  103.     }
  104.     if ($x == 0 and $e <> 0) {
  105.         $importresult = "<br><br>The following users where not imported due to duplicates:<br>" . $userexistlist;
  106.         $impdonecolor = "#FF0000";
  107.     }
  108.     if ($y <> 0) {
  109.         if ($x == 0) {
  110.             $toolstatus = "<font color=\"#FF0000\">" . $x . " users imported into database! There were " . $y . " errors! Could be empty lines, not matching lines or users without username or password!" . $importresult . "</font>";
  111.         } else {
  112.             $toolstatus = "<font color=\"#FF6600\">" . $x . " users successfully imported into database! But there were " . $y . " errors! Could be empty lines, not matching lines or users without username or password!" . $importresult . "</font>";
  113.         }
  114.     } else {
  115.         $toolstatus = "<font color=\"" . $impdonecolor . "\">" . $x . " users successfully imported into database!" . $importresult . "</font>";
  116.     }
  117.     $tool       = "tools/imusrxmldone.php";
  118.     $toolselect = "Import users (CSP XML)";
  119. }
  120.  
  121. if (isset($_POST["subimportcsv"]) and $_POST["subimportcsv"] == "Import users") {
  122.     $cspcsvusers = $_POST["cspcsvusers"];
  123.    
  124.     $cspuserlines = explode("\n", $cspcsvusers);
  125.    
  126.     $conn = @mysql_connect($dbhost, $dbuser, $dbpass) or die("Error connecting to database");
  127.     mysql_select_db($dbname, $conn);
  128.    
  129.     $i              = 0;
  130.     $x              = 0;
  131.     $y              = 0;
  132.     $e              = 0;
  133.     $userimportlist = "";
  134.     $userexistlist  = "";
  135.     $importresult   = "";
  136.     $impdonecolor   = "#347C2C";
  137.     foreach ($cspuserlines as $i => $value) {
  138.         $csvuser = explode(";", $cspuserlines[$i]);
  139.         if ($csvuser[0] == "" or $csvuser[1] == "") {
  140.             $y = $y + 1;
  141.         } else {
  142.             $uesql      = mysql_query("SELECT * FROM cmum_udb WHERE name='" . $csvuser[0] . "'");
  143.             $foundusers = mysql_num_rows($uesql);
  144.             if ($foundusers == 0) {
  145.                 if (isset($csvuser[9])) {
  146.                     $improf = explode(" ", $csvuser[4]);
  147.                     foreach ($improf as $profvalue) {
  148.                         $sql  = mysql_query("SELECT * FROM cmum_profiles WHERE value='" . $profvalue . "'");
  149.                         $line = mysql_fetch_array($sql);
  150.                         if ($line["id"] <> "") {
  151.                             $convporf[] = $line["id"];
  152.                         }
  153.                     }
  154.                     if (!isset($convporf)) {
  155.                         $convporf = "N;";
  156.                     } else {
  157.                         $convporf = serialize($convporf);
  158.                     }
  159.                     if (!isset($csvuser[1])) {
  160.                         $csvuser[1] = "";
  161.                     }
  162.                     if (!isset($csvuser[2])) {
  163.                         $csvuser[2] = "";
  164.                     }
  165.                     if (!isset($csvuser[3])) {
  166.                         $csvuser[3] = "";
  167.                     }
  168.                     if (!isset($csvuser[4])) {
  169.                         $csvuser[4] = "";
  170.                     }
  171.                     if (!isset($csvuser[5])) {
  172.                         $csvuser[5] = "";
  173.                     }
  174.                     if (!isset($csvuser[6])) {
  175.                         $csvuser[6] = "";
  176.                     }
  177.                     if (!isset($csvuser[7])) {
  178.                         $csvuser[7] = "";
  179.                     }
  180.                     if (!isset($csvuser[8])) {
  181.                         $csvuser[8] = "";
  182.                     }
  183.                     if (!isset($csvuser[9])) {
  184.                         $csvuser[9] = "";
  185.                     }
  186.                     if (!isset($csvuser[10])) {
  187.                         $csvuser[10] = "";
  188.                     }
  189.                     if (!isset($csvuser[11])) {
  190.                         $csvuser[11] = "";
  191.                     }
  192.                     if (!isset($csvuser[12])) {
  193.                         $csvuser[12] = "";
  194.                     }
  195.                     if (!isset($csvuser[13])) {
  196.                         $csvuser[13] = "";
  197.                     }
  198.                     if (!isset($csvuser[14])) {
  199.                         $csvuser[14] = "";
  200.                     }
  201.                     if (!isset($csvuser[15])) {
  202.                         $csvuser[15] = "";
  203.                     }
  204.                     if (!isset($csvuser[16])) {
  205.                         $csvuser[16] = "";
  206.                     }
  207.                     $chkid = "0";
  208.                     do {
  209.                         $csvuser[$chkid] = replacechars($csvuser[$chkid]);
  210.                         $chkid++;
  211.                     } while ($chkid < "12");
  212.                     mysql_query("INSERT INTO cmum_udb (name,password,displayname,ipmask,profiles,maxconnections,admin,enabled,mapexclude,debug,comment,email,usrgroup,customvalues,ecmrate,startdate,expiredate,added,addedby,changed,changedby) VALUES ('" . $csvuser[0] . "','" . $csvuser[1] . "','" . $csvuser[2] . "','" . $csvuser[3] . "','" . $convporf . "','" . $csvuser[5] . "','" . strtolower($csvuser[6]) . "','" . strtolower($csvuser[7]) . "','" . strtolower($csvuser[8]) . "','" . strtolower($csvuser[9]) . "','" . trim($csvuser[10]) . "','" . trim($csvuser[11]) . "','" . trim($csvuser[12]) . "','" . replacechars(trim($csvuser[13])) . "','" . trim($csvuser[14]) . "','" . trim($csvuser[15]) . "','" . trim($csvuser[16]) . "','" . date('Y-m-d H:i') . "','" . $_SESSION["loginuser"] . "','','')");
  213.                     $x = $x + 1;
  214.                     unset($convporf);
  215.                     $sql            = "";
  216.                     $uesql          = "";
  217.                     $foundusers     = "";
  218.                     $userimportlist = $userimportlist . $csvuser[0] . "<br>";
  219.                 } else {
  220.                     $y = $y + 1;
  221.                 }
  222.             } else {
  223.                 $e             = $e + 1;
  224.                 $userexistlist = $userexistlist . $csvuser[0] . "<br>";
  225.             }
  226.         }
  227.     }
  228.     mysql_close($conn);
  229.     if ($x <> 0 and $e <> 0) {
  230.         $importresult = "<br><br>The following users where imported:<br>" . $userimportlist . "<br>The following users where not imported due to duplicates:<br>" . $userexistlist;
  231.         $impdonecolor = "#FF6600";
  232.     }
  233.     if ($x <> 0 and $e == 0) {
  234.         $importresult = "<br><br>The following users where imported:<br>" . $userimportlist;
  235.         $impdonecolor = "#347C2C";
  236.     }
  237.     if ($x == 0 and $e <> 0) {
  238.         $importresult = "<br><br>The following users where not imported due to duplicates:<br>" . $userexistlist;
  239.         $impdonecolor = "#FF0000";
  240.     }
  241.     if ($y <> 0) {
  242.         if ($x == 0) {
  243.             $toolstatus = "<font color=\"#FF0000\">" . $x . " users imported into database! There were " . $y . " errors! Could be empty lines, not matching lines or users without username or password!" . $importresult . "</font>";
  244.         } else {
  245.             $toolstatus = "<font color=\"#FF6600\">" . $x . " users successfully imported into database! But there were " . $y . " errors! Could be empty lines, not matching lines or users without username or password!" . $importresult . "</font>";
  246.         }
  247.     } else {
  248.         $toolstatus = "<font color=\"" . $impdonecolor . "\">" . $x . " users successfully imported into database!" . $importresult . "</font>";
  249.     }
  250.     $tool       = "tools/imusrcsvdone.php";
  251.     $toolselect = "Import users (CSV)";
  252. }
  253.  
  254. if (isset($_POST["subemptyudb"]) and $_POST["subemptyudb"] == "Yes") {
  255.     $adminpassword = sha1($_POST["adminpassword"]);
  256.     $conn = @mysql_connect($dbhost, $dbuser, $dbpass) or die("Error connecting to database");
  257.     mysql_select_db($dbname, $conn);
  258.     $sql = mysql_query("SELECT * FROM cmum_admins WHERE username='" . $_SESSION["loginuser"] . "'");
  259.     while ($line = mysql_fetch_array($sql)) {
  260.         if ($adminpassword == $line["password"]) {
  261.             $esql           = mysql_query("TRUNCATE TABLE cmum_udb");
  262.             $emptyudbstatus = "<font color=\"#347C2C\">User database successfully erased!</font>";
  263.             $tool           = "tools/emptyudbdone.php";
  264.             $toolselect     = "Empty user database";
  265.             mysql_close($conn);
  266.         } else {
  267.             $emptyudbstatus = "<font color=\"#FF0000\">Password didn't match!</font>";
  268.             $tool           = "tools/emptyudb.php";
  269.             $toolselect     = "Empty user database";
  270.             mysql_close($conn);
  271.         }
  272.     }
  273. }
  274.  
  275. if (isset($_POST["subendiudb"]) and $_POST["subendiudb"] == "Enable all") {
  276.     $adminpassword = sha1($_POST["adminpassword"]);
  277.     $conn = @mysql_connect($dbhost, $dbuser, $dbpass) or die("Error connecting to database");
  278.     mysql_select_db($dbname, $conn);
  279.     $sql = mysql_query("SELECT * FROM cmum_admins WHERE username='" . $_SESSION["loginuser"] . "'");
  280.     while ($line = mysql_fetch_array($sql)) {
  281.         if ($adminpassword == $line["password"]) {
  282.             $ensql = mysql_query("SELECT * FROM cmum_udb");
  283.             while ($line = mysql_fetch_array($ensql)) {
  284.                 mysql_query("UPDATE cmum_udb SET enabled='true' WHERE id='" . $line["id"] . "'");
  285.             }
  286.             $endiudbstatus = "<font color=\"#347C2C\">All users have been enabled!</font>";
  287.             $tool          = "tools/endiudbdone.php";
  288.             $toolselect    = "Enable/disable all users";
  289.             mysql_close($conn);
  290.         } else {
  291.             $endiudbstatus = "<font color=\"#FF0000\">Password didn't match!</font>";
  292.             $tool          = "tools/endiudb.php";
  293.             $toolselect    = "Enable/disable all users";
  294.             mysql_close($conn);
  295.         }
  296.     }
  297. }
  298.  
  299. if (isset($_POST["subendiudb"]) and $_POST["subendiudb"] == "Disable all") {
  300.     $adminpassword = sha1($_POST["adminpassword"]);
  301.     $conn = @mysql_connect($dbhost, $dbuser, $dbpass) or die("Error connecting to database");
  302.     mysql_select_db($dbname, $conn);
  303.     $sql = mysql_query("SELECT * FROM cmum_admins WHERE username='" . $_SESSION["loginuser"] . "'");
  304.     while ($line = mysql_fetch_array($sql)) {
  305.         if ($adminpassword == $line["password"]) {
  306.             $disql = mysql_query("SELECT * FROM cmum_udb");
  307.             while ($line = mysql_fetch_array($disql)) {
  308.                 mysql_query("UPDATE cmum_udb SET enabled='false' WHERE id='" . $line["id"] . "'");
  309.             }
  310.             $endiudbstatus = "<font color=\"#347C2C\">All users have been disabled!</font>";
  311.             $tool          = "tools/endiudbdone.php";
  312.             $toolselect    = "Enable/disable all users";
  313.             mysql_close($conn);
  314.         } else {
  315.             $endiudbstatus = "<font color=\"#FF0000\">Password didn't match!</font>";
  316.             $tool          = "tools/endiudb.php";
  317.             $toolselect    = "Enable/disable all users";
  318.             mysql_close($conn);
  319.         }
  320.     }
  321. }
  322.  
  323. if (isset($_POST["subdeldisusr"]) and $_POST["subdeldisusr"] == "Yes") {
  324.     $adminpassword = sha1($_POST["adminpassword"]);
  325.     $conn = @mysql_connect($dbhost, $dbuser, $dbpass) or die("Error connecting to database");
  326.     mysql_select_db($dbname, $conn);
  327.     $sql = mysql_query("SELECT * FROM cmum_admins WHERE username='" . $_SESSION["loginuser"] . "'");
  328.     while ($line = mysql_fetch_array($sql)) {
  329.         if ($adminpassword == $line["password"]) {
  330.             $deldisql = mysql_query("SELECT * FROM cmum_udb WHERE enabled='false'");
  331.             while ($line = mysql_fetch_array($deldisql)) {
  332.                 mysql_query("DELETE FROM cmum_udb WHERE id='" . $line["id"] . "'");
  333.             }
  334.             $deldisusrstatus = "<font color=\"#347C2C\">All disabled users have been removed!</font>";
  335.             $tool            = "tools/deldisusrdone.php";
  336.             $toolselect      = "Delete disabled users";
  337.             mysql_close($conn);
  338.         } else {
  339.             $deldisusrstatus = "<font color=\"#FF0000\">Password didn't match!</font>";
  340.             $tool            = "tools/deldisusr.php";
  341.             $toolselect      = "Delete disabled users";
  342.             mysql_close($conn);
  343.         }
  344.     }
  345. }
  346.  
  347. if (isset($_POST["subupdatecspudb"]) and $_POST["subupdatecspudb"] == "Yes") {
  348.     $updatecspudbstatus = updatecspudb();
  349.     $tool               = "tools/updatecspudbdone.php";
  350.     $toolselect         = "Update CSP users";
  351. }
  352.  
  353. if (isset($_POST["bimcspprof"]) and $_POST["bimcspprof"] == "Import") {
  354.     $conn = @mysql_connect($dbhost, $dbuser, $dbpass) or die("Error connecting to database");
  355.     mysql_select_db($dbname, $conn);
  356.    
  357.     $i          = 0;
  358.     $e          = 0;
  359.     $pfexists   = "";
  360.     $pfimported = "";
  361.    
  362.     $cspvalue    = $_POST["cspvalue"];
  363.     $profilename = $_POST["profilename"];
  364.     $cvnum       = count($cspvalue);
  365.    
  366.     foreach ($cspvalue as $x => $value) {
  367.         $cpsql        = mysql_query("SELECT * FROM cmum_profiles WHERE value='" . $cspvalue[$x] . "'");
  368.         $foundcspprof = mysql_num_rows($cpsql);
  369.         if ($foundcspprof == 0 and $cspvalue[$x] <> "") {
  370.             $pnsql         = mysql_query("SELECT * FROM cmum_profiles WHERE name='" . $profilename[$x] . "'");
  371.             $foundprofname = mysql_num_rows($pnsql);
  372.             if ($foundprofname == 0 and $profilename[$x] <> "") {
  373.                 mysql_query("INSERT INTO cmum_profiles (name,value) VALUES ('" . $profilename[$x] . "','" . $cspvalue[$x] . "')");
  374.                 $i++;
  375.                 $pfimported = $pfimported . $profilename[$x] . " (" . $cspvalue[$x] . ")<br>";
  376.             } else {
  377.                 $e++;
  378.                 $pfexists = $pfexists . $profilename[$x] . " (" . $cspvalue[$x] . ")<br>";
  379.             }
  380.         } else {
  381.             $e++;
  382.             $pfexists = $pfexists . $profilename[$x] . " (" . $cspvalue[$x] . ")<br>";
  383.         }
  384.     }
  385.    
  386.     if ($i <> 0 and $e <> 0) {
  387.         $importresult = "<br><br>The following profiles where imported:<br>" . $pfimported . "<br>The following profiles where not imported due to duplicates:<br>" . $pfexists;
  388.         $impdonecolor = "#FF6600";
  389.     }
  390.     if ($i <> 0 and $e == 0) {
  391.         $importresult = "<br><br>The following profiles where imported:<br>" . $pfimported;
  392.         $impdonecolor = "#347C2C";
  393.     }
  394.     if ($i == 0 and $e <> 0) {
  395.         $importresult = "<br><br>The following profiles where not imported due to duplicates:<br>" . $pfexists;
  396.         $impdonecolor = "#FF0000";
  397.     }
  398.     if ($e <> 0) {
  399.         if ($i == 0) {
  400.             $toolstatus = "<font color=\"#FF0000\">" . $i . " profiles imported into database! There were " . $e . " duplicates!" . $importresult . "</font>";
  401.         } else {
  402.             $toolstatus = "<font color=\"#FF6600\">" . $i . " profiles successfully imported into database! But there were " . $e . " duplicates!" . $importresult . "</font>";
  403.         }
  404.     } else {
  405.         $toolstatus = "<font color=\"" . $impdonecolor . "\">" . $i . " profiles successfully imported into database!" . $importresult . "</font>";
  406.     }
  407.     mysql_close($conn);
  408.     $tool       = "tools/imcspprofilesdone.php";
  409.     $toolselect = "Import profiles from CSP";
  410. }
  411.  
  412. if (isset($_POST["choosetool"]) and $_POST["choosetool"] == "Choose a tool...") {
  413.     $tool = "";
  414. }
  415.  
  416. if (isset($_POST["choosetool"]) and $_POST["choosetool"] == "Enable/disable all users") {
  417.     $tool = "tools/endiudb.php";
  418. }
  419.  
  420. if (isset($_POST["choosetool"]) and $_POST["choosetool"] == "Delete disabled users") {
  421.     $tool = "tools/deldisusr.php";
  422. }
  423.  
  424. if (isset($_POST["choosetool"]) and $_POST["choosetool"] == "Empty user database") {
  425.     $tool = "tools/emptyudb.php";
  426. }
  427.  
  428. if (isset($_POST["choosetool"]) and $_POST["choosetool"] == "Update CSP users") {
  429.     $tool = "tools/updatecspudb.php";
  430. }
  431.  
  432. if (isset($_POST["choosetool"]) and $_POST["choosetool"] == "Import profiles from CSP") {
  433.     $tool = "tools/imcspprofiles.php";
  434. }
  435.  
  436. if (isset($_POST["choosetool"]) and $_POST["choosetool"] == "Import users (CSP XML)") {
  437.     $tool = "tools/imusrxml.php";
  438. }
  439.  
  440. if (isset($_POST["choosetool"]) and $_POST["choosetool"] == "Import users (CSV)") {
  441.     $tool = "tools/imusrcsv.php";
  442. }
  443.  
  444. if (isset($_POST["choosetool"]) and $_POST["choosetool"] == "Export users (CSP XML)") {
  445.     $tool = "tools/expusrxml.php";
  446. }
  447.  
  448. if (isset($_POST["choosetool"]) and $_POST["choosetool"] == "Export users (CSV)") {
  449.     $tool = "tools/expusrcsv.php";
  450. }
  451. echo '<html xmlns="http://www.w3.org/1999/xhtml">
  452. <head>
  453. <meta http-equiv="Content-Type" content="text/html; charset=';
  454. print($charset);
  455. echo '" />
  456. <p align="center">
  457. <link href="css/main.css" rel="stylesheet" type="text/css">
  458. </head>
  459. <body>
  460.  
  461.  <tr bgcolor="#FFFFFF">
  462.    <td height="18">&nbsp;</td>
  463.    <td height="18"><center>';
  464. require("includes/menu.php");
  465. echo '</center></td>
  466.    <td height="18">&nbsp;</td>
  467.  </tr>
  468.    <tr bgcolor="#FFFFFF">
  469.    <td height="18">&nbsp;</td>
  470.    <td height="18">&nbsp;</td>
  471.    <td height="18">&nbsp;</td>
  472.  </tr>
  473. </table>
  474. <table width="780" height="20" border="0" align="center" valign="top" cellpadding="0" cellspacing="0" style="border-left: 1px solid #DDDDDD; border-right: 1px solid #DDDDDD; text-align: left;">
  475.  <tr bgcolor="#FFFFFF">
  476.    <td width="15" height="20">&nbsp;</td>
  477.    <td width="195" height="20">
  478.    <form name="tool" action="tools.php" method="post">
  479.    <fieldset>
  480.    <legend>Tools</legend>
  481.    <select name="choosetool" onChange="this.form.submit();" tabindex="1">
  482.    <option ';
  483. if (isset($_POST["choosetool"]) and $_POST["choosetool"] == "Choose a tool..." or $toolselect == "Choose a tool...") {
  484.     print("selected=\"selected\"");
  485. }
  486. echo '>Choose a tool...</option>
  487.    <option ';
  488. if (isset($_POST["choosetool"]) and $_POST["choosetool"] == "Enable/disable all users" or $toolselect == "Enable/disable all users") {
  489.     print("selected=\"selected\"");
  490. }
  491. echo '>Enable/disable all users</option>
  492.    <option ';
  493. if (isset($_POST["choosetool"]) and $_POST["choosetool"] == "Delete disabled users" or $toolselect == "Delete disabled users") {
  494.     print("selected=\"selected\"");
  495. }
  496. echo '>Delete disabled users</option>
  497.    <option ';
  498. if (isset($_POST["choosetool"]) and $_POST["choosetool"] == "Empty user database" or $toolselect == "Empty user database") {
  499.     print("selected=\"selected\"");
  500. }
  501. echo '>Empty user database</option>
  502.    
  503.    ';
  504. $conn = @mysql_connect($dbhost, $dbuser, $dbpass) or die("Error connecting to database");
  505. mysql_select_db($dbname, $conn);
  506. $sql  = mysql_query("SELECT * FROM cmum_settings WHERE id='1'");
  507. $line = mysql_fetch_array($sql);
  508. if ($line["fetchfromcsp"] == "1") {
  509.     if (isset($_POST["choosetool"]) and $_POST["choosetool"] == "Update CSP users" or $toolselect == "Update CSP users") {
  510.         $selected = "selected";
  511.     }
  512.     print("<option " . $selected . ">Update CSP users</option>");
  513. }
  514. $selected = "";
  515. if ($line["fetchfromcsp"] == "1") {
  516.     if (isset($_POST["choosetool"]) and $_POST["choosetool"] == "Import profiles from CSP" or $toolselect == "Import profiles from CSP") {
  517.         $selected = "selected";
  518.     }
  519.     print("<option " . $selected . ">Import profiles from CSP</option>");
  520. }
  521. mysql_close($conn);
  522. echo '    
  523.    <option ';
  524. if (isset($_POST["choosetool"]) and $_POST["choosetool"] == "Import users (CSP XML)" or $toolselect == "Import users (CSP XML)") {
  525.     print("selected=\"selected\"");
  526. }
  527. echo '>Import users (CSP XML)</option>
  528.    <option ';
  529. if (isset($_POST["choosetool"]) and $_POST["choosetool"] == "Import users (CSV)" or $toolselect == "Import users (CSV)") {
  530.     print("selected=\"selected\"");
  531. }
  532. echo '>Import users (CSV)</option>
  533.    <option ';
  534. if (isset($_POST["choosetool"]) and $_POST["choosetool"] == "Export users (CSP XML)" or $toolselect == "Export users (CSP XML)") {
  535.     print("selected=\"selected\"");
  536. }
  537. echo '>Export users (CSP XML)</option>
  538.    <option ';
  539. if (isset($_POST["choosetool"]) and $_POST["choosetool"] == "Export users (CSV)" or $toolselect == "Export users (CSV)") {
  540.     print("selected=\"selected\"");
  541. }
  542. echo '>Export users (CSV)</option>
  543.    </select>  
  544.    </fieldset>
  545.    </form>
  546.    </td>
  547.    <td width="555" height="20">&nbsp;</td>
  548.    <td width="15" height="20">&nbsp;</td>
  549.  </tr>
  550. </table>
  551.    ';
  552. if ($tool <> "") {
  553.     include $tool;
  554. }
  555. echo '<table width="780" height="20" border="0" align="center" valign="top" cellpadding="0" cellspacing="0" style="border-left: 1px solid #DDDDDD; border-right: 1px solid #DDDDDD; border-bottom: 1px solid #DDDDDD; text-align: left;">
  556.    <tr bgcolor="#FFFFFF">
  557.    <td height="20" width="780">&nbsp;</td>
  558.  </tr>
  559. </table>
  560. ';
  561. require("includes/footer.php");
  562. echo '</body>
  563. </html>';
  564. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement