Example #1
0
<?php

/**
 * ManiaPress: a suite to display your WordPress install directly in Maniaplanet.
 * 
 * @see         http://code.google.com/p/maniapress/
 * @copyright   Copyright (c) 2011-2012 NADEO (http://www.nadeo.com)
 * @license     http://www.gnu.org/licenses/lgpl.html LGPL License 3
 * @version     $Revision$:
 * @author      $Author$:
 * @date        $Date$:
 */
get_header('single');
if (have_posts()) {
    the_post();
    get_template_part('content', 'single');
} else {
    $ui = new Label(120 / 1.5);
    $ui->setScale(1.5);
    $ui->setHalign('center');
    $ui->setPosition(0, 40, 0.2);
    $ui->enableAutonewline();
    $ui->setStyle(Label::TextButtonSmall);
    $ui->setText('Apologies, but no results were found for the requested archive. Perhaps searching will help find a related post.');
    $ui->save();
}
get_sidebar('single');
get_footer('single');
 /**
  * Method userIsAuthentificated
  * @access protected
  * @param mixed $strUserRights 
  * @param mixed $redirect 
  * @param mixed $redirect_url 
  * @since 1.1.11
  */
 protected function userIsAuthentificated($strUserRights, $redirect, $redirect_url)
 {
     $this->page_object->setUserRights($strUserRights);
     $_SESSION['wsp-login'] = $this->getLogin();
     if ($redirect) {
         if ($this->authentication_msg) {
             $str_msg = new Label(__(AUTHENTICATION_LOGIN_OK_REDIRECT));
             $str_msg->setStyle("text-shadow:#888888 1px 1px 1px;");
             $this->error_obj->add($str_msg->setColor($this->color_ok));
         }
         if ($redirect_url == "") {
             $this->page_object->redirect($this->page_object->getBaseLanguageURL() . WSP_ADMIN_URL . "/admin.html");
         } else {
             if (strtoupper($redirect_url) == "REFERER") {
                 if ($this->getReferer() != "") {
                     $this->page_object->redirect($this->getReferer());
                 } else {
                     $this->page_object->redirect($this->page_object->getBaseLanguageURL() . WSP_ADMIN_URL . "/admin.html");
                 }
             } else {
                 $this->page_object->redirect($redirect_url);
             }
         }
     } else {
         if ($this->authentication_msg) {
             $str_msg = new Label(__(AUTHENTICATION_LOGIN_OK));
             $str_msg->setStyle("text-shadow:#888888 1px 1px 1px;");
             $this->error_obj->add($str_msg->setColor($this->color_ok));
         }
     }
 }
 /**
  * Method connect
  * @access public
  * @param boolean $redirect [default value: true]
  * @param string $redirect_url [default value: REFERER]
  * @return boolean
  * @since 1.1.11
  */
 public function connect($redirect = true, $redirect_url = 'REFERER')
 {
     $ldap = @ldap_connect($this->ldap_host, $this->ldap_port);
     // doit ĂȘtre un serveur LDAP valide !
     if ($ldap !== false) {
         $r = @ldap_bind($ldap, $this->getLogin() . $this->ldap_user_domain, $this->getPassword());
         if ($r !== false) {
             $filter = "(sAMAccountName=" . $this->getLogin() . ")";
             $result = @ldap_search($ldap, $this->ldap_dn, $filter);
             if ($result !== false) {
                 $strUserRights = $this->default_right;
                 $info = ldap_get_entries($ldap, $result);
                 if (isset($info[0])) {
                     $this->ldap_user_info = $info[0];
                     if (isset($info[0]["memberof"])) {
                         $rights_exists = false;
                         for ($i = 0; $i < sizeof($info[0]["memberof"]); $i++) {
                             $tmp_rights = $info[0]["memberof"][$i];
                             foreach ($this->rights_mapping as $key => $value) {
                                 if ($this->rights_mapping[$i][0] == $key) {
                                     $strUserRights = $value;
                                     $rights_exists = true;
                                     break;
                                 }
                             }
                             if ($rights_exists == true) {
                                 break;
                             }
                         }
                     }
                     $this->userIsAuthentificated($strUserRights, $redirect, $redirect_url);
                 } else {
                     $str_msg = new Label(__(AUTHENTICATION_ERROR_LOGIN_PASS));
                     $str_msg->setStyle("text-shadow:#888888 1px 1px 1px;");
                     $this->error_obj->add($str_msg->setColor($this->color_error));
                     return false;
                 }
             } else {
                 throw new NewException("Unable to search on LDAP server", 0, getDebugBacktrace(1));
             }
         } else {
             $str_msg = new Label(__(AUTHENTICATION_ERROR_LOGIN_PASS));
             $str_msg->setStyle("text-shadow:#888888 1px 1px 1px;");
             $this->error_obj->add($str_msg->setColor($this->color_error));
             return false;
         }
         ldap_unbind($ldap);
         ldap_close($ldap);
         return true;
     } else {
         throw new NewException("Unable to connect on LDAP server", 0, getDebugBacktrace(1));
     }
 }