diff --git a/user-managment.php b/user-managment.php index 291e63e..873f5b1 100644 --- a/user-managment.php +++ b/user-managment.php @@ -1,1096 +1,1101 @@ -$old_add_file Has Been Successfully Deleted.
This file was deleted because it is no longer needed for this plugin."; - } - else - { - print "
ERROR!! - Unable To Delete $old_add_file
You could delete $old_add_file if you would like.
It is no longer needed for this plugin.
"; - } - } - } - public function mmUserFile($get_Data, $data_Type = "") - { - if(get_cookie('GS_ADMIN_USERNAME') != "") - { - $current_user = get_cookie('GS_ADMIN_USERNAME'); - $dir = GSUSERSPATH . $current_user . ".xml"; - $user_file = simplexml_load_file($dir) or die("Unable to load XML file!"); - - if($data_Type == "") - { - $return_user_data = $user_file->PERMISSIONS->$get_Data; - return $return_user_data; - } - elseif($data_Type != "") - { - $return_user_data = $user_file->$get_Data; - return $return_user_data; - } - } - } - - public function mmProcessSettings() - { - if(get_cookie('GS_ADMIN_USERNAME') != "") - { - global $xml; - $perm = $xml->addChild('PERMISSIONS'); - $perm->addChild('PAGES', $this->mmUserFile('PAGES')); - $perm->addChild('FILES', $this->mmUserFile('FILES')); - $perm->addChild('THEME', $this->mmUserFile('THEME')); - $perm->addChild('PLUGINS', $this->mmUserFile('PLUGINS')); - $perm->addChild('BACKUPS', $this->mmUserFile('BACKUPS')); - $perm->addChild('SETTINGS', $this->mmUserFile('SETTINGS')); - $perm->addChild('SUPPORT', $this->mmUserFile('SUPPORT')); - $perm->addChild('EDIT', $this->mmUserFile('EDIT')); - $perm->addChild('LANDING', $this->mmUserFile('LANDING')); - $perm->addChild('ADMIN', $this->mmUserFile('ADMIN')); - } - } - - public function mmDeleteUser() - { - $deletename = $_GET['deletefile']; - $thedelete = GSUSERSPATH . $deletename . '.xml'; - $success = unlink($thedelete); - if($success) - { - print "
$deletename Has Been Successfully Deleted
"; - } - else - { - print "
ERROR!! - Unable To Delete File, Please Check Error Log Or Turn On Debug Mode
"; - } - $this->mmManageUsersForm(); - } - - public function mmProcessEditUser() - { - // check if new password was provided - if (isset($_POST['userpassword'])) - { - $pwd1 = $_POST['userpassword']; - if ($pwd1 != '') - { - $NPASSWD = passhash($pwd1); - } - else - { - $NPASSWD = $_POST['nano']; - } - } - - // GRAB DATA FROM FORM FORM - $NUSR = $_POST['usernamec']; - $usrfile = $_POST['usernamec'] . '.xml'; - $NLANDING = $_POST['Landing']; - if($NLANDING == "pages.php") - { - $NLANDING == ""; - } - - if (isset($_POST['usernamec'])) - { - // Edit user xml file - This coding was mostly taken from the 'settings.php' page.. - $xml = new SimpleXMLElement(''); - $xml->addChild('USR', $NUSR); - $xml->addChild('PWD', $NPASSWD); - $xml->addChild('EMAIL', $_POST['useremail']); - $xml->addChild('HTMLEDITOR', $_POST['usereditor']); - $xml->addChild('TIMEZONE', $_POST['ntimezone']); - $xml->addChild('LANG', $_POST['userlng']); - $perm = $xml->addChild('PERMISSIONS'); - $perm->addChild('PAGES', $_POST['Pages']); - $perm->addChild('FILES', $_POST['Files']); - $perm->addChild('THEME', $_POST['Theme']); - $perm->addChild('PLUGINS', $_POST['Plugins']); - $perm->addChild('BACKUPS', $_POST['Backups']); - $perm->addChild('SETTINGS', $_POST['Settings']); - $perm->addChild('SUPPORT', $_POST['Support']); - $perm->addChild('EDIT', $_POST['Edit']); - $perm->addChild('LANDING', $NLANDING); - $perm->addChild('ADMIN', $_POST['Admin']); - if (!XMLsave($xml, GSUSERSPATH . $usrfile)) - { - $error = "Did Not Save File - ERROR!"; - echo $error; - } - - // Redirect after script is completed... I will make the script submit via ajax later - else - { - print '
Your changes have been saved.
'; - } - $this->mmManageUsersForm(); - } - } - public function mmAddUser() - { - //Set User File, Username, And Password From Submission - $usrfile = strtolower($_POST['usernamec']); - $usrfile = $usrfile . '.xml'; - $NUSR = strtolower($_POST['usernamec']); - $pwd1 = $_POST['userpassword']; - $NPASSWD = passhash($pwd1); - - // create user xml file - This coding was mostly taken from the 'settings.php' page.. - createBak($usrfile, GSUSERSPATH, GSBACKUSERSPATH); - if (file_exists(GSUSERSPATH . _id($NUSR).'.xml.reset')) { unlink(GSUSERSPATH . _id($NUSR).'.xml.reset'); } - $xml = new SimpleXMLElement(''); - $xml->addChild('USR', $NUSR); - $xml->addChild('PWD', $NPASSWD); - $xml->addChild('EMAIL', $_POST['useremail']); - $xml->addChild('HTMLEDITOR', $_POST['usereditor']); - $xml->addChild('TIMEZONE', $_POST['ntimezone']); - $xml->addChild('LANG', $_POST['userlng']); - $perm = $xml->addChild('PERMISSIONS'); - $perm->addChild('PAGES', $_POST['Pages']); - $perm->addChild('FILES', $_POST['Files']); - $perm->addChild('THEME', $_POST['Theme']); - $perm->addChild('PLUGINS', $_POST['Plugins']); - $perm->addChild('BACKUPS', $_POST['Backups']); - $perm->addChild('SETTINGS', $_POST['Settings']); - $perm->addChild('SUPPORT', $_POST['Support']); - $perm->addChild('EDIT', $_POST['Edit']); - $perm->addChild('LANDING', $_POST['Landing']); - $perm->addChild('ADMIN', $_POST['Admin']); - if (! XMLsave($xml, GSUSERSPATH . $usrfile) ) { - $error = i18n_r('CHMOD_ERROR'); - } - // Redirect after script is completed... I will make the script submit via ajax later - else - { - print '
'.$NUSR.' Has Been Created.
'; - } - //Show Manage Form - $this->mmManageUsersForm(); - } - - public function mmManageUsersForm() - { - # get all available language files - $lang_handle = opendir(GSLANGPATH) or die("Unable to open ". GSLANGPATH); - while ($lfile = readdir($lang_handle)) { - if( is_file(GSLANGPATH . $lfile) && $lfile != "." && $lfile != ".." ) { - $lang_array[] = basename($lfile, ".php"); - } - } - if (count($lang_array) != 0) { - sort($lang_array); - $count = '0'; $sel = ''; $langs = ''; - foreach ($lang_array as $larray){ - $langs .= ''; - $count++; - } - } - - //Get Available Timezones - ob_start(); include ("../admin/inc/timezone_options.txt");$Timezone_Include = ob_get_contents();ob_end_clean(); - - //Styles For Form - ?> - - - - -

User Management

-
-

- Add New User -

-

- Update This Plugin -

-
- - - - - - - - - -PERMISSIONS->PAGES != "") - { - $pageschecked = "checked"; - $pages_dropdown = ""; - } - else - { - $pageschecked = ""; - $pages_dropdown = ""; - } - - //Files - uploads.php - if ($xml->PERMISSIONS->FILES != "") - { - $fileschecked = "checked"; - } - else {$fileschecked = "";} - - //Theme - if ($xml->PERMISSIONS->THEME != "") - { - $themechecked = "checked"; - } - else {$themechecked = "";} - - //Plugins - if ($xml->PERMISSIONS->PLUGINS != "") - { - $pluginschecked = "checked"; - } - else {$pluginschecked = "";} - - //Backuops - if ($xml->PERMISSIONS->BACKUPS != "") - { - $backupschecked = "checked"; - } - else {$backupschecked = "";} - - //Settings - if ($xml->PERMISSIONS->SETTINGS != "") - { - $settingschecked = "checked"; - } - else {$settingschecked = "";} - - - //Support - if ($xml->PERMISSIONS->SUPPORT != "") - { - $supportchecked = "checked"; - } - else {$supportchecked = "";} - - //Admin - if ($xml->PERMISSIONS->ADMIN != "") - { - $adminchecked = "checked"; - } - else {$adminchecked = "";} - - //Landing Page - if ($xml->PERMISSIONS->LANDING != "pages.php") - { - $landingselected = $xml->PERMISSIONS->LANDING; - } - else {$landingselected = "pages.php";} - - //Edit - if ($xml->PERMISSIONS->EDIT != "") - { - $editchecked = "checked"; - } - else {$editchecked = "";} - - //Html Editor - if ($xml->HTMLEDITOR == "") - { - $htmledit = "No"; - } - else - { - $htmledit = "Yes"; - } - - if ($htmledit == "No") - { - $cchecked = ""; - } - elseif ($htmledit == "Yes") - { - $cchecked = "checked"; - } - - //Below is the User Data - -?> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -"; - echo '"; - - // ADD USER FORM // -?> - - - - - mmUserFile('SETTINGS'); - //Find Current script and trim path - $current_file = $_SERVER["PHP_SELF"]; - $current_file = basename(rtrim($current_file, '/')); - $current_script = $_SERVER["QUERY_STRING"]; - - //Settings.php permissions - if ($current_file == "settings.php") { - if ($this->mmUserFile('SETTINGS') == "no") { - die('You Do Not Have Permissions To Access This Page'); - } - else { - $settings_menu =""; - } - } - if ($this->mmUserFile('SETTINGS') == "no") { - $settings_menu = ".settings {display:none !important;}"; - $settings_footer = "$(\"a\").remove(\":contains('General Settings')\");"; - } - else { - $settings_menu =""; - $settings_footer = ""; - } - - //backups.php permisions - if ($current_file == "backups.php") { - if ($this->mmUserFile('BACKUPS') == "no") { - die('You Do Not Have Permissions To Access This Page'); - } - else { - $backups_menu =""; - } - } - if ($this->mmUserFile('BACKUPS') == "no") { - $backups_menu = ".backups {display:none !important;}"; - $backups_footer = "$(\"a\").remove(\":contains('Backup Management')\");"; - } - else { - $backups_menu =""; - $backups_footer = ""; - } - - //plugins.php permissions - if ($current_file == "plugins.php") { - if ($this->mmUserFile('PLUGINS') == "no") { - die('You Do Not Have Permissions To Access This Page'); - } - else { - $plugins_menu =""; - } - } - if ($this->mmUserFile('PLUGINS') == "no") { - $plugins_menu = ".plugins {display:none !important;}"; - $plugins_footer = "$(\"a\").remove(\":contains('Plugin Management')\");"; - } - else { - $plugins_menu =""; - $plugins_footer = ""; - } - - //pages.php permissions - If pages is disabled, this coding will kill the pages script and redirect to the chosen alternate landing page - if ($current_file == "pages.php") { - if ($this->mmUserFile('PAGES') == "no") { - die(''); - } - else { - $pages_menu =""; - } - } - if ($this->mmUserFile('PAGES') == "no") { - $pages_menu = ".pages {display:none !important;}"; - $pages_footer = "$(\"a\").remove(\":contains('Page Management')\");"; - } - else { - $pages_menu =""; - $pages_footer = ""; - } - - //support.php & health-check.php permissions - if ($current_file == "support.php") { - if ($this->mmUserFile('SUPPORT') == "no") { - die('You Do Not Have Permissions To Access This Page'); - } - else { - $support_menu = ""; - } - } - if ($this->mmUserFile('SUPPORT') == "no") { - $support_menu = ".support {display:none !important;}"; - $support_footer = "$(\"a\").remove(\":contains('Support')\");"; - } - else { - $support_menu = ""; - $support_footer = ""; - } - - //uploads.php (files page) permissions - if ($current_file == "upload.php") { - if ($this->mmUserFile('FILES') == "no") { - die('You Do Not Have Permissions To Access This Page'); - } - else { - $files_menu = ""; - $files_footer = ""; - } - } - if ($this->mmUserFile('FILES') == "no") { - $files_menu = ".files {display:none !important;}"; - $files_footer = "$(\"a\").remove(\":contains('File Management')\");"; - } - else { - $files_menu = ""; - $files_footer = ""; - } - - //theme.php permissions - if ($current_file == "theme.php") { - if ($this->mmUserFile('THEME') == "no") { - die('You Do Not Have Permissions To Access This Page'); - } - else { - $theme_menu = ""; - } - } - if ($this->mmUserFile('THEME') == "no") { - $theme_menu = ".theme {display:none !important;}"; - $theme_footer = "$(\"a\").remove(\":contains('Theme Management')\");"; - } - else { - $theme_menu = ""; - $theme_footer = ""; - } - - //archive.php - if ($current_file == "archive.php") { - if ($this->mmUserFile('BACKUPS') == "no") { - die('You Do Not Have Permissions To Access This Page'); - } - else { - - } - } - - //theme-edit.php permissions - if ($current_file == "theme-edit.php") { - if ($this->mmUserFile('THEME') == "no") { - die('You Do Not Have Permissions To Access This Page'); - } - else { - - } - } - - //components.php permissions - if ($current_file == "components.php") { - if ($this->mmUserFile('THEME') == "no") { - die('You Do Not Have Permissions To Access This Page'); - } - else { - - } - } - - - //edit.php - if ($current_file == "edit.php") { - if ($this->mmUserFile('EDIT') == "no") { - die('You Do Not Have Permissions To Access This Page'); - } - else { - $edit_menu = ""; - } - } - if ($this->mmUserFile('EDIT') == "no") { - $edit_footer = "$(\"a\").remove(\":contains('reate New Page')\");"; - } - else { - $edit_menu = ""; - $edit_footer =""; - } - - //Admin - Do not allow permissions to edit users - if ($current_script == "id=user-managment") { - if ($this->mmUserFile('ADMIN') == "no") { - die('You Do Not Have Permissions To Access This Page'); - } - } - - if ($this->mmUserFile('ADMIN') == "no") { - $admin_footer = "$(\"a\").remove(\":contains('User Management')\");"; - } - else { - $admin_footer =""; - } - - //Hide Menu Items - echo""; - - //Hide Footer Menu Items With Jquery - echo ""; - } - - public function DownloadPlugin($id) - { - $pluginurl = $this->DownloadPlugins($id, 'file'); - $pluginfile = $this->DownloadPlugins($id, 'filename_id'); - - $data = file_get_contents($pluginurl); - $fp = fopen($pluginfile, "wb"); - fwrite($fp, $data); - fclose($fp); - - function unzip($src_file, $dest_dir=false, $create_zip_name_dir=true, $overwrite=true) - { - if ($zip = zip_open($src_file)) - { - if ($zip) - { - $splitter = ($create_zip_name_dir === true) ? "." : "/"; - if ($dest_dir === false) $dest_dir = substr($src_file, 0, strrpos($src_file, $splitter))."/"; - - // Create the directories to the destination dir if they don't already exist - create_dirs($dest_dir); - - // For every file in the zip-packet - while ($zip_entry = zip_read($zip)) - { - // Now we're going to create the directories in the destination directories - - // If the file is not in the root dir - $pos_last_slash = strrpos(zip_entry_name($zip_entry), "/"); - if ($pos_last_slash !== false) - { - // Create the directory where the zip-entry should be saved (with a "/" at the end) - create_dirs($dest_dir.substr(zip_entry_name($zip_entry), 0, $pos_last_slash+1)); - } - - // Open the entry - if (zip_entry_open($zip,$zip_entry,"r")) - { - - // The name of the file to save on the disk - $file_name = $dest_dir.zip_entry_name($zip_entry); - - // Check if the files should be overwritten or not - if ($overwrite === true || $overwrite === false && !is_file($file_name)) - { - // Get the content of the zip entry - $fstream = zip_entry_read($zip_entry, zip_entry_filesize($zip_entry)); - - file_put_contents($file_name, $fstream ); - // Set the rights - chmod($file_name, 0755); - } - - // Close the entry - zip_entry_close($zip_entry); - } - } - // Close the zip-file - zip_close($zip); - } - } - else - { - return false; - } - - return true; - } - - /** - * This function creates recursive directories if it doesn't already exist - * - * @param String The path that should be created - * - * @return void - */ - function create_dirs($path) - { - if (!is_dir($path)) - { - $directory_path = ""; - $directories = explode("/",$path); - array_pop($directories); - - foreach($directories as $directory) - { - $directory_path .= $directory."/"; - if (!is_dir($directory_path)) - { - mkdir($directory_path); - chmod($directory_path, 0777); - } - } - } - } - - $pluginname = $this->DownloadPlugins($id, 'name'); - - /* Unzip the source_file in the destination dir - * - * @param string The path to the ZIP-file. - * @param string The path where the zipfile should be unpacked, if false the directory of the zip-file is used - * @param boolean Indicates if the files will be unpacked in a directory with the name of the zip-file (true) or not (false) (only if the destination directory is set to false!) - * @param boolean Overwrite existing files (true) or not (false) - * - * @return boolean Succesful or not - */ - - // Extract C:/zipfiletest/zip-file.zip to C:/another_map/zipfiletest/ and doesn't overwrite existing files. NOTE: It doesn't create a map with the zip-file-name! - $success = unzip($pluginfile, "../plugins/", true, true); - if ($success){ - print '
'.$pluginname.' Was Succesfully Updated
'; - } - else{ - print "
Error: DAMN! The Script Could Not Extract And CHMOD The Archive
"; - } - $this->mmManageUsersForm(); - } - - public function DownloadPlugins($id, $get_field) - { - $my_plugin_id = $id; // replace this with yours - - $apiback = file_get_contents('http://get-simple.info/api/extend/?id='.$my_plugin_id); - $response = json_decode($apiback); - if ($response->status == 'successful') { - // Successful api response sent back. - $get_field_data = $response->$get_field; - } - - return $get_field_data; - } -} - - function mm_admin() - { - $mm_admin = new MultiUser; - - if(!isset($_POST['usernamec']) && !isset($_GET['deletefile']) && !isset($_POST['add-user']) && !isset($_GET['download_id'])) - { - $mm_admin->mmManageUsersForm(); - } - - if(isset($_POST['edit-user'])) - { - $mm_admin->mmProcessEditUser(); - } - - if(isset($_GET['deletefile'])) - { - $mm_admin->mmDeleteUser(); - } - - if(isset($_POST['add-user'])) - { - $mm_admin->mmAddUser(); - } - - if(isset($_GET['download_id'])) - { - $mm_admin->DownloadPlugin($_GET['download_id']); - } - } - - function mm_permissions() - { - $mm_admin = new MultiUser; - $mm_admin->mmCheckPermissions(); - } - - function mm_gs_settings_pg() - { - $mm_settings = new MultiUser; - $mm_settings->mmProcessSettings(); - } -?> \ No newline at end of file +$old_add_file Has Been Successfully Deleted.
This file was deleted because it is no longer needed for this plugin."; + } + else + { + print "
ERROR!! - Unable To Delete $old_add_file
You could delete $old_add_file if you would like.
It is no longer needed for this plugin.
"; + } + } + } + public function mmUserFile($get_Data, $data_Type = "") + { + if(get_cookie('GS_ADMIN_USERNAME') != "") + { + $current_user = get_cookie('GS_ADMIN_USERNAME'); + $dir = GSUSERSPATH . $current_user . ".xml"; + $user_file = simplexml_load_file($dir) or die("Unable to load XML file!"); + + if($data_Type == "") + { + $return_user_data = $user_file->PERMISSIONS->$get_Data; + return $return_user_data; + } + elseif($data_Type != "") + { + $return_user_data = $user_file->$get_Data; + return $return_user_data; + } + } + } + + public function mmProcessSettings() + { + if(get_cookie('GS_ADMIN_USERNAME') != "") + { + global $xml; + $perm = $xml->addChild('PERMISSIONS'); + $perm->addChild('PAGES', $this->mmUserFile('PAGES')); + $perm->addChild('FILES', $this->mmUserFile('FILES')); + $perm->addChild('THEME', $this->mmUserFile('THEME')); + $perm->addChild('PLUGINS', $this->mmUserFile('PLUGINS')); + $perm->addChild('BACKUPS', $this->mmUserFile('BACKUPS')); + $perm->addChild('SETTINGS', $this->mmUserFile('SETTINGS')); + $perm->addChild('SUPPORT', $this->mmUserFile('SUPPORT')); + $perm->addChild('EDIT', $this->mmUserFile('EDIT')); + $perm->addChild('LANDING', $this->mmUserFile('LANDING')); + $perm->addChild('ADMIN', $this->mmUserFile('ADMIN')); + } + } + + public function mmDeleteUser() + { + $deletename = $_GET['deletefile']; + $thedelete = GSUSERSPATH . $deletename . '.xml'; + $success = unlink($thedelete); + if($success) + { + print "
$deletename ". i18n_r('user-managment/DELETED') . "
"; + } + else + { + print "
" . i18n_r('user-managment/DELETEERROR') . "
"; + } + $this->mmManageUsersForm(); + } + + public function mmProcessEditUser() + { + // check if new password was provided + if (isset($_POST['userpassword'])) + { + $pwd1 = $_POST['userpassword']; + if ($pwd1 != '') + { + $NPASSWD = passhash($pwd1); + } + else + { + $NPASSWD = $_POST['nano']; + } + } + + // GRAB DATA FROM FORM FORM + $NUSR = $_POST['usernamec']; + $usrfile = $_POST['usernamec'] . '.xml'; + $NLANDING = $_POST['Landing']; + if($NLANDING == "pages.php") + { + $NLANDING == ""; + } + + if (isset($_POST['usernamec'])) + { + // Edit user xml file - This coding was mostly taken from the 'settings.php' page.. + $xml = new SimpleXMLElement(''); + $xml->addChild('USR', $NUSR); + $xml->addChild('PWD', $NPASSWD); + $xml->addChild('EMAIL', $_POST['useremail']); + $xml->addChild('HTMLEDITOR', $_POST['usereditor']); + $xml->addChild('TIMEZONE', $_POST['ntimezone']); + $xml->addChild('LANG', $_POST['userlng']); + $perm = $xml->addChild('PERMISSIONS'); + $perm->addChild('PAGES', $_POST['Pages']); + $perm->addChild('FILES', $_POST['Files']); + $perm->addChild('THEME', $_POST['Theme']); + $perm->addChild('PLUGINS', $_POST['Plugins']); + $perm->addChild('BACKUPS', $_POST['Backups']); + $perm->addChild('SETTINGS', $_POST['Settings']); + $perm->addChild('SUPPORT', $_POST['Support']); + $perm->addChild('EDIT', $_POST['Edit']); + $perm->addChild('LANDING', $NLANDING); + $perm->addChild('ADMIN', $_POST['Admin']); + if (!XMLsave($xml, GSUSERSPATH . $usrfile)) + { + $error = i18n_r('user-managment/SAVEERROR'); + echo $error; + } + + // Redirect after script is completed... I will make the script submit via ajax later + else + { + print '
'.i18n_r('user-managment/SAVED').'
'; + } + $this->mmManageUsersForm(); + } + } + public function mmAddUser() + { + //Set User File, Username, And Password From Submission + $usrfile = strtolower($_POST['usernamec']); + $usrfile = $usrfile . '.xml'; + $NUSR = strtolower($_POST['usernamec']); + $pwd1 = $_POST['userpassword']; + $NPASSWD = passhash($pwd1); + + // create user xml file - This coding was mostly taken from the 'settings.php' page.. + createBak($usrfile, GSUSERSPATH, GSBACKUSERSPATH); + if (file_exists(GSUSERSPATH . _id($NUSR).'.xml.reset')) { unlink(GSUSERSPATH . _id($NUSR).'.xml.reset'); } + $xml = new SimpleXMLElement(''); + $xml->addChild('USR', $NUSR); + $xml->addChild('PWD', $NPASSWD); + $xml->addChild('EMAIL', $_POST['useremail']); + $xml->addChild('HTMLEDITOR', $_POST['usereditor']); + $xml->addChild('TIMEZONE', $_POST['ntimezone']); + $xml->addChild('LANG', $_POST['userlng']); + $perm = $xml->addChild('PERMISSIONS'); + $perm->addChild('PAGES', $_POST['Pages']); + $perm->addChild('FILES', $_POST['Files']); + $perm->addChild('THEME', $_POST['Theme']); + $perm->addChild('PLUGINS', $_POST['Plugins']); + $perm->addChild('BACKUPS', $_POST['Backups']); + $perm->addChild('SETTINGS', $_POST['Settings']); + $perm->addChild('SUPPORT', $_POST['Support']); + $perm->addChild('EDIT', $_POST['Edit']); + $perm->addChild('LANDING', $_POST['Landing']); + $perm->addChild('ADMIN', $_POST['Admin']); + if (! XMLsave($xml, GSUSERSPATH . $usrfile) ) { + $error = i18n_r('CHMOD_ERROR'); + } + // Redirect after script is completed... I will make the script submit via ajax later + else + { + print '
'.$NUSR.' '. i18n_r('user-managment/CREATED') . '
'; + } + //Show Manage Form + $this->mmManageUsersForm(); + } + + public function mmManageUsersForm() + { + # get all available language files + $lang_handle = opendir(GSLANGPATH) or die("Unable to open ". GSLANGPATH); + while ($lfile = readdir($lang_handle)) { + if( is_file(GSLANGPATH . $lfile) && $lfile != "." && $lfile != ".." ) { + $lang_array[] = basename($lfile, ".php"); + } + } + if (count($lang_array) != 0) { + sort($lang_array); + $count = '0'; $sel = ''; $langs = ''; + foreach ($lang_array as $larray){ + $langs .= ''; + $count++; + } + } + + //Get Available Timezones + ob_start(); include ("../admin/inc/timezone_options.txt");$Timezone_Include = ob_get_contents();ob_end_clean(); + + //Styles For Form + ?> + + + + +

+
+

+ +

+

+ +

+
+ +
Username:Email:HTML Editor:Edit
-  USR; ?> - -  EMAIL; ?> - -   - - EditHide -
- - - /> -
- - - - - - - - -
-

Permissions (Check Areas You Would Like To Block Access To)

-
-
- /> -
- -
- /> -
- -
- /> -
- -
- /> -
- -
- /> -
- -
- /> -
- -
- /> -
- -
- /> -
- -
- -
- -
- - /> -
- -
- -
- -    Delete User -
+ + + + + + + +PERMISSIONS->PAGES != "") + { + $pageschecked = "checked"; + $pages_dropdown = ""; + } + else + { + $pageschecked = ""; + $pages_dropdown = ""; + } + + //Files - uploads.php + if ($xml->PERMISSIONS->FILES != "") + { + $fileschecked = "checked"; + } + else {$fileschecked = "";} + + //Theme + if ($xml->PERMISSIONS->THEME != "") + { + $themechecked = "checked"; + } + else {$themechecked = "";} + + //Plugins + if ($xml->PERMISSIONS->PLUGINS != "") + { + $pluginschecked = "checked"; + } + else {$pluginschecked = "";} + + //Backuops + if ($xml->PERMISSIONS->BACKUPS != "") + { + $backupschecked = "checked"; + } + else {$backupschecked = "";} + + //Settings + if ($xml->PERMISSIONS->SETTINGS != "") + { + $settingschecked = "checked"; + } + else {$settingschecked = "";} + + + //Support + if ($xml->PERMISSIONS->SUPPORT != "") + { + $supportchecked = "checked"; + } + else {$supportchecked = "";} + + //Admin + if ($xml->PERMISSIONS->ADMIN != "") + { + $adminchecked = "checked"; + } + else {$adminchecked = "";} + + //Landing Page + if ($xml->PERMISSIONS->LANDING != "pages.php") + { + $landingselected = $xml->PERMISSIONS->LANDING; + } + else {$landingselected = "pages.php";} + + //Edit + if ($xml->PERMISSIONS->EDIT != "") + { + $editchecked = "checked"; + } + else {$editchecked = "";} + + //Html Editor + if ($xml->HTMLEDITOR == "") + { + $htmledit = "No"; + } + else + { + $htmledit = "Yes"; + } + + if ($htmledit == "No") + { + $cchecked = ""; + } + elseif ($htmledit == "Yes") + { + $cchecked = "checked"; + } + + //Below is the User Data + +?> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +"; + echo '"; + + // ADD USER FORM // +?> + + + + + mmUserFile('SETTINGS'); //only for debug purposes + //Find Current script and trim path + $current_file = $_SERVER["PHP_SELF"]; + $current_file = basename(rtrim($current_file, '/')); + $current_script = $_SERVER["QUERY_STRING"]; + + //Settings.php permissions + if ($current_file == "settings.php") { + if ($this->mmUserFile('SETTINGS') == "no") { + die('You Do Not Have Permissions To Access This Page'); + } + else { + $settings_menu =""; + } + } + if ($this->mmUserFile('SETTINGS') == "no") { + $settings_menu = ".settings {display:none !important;}"; + $settings_footer = "$(\"a\").remove(\":contains('General Settings')\");"; + } + else { + $settings_menu =""; + $settings_footer = ""; + } + + //backups.php permisions + if ($current_file == "backups.php") { + if ($this->mmUserFile('BACKUPS') == "no") { + die('You Do Not Have Permissions To Access This Page'); + } + else { + $backups_menu =""; + } + } + if ($this->mmUserFile('BACKUPS') == "no") { + $backups_menu = ".backups {display:none !important;}"; + $backups_footer = "$(\"a\").remove(\":contains('Backup Management')\");"; + } + else { + $backups_menu =""; + $backups_footer = ""; + } + + //plugins.php permissions + if ($current_file == "plugins.php") { + if ($this->mmUserFile('PLUGINS') == "no") { + die('You Do Not Have Permissions To Access This Page'); + } + else { + $plugins_menu =""; + } + } + if ($this->mmUserFile('PLUGINS') == "no") { + $plugins_menu = ".plugins {display:none !important;}"; + $plugins_footer = "$(\"a\").remove(\":contains('Plugin Management')\");"; + } + else { + $plugins_menu =""; + $plugins_footer = ""; + } + + //pages.php permissions - If pages is disabled, this coding will kill the pages script and redirect to the chosen alternate landing page + if ($current_file == "pages.php") { + if ($this->mmUserFile('PAGES') == "no") { + die(''); + } + else { + $pages_menu =""; + } + } + if ($this->mmUserFile('PAGES') == "no") { + $pages_menu = ".pages {display:none !important;}"; + $pages_footer = "$(\"a\").remove(\":contains('Page Management')\");"; + } + else { + $pages_menu =""; + $pages_footer = ""; + } + + //support.php & health-check.php permissions + if ($current_file == "support.php") { + if ($this->mmUserFile('SUPPORT') == "no") { + die('You Do Not Have Permissions To Access This Page'); + } + else { + $support_menu = ""; + } + } + if ($this->mmUserFile('SUPPORT') == "no") { + $support_menu = ".support {display:none !important;}"; + $support_footer = "$(\"a\").remove(\":contains('Support')\");"; + } + else { + $support_menu = ""; + $support_footer = ""; + } + + //uploads.php (files page) permissions + if ($current_file == "upload.php") { + if ($this->mmUserFile('FILES') == "no") { + die('You Do Not Have Permissions To Access This Page'); + } + else { + $files_menu = ""; + $files_footer = ""; + } + } + if ($this->mmUserFile('FILES') == "no") { + $files_menu = ".files {display:none !important;}"; + $files_footer = "$(\"a\").remove(\":contains('File Management')\");"; + } + else { + $files_menu = ""; + $files_footer = ""; + } + + //theme.php permissions + if ($current_file == "theme.php") { + if ($this->mmUserFile('THEME') == "no") { + die('You Do Not Have Permissions To Access This Page'); + } + else { + $theme_menu = ""; + } + } + if ($this->mmUserFile('THEME') == "no") { + $theme_menu = ".theme {display:none !important;}"; + $theme_footer = "$(\"a\").remove(\":contains('Theme Management')\");"; + } + else { + $theme_menu = ""; + $theme_footer = ""; + } + + //archive.php + if ($current_file == "archive.php") { + if ($this->mmUserFile('BACKUPS') == "no") { + die('You Do Not Have Permissions To Access This Page'); + } + else { + + } + } + + //theme-edit.php permissions + if ($current_file == "theme-edit.php") { + if ($this->mmUserFile('THEME') == "no") { + die('You Do Not Have Permissions To Access This Page'); + } + else { + + } + } + + //components.php permissions + if ($current_file == "components.php") { + if ($this->mmUserFile('THEME') == "no") { + die('You Do Not Have Permissions To Access This Page'); + } + else { + + } + } + + + //edit.php + if ($current_file == "edit.php") { + if ($this->mmUserFile('EDIT') == "no") { + die('You Do Not Have Permissions To Access This Page'); + } + else { + $edit_menu = ""; + } + } + if ($this->mmUserFile('EDIT') == "no") { + $edit_footer = "$(\"a\").remove(\":contains('reate New Page')\");"; + } + else { + $edit_menu = ""; + $edit_footer =""; + } + + //Admin - Do not allow permissions to edit users + if ($current_script == "id=user-managment") { + if ($this->mmUserFile('ADMIN') == "no") { + die('You Do Not Have Permissions To Access This Page'); + } + } + + if ($this->mmUserFile('ADMIN') == "no") { + $admin_footer = "$(\"a\").remove(\":contains('User Management')\");"; + } + else { + $admin_footer =""; + } + + //Hide Menu Items + echo""; + + //Hide Footer Menu Items With Jquery + echo ""; + } + + public function DownloadPlugin($id) + { + $pluginurl = $this->DownloadPlugins($id, 'file'); + $pluginfile = $this->DownloadPlugins($id, 'filename_id'); + + $data = file_get_contents($pluginurl); + $fp = fopen($pluginfile, "wb"); + fwrite($fp, $data); + fclose($fp); + + function unzip($src_file, $dest_dir=false, $create_zip_name_dir=true, $overwrite=true) + { + if ($zip = zip_open($src_file)) + { + if ($zip) + { + $splitter = ($create_zip_name_dir === true) ? "." : "/"; + if ($dest_dir === false) $dest_dir = substr($src_file, 0, strrpos($src_file, $splitter))."/"; + + // Create the directories to the destination dir if they don't already exist + create_dirs($dest_dir); + + // For every file in the zip-packet + while ($zip_entry = zip_read($zip)) + { + // Now we're going to create the directories in the destination directories + + // If the file is not in the root dir + $pos_last_slash = strrpos(zip_entry_name($zip_entry), "/"); + if ($pos_last_slash !== false) + { + // Create the directory where the zip-entry should be saved (with a "/" at the end) + create_dirs($dest_dir.substr(zip_entry_name($zip_entry), 0, $pos_last_slash+1)); + } + + // Open the entry + if (zip_entry_open($zip,$zip_entry,"r")) + { + + // The name of the file to save on the disk + $file_name = $dest_dir.zip_entry_name($zip_entry); + + // Check if the files should be overwritten or not + if ($overwrite === true || $overwrite === false && !is_file($file_name)) + { + // Get the content of the zip entry + $fstream = zip_entry_read($zip_entry, zip_entry_filesize($zip_entry)); + + file_put_contents($file_name, $fstream ); + // Set the rights + chmod($file_name, 0755); + } + + // Close the entry + zip_entry_close($zip_entry); + } + } + // Close the zip-file + zip_close($zip); + } + } + else + { + return false; + } + + return true; + } + + /** + * This function creates recursive directories if it doesn't already exist + * + * @param String The path that should be created + * + * @return void + */ + function create_dirs($path) + { + if (!is_dir($path)) + { + $directory_path = ""; + $directories = explode("/",$path); + array_pop($directories); + + foreach($directories as $directory) + { + $directory_path .= $directory."/"; + if (!is_dir($directory_path)) + { + mkdir($directory_path); + chmod($directory_path, 0777); + } + } + } + } + + $pluginname = $this->DownloadPlugins($id, 'name'); + + /* Unzip the source_file in the destination dir + * + * @param string The path to the ZIP-file. + * @param string The path where the zipfile should be unpacked, if false the directory of the zip-file is used + * @param boolean Indicates if the files will be unpacked in a directory with the name of the zip-file (true) or not (false) (only if the destination directory is set to false!) + * @param boolean Overwrite existing files (true) or not (false) + * + * @return boolean Succesful or not + */ + + // Extract C:/zipfiletest/zip-file.zip to C:/another_map/zipfiletest/ and doesn't overwrite existing files. NOTE: It doesn't create a map with the zip-file-name! + $success = unzip($pluginfile, "../plugins/", true, true); + if ($success){ + print '
'.$pluginname.' Was Succesfully Updated
'; + } + else{ + print "
Error: DAMN! The Script Could Not Extract And CHMOD The Archive
"; + } + $this->mmManageUsersForm(); + } + + public function DownloadPlugins($id, $get_field) + { + $my_plugin_id = $id; // replace this with yours + + $apiback = file_get_contents('http://get-simple.info/api/extend/?id='.$my_plugin_id); + $response = json_decode($apiback); + if ($response->status == 'successful') { + // Successful api response sent back. + $get_field_data = $response->$get_field; + } + + return $get_field_data; + } +} + + function mm_admin() + { + $mm_admin = new MultiUser; + + if(!isset($_POST['usernamec']) && !isset($_GET['deletefile']) && !isset($_POST['add-user']) && !isset($_GET['download_id'])) + { + $mm_admin->mmManageUsersForm(); + } + + if(isset($_POST['edit-user'])) + { + $mm_admin->mmProcessEditUser(); + } + + if(isset($_GET['deletefile'])) + { + $mm_admin->mmDeleteUser(); + } + + if(isset($_POST['add-user'])) + { + $mm_admin->mmAddUser(); + } + + if(isset($_GET['download_id'])) + { + $mm_admin->DownloadPlugin($_GET['download_id']); + } + } + + function mm_permissions() + { + $mm_admin = new MultiUser; + $mm_admin->mmCheckPermissions(); + } + + function mm_gs_settings_pg() + { + $mm_settings = new MultiUser; + $mm_settings->mmProcessSettings(); + } +?> diff --git a/user-managment/lang/.giosaveTIB9AW b/user-managment/lang/.giosaveTIB9AW new file mode 100644 index 0000000..e69de29 diff --git a/user-managment/lang/.htaccess b/user-managment/lang/.htaccess new file mode 100644 index 0000000..3a42882 --- /dev/null +++ b/user-managment/lang/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/user-managment/lang/en_US.php b/user-managment/lang/en_US.php new file mode 100755 index 0000000..57ee0b2 --- /dev/null +++ b/user-managment/lang/en_US.php @@ -0,0 +1,30 @@ + "User Management", +'SIDEBAR' => "User Management", +'PLUGIN_DESCRIPTION' => "Adds Multi-User Management - Edit all options for current users and manage permissions.", +'ADDUSER' => "Add New User", +'UPDATE' => "Update This Plugin", +'EDIT' => "Edit", +'HIDE' => "Hide", +'PERM' => "Permissions (Check Areas You Would Like To Block Access To)", +'PAGES' => "Pages", +'FILES' => "Files", +'THEME' => "Theme", +'PLUGINS' => "Plugins", +'BACKUPS' => "Backups", +'SETTINGS' => "Settings", +'SUPPORT' => "Support", +'LAND' => "Custom Landing Page (Optional)", +'ADMIN' => "Disable Admin Access (Cannot Manage Users)", +'SAVE' => "Save Changes", +'DELETE' => "Delete User", +'DELETED' => "Has Been Successfully Deleted", +'DELETEERROR' => "ERROR!! - Unable To Delete File, Please Check Error Log Or Turn On Debug Mode", +'SAVEERROR' => "Did Not Save File - ERROR!", +'SAVED' => "Your changes have been saved.", +'CREATED' => "Has Been Created.", +'DELETESURE' => "Are You Sure You Want To Delete", +'UPDATESURE' => "Are You Sure You Want To Update This Plugin?" + +); diff --git a/user-managment/lang/it_IT.php b/user-managment/lang/it_IT.php new file mode 100644 index 0000000..a89e2a0 --- /dev/null +++ b/user-managment/lang/it_IT.php @@ -0,0 +1,29 @@ + "Gestione Utenti", +'SIDEBAR' => "Gestione Utenti", +'PLUGIN_DESCRIPTION' => "Aggiunge funzionalità per la gestione di più utenti, ciascuno con i suoi permessi e opzioni", +'ADDUSER' => "Crea Nuovo Utente", +'UPDATE' => "Aggiorna questo plugin", +'EDIT' => "Modifica", +'HIDE' => "Nascondi", +'PERM' => "Permessi (Seleziona a quali aree vuoi impedire l'accesso)", +'PAGES' => "Pagine", +'FILES' => "File", +'THEME' => "Temi grafici", +'PLUGINS' => "Plugin", +'BACKUPS' => "Backup", +'SETTINGS' => "Impostaz.", +'SUPPORT' => "Supporto", +'LAND' => "Pagina di arrivo (opzionale)", +'ADMIN' => "Disattiva l'accesso come amministratore (Non puo' gestire gli utenti)", +'SAVE' => "Salva modifiche", +'DELETE' => "Elimina utente", +'DELETED' => "è stato eliminato.", +'DELETEERROR' => "ERRORE! - Non riesco a eliminare il file, si prega di verificare nei log", +'SAVEERROR' => "ERRORE! - Non ho salvato il file", +'SAVED' => "Le tue modifiche sono state salvate.", +'CREATED' => "è stato creato.", +'DELETESURE' => "Sei sicuro di voler eliminare", +'UPDATESURE' => "Sei sicuro di voler aggiornare il plugin?" +);
Username:Email:HTML Editor:
+  USR; ?> + +  EMAIL; ?> + +   + + +
+ + + /> +
+ + + + + + + + +
+

+
+
+ /> +
+ +
+ /> +
+ +
+ /> +
+ +
+ /> +
+ +
+ /> +
+ +
+ /> +
+ +
+ /> +
+ +
+ /> +
+ +
+ +
+ +
+ + /> +
+ +
+ +
+ +     +