예제 #1
0
// -- REGIONS bar[top|right|bottom|left]
// -----------------------
$GLOBALS[SUBSITE]["regions"]["bartop"] = array();
if (SHOW_MYMENU) {
    $GLOBALS[SUBSITE]["regions"]["bartop"][] = "block::BmyMenu('mymenu')";
}
$GLOBALS[SUBSITE]["regions"]["barright"] = array();
$GLOBALS[SUBSITE]["regions"]["barbottom"] = array();
$GLOBALS[SUBSITE]["regions"]["barleft"] = array();
// -----------------------
// -- REGION pagetop
// -----------------------
$GLOBALS[SUBSITE]["regions"]["pagetop"][] = "block::BskipToContent('skiptocontent','region-content')";
//$GLOBALS[SUBSITE]["regions"]["pagetop"][] = "block::BfeedLink('feed')"; // --> region-top
$GLOBALS[SUBSITE]["regions"]["pagetop"][] = "block::BloginForm('modalbox')";
if (!SHOW_MYMENU || !auth::isAuthenticated()) {
    $GLOBALS[SUBSITE]["regions"]["pagetop"][] = "block::BloginLink('login')";
}
// -----------------------
// -- REGION banner
// -----------------------
$GLOBALS[SUBSITE]["regions"]["banner"][] = "block::Blogo('logo')";
// -----------------------
// -- REGION headlineleft
// -----------------------
$GLOBALS[SUBSITE]["regions"]["headlineleft"] = array();
if (IS_ENTRANCE) {
    $GLOBALS[SUBSITE]["regions"]["headlineleft"] = array();
} elseif (!IS_INDEXPAGE && $this->getConfig("showsplash") && (!isset($_SESSION["splashimage"]) || $_SESSION["splashimage"])) {
    // 1st parameter: 'sprite' or 'single':
    $GLOBALS[SUBSITE]["regions"]["headlineleft"][] = "block::Bsplashimage('single','splashimage')";
예제 #2
0
 public static function drawLoginForm($modal = false)
 {
     // -----------------------
     // If myPear authentication fails, simulate login call in order to present
     // login form again, with error message.
     // -----------------------
     if (!auth::isAuthenticated() && isset($_SESSION["mypear_auth_attempted"])) {
         $_REQUEST["login"] = 1;
         $GLOBALS["nw_loginerror"]["username"][] = "Please enter correct username and password";
         unset($_SESSION["mypear_auth_attempted"]);
     }
     // -----------------------
     // If page requests inline form, the $modal parameter should always be FALSE.
     // -----------------------
     if (self::isLoginType("inline")) {
         $modal = false;
     }
     // -----------------------
     // -- No output if no login required
     // -----------------------
     if (!self::isLoginRequired() && !self::isLoginAllowed()) {
         return "";
     }
     // -----------------------
     // -- No output if login allowed but not mandatory
     // -----------------------
     if (self::isLoginAllowed() && !self::isLoginRequested()) {
         return "";
     }
     // -----------------------
     // -- No output if login should be via link but no login requested from login link
     // -----------------------
     if (self::isLoginType("link") && !self::isLoginRequested()) {
         return "";
     }
     // -----------------------
     // -- No output if already authenticated
     // -----------------------
     if (self::isAuthenticated()) {
         return "";
     }
     // -----------------------
     // -- If authentication failed, set output parameters and then output the login form
     // -----------------------
     // -- set $error_msg
     $error_msg = "";
     if (isset($GLOBALS["nw_loginerror"])) {
         foreach ($GLOBALS["nw_loginerror"] as $field => $msgs) {
             $error_msg .= "<p>" . implode("</p><p>", $msgs) . "</p>";
         }
     }
     $a = trim(strip_tags($error_msg));
     if (empty($a)) {
         $error_msg = "";
     }
     // -- set $action
     // -----------------------
     // -- Assemble pieces of login form
     // -----------------------
     $theform = "            <form method='post' action='" . PATH_FROM_DOCROOT . "' " . "name='nw-login-form' id='nw-login-form'>\r\n" . "              <table>\r\n" . (!empty($error_msg) ? "                <tr>\r\n" . "                  <td colspan='3' " . "class='nw-login-error'" . ">" . $error_msg . "</td>\r\n" . "                </tr>\r\n" : "") . "                <tr>\r\n" . "                  <td><img src='" . PATH_IMG . "/auth_man.png' alt='Username'></td>\r\n" . "                  <td>Username:</td>\r\n" . "                  <td><input type='text' " . "name='auth_username' id='auth_username' " . "value='' size='25' " . "autofocus='autofocus'></td>\r\n" . "                </tr>\r\n" . "                <tr>\r\n" . "                  <td><img src='" . PATH_IMG . "/auth_key.png' alt='Password'></td>\r\n" . "                  <td>Password:</td>\r\n" . "                  <td><input type='password' " . "name='auth_password' id='auth_password' " . "value='' size='25'></td>\r\n" . "                </tr>\r\n" . "                <tr>\r\n" . "                  <td colspan='2'></td>\r\n" . "                  <td>" . "<input type='submit'" . " value='LOGIN'>" . "<input type='hidden' name='auth_submitted' value='1'>" . "<input type='hidden' name='login' value='1'>" . "</td>\r\n" . "                </tr>\r\n" . "              </table>\r\n" . "            </form>\r\n";
     return functions::drawReallyDothisBox($theform, "nw-login", "nw_modal_fade", $modal);
     /*
         $close_plainbox =
           "            <p><a href='" .
           //( (!empty($GLOBALS["cb"])) ? urldecode($GLOBALS["cb"]) : "#" ) .
           PATH_FROM_DOCROOT .
     //      $_SERVER["PHP_SELF"] .
           "' onclick='" .
           "document.getElementById(\"nw-login\").style.display=\"none\";" .      //TODO: problems with " ?
           "document.getElementById(\"nw_modal_fade\").style.display=\"none\";" . //TODO: problems with " ?
           "'>" .
           "close" .
           "<img src='".PATH_IMG."/auth_close.png' alt='Close'>" .
           "</a></p>\r\n";
     
         $close_fancybox =
           "            <div>" .
           "<a href='" .
           PATH_FROM_DOCROOT .
     //      $_SERVER["PHP_SELF"] .
           "' class='fancybox-close'" .
           " title='close'" .
           " onclick='" .
           "document.getElementById(\"nw-login\").style.display=\"none\";" .      //TODO: problems with " ?
           "document.getElementById(\"nw_modal_fade\").style.display=\"none\";" . //TODO: problems with " ?
           "'" .
           ">" .
           "</a>" .
           "</div>\r\n";
     
         // -----------------------
         // -- Output plain form or form in modal box
         // -----------------------
     
         if ($modal) {
     
           return
             "          <div id='nw-login'>\r\n" .
     //        $close_plainbox .
             $close_fancybox .
             $theform .
             "          </div>\r\n" .
             "          <div id='nw_modal_fade'></div>\r\n" .
             "          <script type='text/javascript'><!--//--><![CDATA[//><!--\r\n" .
             "            document.getElementById('nw-login').style.display='block'; \r\n" .
             "            document.getElementById('nw_modal_fade').style.display='block';\r\n" .
             "          //--><!]]></script>\r\n";
     
         } else {
     
           return
             "          <div id='nw-login' class='box roundcorners grayborder shadow'>\r\n" .
             $theform .
             "          </div>\r\n";
     
         }
     */
 }
예제 #3
0
 public static function drawAddComment()
 {
     $stdout = "";
     $showform = 1;
     $errormessage["left"] = $errormessage["right"] = "";
     $founderror = array();
     $confirmation = "";
     if (!class_exists("openid", FALSE)) {
         require_once PATH_CLASSES . "/lib/openid.php";
     }
     if (OPENIDDEBUG) {
         echo "<h2>drawAddComment</h2>";
         echo "<br>REQUEST=";
         debug::rrr();
         echo "<br>SESSION=";
         debug::rr(array_keys($_SESSION));
         echo "<br>COOKIE=";
         debug::rr(array_keys($_COOKIE));
     }
     //,"openid_identifier","openid_return_url","openid_server_url","openid_request","openid_identifier","openid_request"
     //$a=array("openid_news_validation_error","openid_news_form_html","openid_news_return_url","openid_news_request","openid_news_server_url");foreach ($a as $b) unset($_SESSION[$b]);
     /*
     echo "<html><head><title>OpenId transaction in progress</title></head>
     <body onload='document.forms[0].submit();'>
     <form accept-charset='UTF-8' enctype='application/x-www-form-urlencoded' id='openid_message' method='post' action='http://www.myopenid.com/server'>
     <input type='hidden' name='openid.ns' value='http://specs.openid.net/auth/2.0' />
     <input type='hidden' name='openid.ns.sreg' value='http://openid.net/extensions/sreg/1.1' />
     <input type='hidden' name='openid.ns.pape' value='http://specs.openid.net/extensions/pape/1.0' />
     <input type='hidden' name='openid.sreg.required' value='nickname,fullname,email' />
     <input type='hidden' name='openid.sreg.optional' value='gender,dob,postcode,country,language,timezone' />
     <input type='hidden' name='openid.pape.preferred_auth_policies' value='http://schemas.openid.net/pape/policies/2007/06/multi-factor-physical http://schemas.openid.net/pape/policies/2007/06/multi-factor http://schemas.openid.net/pape/policies/2007/06/phishing-resistant' />
     <input type='hidden' name='openid.pape.max_auth_age' value='0' />
     <input type='hidden' name='openid.realm' value='http://www.nordita.org/~hvzm/www.nordita.org/' />
     <input type='hidden' name='openid.mode' value='checkid_setup' />
     <input type='hidden' name='openid.return_to' value='http://www.nordita.org/~hvzm/www.nordita.org/news/nordic/index.php?articleid=25&amp;janrain_nonce=2013-03-09T03%3A04%3A18ZMC2RJ2' />
     <input type='hidden' name='openid.identity' value='http://hvzm.myopenid.com/' />
     <input type='hidden' name='openid.claimed_id' value='http://hvzm.myopenid.com/' />
     <input type='hidden' name='openid.assoc_handle' value='{HMAC-SHA1}{513aa6b2}{QGWDEw==}' />
     <input type='submit' value='Continue' />
     </form>
     <script>var elements = document.forms[0].elements;for (var i = 0; i < elements.length; i++) {  elements[i].style.display = 'none';}</script>
     </body></html>";die();
     */
     //if (OPENIDDEBUG) {echo "<br><strong>REFERRER</strong>: ";var_dump($_SERVER["HTTP_REFERER"]);}
     //if (OPENIDDEBUG) {echo "<br>SESSION BEFORE ADDCMT = ";if (isset($_SESSION["addcmt"])) var_dump($_SESSION["addcmt"]);echo "<br>SESSION BEFORE: CMT_TEXT = ";if (isset($_SESSION["cmt_text"])) var_dump($_SESSION["cmt_text"]);echo "<br>SESSION BEFORE: openid_identifier = ";if (isset($_SESSION["openid_identifier"])) var_dump($_SESSION["openid_identifier"]);echo "<br>SESSION BEFORE: janrain_nonce = ";if (isset($_SESSION["janrain_nonce"])) var_dump($_SESSION["janrain_nonce"]);echo "<br>SESSION BEFORE: openid_return_url = ";if (isset($_SESSION["openid_return_url"])) var_dump($_SESSION["openid_return_url"]);}
     //if (!class_exists("openid",FALSE)) require_once PATH_CLASSES . "/lib/openid.php";echo "<br><hr>";$pth = "/tmp/_php_consumer_test";echo "<h4>Content of directory $pth BEFORE:</h4>";if (is_dir($pth)) {$dir = scandir($pth);reset($dir);while ((list($k,$v)=each($dir))) echo "<br>$k $v";}$pth = "/tmp/_php_consumer_test/associations";echo "<h4>Content of directory $pth BEFORE:</h4>";if (is_dir($pth)) {$dir = scandir($pth);reset($dir);while ((list($k,$v)=each($dir))) echo "<br>$k $v";}
     //CLEAN://debug::rr(openid::cleanStore());echo "<h4>Content of directory $pth AFTER:</h4>";if (is_dir($pth)) {$dir = scandir($pth);reset($dir);while ((list($k,$v)=each($dir))) echo "<br>$k $v";}debug::rr(array_keys($_SESSION));echo "<br><hr>";
     /*
     //TODO: perhaps simplify with glob() ?
     
     echo "<hr>";
     $pth = "/tmp/_php_consumer_test";echo "<h4>$pth</h4>";if (is_dir($pth)) {$dir = scandir($pth);reset($dir);while ((list($k,$v)=each($dir))) echo "<br>$k $v";}
     $pth = "/tmp/_php_consumer_test/associations";echo "<h4>$pth</h4>";if (is_dir($pth)) {$dir = scandir($pth);reset($dir);while ((list($k,$v)=each($dir))) {echo "<br>$k $v : ";var_dump(is_dir($v));var_dump(is_file($v));var_dump(is_readable($v));var_dump(is_executable($v));var_dump(is_link($v));}}
     
     //$pth = "/tmp/_php_consumer_test/associations";echo "<h4>$pth</h4>";if (is_dir($pth)) {$dir = scandir($pth);reset($dir);while ((list($k,$v)=each($dir))) echo "<br>$k $v";}
     
     $pth = "/tmp/_php_consumer_test/nonces";echo "<h4>$pth</h4>";if (is_dir($pth)) {$dir = scandir($pth);reset($dir);while ((list($k,$v)=each($dir))) echo "<br>$k $v";}
     $pth = "/tmp/_php_consumer_test/temp";echo "<h4>$pth</h4>";if (is_dir($pth)) {$dir = scandir($pth);reset($dir);while ((list($k,$v)=each($dir))) echo "<br>$k $v";}
      echo "<hr>";
     */
     //debug::rrr();
     // --------------------------------
     // -- GPC indata
     // --------------------------------
     // needed for form, in all situations
     functions::gpc_declare_input("openid_identifier", "", false, array(), true);
     // needed for form, in all situations
     functions::gpc_declare_input("cmt_text", "", false, array(), true, false);
     functions::gpc_declare_input("cmt_name", "", false, array(), true, true);
     // needed on return from openid check
     functions::gpc_declare_input("addcmt", 0, true, array(), true);
     //functions::gpc_declare_input("janrain_nonce","",false,array(),true); // OBSOLETE?
     // -------------------------
     // -- If sign-out requested
     if (isset($_REQUEST["relog"])) {
         unset($_SESSION["openid_last_valid_identifier"]);
         unset($_SESSION["openid_identifier"]);
         if (isset($GLOBALS["domain"])) {
             unset($GLOBALS["domain"]);
         }
     }
     if (OPENIDDEBUG && isset($_REQUEST["relog"])) {
         echo "<br>openid_last_valid_identifier <strong>after relog</strong>= ";
         var_dump($_SESSION["openid_last_valid_identifier"]);
     }
     functions::gpc_declare_input("openid_last_valid_identifier", "", false, array(), true);
     if (OPENIDDEBUG) {
         echo "<br>openid_last_valid_identifier <strong>after gpc</strong> = ";
         var_dump($_SESSION["openid_last_valid_identifier"]);
     }
     if (OPENIDDEBUG) {
         echo "<br>openid_last_valid_identifier <strong>when setting domain</strong> = ";
         var_dump($_SESSION["openid_last_valid_identifier"]);
     }
     // -- Set domain of OpenID provider
     $GLOBALS["domain"] = openid::setOpDomain();
     if (OPENIDDEBUG) {
         echo "<br>freshly set <strong>DOMAIN</strong> = ";
         var_dump($GLOBALS["domain"]);
     }
     // -- Part of spam filter
     functions::gpc_declare_input(HONEYTRAP_ID, "", false);
     if (!empty($GLOBALS[HONEYTRAP_ID]) && isset($GLOBALS["addcmt"])) {
         $GLOBALS["addcmt"] = false;
     }
     // sent to openid check
     $_SESSION["articleid"] = !empty($GLOBALS["articleid"]) ? $GLOBALS["articleid"] : "";
     $_SESSION["openid_return_url"] = $GLOBALS["openid_return_url"] = URL_PREFIX . $_SERVER["PHP_SELF"] . (!empty($GLOBALS["articleid"]) ? "?articleid=" . $GLOBALS["articleid"] : "") . "";
     // -- Is user logged in to the news site
     $loggedinas = auth::isAuthenticated() ? auth::getUsername() : false;
     //if (OPENIDDEBUG) {echo "<br>SESSION AFTER: RETURN URL= ";if (isset($_SESSION["openid_return_url"])) var_dump($_SESSION["openid_return_url"]);echo "<br><br>GLOBALS CMT_TEXT=";var_dump($GLOBALS["cmt_text"]);echo "<br>GLOBALS ADDCMT=";var_dump($GLOBALS["addcmt"]);echo "<br>GLOBALS janrain_nonce=";var_dump($GLOBALS["janrain_nonce"]);}
     // --------------------------------
     // -- Check form input
     // --------------------------------
     if ($GLOBALS["addcmt"]) {
         if (OPENIDDEBUG) {
             echo "<h3>IN ADDCMT</h3>";
         }
         //echo "<p>openid_identifier=";var_dump($GLOBALS["openid_identifier"]);echo "<hr>"; echo "<p>openid_validation_error=";var_dump($GLOBALS["openid_validation_error"]);echo "<hr>";
         // -- Trim indata
         //TODO: spam filtering
         //TODO: check HTML validity
         //TODO: http://se.php.net/manual/en/function.strip-tags.php
         //$GLOBALS["cmt_text"] = "<p>" . str_replace("\r","</p>\r<p>",$GLOBALS["cmt_text"]) . "</p>";
         $allowed_html_tags = "";
         // "<p> <a> <b> <i> <strong> <em> <br>";
         $GLOBALS["cmt_text"] = strip_tags($GLOBALS["cmt_text"], $allowed_html_tags);
         $GLOBALS["cmt_text"] = trim($GLOBALS["cmt_text"]);
         $_SESSION["cmt_text"] = $GLOBALS["cmt_text"];
         $_SESSION["cmt_name"] = $GLOBALS["cmt_name"];
         //if (OPENIDDEBUG) {echo "<br>GLOBALS CMT_TEXT=";var_dump($GLOBALS["cmt_text"]);echo "<br>SESSION CMT_TEXT=";var_dump($_SESSION["cmt_text"]);}
         // -- Check for errors in submitted comment text
         if (empty($GLOBALS["cmt_text"])) {
             $founderror["cmt_text"] = 1;
             $errormessage["left"] .= "<p class='messages error'>Your comment looks quite empty</p>\r\n";
         }
         // -- Check for error messages from OpenId authentication call.
         //    Retrieved via session variable from page treated by CheckOpenid().
         functions::gpc_declare_input("openid_validation_error", "", false, array(), true);
         if (!empty($GLOBALS["openid_validation_error"])) {
             $founderror["openid_identifier"] = 1;
             $errormessage["right"] .= "<p class='messages error'>" . $GLOBALS["openid_validation_error"] . "</p>\r\n";
         }
         // -- Act on presence or absence of errors
         if (array_sum($founderror)) {
             // If errors found, display form with error messages
             $showform = 1;
         }
         // end if ($noerror)
     }
     // end "addcmt"
     // --------------------------------
     // -- If no errors found, insert comment into DB
     // --------------------------------
     if (!array_sum($founderror) && $GLOBALS["addcmt"]) {
         if (!class_exists("openid", FALSE)) {
             require_once PATH_CLASSES . "/lib/openid.php";
         }
         // set from session with fixed value; needed on return from openid check
         //functions::gpc_declare_input("openid_return_url","",false,array(),true);
         if ($loggedinas) {
             if (!class_exists("fromdb_nwnews", FALSE)) {
                 require_once PATH_CLASSES . "/fromdb/nwnews.php";
             }
             $GLOBALS["newsClass"] = new fromdb_nwnews();
             $idData = $GLOBALS["newsClass"]->getDataForLocalUser($loggedinas);
         } else {
             // needed on return from openid check
             functions::gpc_declare_input("openid_server_url", "", false, array(), true);
             if (in_array(openid::reduceDomain($GLOBALS["domain"]), openid::$oauthProviders)) {
                 // -- OAuth return values
                 if (OPENIDDEBUG) {
                     echo "<h3>ANALYZING OAUTH RETURN DATA</h3>";
                 }
                 //$returnUrl = isset($_SESSION["returnUrl"]) ? $_SESSION["returnUrl"] : URL_PREFIX.$_SERVER["REQUEST_URI"];
                 //$idData = openid::analyzeOauthResponse($returnUrl);
                 $idData = openid::analyzeOauthResponse($GLOBALS["openid_return_url"], openid::reduceDomain($GLOBALS["domain"]));
             } else {
                 // -- OpenID return values
                 if (OPENIDDEBUG) {
                     echo "<h3>ANALYZING OPENID RETURN DATA</h3>";
                 }
                 $idData = openid::analyzeOpenidResponse($GLOBALS["openid_return_url"], $GLOBALS["openid_server_url"]);
             }
             // $anonymous = false; foreach (openid::$anonymousUrlProviders as $p) if () $anonymous = true;
             if (is_string($idData)) {
                 $errormessage["right"] = "<p class='messages error'>" . $idData . "</p>";
                 $showform = 1;
             }
         }
         /*
         $idData = Array
         (
             [openid_identity] => http://hvzm.myopenid.com/
             [email] => hvzm@nordita.org
             [nickname] => hvzm
             [fullname] => Hans Mühlen
             [pape] => Array ()
         )
         idData = Array
         (
             [openid_news_identity] => http://openid.aol.com/hans.muhlen
             [email] => hans.muhlen@aol.com
             [pape] => Array
                 (
                     [extension] => Array
                         (
                             [0] => http://schemas.openid.net/pape/policies/2007/06/none
                         )
                 )
         )
         */
         //echo "<hr>IDATA=";debug::rr($idData);
         if (is_array($idData)) {
             //$name = "Anonymous";
             //if (isset($idData["data"]["nickname"]) && !empty($idData["data"]["nickname"])) $name = $idData["data"]["nickname"];
             //TODO
             $oidNick = openid::guessNickname($idData);
             if (!empty($GLOBALS["cmt_name"])) {
                 $name = $GLOBALS["cmt_name"];
             } elseif (!empty($oidNick)) {
                 $name = $oidNick;
             } else {
                 $name = "Anonymous";
             }
             $record = array("article_id" => $GLOBALS["articleid"], "text" => $GLOBALS["cmt_text"], "name" => $name, "author_id" => openid::guessEndUserField("author_id", $idData, 0), "image" => openid::guessEndUserField("image", $idData, ""));
             $res = self::addCommentInsert($record);
             if ($res) {
                 self::commentNotifyAdmin($record);
             }
             if (!$res) {
                 $errormessage["left"] = "\r\n" . "<p class='messages error'>Sorry, could not upload your comment</p>\r\n" . "\r\n";
                 $showform = 1;
             } else {
                 $showform = 1;
             }
         } else {
             $showform = 1;
         }
     }
     // --------------------------------
     // -- Output form, if requested
     // --------------------------------
     if ($showform) {
         // form uses $GLOBALS["cmt_text"] and $GLOBALS["articleid"]
         $stdout .= self::drawAddCommentForm($founderror, $errormessage, $loggedinas);
     }
     // --------------------------------
     // -- Cleanup
     // --------------------------------
     // always set from GPC;
     unset($_SESSION["addcmt"]);
     // always set from GPC; needed for form, in all situations
     unset($_SESSION["cmt_text"]);
     unset($_SESSION["cmt_name"]);
     // set on form submit in CheckOpenid() as result from openid check; then set here on second run from GPC
     unset($_SESSION["openid_validation_error"]);
     // always set from GPC;
     //    unset($_SESSION["janrain_nonce"]); // OBSOLETE?
     // always set to fixed value; sent to openid check and needed on return from openid check
     //    unset($_SESSION["openid_return_url"]);
     // always set from GPC; needed for form, in all situations
     //    unset($_SESSION["openid_identifier"]); // never delete!
     // set on form submit with no errors from GPC; needed on return from openid check
     //unset($_SESSION["openid_server_url"]);
     // --------------------------------
     //DEBUG:
     $t = "";
     $t .= "<div class='box blackborder padding'>\r\n<h4>OPENID REQUEST:</h4><pre>\r\n" . (!empty($_SESSION["openid_request"]) ? $_SESSION["openid_request"] : "-\r\n") . "</pre></div>\r\n\r\n";
     $t .= "<div class='box blackborder padding'>\r\n<h4>OPENID RESPONSE:</h4> <pre>\r\n" . (!empty($_SESSION["openid_response"]) ? $_SESSION["openid_response"] : "-\r\n") . "</pre></div>";
     //$t .= "\r\n\r\n<p>URL_PREFIX=".URL_PREFIX."\r\n<br>PHPSELF_PREFIX=".PHPSELF_PREFIX."\r\n<br>DOCROOT_PREFIX=".DOCROOT_PREFIX."</p>\r\n";
     if (IS_TESTSERVER && OPENIDDEBUG) {
         echo $t;
     } else {
         $stdout .= "\r\r<!--\r\r\n" . $t . "\r\n\r-->\r\r";
     }
     if (OPENIDDEBUG) {
         if (isset($idData)) {
             echo "<h4>idData:</h4> ";
             debug::rr($idData);
         }
     }
     return $stdout;
 }
예제 #4
0
 function buildPageHtml()
 {
     $stdout = "";
     /* RESTORE if test tabs needed */
     /*
     if (SHOW_TEST_TABS) {
         // -- GET switches, used in test site
         functions::gpc_declare_input("nostartpageboxes",true, true,array(),true);
         // -- Optionally display startpage boxes
         if (isset($_REQUEST["nostartpageboxes"])) {
           $_SESSION["nostartpageboxes"] = $GLOBALS["nostartpageboxes"];
         }
     } */
     // ---------------------------------------------------------------------------
     // PAGE PREAMBLE
     // ---------------------------------------------------------------------------
     // -- Document Type
     $stdout .= DOCTYPE . "\r\n\r\n";
     // ---------------------------------------------------------------------------
     // <HTML> OPEN TAG
     // ---------------------------------------------------------------------------
     // Conditional IE Classes
     //   An alternative to using separate conditionally loaded IE CSS files
     //     http://paulirish.com/2008/conditional-stylesheets-vs-css-hacks-answer-neither/
     //   NB: IE9 is here assumed to be standards-compliant
     // HTML5 Cache Manifest (offline reading)
     //   http://en.wikipedia.org/wiki/Cache_manifest_in_HTML5
     //   http://www.whatwg.org/specs/web-apps/current-work/multipage/offline.html
     $attributes = "lang='" . LANGUAGE_CODE . "'" . "";
     $stdout .= "<!--[if lt IE 7]>      <html " . $attributes . " class='ie6'> <![endif]-->\r\n" . "<!--[if IE 7]>         <html " . $attributes . " class='ie7'> <![endif]-->\r\n" . "<!--[if IE 8]>         <html " . $attributes . " class='ie8'> <![endif]-->\r\n" . "<!--[if gt IE 8]><!--> <html " . $attributes . ">             <!--<![endif]-->\r\n" . "\r\n";
     // ---------------------------------------------------------------------------
     // <HEAD> ELEMENT
     // ---------------------------------------------------------------------------
     $stdout .= "  <head>\r\n\r\n";
     // ---------------------------------------
     // -- Load <head> elements
     //    Invoke after loading menu array config parameters
     // ---------------------------------------
     if (!isset($GLOBALS[SUBSITE]["head"])) {
         $this->buildPageAuxHead();
     }
     foreach ($GLOBALS[SUBSITE]["head"] as $legend => $cd) {
         if (!empty($cd)) {
             $stdout .= $cd;
         }
     }
     if (count($GLOBALS[SUBSITE]["head"])) {
         $stdout .= "\r\n";
     }
     // ---------------------------------------
     // -- Styles (defined in 'layout.php'; extra in 'data/block_margintabs' and document->buildLayoutUpdate())
     // ---------------------------------------
     $txt = "";
     if (isset($GLOBALS[SUBSITE]["stylesheets"])) {
         foreach ($GLOBALS[SUBSITE]["stylesheets"] as $media => $arr) {
             $txt .= $this->buildPageAuxStylesheets($media, $arr);
         }
     }
     if (isset($GLOBALS[SUBSITE]["stylesheets-conditional"])) {
         foreach ($GLOBALS[SUBSITE]["stylesheets-conditional"] as $iecond => $sarr) {
             foreach ($sarr as $media => $arr) {
                 $txt .= $this->buildPageAuxStylesheets($media, $arr, $iecond);
             }
         }
     }
     if (!empty($txt)) {
         $stdout .= $txt . "\r\n";
     } else {
         // -- Fix for the FOUC problem for MSIE;
         //    See: http://bluerobot.com/web/css/fouc.asp/,
         //    http://www.webkit.org/blog/66/the-fouc-problem/
         //    and http://en.wikipedia.org/wiki/Flash_of_unstyled_content
         $stdout .= "    <script type='text/javascript'> </script>\r\n\r\n";
     }
     // ---------------------------------------
     // -- Scripts (defined in 'config.php')
     //    Moved to end of document
     // ---------------------------------------
     if (isset($GLOBALS[SUBSITE]["scripts-head"])) {
         foreach ($this->getConfig("scripts-head") as $type => $arr) {
             $stdout .= $this->buildPageAuxScripts($type, $arr) . "\r\n";
         }
     }
     if (isset($GLOBALS[SUBSITE]["scripts-head-conditional"])) {
         foreach ($GLOBALS[SUBSITE]["scripts-head-conditional"] as $iecond => $sarr) {
             foreach ($sarr as $type => $arr) {
                 $stdout .= $this->buildPageAuxScripts($type, $arr, $iecond) . "\r\n";
             }
         }
     }
     // ---------------------------------------
     // -- Google Analytics script
     //  http://code.google.com/apis/analytics/
     //  https://www.google.com/analytics/settings/ (old site)
     //
     // Asynchronous tracking (recommended):
     //  http://support.google.com/googleanalytics/bin/answer.py?hl=en&answer=174090
     // ---------------------------------------
     if (!IS_TESTSERVER && !in_array(SUBSITECRUMB, array("_admin"))) {
         $stdout .= "    <script type='text/javascript'>\r\n" . "      var _gaq = _gaq || [];\r\n" . "      _gaq.push(['_setAccount', '" . GOOGLE_ANALYTICS_ACCOUNT . "']);\r\n" . "      _gaq.push(['_setDomainName', '" . GOOGLE_ANALYTICS_DOMAIN . "']);\r\n" . "      _gaq.push(['_trackPageview']);\r\n" . "      (function() {\r\n" . "        var ga = document.createElement('script'); " . "ga.type = 'text/javascript'; ga.async = true;\r\n" . "        ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') " . "+ '.google-analytics.com/ga.js';\r\n" . "        var s = document.getElementsByTagName('script')[0]; " . "s.parentNode.insertBefore(ga, s);\r\n" . "      })();\r\n" . "    </script>\r\n\r\n";
     } else {
         $stdout .= "    <!-- suppressed Google Analytics code -->\r\n\r\n";
     }
     // ---------------------------------------
     $stdout .= "  </head>\r\n\r\n\r\n";
     // ---------------------------------------------------------------------------
     // FLUSH TO HTTP RESPONSE
     //   See: http://developer.yahoo.com/performance/rules.html#flush
     // ---------------------------------------------------------------------------
     //    flush();
     // ---------------------------------------------------------------------------
     // <BODY> START TAG, POSSIBLY WITH JAVASCRIPT CALLS
     // ---------------------------------------------------------------------------
     $bodyattributes = "";
     // --- ID
     //     bodyid = ["display"|"timetable"|"slideshow"|"search"|...]
     //     Set in 'PATH_MENU/m_*' as $pg[SUBSITE]["bodyid"]
     unset($bodyattributes_id);
     if ($this->getConfig("bodyid")) {
         $bodyattributes_id[] = $this->getConfig("bodyid");
     }
     if (isset($bodyattributes_id)) {
         $bodyattributes .= " id='" . implode(" ", $bodyattributes_id) . "'";
     }
     // --- CLASS
     //     body.wiki
     //     body.nobackground
     //     body.nobanner
     //     body.wide
     $bclasses = array("tabbed", "nobackground", "nobanner", "wide", "medwide", "rightwide", "nopagetitle", "nosearchfocus", "nobanneronprint", "nomenu");
     $bodyattributes_class = array();
     foreach ($bclasses as $bclass) {
         if ($this->getConfig($bclass) && isset($bodyattributes_class) && !in_array($bclass, $bodyattributes_class)) {
             $bodyattributes_class[] = $bclass;
         }
     }
     if ($this->getConfig("theme") != "") {
         $bodyattributes_class[] = $this->getConfig("theme");
     }
     if (IS_TESTSERVER && IS_INDEXPAGE && (isset($_SESSION["nostartpageboxes"]) && $_SESSION["nostartpageboxes"])) {
         $bodyattributes_class[] = "nostartpageboxes";
     }
     // -- Optionally display screen resolution background
     if (IS_TESTSERVER) {
         functions::gpc_declare_input("nw_screenresolution", false, true, array(), true);
         if ($_SESSION["nw_screenresolution"]) {
             $bodyattributes_class[] = "nw_screenresolution";
         }
     }
     if ($this->getConfig("nolist")) {
         $bodyattributes_class[] = "noindex";
     }
     /* RESTORE if test tabs needed */
     /*
     if (SHOW_TEST_TABS && isset($GLOBALS["frontselect"])) {
           $bodyattributes_class[] = "frontselect".$GLOBALS["frontselect"];
     } */
     // --- SCRIPT
     //$bodyattributes_script[] = "";
     // --- TOTAL
     if (isset($bodyattributes_class) && count($bodyattributes_class)) {
         $bodyattributes .= " class='" . implode(" ", $bodyattributes_class) . "'";
     }
     if (isset($bodyattributes_script) && count($bodyattributes_script)) {
         $bodyattributes .= implode(" ", $bodyattributes_script);
     }
     // --- ONLOAD
     unset($bodyattributes_onload);
     // ======================================================================
     //TODO: these should be put in some config file
     // initiate google map in colophon (call before 'focus'):
     if (isInPath("googlemap")) {
         $bodyattributes_onload[] = "initmap(\"googlemap-map-canvas\",12)";
     }
     // ======================================================================
     // ======================================================================
     //TODO: these should be put in some config file
     if (auth::isLoginRequired() && !auth::isAuthenticated()) {
         $bodyattributes_onload[] = "document.getElementById(\"auth_username\").focus()";
     } elseif (SHOW_SEARCH && !$this->getConfig("nosearchfocus")) {
         if (isInPath("/people/search/") && !isset($_REQUEST["pqry"])) {
             $bodyattributes_onload[] = "document.getElementById(\"pqry\").focus()";
         } elseif (SHOW_SEARCH && isInPath("/search/") && !isset($_REQUEST["qry"]) && !isset($_REQUEST["sqry"])) {
             // orca search form
             $bodyattributes_onload[] = "document.getElementById(\"qry\").focus()";
         } else {
             // simple search form
             $bodyattributes_onload[] = "document.getElementById(\"sqry\").focus()";
             // keep but don't use
         }
     } elseif ($this->getConfig("nosearchfocus") && !isset($_REQUEST["qry"]) && !isset($_REQUEST["sqry"]) && !isset($_REQUEST["pqry"])) {
         if ((isInPath("/" . PATH_NEWS . "/") || isInPath("/" . PATH_NEWSTEST . "/")) && isset($_REQUEST["cmt_text"])) {
             $bodyattributes_onload[] = "document.getElementById(\"cmt_text\").focus()";
         } else {
             // mainly captcha form
             $bodyattributes_onload[] = "document.getElementById(\"" . CAPTCHA_ID . "\").focus()";
         }
     }
     // ======================================================================
     // $bodyattributes_onload[] = "window.location.reload(true)"; //NOP
     if (isset($bodyattributes_onload) && !IS_PRINT) {
         $bodyattributes .= " onLoad='" . implode(";", $bodyattributes_onload) . "'";
     }
     // ---
     $stdout .= "  <body" . $bodyattributes . (HIDE_BACKGROUND_IMAGE ? " style='background-image:none!important'" : "") . ">\r\n" . "\r\n";
     //Only during test period:
     $stdout .= TESTSERVER_FLAG;
     //if (IS_TESTSERVER) $stdout.= "<h1 style='position:fixed;width:50%;margin:0;color:red;top:0px;left:0px;opacity:0.2'>[TESTSERVER]</h1>\r\n\r\n";
     //if (IS_ON_KTH_SERVER) $stdout.= "<h1 style='position:fixed;width:50%;margin:0;color:red;top:0px;left:0px;opacity:0.2'>[VIRTUAL SERVER]</h1>\r\n\r\n";
     // ---------------------------------------------------------------------------
     // PAGE CONTENT
     //   containers -> regions -> blocks
     //   [set in 'layout/<nr>/layout' and 'sites/SUBSITE/config_SUBSITE']
     // ---------------------------------------------------------------------------
     // DEBUG --
     $newlayout = false;
     if ($newlayout) {
         // -- DEBUG
         // *** Handling of the "new layout" has not been debugged yet! ***
         $stdout .= "\r\n" . "    <!-- ========================================================= -->\r\n\r\n\r\n";
         $data = "";
         foreach ($GLOBALS[SUBSITE]["layout"] as $containerId => $callback) {
             $data = $this->renderCallback($callback);
             if (!empty($data)) {
                 $stdout .= "    <div id='" . $containerId . "'" . ($this->getConfig("isindex") ? " class='index'" : "") . ">\r\n\r\n" . $data . "    </div> <!-- " . $containerId . " -->\r\n\r\n\r\n" . "    <!-- ========================================================= -->\r\n\r\n\r\n";
             }
         }
         // end foreach
         // DEBUG --
     } else {
         // -- DEBUG
         $stdout .= "\r\n" . "    <!-- ========================================================= -->\r\n\r\n\r\n";
         foreach ($GLOBALS[SUBSITE]["containers"] as $cont => $regs) {
             $data = "";
             foreach ($regs as $r) {
                 if ($r != "colophon" || !$this->getConfig("nocolophon")) {
                     if (count($GLOBALS[SUBSITE]["regions"][$r])) {
                         $txt = "";
                         if (is_array($GLOBALS[SUBSITE]["regions"][$r])) {
                             foreach ($GLOBALS[SUBSITE]["regions"][$r] as $feat) {
                                 if (!empty($feat)) {
                                     $txt .= functions::outputFunctionCall($feat);
                                 }
                             }
                         }
                         if (!empty($txt)) {
                             $data .= "      <div id='region-" . $r . "'" . (isset($GLOBALS[SUBSITE]["classes"]["region-" . $r]) ? " class='" . $GLOBALS[SUBSITE]["classes"]["region-" . $r] . "'" : "") . ">\r\n\r\n" . $txt . "      </div> <!-- " . $r . " -->\r\n\r\n";
                         }
                     }
                 }
             }
             $data = trim($data);
             if (!empty($data)) {
                 $stdout .= "    <div id='container-" . $cont . "'" . ($this->getConfig("isindex") ? " class='index'" : "") . ">\r\n\r\n" . "      " . $data . "\r\n\r\n" . "    </div> <!-- " . $cont . " -->\r\n\r\n\r\n" . "    <!-- ========================================================= -->\r\n\r\n\r\n";
             }
         }
         // end foreach
         // DEBUG --
     }
     // -- DEBUG
     // ---------------------------------------------------------------------------
     // IMAGE PRELOADING
     // ---------------------------------------------------------------------------
     /* this is NOT particularly useful...
         $stdout .=
           "    <div style='display:none'>\r\n" .
           "      <img src='_css/img/_splash/sprite-splash-nordita.png' alt='' style='width:1px;height:1px;'>\r\n" .
           "      <img src='img/backdrop_pentaflakes_1200_win.jpg' alt='' style='width:1px;height:1px;'>\r\n" .
           "    </div>\r\n" .
           "\r\n";
     */
     // ---------------------------------------------------------------------------
     // JAVASCRIPTS AT END OF DOCUMENT
     //   See http://developer.yahoo.com/performance/rules.html#js_bottom
     // ---------------------------------------------------------------------------
     if (isset($GLOBALS[SUBSITE]["scripts"])) {
         foreach ($GLOBALS[SUBSITE]["scripts"] as $type => $arr) {
             $stdout .= $this->buildPageAuxScripts($type, $arr) . "\r\n";
         }
     }
     if (isset($GLOBALS[SUBSITE]["scripts-conditional"])) {
         foreach ($GLOBALS[SUBSITE]["scripts-conditional"] as $iecond => $sarr) {
             foreach ($sarr as $type => $arr) {
                 $stdout .= $this->buildPageAuxScripts($type, $arr, $iecond);
             }
         }
     }
     $stdout .= "\r\n";
     // ---------------------------------------------------------------------------
     // END OF <BODY> AND <HTML> TAGS
     // ---------------------------------------------------------------------------
     $stdout .= "  </body>\r\n\r\n" . "</html>\r\n\r\n\r\n\r\n";
     // ---------------------------------------------------------------------------
     return $stdout;
 }
예제 #5
0
 public static function Btopmenu($id = "topmenu", $blockclass = "", $liclass = "")
 {
     $stdout = "";
     if (IS_ENTRANCE) {
         return "";
     }
     $work = $GLOBALS["documentClass"]->getMenuThisTop();
     $txt = "";
     foreach ($work as $subpage) {
         if (auth::isAccessGranted($subpage["access"])) {
             if (!empty($subpage)) {
                 $txt .= "            <li class='" . (!empty($liclass) ? $liclass . " " : "") . ($subpage["active"] && !empty($subpage["path"]) ? "expanded" : "collapsed") . ($subpage["path"] == PUBLICCRUMB ? " last " : "") . "'><a href='" . $subpage["url"] . "'>" . str_replace(TEST_PREFIX, "", str_replace(EXTERNAL_LINK, "", $subpage["title"])) . "</a></li>\r\n";
             }
         }
     }
     /* RESTORE if test tabs needed */
     /*
     if (SHOW_TEST_TABS && IS_INDEXPAGE && ($GLOBALS["frontselect"]==10)) $txt = "            <li style='float:none;height:auto;margin:0px;padding:2px 15px 0px 65px;text-decoration:none;font-size:1.4em;font-weight:normal;font-family:\"Baskerville\",\"Times\",\"Times New Roman\",serif;letter-spacing:0.2em;'>The Nordic Institute for Theoretical Physics</li>\r\n"; */
     $stdout = "        <div id='block-" . $id . "'" . (!empty($blockclass) ? " class='" . $blockclass . "'" : "") . ">\r\n" . "          <ul>\r\n" . ($GLOBALS["documentClass"]->getConfig("requirelogin") && (!auth::isAuthenticated() || auth::isLogoutRequested()) ? "" : $txt) . "          </ul>\r\n" . "        </div> <!-- " . $id . " -->\r\n" . "\r\n";
     return $stdout;
 }