<?php #WHMADDON:phpinimgr:PHP.ini Manager $current_version = "1.2"; // SANITY CHECKS // PHP version check if (version_compare(PHP_VERSION, "5.2.0") == -1) { die('Your PHP Version is too old, version 5.2.0+ is required'); } // JSON PHP extension Check if (extension_loaded("json") === FALSE) { die("PHP's JSON extension is missing, it needs to be installed using pecl"); } if (checkacl($acl) == 0) { die("Not Authorized"); } // DEFAULTS $take_backup = 0; $make_user_owner = 0; $protect_root_file = 1; $keep_phpini_on_enable = 1; $keep_phpini_on_disable = 0; $always_show_all = 0; // VARIABLES $base_script = basename($_SERVER['PHP_SELF']); $suphpconf = "/opt/suphp/etc/suphp.conf"; $userdomains = "/etc/userdomains"; $userdatadomains = "/etc/userdatadomains"; $settings_path = "/usr/local/cpanel/whostmgr/docroot/cgi/phpinimgr/"; $settings_file = $settings_path . "settings.inc"; appconfig_upgrade();
$activitylogs = array_reverse($activitylogs); echo '<table class="table table-bordered table-striped">'; echo '<tr><th>Data</th><th>Time</th><th>IP</th></tr>'; foreach ($activitylogs as $i => $log) { if (isset($activitylogs[$i]) && is_array($activitylogs[$i])) { echo '<tr><td>'; echo $activitylogs[$i]['data']; echo '</td><td>' . date("Y-m-d H:i:s", $activitylogs[$i]['time']) . '</td><td>' . $activitylogs[$i]['ip'] . '</td></tr>'; } else { echo '<tr><td>-</td><td>-</td><td>-</td></tr>'; } } echo '</table>'; $smarty->display($config['path'] . '/templates/footer.tpl'); } elseif (isset($_REQUEST['action']) && $_REQUEST['action'] == 'backuplogs') { checkacl('blog'); $smarty->display($config['path'] . '/templates/header.tpl'); echo '<h4>Backup Logs</h4>'; $backuplogs = json_decode(file_get_contents($config['path'] . '/db/db-backuplog.json'), true); $backuplogs = array_reverse($backuplogs); echo '<table class="table table-bordered table-striped">'; echo '<tr><th>Data</th><th>Time</th><th>IP</th></tr>'; foreach ($backuplogs as $i => $log) { if (isset($backuplogs[$i]) && is_array($backuplogs[$i])) { echo '<tr><td>' . $backuplogs[$i]['data'] . '</td><td>' . date("Y-m-d H:i:s", $backuplogs[$i]['time']) . '</td><td>' . $backuplogs[$i]['ip'] . '</td></tr>'; } else { echo '<tr><td>-</td><td>-</td><td>-</td></tr>'; } } echo '</table>'; $smarty->display($config['path'] . '/templates/footer.tpl');
<?php //prevent direct file access if (phpversion() >= 5) { if (count(get_included_files()) == 1) { die; } } else { if (count(get_included_files()) == 0) { die; } } if (!defined('FILEACCESS')) { die; } checkacl('restoreb'); if (isset($_GET['restoreaction']) && $_GET['restoreaction'] == 'initiate') { $tmpfilename = 'cdp-restore-' . md5(rand() . time()) . '.txt'; shell_exec('php ' . $config['path'] . '/restore.php ' . escapeshellcmd($_GET['id']) . ' ' . escapeshellcmd($_GET['host']) . ' > ' . $config['path'] . '/files/' . $tmpfilename . ' 2>&1 &'); echo $tmpfilename; } elseif (isset($_GET['restoreaction']) && $_GET['restoreaction'] == 'readtmpfile' && isset($_GET['tmpfilename'])) { $tmpfile = file_get_contents($config['path'] . '/files/' . $_GET['tmpfilename']); if (!empty($tmpfile)) { echo $tmpfile; } } elseif (isset($_GET['id'])) { $backups = json_decode(file_get_contents($config['path'] . '/db/db-backups.json'), true); $backupjobs = json_decode(file_get_contents($config['path'] . '/db/db-backupjobs.json'), true); $backupservers = json_decode(file_get_contents($config['path'] . '/db/db-backupservers.json'), true); function GetBackupDetails($backupdata) {
<?php //prevent direct file access if (phpversion() >= 5) { if (count(get_included_files()) == 1) { die; } } else { if (count(get_included_files()) == 0) { die; } } if (!defined('FILEACCESS')) { die; } checkacl('viewbackup'); function formatBytes($size, $precision = 2) { $base = log($size) / log(1024); $suffixes = array('b', 'k', 'M', 'G', 'T'); return round(pow(1024, $base - floor($base)), $precision) . $suffixes[floor($base)]; } $backups = json_decode(file_get_contents($config['path'] . '/db/db-backups.json'), true); $backups = array_reverse($backups); //reverse the array to make newest backups at the top $backupjobs = json_decode(file_get_contents($config['path'] . '/db/db-backupjobs.json'), true); $backupservers = json_decode(file_get_contents($config['path'] . '/db/db-backupservers.json'), true); function GetJobDetails($jobid) { global $backupjobs; foreach ($backupjobs as $backupjob) {
checkacl('bjpaccess'); $backupjobs = json_decode(file_get_contents($config['path'] . '/db/db-backupjobs.json'), true); $backupservers = json_decode(file_get_contents($config['path'] . '/db/db-backupservers.json'), true); if (isset($_REQUEST['backupjob'])) { if ($_REQUEST['backupjob'] == 'add' && isset($_REQUEST['source']) && isset($_REQUEST['directory']) && isset($_REQUEST['expiry']) && isset($_REQUEST['encryption'])) { checkacl('addjob'); $id = md5(rand() . time() . $_REQUEST['source']); if (!isset($_REQUEST['encryptionkey'])) { $_REQUEST['encryptionkey'] = null; } $backupjobs[count($backupjobs)] = array('id' => $id, 'source' => $_REQUEST['source'], 'directory' => $_REQUEST['directory'], 'expiry' => $_REQUEST['expiry'], 'encryption' => $_REQUEST['encryption'], 'encryptionkey' => $_REQUEST['encryptionkey'], 'type' => $_REQUEST['type']); file_put_contents($config['path'] . '/db/db-backupjobs.json', json_encode($backupjobs)); logevent('User ' . $_SESSION['user'] . ' added backup job', 'activity'); header('Location: index.php?action=backupjobs&created=true&id=' . $id); } elseif ($_REQUEST['backupjob'] == 'remove' && isset($_REQUEST['id'])) { checkacl('deljob'); foreach ($backupjobs as $key => $backupjob) { if ($backupjob['id'] == $_REQUEST['id']) { unset($backupjobs[$key]); } } file_put_contents($config['path'] . '/db/db-backupjobs.json', json_encode($backupjobs)); logevent('User ' . $_SESSION['user'] . ' removed backup job', 'activity'); header('Location: index.php?action=backupjobs'); } } else { $fileservers = array(); $sqlservers = array(); $cpanelservers = array(); foreach ($backupservers as $backupserver) { if ($backupserver['authtype'] == 'password' || $backupserver['authtype'] == 'key') {
$_REQUEST['2fokey'] = null; } $users[$userkey]['username'] = $_REQUEST['username']; $users[$userkey]['acl'] = $_REQUEST['acl']; $users[$userkey]['2fo'] = $_REQUEST['2fo']; $users[$userkey]['2fokey'] = $_REQUEST['2fokey']; if (isset($_REQUEST['password'])) { $users[$userkey]['password'] = md5($_REQUEST['password']); } } } file_put_contents($config['path'] . '/db/db-users.json', json_encode($users)); logevent('User ' . $_SESSION['user'] . ' edited user ' . $_REQUEST['username'], 'activity'); header('Location: index.php?action=users'); } elseif ($_REQUEST['users'] == 'remove' && isset($_REQUEST['id'])) { checkacl('deluser'); foreach ($users as $userkey => $user) { if ($user['id'] == $_REQUEST['id']) { unset($users[$userkey]); } } file_put_contents($config['path'] . '/db/db-users.json', json_encode($users)); logevent('User ' . $_SESSION['user'] . ' removed user', 'activity'); header('Location: index.php?action=users'); } } else { $smarty->assign('users', $users); $smarty->assign('acls', $acls); if (isset($_REQUEST['id']) && is_array($users)) { foreach ($users as $user) { if ($user['id'] == $_REQUEST['id']) {
} if (!defined('FILEACCESS')) { die; } checkacl('spaccess'); $backupservers = json_decode(file_get_contents($config['path'] . '/db/db-backupservers.json'), true); if (isset($_REQUEST['backupserver'])) { if ($_REQUEST['backupserver'] == 'add' && isset($_REQUEST['host']) && isset($_REQUEST['port']) && isset($_REQUEST['authtype']) && isset($_REQUEST['username']) && isset($_REQUEST['password'])) { checkacl('addserver'); $id = md5(rand() . time() . $_REQUEST['host']); $backupservers[count($backupservers)] = array('id' => $id, 'host' => trim($_REQUEST['host']), 'port' => trim($_REQUEST['port']), 'authtype' => $_REQUEST['authtype'], 'username' => $_REQUEST['username'], 'password' => $_REQUEST['password']); file_put_contents($config['path'] . '/db/db-backupservers.json', json_encode($backupservers)); logevent('User ' . $_SESSION['user'] . ' added server', 'activity'); header('Location: index.php?action=backupservers'); } elseif ($_REQUEST['backupserver'] == 'remove' && isset($_REQUEST['id'])) { checkacl('delserver'); foreach ($backupservers as $key => $backupserver) { if ($backupserver['id'] == $_REQUEST['id']) { unset($backupservers[$key]); } } file_put_contents($config['path'] . '/db/db-backupservers.json', json_encode($backupservers)); logevent('User ' . $_SESSION['user'] . ' removed server', 'activity'); header('Location: index.php?action=backupservers'); } } else { $smarty->assign('backupservers', $backupservers); $smarty->display($config['path'] . '/templates/header.tpl'); $smarty->display($config['path'] . '/templates/backupservers.tpl'); $smarty->display($config['path'] . '/templates/footer.tpl'); }
$acls[count($acls)] = array('id' => count($acls) + 1, 'perms' => $_REQUEST['perms'], 'name' => trim($_REQUEST['name'])); file_put_contents($config['path'] . '/db/db-acl.json', json_encode($acls)); logevent('User ' . $_SESSION['user'] . ' added ACL', 'activity'); header('Location: index.php?action=useracl'); } elseif ($_REQUEST['acl'] == 'edit' && isset($_REQUEST['perms']) && isset($_REQUEST['name']) && isset($_REQUEST['aclid']) && is_array($_REQUEST['perms'])) { checkacl('editacl'); foreach ($acls as $aclkey => $acl) { if ($acl['id'] == $_REQUEST['aclid']) { $acls[$aclkey] = array('id' => $_REQUEST['aclid'], 'perms' => $_REQUEST['perms'], 'name' => trim($_REQUEST['name'])); } } file_put_contents($config['path'] . '/db/db-acl.json', json_encode($acls)); logevent('User ' . $_SESSION['user'] . ' edited ACL ' . $_REQUEST['aclid'], 'activity'); header('Location: index.php?action=useracl'); } elseif ($_REQUEST['acl'] == 'remove' && isset($_REQUEST['id'])) { checkacl('delacl'); foreach ($acls as $aclkey => $acl) { if ($acl['id'] == $_REQUEST['id']) { unset($acls[$aclkey]); } } file_put_contents($config['path'] . '/db/db-acl.json', json_encode($acls)); logevent('User ' . $_SESSION['user'] . ' removed ACL ' . $_REQUEST['id'], 'activity'); header('Location: index.php?action=useracl'); } } else { $smarty->assign('acls', $acls); $smarty->assign('aclarray', $aclarray); if (isset($_REQUEST['id']) && is_array($acls)) { foreach ($acls as $acl) { if ($acl['id'] == $_REQUEST['id']) {