Code

Activated own icon
[gosa.git] / html / main.php
index f39467376b3fb9bb263e720d4ab30ec9208f6291..c73b24a8f39cc44f7f30cc39d091f35db7f4b008 100644 (file)
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 
-/* This will be removed... */
-function raiseError($errno, $errstr, $errfile, $errline)
-{
-  gosa_log ("PHP error: $errstr ($errfile, line $errline)");
-}
-
-//set_error_handler('raiseError');
-/* This will be removed */
-
-
 /* Basic setup, remove eventually registered sessions */
 $timing= array();
 require_once ("../include/php_setup.inc");
 require_once ("functions.inc");
 header("Content-type: text/html; charset=UTF-8");
 
+/* Reset error handler */
+$error_collector= "";
+set_error_handler('gosaRaiseError');
+
 /* Find all class files and include them */
 get_dir_list("$BASE_DIR/plugins");
 
@@ -42,7 +36,6 @@ $domain = 'messages';
 bindtextdomain($domain, "$BASE_DIR/locale");
 textdomain($domain);
 
-
 /* Remember everything we did after the last click */
 session_start ();
 if ($_SERVER["REQUEST_METHOD"] == "POST"){
@@ -146,7 +139,7 @@ eval_sizelimit();
 
 /* Check for memory */
 if (function_exists("memory_get_usage")){
-  if (memory_get_usage() > (to_byte(ini_get('memory_limit')) - 1024000 )){
+  if (memory_get_usage() > (to_byte(ini_get('memory_limit')) - 2048000 )){
     print_red(_("Warning: memory is getting low - please increase the memory_limit!"));
   }
 }
@@ -209,11 +202,19 @@ if(isset($_SESSION['POST'])){
 /* show web frontend */
 $smarty->assign ("date", date("l, dS F Y H:i:s O"));
 $smarty->assign ("must", "<font class=\"must\">*</font>");
+if (isset($plug)){
+  $plug= "?plug=$plug";
+} else {
+  $plug= "";
+}
 if ($_SESSION['js']==FALSE){
   $smarty->assign("javascript", "false");
+  $smarty->assign("help_method", "href='helpviewer.php$plug' target='_new'");
 } else {
   $smarty->assign("javascript", "true");
+  $smarty->assign("help_method","href='' onclick=\"return popup('helpviewer.php$plug','GOsa help');\"");
 }
+
 $smarty->assign ("username", $ui->username);
 $smarty->assign ("go_logo", get_template_path('images/go_logo.png'));
 $smarty->assign ("go_base", get_template_path('images/dtree.png'));
@@ -225,15 +226,10 @@ $smarty->assign ("go_left", get_template_path('images/go_left.png'));
 $smarty->assign ("go_help", get_template_path('images/help.png'));
 $plist->gen_menu();
 $smarty->assign ("menu", $plist->menu);
-if (isset($plug)){
-  $smarty->assign ("plug", "?plug=$plug");
-} else {
-  $smarty->assign ("plug", "");
-}
-$smarty->display(get_template_path('headers.tpl'));
-if (isset($_GET['version'])){
-  require_once("version.inc");
-}
+$smarty->assign ("plug", "$plug");
+
+$header= "<!-- headers.tpl-->".$smarty->fetch(get_template_path('headers.tpl'));
+
 
 /* React on clicks */
 if ($_SERVER["REQUEST_METHOD"] == "POST"){
@@ -278,7 +274,34 @@ $smarty->assign("contents", $display);
 if (isset($_SESSION['errors'])){
   $smarty->assign("errors", $_SESSION['errors']);
 }
-$smarty->display(get_template_path('framework.tpl'));
+if ($error_collector != ""){
+  $smarty->assign("php_errors", $error_collector."</div>");
+} else {
+  $smarty->assign("php_errors", "");
+}
+$smarty->assign("w3c", "");
+$display= $header.$smarty->fetch(get_template_path('framework.tpl'));
+
+/* For development, perform a W3C conformance check if specified in gosa.conf */
+if (isset($config->data['MAIN']['W3CTEST'])) {
+  $fp = fopen("/tmp/gosa.html","w+");
+  fwrite($fp, $display, strlen($display));
+  $url= $config->data['MAIN']['W3CTEST'];
+  $str = shell_exec( "curl -F uploaded_file=@/tmp/gosa.html $url/check");
+  if(!preg_match("/This Page Is Valid/i",$str )){
+    /* Show errors */
+    echo $str;
+  } else {
+    /* Re-render page with W3C logo */
+    $smarty->assign("w3c", "<a href=\"$url/check?uri=referer\"><img alt=\"\" border=\"0\" src=\"$url/images/vh401.png\" alt=\"Valid HTML 4.01!\" height=\"31\" width=\"88\"></a>");
+    $display= $header.$smarty->fetch(get_template_path('framework.tpl'));
+  }
+}
+
+/* Show page... */
+echo $display;
+
+/* Save plist */
 $_SESSION['plist']= $plist;
 
 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: