requested = str_replace(' ','_',$title);
$this->title = $title;
$this->get_theme_css = false;
$_REQUEST['gpreq'] = 'admin';
$this->head .= "\n".'';
@header( 'X-Frame-Options: SAMEORIGIN' );
}
public function RunScript(){}
public function GetGpxContent(){
$this->head .= "\n";
$this->head_js[] = '/include/js/login.js';
$this->head_js[] = '/include/js/md5_sha.js';
$this->head_js[] = '/include/thirdparty/js/jsSHA.js';
$this->css_admin[] = '/include/css/login.css';
$_POST += array('username'=>'');
$this->admin_js = true;
\gp\tool\Session::cookie('g',2);
$this->BrowserWarning();
$this->JavascriptWarning();
echo '
';
echo '
';
$cmd = \gp\tool::GetCommand();
switch($cmd){
case 'send_password';
if( $this->SendPassword() ){
$this->LoginForm();
}else{
$this->FogottenPassword();
}
break;
case 'forgotten':
$this->FogottenPassword();
break;
default:
$this->LoginForm();
break;
}
echo ' |
';
echo '
';
}
public function FogottenPassword(){
global $langmessage;
$_POST += array('username'=>'');
$this->css_admin[] = '/include/css/login.css';
echo '';
}
public function LoginForm(){
global $langmessage;
$_REQUEST += array('file'=>'');
echo '';
}
public function BrowserWarning(){
global $langmessage;
echo '';
echo '
'.$langmessage['Browser Warning'].'
';
echo '
';
echo $langmessage['Browser !Supported'];
echo '
';
echo '
';
echo 'Firefox';
echo 'Chrome';
echo 'Safari';
echo 'Explorer';
echo '
';
echo'
';
}
public function JavascriptWarning(){
global $langmessage;
echo '';
echo '
'.$langmessage['JAVASCRIPT_REQ'].'
';
echo '
';
echo $langmessage['INCOMPAT_BROWSER'];
echo ' ';
echo $langmessage['MODERN_BROWSER'];
echo '
';
echo '
';
}
public function Checked($name){
if( strtoupper($_SERVER['REQUEST_METHOD']) !== 'POST' )
return ' checked="checked" ';
if( !isset($_POST[$name]) )
return '';
return ' checked="checked" ';
}
public function SendPassword(){
global $langmessage, $config;
$users = \gp\tool\Files::Get('_site/users');
$username = $_POST['username'];
if( !isset($users[$username]) ){
message($langmessage['OOPS']);
return false;
}
$userinfo = $users[$username];
if( empty($userinfo['email']) ){
message($langmessage['no_email_provided']);
return false;
}
$passwordChars = str_repeat('abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ',3);
$newpass = str_shuffle($passwordChars);
$newpass = substr($newpass,0,8);
$pass_hash = \gp\tool\Session::PassAlgo($userinfo);
$users[$username]['newpass'] = \gp\tool::hash($newpass,$pass_hash);
if( !\gp\tool\Files::SaveData('_site/users','users',$users) ){
message($langmessage['OOPS']);
return false;
}
$server = \gp\tool::ServerName();
$link = \gp\tool::AbsoluteLink('Admin',$langmessage['login']);
$message = sprintf($langmessage['passwordremindertext'],$server,$link,$username,$newpass);
//send email
$mailer = new \gp\tool\Emailer();
if( $mailer->SendEmail($userinfo['email'], $langmessage['new_password'], $message) ){
list($namepart,$sitepart) = explode('@',$userinfo['email']);
$showemail = substr($namepart,0,3).'...@'.$sitepart;
message(sprintf($langmessage['password_sent'],$username,$showemail));
return true;
}
message($langmessage['OOPS'].' (Email not sent)');
return false;
}
}