Example #1
0
 /**
  * Returns null and sets a flash message on all errors.
  **/
 static function beginAuth($openid, $policyUris)
 {
     $consumer = self::getConsumer();
     $auth_request = $consumer->begin($openid);
     if (!$auth_request) {
         FlashMessage::add('Ați introdus un OpenID incorect.');
         return null;
     }
     $sreg_request = Auth_OpenID_SRegRequest::build(array('nickname'), array('fullname', 'email'));
     if ($sreg_request) {
         $auth_request->addExtension($sreg_request);
     }
     $ax = new Auth_OpenID_AX_FetchRequest();
     $ax->add(Auth_OpenID_AX_AttrInfo::make('http://axschema.org/namePerson', 1, 1, 'fullname'));
     $ax->add(Auth_OpenID_AX_AttrInfo::make('http://axschema.org/contact/email', 1, 1, 'email'));
     $ax->add(Auth_OpenID_AX_AttrInfo::make('http://axschema.org/namePerson/first', 1, 1, 'firstname'));
     $ax->add(Auth_OpenID_AX_AttrInfo::make('http://axschema.org/namePerson/last', 1, 1, 'lastname'));
     $auth_request->addExtension($ax);
     // For OpenID 1, send a redirect.  For OpenID 2, use a Javascript form to send a POST request to the server.
     if ($auth_request->shouldSendRedirect()) {
         $redirect_url = $auth_request->redirectURL(util_getFullServerUrl(), self::getReturnTo());
         if (Auth_OpenID::isFailure($redirect_url)) {
             FlashMessage::add('Nu vă putem redirecționa către serverul OpenID: ' . $redirect_url->message);
             return null;
         } else {
             header("Location: {$redirect_url}");
             exit;
         }
     } else {
         $form_html = $auth_request->htmlMarkup(util_getFullServerUrl(), self::getReturnTo(), false, array('id' => 'openid_message'));
         if (Auth_OpenID::isFailure($form_html)) {
             FlashMessage::add('Nu vă putem redirecționa către serverul OpenID: ' . $form_html->message);
             return null;
         } else {
             print $form_html;
         }
     }
 }
Example #2
0
 function authenticate($clientId, $secret)
 {
     $this->fetchWellKnownConfig();
     if (!$clientId || !$secret) {
         throw new OpenIDException('Autentificare eșuată.');
     }
     $url = $this->wellKnownConfig['authorization_endpoint'];
     $nonce = util_randomCapitalLetterString(32);
     $state = util_randomCapitalLetterString(32);
     session_setVariable('openid_connect_nonce', $nonce);
     session_setVariable('openid_connect_state', $state);
     session_setVariable('openid_connect_provider', $this->provider);
     session_setVariable('openid_connect_client', $clientId);
     session_setVariable('openid_connect_secret', $secret);
     $params = array('client_id' => $clientId, 'openid.realm' => util_getFullServerUrl(), 'nonce' => $nonce, 'redirect_uri' => $this->getReturnTo(), 'response_type' => 'code', 'scope' => 'openid email', 'state' => $state);
     $url .= '?' . http_build_query($params, null, '&');
     util_redirect($url);
 }
Example #3
0
// TODO optimize & factorize
if ($type == 'rss') {
    $words = WordOfTheDay::getRSSWotD();
    $results = array();
    foreach ($words as $w) {
        $item = array();
        $ts = strtotime($w->displayDate);
        $defId = WordOfTheDayRel::getRefId($w->id);
        $def = Model::factory('Definition')->where('id', $defId)->where('status', ST_ACTIVE)->find_one();
        smarty_assign('def', $def);
        smarty_assign('imageUrl', $w->getImageUrl());
        smarty_assign('fullServerUrl', util_getFullServerUrl());
        $item['title'] = $def->lexicon;
        $item['description'] = smarty_fetch('common/bits/wotdRssItem.ihtml');
        $item['pubDate'] = date('D, d M Y H:i:s', $ts) . ' EEST';
        $item['link'] = util_getFullServerUrl() . 'cuvantul-zilei/' . date('Y/m/d', $ts);
        $results[] = $item;
    }
    header("Content-type: text/xml");
    smarty_assign('rss_title', 'Cuvântul zilei');
    smarty_assign('rss_link', 'http://' . $_SERVER['HTTP_HOST'] . '/cuvantul-zilei/');
    smarty_assign('rss_description', 'Doza zilnică de cuvinte propuse de DEXonline!');
    smarty_assign('rss_pubDate', date('D, d M Y H:i:s') . ' EEST');
    smarty_assign('results', $results);
    smarty_displayWithoutSkin('common/rss.ixml');
    exit;
}
$today = date('Y-m-d', time());
$timestamp = $date ? strtotime($date) : time();
$mysqlDate = date("Y-m-d", $timestamp);
if ($mysqlDate < WOTD_BIG_BANG || $mysqlDate > $today) {
<?php

error_reporting(0);
// Set E_ALL for debuging
if (function_exists('date_default_timezone_set')) {
    date_default_timezone_set('Europe/Moscow');
}
include_once __DIR__ . '/../../phplib/util.php';
include_once __DIR__ . '/elFinder.class.php';
/**
 * Simple example how to use logger with elFinder
 **/
class elFinderLogger implements elFinderILogger
{
    public function log($cmd, $ok, $context, $err = '', $errorData = array())
    {
        if (false != ($fp = fopen('./log.txt', 'a'))) {
            if ($ok) {
                $str = "cmd: {$cmd}; OK; context: " . str_replace("\n", '', var_export($context, true)) . "; \n";
            } else {
                $str = "cmd: {$cmd}; FAILED; context: " . str_replace("\n", '', var_export($context, true)) . "; error: {$err}; errorData: " . str_replace("\n", '', var_export($errorData, true)) . "\n";
            }
            fwrite($fp, $str);
            fclose($fp);
        }
    }
}
$opts = array('root' => __DIR__ . '/../img/wotd/', 'URL' => util_getFullServerUrl() . '/img/wotd/', 'rootAlias' => 'Imagini cuvântul zilei', 'debug' => true, 'uploadAllow' => array('images/*'), 'disabled' => array('mkfile', 'resize'), 'imgLib' => 'gd', 'tmbDir' => '.tmb', 'tmbCleanProb' => 100, 'debug' => true);
$fm = new elFinder($opts);
$fm->run();
SmartyWrap::assign('identity', $identity);
SmartyWrap::assign('email', $email);
SmartyWrap::assign('page_title', 'Parolă uitată');
SmartyWrap::assign('suggestHiddenSearchForm', true);
if ($submitButton) {
    if (!$email) {
        FlashMessage::add('Trebuie să introduceți o adresă de e-mail.');
        SmartyWrap::display('auth/parola-uitata.ihtml');
    } else {
        $user = User::get_by_email($email);
        if ($user) {
            log_userLog("Password recovery requested for {$email} from " . $_SERVER['REMOTE_ADDR']);
            // Create the token
            $pt = Model::factory('PasswordToken')->create();
            $pt->userId = $user->id;
            $pt->token = util_randomCapitalLetterString(20);
            $pt->save();
            // Send email
            SmartyWrap::assign('homePage', util_getFullServerUrl());
            SmartyWrap::assign('token', $pt->token);
            $body = SmartyWrap::fetch('email/resetPassword.ihtml');
            $ourEmail = Config::get('global.contact');
            $headers = array("From: DEX online <{$ourEmail}>", "Reply-To: {$ourEmail}", 'Content-Type: text/plain; charset=UTF-8');
            $result = mail($email, "Schimbarea parolei pentru DEX online", $body, implode("\r\n", $headers));
        }
        // Display a confirmation even for incorrect addresses.
        SmartyWrap::display('auth/passwordRecoveryEmailSent.ihtml');
    }
} else {
    SmartyWrap::display('auth/parola-uitata.ihtml');
}
$identity = util_getRequestParameter('identity');
$email = util_getRequestParameter('email');
smarty_assign('identity', $identity);
smarty_assign('email', $email);
smarty_assign('page_title', 'Parolă uitată');
smarty_assign('suggestHiddenSearchForm', true);
if (!$submitButton) {
    smarty_displayCommonPageWithSkin('auth/parola-uitata.ihtml');
} else {
    if (!$email) {
        FlashMessage::add('Trebuie să introduceți o adresă de e-mail.');
    } else {
        $user = User::get_by_email($email);
        if ($user) {
            log_userLog("Password recovery requested for {$email} from " . $_SERVER['REMOTE_ADDR']);
            // Create the token
            $pt = Model::factory('PasswordToken')->create();
            $pt->userId = $user->id;
            $pt->token = util_randomCapitalLetterString(20);
            $pt->save();
            // Send email
            smarty_assign('homePage', util_getFullServerUrl());
            smarty_assign('token', $pt->token);
            $body = smarty_fetch('email/resetPassword.ihtml');
            $ourEmail = pref_getContactEmail();
            $result = mail($email, "Schimbarea parolei pentru DEX online", $body, "From: DEX online <{$ourEmail}>\r\nReply-To: {$ourEmail}");
            // Display a confirmation even for incorrect addresses.
            smarty_displayCommonPageWithSkin('auth/passwordRecoveryEmailSent.ihtml');
        }
    }
}