function createServerKeys($openSslCnfPath) { $spotSigning = new SpotSigning(true); $x = $spotSigning->createPrivateKey($openSslCnfPath); $this->setIfNot('publickey', $x['public']); $this->setIfNot('privatekey', $x['private']); } # createServerKeys
function updateUserPreferences() { $userList = $this->_db->listUsers("", 0, 9999999); # loop through every user and fix it foreach ($userList['list'] as $user) { # Omdat we vanuit listUsers() niet alle velden meekrijgen # vragen we opnieuw het user record op $user = $this->_db->getUser($user['userid']); # set the users' preferences $this->setSettingIfNot($user['prefs'], 'perpage', 25); $this->setSettingIfNot($user['prefs'], 'date_formatting', 'human'); $this->setSettingIfNot($user['prefs'], 'template', 'we1rdo'); $this->setSettingIfNot($user['prefs'], 'count_newspots', true); $this->setSettingIfNot($user['prefs'], 'keep_seenlist', true); $this->setSettingIfNot($user['prefs'], 'auto_markasread', true); $this->setSettingIfNot($user['prefs'], 'keep_downloadlist', true); $this->setSettingIfNot($user['prefs'], 'keep_watchlist', true); $this->setSettingIfNot($user['prefs'], 'nzb_search_engine', 'nzbindex'); $this->setSettingIfNot($user['prefs'], 'show_filesize', true); $this->setSettingIfNot($user['prefs'], 'show_reportcount', true); $this->setSettingIfNot($user['prefs'], 'show_multinzb', true); $this->setSettingIfNot($user['prefs'], 'customcss', ''); $this->setSettingIfNot($user['prefs'], 'newspotdefault_tag', $user['username']); $this->setSettingIfNot($user['prefs'], 'newspotdefault_body', ''); $this->setSettingIfNot($user['prefs']['nzbhandling'], 'action', 'disable'); $this->setSettingIfNot($user['prefs']['nzbhandling'], 'local_dir', '/tmp'); $this->setSettingIfNot($user['prefs']['nzbhandling'], 'prepare_action', 'merge'); $this->setSettingIfNot($user['prefs']['nzbhandling'], 'command', ''); $this->setSettingIfNot($user['prefs']['nzbhandling']['sabnzbd'], 'url', ''); $this->setSettingIfNot($user['prefs']['nzbhandling']['sabnzbd'], 'apikey', ''); $this->setSettingIfNot($user['prefs']['nzbhandling']['nzbget'], 'host', ''); $this->setSettingIfNot($user['prefs']['nzbhandling']['nzbget'], 'port', ''); $this->setSettingIfNot($user['prefs']['nzbhandling']['nzbget'], 'username', ''); $this->setSettingIfNot($user['prefs']['nzbhandling']['nzbget'], 'password', ''); $this->setSettingIfNot($user['prefs']['nzbhandling']['nzbget'], 'timeout', 15); $this->setSettingIfNot($user['prefs']['notifications']['growl'], 'host', ''); $this->setSettingIfNot($user['prefs']['notifications']['growl'], 'password', ''); $this->setSettingIfNot($user['prefs']['notifications']['nma'], 'api', ''); $this->setSettingIfNot($user['prefs']['notifications']['notifo'], 'username', ''); $this->setSettingIfNot($user['prefs']['notifications']['notifo'], 'api', ''); $this->setSettingIfNot($user['prefs']['notifications']['prowl'], 'apikey', ''); $this->setSettingIfNot($user['prefs']['notifications']['twitter'], 'screen_name', ''); $this->setSettingIfNot($user['prefs']['notifications']['twitter'], 'request_token', ''); $this->setSettingIfNot($user['prefs']['notifications']['twitter'], 'request_token_secret', ''); $this->setSettingIfNot($user['prefs']['notifications']['twitter'], 'access_token', ''); $this->setSettingIfNot($user['prefs']['notifications']['twitter'], 'access_token_secret', ''); $notifProviders = Notifications_Factory::getActiveServices(); foreach ($notifProviders as $notifProvider) { $this->setSettingIfNot($user['prefs']['notifications'][$notifProvider], 'enabled', false); $this->setSettingIfNot($user['prefs']['notifications'][$notifProvider]['events'], 'watchlist_handled', false); $this->setSettingIfNot($user['prefs']['notifications'][$notifProvider]['events'], 'nzb_handled', false); $this->setSettingIfNot($user['prefs']['notifications'][$notifProvider]['events'], 'retriever_finished', false); $this->setSettingIfNot($user['prefs']['notifications'][$notifProvider]['events'], 'spot_posted', false); $this->setSettingIfNot($user['prefs']['notifications'][$notifProvider]['events'], 'user_added', false); } // foreach # make sure a sort preference is defined. An empty field means relevancy $this->setSettingIfNot($user['prefs'], 'defaultsortfield', ''); # oude settings verwijderen $this->unsetSetting($user['prefs'], 'search_url'); $this->unsetSetting($user['prefs']['notifications'], 'libnotify'); # controleren dat de user een geldige RSA key heeft if ($user['userid'] > 2) { $rsaKey = $this->_db->getUserPrivateRsaKey($user['userid']); if (empty($rsaKey)) { # Creer een private en public key paar voor deze user $spotSigning = new SpotSigning(); $userKey = $spotSigning->createPrivateKey($this->_settings->get('openssl_cnf_path')); $this->_db->setUserRsaKeys($user['userid'], $userKey['public'], $userKey['private']); } # if } # if # update the user record in the database $this->_db->setUser($user); } # foreach }
function render() { $formMessages = array('errors' => array(), 'info' => array()); # Controleer de users' rechten $this->_spotSec->fatalPermCheck(SpotSecurity::spotsec_create_new_user, ''); # creeer een default spotuser zodat het form altijd # de waardes van het form kan renderen $spotUser = array('username' => '', 'firstname' => '', 'lastname' => '', 'mail' => ''); # createuser resultaat is standaard niet geprobeerd $createResult = array(); # Instantieer het Spot user system $spotUserSystem = new SpotUserSystem($this->_db, $this->_settings); # zet de page title $this->_pageTitle = "spot: create user"; # Is dit een submit van een form, of nog maar de aanroep? if (isset($this->_createUserForm['submit'])) { # submit unsetten we altijd unset($this->_createUserForm['submit']); # userid zetten we altijd op false voor het maken van een # nieuwe user, omdat validateUserRecord() anders denkt # dat we een bestaande user aan het bewerken zijn en we bv. # het mailaddress niet controleren op dubbelen behalve 'zichzelf' $this->_createUserForm['userid'] = false; # creeer een random password voor deze user $spotUser['newpassword1'] = substr($spotUserSystem->generateUniqueId(), 1, 9); $spotUser['newpassword2'] = $spotUser['newpassword1']; # valideer de user $spotUser = array_merge($spotUser, $this->_createUserForm); $formMessages['errors'] = $spotUserSystem->validateUserRecord($spotUser, false); # Is er geen andere user met dezelfde username? if ($this->_db->usernameExists($spotUser['username'])) { $formMessages['errors'][] = array('validateuser_usernameexists', array($spotUser['username'])); } # if if (empty($formMessages['errors'])) { # Creer een private en public key paar voor deze user $spotSigning = new SpotSigning(); $userKey = $spotSigning->createPrivateKey($this->_settings->get('openssl_cnf_path')); $spotUser['publickey'] = $userKey['public']; $spotUser['privatekey'] = $userKey['private']; # Notificatiesysteem initialiseren $spotsNotifications = new SpotNotifications($this->_db, $this->_settings, $this->_currentSession); # voeg de user toe $spotUserSystem->addUser($spotUser); # als het toevoegen van de user gelukt is, laat het weten $createResult = array('result' => 'success', 'user' => $spotUser['username'], 'password' => $spotUser['newpassword1']); # verstuur een e-mail naar de nieuwe gebruiker als daar om is gevraagd if ($this->_createUserForm['sendmail'] == "true" || $this->_createUserForm['sendmail'] == "on" || $this->_settings->get('sendwelcomemail')) { $spotsNotifications->sendNewUserMail($spotUser); } # if # en verstuur een notificatie $spotsNotifications->sendUserAdded($spotUser['username'], $spotUser['newpassword1']); } else { $createResult = array('result' => 'failure'); } # else } # if #- display stuff -# $this->template('createuser', array('createuserform' => $spotUser, 'formmessages' => $formMessages, 'createresult' => $createResult)); }
showResult(extension_loaded('xml')); ?> </td> </tr> <tr> <td colspan="2"> zip </td> <td> NZB files comprimeren </td> <td> <?php showResult(extension_loaded('zip')); ?> </td> </tr> <tr> <td colspan="2"> zlib </td> <td> </td> <td> <?php showResult(extension_loaded('zlib')); ?> </td> </tr> <tr> <th colspan="3"> OpenSSL </th> </tr> <?php require_once "lib/SpotSigning.php"; $spotSigning = new SpotSigning(); $privKey = $spotSigning->createPrivateKey($settings['openssl_cnf_path']); ?> <tr> <td rowspan="3"> Minimaal 1 moet OK zijn<br />In volgorde van snelste naar langzaamste </td> <td> openssl </td> <td> </td> <td> <?php showResult(extension_loaded('openssl')); ?> </td> </tr> <tr> <td> gmp </td> <td> </td> <td> <?php showResult(extension_loaded('gmp')); ?> </td> </tr> <tr> <td> bcmath </td> <td> </td> <td> <?php showResult(extension_loaded('bcmath')); ?> </td> </tr> <tr> <td colspan="2"> Can create private key? </td> <td> </td> <td> <?php showResult(isset($privKey['public']) && !empty($privKey['public']) && !empty($privKey['private']));