authenticated) : header( 'Location: error.php?error=999' ); elseif($USER->authenticated && $USER->role !== "admin") : header( 'Location: error.php?error=401' ); endif; $dbfile = DATABASE_LOCATION.'users.db'; $databaseLocation = "databaseLocation.ini.php"; $homepageSettings = "homepageSettings.ini.php"; $userdirpath = USER_HOME; $userdirpath = substr_replace($userdirpath, "", -1); $file_db = new PDO("sqlite:" . $dbfile); $file_db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); $getUsers = $file_db->query('SELECT * FROM users'); $gotUsers = $file_db->query('SELECT * FROM users'); $dbTab = $file_db->query('SELECT name FROM sqlite_master WHERE type="table" AND name="tabs"'); $dbOptions = $file_db->query('SELECT name FROM sqlite_master WHERE type="table" AND name="options"'); $tabSetup = "Yes"; $hasOptions = "No"; foreach($dbTab as $row) : if (in_array("tabs", $row)) : $tabSetup = "No"; endif; endforeach; foreach($dbOptions as $row) : if (in_array("options", $row)) : $hasOptions = "Yes"; endif; endforeach; if($hasOptions == "No") : $title = "Organizr"; $topbar = "#333333"; $topbartext = "#66D9EF"; $bottombar = "#333333"; $sidebar = "#393939"; $hoverbg = "#AD80FD"; $activetabBG = "#F92671"; $activetabicon = "#FFFFFF"; $activetabtext = "#FFFFFF"; $inactiveicon = "#66D9EF"; $inactivetext = "#66D9EF"; $loading = "#66D9EF"; $hovertext = "#000000"; endif; if($tabSetup == "No") : $result = $file_db->query('SELECT * FROM tabs'); endif; if($hasOptions == "Yes") : $resulto = $file_db->query('SELECT * FROM options'); endif; if($hasOptions == "Yes") : foreach($resulto as $row) : $title = isset($row['title']) ? $row['title'] : "Organizr"; $topbartext = isset($row['topbartext']) ? $row['topbartext'] : "#66D9EF"; $topbar = isset($row['topbar']) ? $row['topbar'] : "#333333"; $bottombar = isset($row['bottombar']) ? $row['bottombar'] : "#333333"; $sidebar = isset($row['sidebar']) ? $row['sidebar'] : "#393939"; $hoverbg = isset($row['hoverbg']) ? $row['hoverbg'] : "#AD80FD"; $activetabBG = isset($row['activetabBG']) ? $row['activetabBG'] : "#F92671"; $activetabicon = isset($row['activetabicon']) ? $row['activetabicon'] : "#FFFFFF"; $activetabtext = isset($row['activetabtext']) ? $row['activetabtext'] : "#FFFFFF"; $inactiveicon = isset($row['inactiveicon']) ? $row['inactiveicon'] : "#66D9EF"; $inactivetext = isset($row['inactivetext']) ? $row['inactivetext'] : "#66D9EF"; $loading = isset($row['loading']) ? $row['loading'] : "#66D9EF"; $hovertext = isset($row['hovertext']) ? $row['hovertext'] : "#000000"; endforeach; endif; $action = ""; if(isset($_POST['action'])) : $action = $_POST['action']; endif; if($action == "deleteDB") : unset($_COOKIE['Organizr']); setcookie('Organizr', '', time() - 3600, '/'); unset($_COOKIE['OrganizrU']); setcookie('OrganizrU', '', time() - 3600, '/'); $file_db = null; unlink($dbfile); foreach(glob($userdirpath . '/*') as $file) : if(is_dir($file)) : rmdir($file); elseif(!is_dir($file)) : unlink($file); endif; endforeach; rmdir($userdirpath); echo ""; endif; if($action == "deleteLog") : unlink(FAIL_LOG); echo ""; endif; if($action == "upgrade") : function downloadFile($url, $path){ $folderPath = "upgrade/"; if(!mkdir($folderPath)) : echo "can't make dir"; endif; $newfname = $folderPath . $path; $file = fopen ($url, 'rb'); if ($file) { $newf = fopen ($newfname, 'wb'); if ($newf) { while(!feof($file)) { fwrite($newf, fread($file, 1024 * 8), 1024 * 8); } } } if ($file) { fclose($file); } if ($newf) { fclose($newf); } } function unzipFile($zipFile){ $zip = new ZipArchive; $extractPath = "upgrade/"; if($zip->open($extractPath . $zipFile) != "true"){ echo "Error :- Unable to open the Zip File"; } /* Extract Zip File */ $zip->extractTo($extractPath); $zip->close(); } // Function to remove folders and files function rrmdir($dir) { if (is_dir($dir)) { $files = scandir($dir); foreach ($files as $file) if ($file != "." && $file != "..") rrmdir("$dir/$file"); rmdir($dir); } else if (file_exists($dir)) unlink($dir); } // Function to Copy folders and files function rcopy($src, $dst) { if (is_dir ( $src )) { if (!file_exists($dst)) : mkdir ( $dst ); endif; $files = scandir ( $src ); foreach ( $files as $file ) if ($file != "." && $file != "..") rcopy ( "$src/$file", "$dst/$file" ); } else if (file_exists ( $src )) copy ( $src, $dst ); } $url = "https://github.com/causefx/Organizr/archive/master.zip"; $file = "upgrade.zip"; $source = __DIR__ . "/upgrade/Organizr-master/"; $cleanup = __DIR__ . "/upgrade/"; $destination = __DIR__ . "/"; downloadFile($url, $file); unzipFile($file); rcopy($source, $destination); rrmdir($cleanup); echo ""; endif; if($action == 'createLocation' || $action == 'homepageSettings') { unset($_POST['action']); updateConfig($_POST); echo ""; echo ""; } if(!isset($_POST['op'])) : $_POST['op'] = ""; endif; if($action == "addTabz") : if($tabSetup == "No") : $file_db->exec("DELETE FROM tabs"); endif; if($tabSetup == "Yes") : $file_db->exec("CREATE TABLE tabs (name TEXT UNIQUE, url TEXT, defaultz TEXT, active TEXT, user TEXT, guest TEXT, icon TEXT, iconurl TEXT, window TEXT)"); endif; $addTabName = array(); $addTabUrl = array(); $addTabIcon = array(); $addTabIconUrl = array(); $addTabDefault = array(); $addTabActive = array(); $addTabUser = array(); $addTabGuest = array(); $addTabWindow = array(); $buildArray = array(); foreach ($_POST as $key => $value) : $trueKey = explode('-', $key); if ($value == "on") : $value = "true"; endif; if($trueKey[0] == "name"): array_push($addTabName, $value); endif; if($trueKey[0] == "url"): array_push($addTabUrl, $value); endif; if($trueKey[0] == "icon"): array_push($addTabIcon, $value); endif; if($trueKey[0] == "iconurl"): array_push($addTabIconUrl, $value); endif; if($trueKey[0] == "default"): array_push($addTabDefault, $value); endif; if($trueKey[0] == "active"): array_push($addTabActive, $value); endif; if($trueKey[0] == "user"): array_push($addTabUser, $value); endif; if($trueKey[0] == "guest"): array_push($addTabGuest, $value); endif; if($trueKey[0] == "window"): array_push($addTabWindow, $value); endif; endforeach; $tabArray = 0; if(count($addTabName) > 0) : foreach(range(1,count($addTabName)) as $index) : if(!isset($addTabDefault[$tabArray])) : $tabDefault = "false"; else : $tabDefault = $addTabDefault[$tabArray]; endif; $buildArray[] = array('name' => $addTabName[$tabArray], 'url' => $addTabUrl[$tabArray], 'defaultz' => $tabDefault, 'active' => $addTabActive[$tabArray], 'user' => $addTabUser[$tabArray], 'guest' => $addTabGuest[$tabArray], 'icon' => $addTabIcon[$tabArray], 'window' => $addTabWindow[$tabArray], 'iconurl' => $addTabIconUrl[$tabArray]); $tabArray++; endforeach; endif; $insert = "INSERT INTO tabs (name, url, defaultz, active, user, guest, icon, iconurl, window) VALUES (:name, :url, :defaultz, :active, :user, :guest, :icon, :iconurl, :window)"; $stmt = $file_db->prepare($insert); $stmt->bindParam(':name', $name); $stmt->bindParam(':url', $url); $stmt->bindParam(':defaultz', $defaultz); $stmt->bindParam(':active', $active); $stmt->bindParam(':user', $user); $stmt->bindParam(':guest', $guest); $stmt->bindParam(':icon', $icon); $stmt->bindParam(':iconurl', $iconurl); $stmt->bindParam(':window', $window); foreach ($buildArray as $t) : $name = $t['name']; $url = $t['url']; $defaultz = $t['defaultz']; $active = $t['active']; $user = $t['user']; $guest = $t['guest']; $icon = $t['icon']; $iconurl = $t['iconurl']; $window = $t['window']; $stmt->execute(); endforeach; endif; if($action == "addOptionz") : if($hasOptions == "Yes") : $file_db->exec("DELETE FROM options"); endif; if($hasOptions == "No") : $file_db->exec("CREATE TABLE options (title TEXT UNIQUE, topbar TEXT, bottombar TEXT, sidebar TEXT, hoverbg TEXT, topbartext TEXT, activetabBG TEXT, activetabicon TEXT, activetabtext TEXT, inactiveicon TEXT, inactivetext TEXT, loading TEXT, hovertext TEXT)"); endif; $title = $_POST['title']; $topbartext = $_POST['topbartext']; $topbar = $_POST['topbar']; $bottombar = $_POST['bottombar']; $sidebar = $_POST['sidebar']; $hoverbg = $_POST['hoverbg']; $hovertext = $_POST['hovertext']; $activetabBG = $_POST['activetabBG']; $activetabicon = $_POST['activetabicon']; $activetabtext = $_POST['activetabtext']; $inactiveicon = $_POST['inactiveicon']; $inactivetext = $_POST['inactivetext']; $loading = $_POST['loading']; $insert = "INSERT INTO options (title, topbartext, topbar, bottombar, sidebar, hoverbg, activetabBG, activetabicon, activetabtext, inactiveicon, inactivetext, loading, hovertext) VALUES (:title, :topbartext, :topbar, :bottombar, :sidebar, :hoverbg, :activetabBG, :activetabicon , :activetabtext , :inactiveicon, :inactivetext, :loading, :hovertext)"; $stmt = $file_db->prepare($insert); $stmt->bindParam(':title', $title); $stmt->bindParam(':topbartext', $topbartext); $stmt->bindParam(':topbar', $topbar); $stmt->bindParam(':bottombar', $bottombar); $stmt->bindParam(':sidebar', $sidebar); $stmt->bindParam(':hoverbg', $hoverbg); $stmt->bindParam(':activetabBG', $activetabBG); $stmt->bindParam(':activetabicon', $activetabicon); $stmt->bindParam(':activetabtext', $activetabtext); $stmt->bindParam(':inactiveicon', $inactiveicon); $stmt->bindParam(':inactivetext', $inactivetext); $stmt->bindParam(':loading', $loading); $stmt->bindParam(':hovertext', $hovertext); $stmt->execute(); endif; if(SLIMBAR == "true") : $slimBar = "30"; $userSize = "25"; else : $slimBar = "56"; $userSize = "40"; endif; ?> Settings