array( 'refresh' => array_filter($GLOBALS, function ($k) use ($refreshSearch) { return stripos($k, $refreshSearch) !== false; }, ARRAY_FILTER_USE_KEY), 'search' => array( 'enabled' => (qualifyRequest($GLOBALS['mediaSearchAuth']) && $GLOBALS['mediaSearch'] == true && $GLOBALS['plexToken']) ? true : false, 'type' => $GLOBALS['mediaSearchType'], ), 'ombi' => array( 'enabled' => (qualifyRequest($GLOBALS['homepageOmbiAuth']) && $GLOBALS['homepageOmbiEnabled'] == true && $GLOBALS['ssoOmbi']) ? true : false, ), 'options' => array( 'alternateHomepageHeaders' => $GLOBALS['alternateHomepageHeaders'], ) ) ); } function wizardConfig($array) { foreach ($array['data'] as $items) { foreach ($items as $key => $value) { if ($key == 'name') { $newKey = $value; } if ($key == 'value') { $newValue = $value; } if (isset($newKey) && isset($newValue)) { $$newKey = $newValue; } } } $location = cleanDirectory($location); $dbName = $dbName.'.db'; $configVersion = $GLOBALS['installedVersion']; $configArray = array( 'dbName' => $dbName, 'dbLocation' => $location, 'license' => $license, 'organizrHash' => $hashKey, 'organizrAPI' => $api, 'registrationPassword' => $registrationPassword, ); // Create Config if (createConfig($configArray)) { // Call DB Create if (createDB($location, $dbName)) { // Add in first user if (createFirstAdmin($location, $dbName, $username, $password, $email)) { if (createToken($username, $email, gravatar($email), 'Admin', 0, $hashKey, 1)) { return true; } else { return 'token'; } } else { return 'admin'; } } else { return 'db'; } } else { return 'config'; } return false; } function register($array) { // Grab username and password from login form foreach ($array['data'] as $items) { foreach ($items as $key => $value) { if ($key == 'name') { $newKey = $value; } if ($key == 'value') { $newValue = $value; } if (isset($newKey) && isset($newValue)) { $$newKey = $newValue; } } } if ($registrationPassword == $GLOBALS['registrationPassword']) { $defaults = defaultUserGroup(); writeLog('success', 'Registration Function - Registration Password Verified', $username); if (createUser($username, $password, $defaults, $email)) { writeLog('success', 'Registration Function - A User has registered', $username); if (createToken($username, $email, gravatar($email), $defaults['group'], $defaults['group_id'], $GLOBALS['organizrHash'], 1)) { writeLoginLog($username, 'success'); writeLog('success', 'Login Function - A User has logged in', $username); return true; } } else { writeLog('error', 'Registration Function - An error occured', $username); return 'username taken'; } } else { writeLog('warning', 'Registration Function - Wrong Password', $username); return 'mismatch'; } } function removeFile($array) { $filePath = $array['data']['path']; $fileName = $array['data']['name']; if (file_exists($filePath)) { if (unlink($filePath)) { writeLog('success', 'Log Management Function - Log: '.$fileName.' has been purged/deleted', 'SYSTEM'); return true; } else { writeLog('error', 'Log Management Function - Log: '.$fileName.' - Error Occured', 'SYSTEM'); return false; } } else { writeLog('error', 'Log Management Function - Log: '.$fileName.' does not exist', 'SYSTEM'); return false; } } function recover($array) { $email = $array['data']['email']; $newPassword = randString(10); try { $connect = new Dibi\Connection([ 'driver' => 'sqlite3', 'database' => $GLOBALS['dbLocation'].$GLOBALS['dbName'], ]); $isUser = $connect->fetch('SELECT * FROM users WHERE email = ? COLLATE NOCASE', $email); if ($isUser) { $connect->query(' UPDATE users SET', [ 'password' => password_hash($newPassword, PASSWORD_BCRYPT) ], ' WHERE email=? COLLATE NOCASE', $email); if ($GLOBALS['PHPMAILER-enabled']) { $emailTemplate = array( 'type' => 'reset', 'body' => $GLOBALS['PHPMAILER-emailTemplateResetPassword'], 'subject' => $GLOBALS['PHPMAILER-emailTemplateResetPasswordSubject'], 'user' => $isUser['username'], 'password' => $newPassword, 'inviteCode' => null, ); $emailTemplate = phpmEmailTemplate($emailTemplate); $sendEmail = array( 'to' => $email, 'user' => $isUser['username'], 'subject' => $emailTemplate['subject'], 'body' => phpmBuildEmail($emailTemplate), ); phpmSendEmail($sendEmail); } writeLog('success', 'User Management Function - User: '.$isUser['username'].'\'s password was reset', $isUser['username']); return true; } else { writeLog('error', 'User Management Function - Error - User: '.$email.' An error Occured', $email); return 'an error occured'; } } catch (Dibi\Exception $e) { writeLog('error', 'User Management Function - Error - User: '.$email.' An error Occured', $email); return 'an error occured'; } } function editUser($array) { if ($array['data']['username'] == '' && $array['data']['username'] == '') { return 'Username/email not set'; } try { $connect = new Dibi\Connection([ 'driver' => 'sqlite3', 'database' => $GLOBALS['dbLocation'].$GLOBALS['dbName'], ]); if (!usernameTakenExcept($array['data']['username'], $array['data']['email'], $GLOBALS['organizrUser']['userID'])) { $connect->query(' UPDATE users SET', [ 'username' => $array['data']['username'], 'email' => $array['data']['email'], ], ' WHERE id=?', $GLOBALS['organizrUser']['userID']); if (!empty($array['data']['password'])) { $connect->query(' UPDATE users SET', [ 'password' => password_hash($array['data']['password'], PASSWORD_BCRYPT) ], ' WHERE id=?', $GLOBALS['organizrUser']['userID']); } writeLog('success', 'User Management Function - User: '.$array['data']['username'].'\'s info was changed', $GLOBALS['organizrUser']['username']); return true; } else { return 'Username/Email Already Taken'; } } catch (Dibi\Exception $e) { writeLog('error', 'User Management Function - Error - User: '.$array['data']['username'].' An error Occured', $GLOBALS['organizrUser']['username']); return 'an error occured'; } } function logout() { coookie('delete', 'organizrToken'); coookie('delete', 'mpt'); coookie('delete', 'Auth'); $GLOBALS['organizrUser'] = false; return true; } function qualifyRequest($accessLevelNeeded) { if (getUserLevel() <= $accessLevelNeeded) { return true; } else { return false; } } function getUserLevel() { $requesterToken = isset(getallheaders()['Token']) ? getallheaders()['Token'] : false; // Check token or API key // If API key, return 0 for admin if (strlen($requesterToken) == 20 && $requesterToken == $GLOBALS['organizrAPI']) { //DO API CHECK return 0; } elseif (isset($GLOBALS['organizrUser'])) { return $GLOBALS['organizrUser']['groupID']; } // All else fails? return guest id return 999; } function organizrStatus() { $status = array(); $dependenciesActive = array(); $dependenciesInactive = array(); $extensions = array("PDO_SQLITE", "PDO", "SQLITE3", "zip", "cURL", "openssl", "simplexml", "json", "session"); $functions = array("hash", "fopen", "fsockopen", "fwrite", "fclose", "readfile"); foreach ($extensions as $check) { if (extension_loaded($check)) { array_push($dependenciesActive, $check); } else { array_push($dependenciesInactive, $check); } } foreach ($functions as $check) { if (function_exists($check)) { array_push($dependenciesActive, $check); } else { array_push($dependenciesInactive, $check); } } if (!file_exists('config'.DIRECTORY_SEPARATOR.'config.php')) { $status['status'] = "wizard";//wizard - ok for test } if (count($dependenciesInactive)>0 || !is_writable(dirname(__DIR__, 2)) || !(version_compare(PHP_VERSION, '7.0.0') >= 0)) { $status['status'] = "dependencies"; } $status['status'] = (!empty($status['status'])) ? $status['status'] : $status['status'] = "ok"; $status['writable'] = is_writable(dirname(__DIR__, 2)) ? 'yes' : 'no'; $status['minVersion'] = (version_compare(PHP_VERSION, '7.0.0') >= 0) ? 'yes' : 'no'; $status['dependenciesActive'] = $dependenciesActive; $status['dependenciesInactive'] = $dependenciesInactive; $status['version'] = $GLOBALS['installedVersion']; $status['os'] = getOS(); $status['php'] = phpversion(); return $status; } function getSettingsMain() { return array( 'Github' => array( array( 'type' => 'select', 'name' => 'branch', 'label' => 'Branch', 'value' => $GLOBALS['branch'], 'options' => getBranches() ), array( 'type' => 'button', 'label' => 'Force Install Branch', 'class' => 'updateNow', 'icon' => 'fa fa-download', 'text' => 'Retrieve' ) ), 'API' => array( array( 'type' => 'password-alt', 'name' => 'organizrAPI', 'label' => 'Organizr API', 'value' => $GLOBALS['organizrAPI'] ), array( 'type' => 'button', 'label' => 'Generate New API Key', 'class' => 'newAPIKey', 'icon' => 'fa fa-refresh', 'text' => 'Generate' ) ), 'Authentication' => array( array( 'type' => 'select', 'name' => 'authType', 'id' => 'authSelect', 'label' => 'Authentication Type', 'value' => $GLOBALS['authType'], 'options' => getAuthTypes() ), array( 'type' => 'select', 'name' => 'authBackend', 'id' => 'authBackendSelect', 'label' => 'Authentication Backend', 'class' => 'backendAuth switchAuth', 'value' => $GLOBALS['authBackend'], 'options' => getAuthBackends() ), array( 'type' => 'password-alt', 'name' => 'plexToken', 'class' => 'plexAuth switchAuth', 'label' => 'Plex Token', 'value' => $GLOBALS['plexToken'], 'placeholder' => 'Use Get Token Button' ), array( 'type' => 'button', 'label' => 'Get Plex Token', 'class' => 'popup-with-form getPlexTokenAuth plexAuth switchAuth', 'icon' => 'fa fa-ticket', 'text' => 'Retrieve', 'href' => '#auth-plex-token-form', 'attr' => 'data-effect="mfp-3d-unfold"' ), array( 'type' => 'password-alt', 'name' => 'plexID', 'class' => 'plexAuth switchAuth', 'label' => 'Plex Machine', 'value' => $GLOBALS['plexID'], 'placeholder' => 'Use Get Plex Machine Button' ), array( 'type' => 'button', 'label' => 'Get Plex Machine', 'class' => 'popup-with-form getPlexMachineAuth plexAuth switchAuth', 'icon' => 'fa fa-id-badge', 'text' => 'Retrieve', 'href' => '#auth-plex-machine-form', 'attr' => 'data-effect="mfp-3d-unfold"' ), array( 'type' => 'input', 'name' => 'authBackendHost', 'class' => 'ldapAuth ftpAuth switchAuth', 'label' => 'Host Address', 'value' => $GLOBALS['authBackendHost'], 'placeholder' => 'http{s) | ftp(s) | ldap(s)://hostname:port' ), array( 'type' => 'input', 'name' => 'authBaseDN', 'class' => 'ldapAuth switchAuth', 'label' => 'Host Base DN', 'value' => $GLOBALS['authBaseDN'], 'placeholder' => 'cn=%s,dc=sub,dc=domain,dc=com' ), array( 'type' => 'input', 'name' => 'embyURL', 'class' => 'embyAuth switchAuth', 'label' => 'Emby URL', 'value' => $GLOBALS['embyURL'], 'placeholder' => 'http(s)://hostname:port' ), array( 'type' => 'password-alt', 'name' => 'embyToken', 'class' => 'embyAuth switchAuth', 'label' => 'Emby Token', 'value' => $GLOBALS['embyToken'], 'placeholder' => '' ) /*array( 'type' => 'button', 'label' => 'Send Test', 'class' => 'phpmSendTestEmail', 'icon' => 'fa fa-paper-plane', 'text' => 'Send' )*/ ), 'Misc' => array( array( 'type' => 'password-alt', 'name' => 'registrationPassword', 'label' => 'Registration Password', 'value' => $GLOBALS['registrationPassword'], ), ) ); } function getSSO() { return array( 'Plex' => array( array( 'type' => 'password-alt', 'name' => 'plexToken', 'label' => 'Plex Token', 'value' => $GLOBALS['plexToken'], 'placeholder' => 'Use Get Token Button' ), array( 'type' => 'button', 'label' => 'Get Plex Token', 'class' => 'popup-with-form getPlexTokenSSO', 'icon' => 'fa fa-ticket', 'text' => 'Retrieve', 'href' => '#sso-plex-token-form', 'attr' => 'data-effect="mfp-3d-unfold"' ), array( 'type' => 'password-alt', 'name' => 'plexID', 'label' => 'Plex Machine', 'value' => $GLOBALS['plexID'], 'placeholder' => 'Use Get Plex Machine Button' ), array( 'type' => 'button', 'label' => 'Get Plex Machine', 'class' => 'popup-with-form getPlexMachineSSO', 'icon' => 'fa fa-id-badge', 'text' => 'Retrieve', 'href' => '#sso-plex-machine-form', 'attr' => 'data-effect="mfp-3d-unfold"' ), array( 'type' => 'input', 'name' => 'plexAdmin', 'label' => 'Admin Username', 'value' => $GLOBALS['plexAdmin'], 'placeholder' => 'Admin username for Plex' ), array( 'type' => 'blank', 'label' => '' ), array( 'type' => 'html', 'label' => 'Plex Note', 'html' => 'Please make sure both Token and Machine are filled in' ), array( 'type' => 'switch', 'name' => 'ssoPlex', 'label' => 'Enable', 'value' => $GLOBALS['ssoPlex'] ) ), 'Ombi' => array( array( 'type' => 'input', 'name' => 'ombiURL', 'label' => 'Ombi URL', 'value' => $GLOBALS['ombiURL'], 'placeholder' => 'http(s)://hostname:port' ), array( 'type' => 'switch', 'name' => 'ssoOmbi', 'label' => 'Enable', 'value' => $GLOBALS['ssoOmbi'] ) ), 'Tautulli' => array( array( 'type' => 'input', 'name' => 'tautulliURL', 'label' => 'Tautulli URL', 'value' => $GLOBALS['tautulliURL'], 'placeholder' => 'http(s)://hostname:port' ), array( 'type' => 'switch', 'name' => 'ssoTautulli', 'label' => 'Enable', 'value' => $GLOBALS['ssoTautulli'] ) ) ); } function loadAppearance() { $appearance = array(); $appearance['logo'] = $GLOBALS['logo']; $appearance['title'] = $GLOBALS['title']; $appearance['useLogo'] = $GLOBALS['useLogo']; $appearance['headerColor'] = $GLOBALS['headerColor']; $appearance['headerTextColor'] = $GLOBALS['headerTextColor']; $appearance['sidebarColor'] = $GLOBALS['sidebarColor']; $appearance['headerTextColor'] = $GLOBALS['headerTextColor']; $appearance['sidebarTextColor'] = $GLOBALS['sidebarTextColor']; $appearance['accentColor'] = $GLOBALS['accentColor']; $appearance['accentTextColor'] = $GLOBALS['accentTextColor']; $appearance['buttonColor'] = $GLOBALS['buttonColor']; $appearance['buttonTextColor'] = $GLOBALS['buttonTextColor']; $appearance['buttonTextHoverColor'] = $GLOBALS['buttonTextHoverColor']; $appearance['buttonHoverColor'] = $GLOBALS['buttonHoverColor']; $appearance['loginWallpaper'] = $GLOBALS['loginWallpaper']; $appearance['customCss'] = $GLOBALS['customCss']; return $appearance; } function getCustomizeAppearance() { if (file_exists(dirname(__DIR__, 1).DIRECTORY_SEPARATOR.'config'.DIRECTORY_SEPARATOR.'config.php')) { return array( 'Top Bar' => array( array( 'type' => 'input', 'name' => 'logo', 'label' => 'Logo', 'value' => $GLOBALS['logo'] ), array( 'type' => 'input', 'name' => 'title', 'label' => 'Title', 'value' => $GLOBALS['title'] ), array( 'type' => 'switch', 'name' => 'useLogo', 'label' => 'Use Logo instead of Title', 'value' => $GLOBALS['useLogo'] ) ), 'Login Page' => array( array( 'type' => 'input', 'name' => 'loginWallpaper', 'label' => 'Login Wallpaper', 'value' => $GLOBALS['loginWallpaper'] ) ), 'Options' => array( array( 'type' => 'switch', 'name' => 'alternateHomepageHeaders', 'label' => 'Alternate Homepage Titles', 'value' => $GLOBALS['alternateHomepageHeaders'] ) ), 'custom' => '
Notice
The value of #987654 is just a placeholder, you can change to any value you like.
', 'Colors & Themes' => array( array( 'type' => 'input', 'name' => 'headerColor', 'label' => 'Nav Bar Color', 'value' => $GLOBALS['headerColor'], 'class' => 'pick-a-color', 'attr' => 'data-original="'.$GLOBALS['headerColor'].'"' ), array( 'type' => 'input', 'name' => 'headerTextColor', 'label' => 'Nav Bar Text Color', 'value' => $GLOBALS['headerTextColor'], 'class' => 'pick-a-color', 'attr' => 'data-original="'.$GLOBALS['headerTextColor'].'"' ), array( 'type' => 'input', 'name' => 'sidebarColor', 'label' => 'Side Bar Color', 'value' => $GLOBALS['sidebarColor'], 'class' => 'pick-a-color', 'attr' => 'data-original="'.$GLOBALS['sidebarColor'].'"' ), array( 'type' => 'input', 'name' => 'sidebarTextColor', 'label' => 'Side Bar Text Color', 'value' => $GLOBALS['sidebarTextColor'], 'class' => 'pick-a-color', 'attr' => 'data-original="'.$GLOBALS['sidebarTextColor'].'"' ), array( 'type' => 'input', 'name' => 'accentColor', 'label' => 'Accent Color', 'value' => $GLOBALS['accentColor'], 'class' => 'pick-a-color', 'attr' => 'data-original="'.$GLOBALS['accentColor'].'"' ), array( 'type' => 'input', 'name' => 'accentTextColor', 'label' => 'Accent Text Color', 'value' => $GLOBALS['accentTextColor'], 'class' => 'pick-a-color', 'attr' => 'data-original="'.$GLOBALS['accentTextColor'].'"' ), array( 'type' => 'input', 'name' => 'buttonColor', 'label' => 'Button Color', 'value' => $GLOBALS['buttonColor'], 'class' => 'pick-a-color', 'attr' => 'data-original="'.$GLOBALS['buttonColor'].'"' ), array( 'type' => 'input', 'name' => 'buttonTextColor', 'label' => 'Button Text Color', 'value' => $GLOBALS['buttonTextColor'], 'class' => 'pick-a-color', 'attr' => 'data-original="'.$GLOBALS['buttonTextColor'].'"' ),/* array( 'type' => 'input', 'name' => 'buttonHoverColor', 'label' => 'Button Hover Color', 'value' => $GLOBALS['buttonHoverColor'], 'class' => 'pick-a-color', 'disabled' => true ), array( 'type' => 'input', 'name' => 'buttonTextHoverColor', 'label' => 'Button Hover Text Color', 'value' => $GLOBALS['buttonTextHoverColor'], 'class' => 'pick-a-color', 'disabled' => true ),*/ array( 'type' => 'select', 'name' => 'theme', 'label' => 'Theme', 'class' => 'themeChanger', 'value' => $GLOBALS['theme'], 'options' => getThemes() ), array( 'type' => 'select', 'name' => 'style', 'label' => 'Style', 'class' => 'styleChanger', 'value' => $GLOBALS['style'], 'options' => array( array( 'name' => 'Light', 'value' => 'light' ), array( 'name' => 'Dark', 'value' => 'dark' ), array( 'name' => 'Horizontal', 'value' => 'horizontal' ) ) ), array( 'type' => 'textbox', 'name' => 'customCss', 'class' => 'hidden cssTextarea', 'label' => '', 'value' => $GLOBALS['customCss'], 'placeholder' => 'No