[ Index ]

PHP Cross Reference of Moodle 1.9.3 [Build 15-Oct-2008]

title

Body

[close]

/mod/wiki/ewiki/fragments/ -> homepage.src (source)

   1  <?php
   2  
   3  
   4     #-- This is an example standalone lite-CMS Homepage based on ewiki.php
   5  
   6     # - it requires PHP4.1+
   7     # - you should install it as index.php into your dedicated webspace
   8     # - copy the ewiki.php there, too
   9     # - DON'T upload the tools/ directory, as this requires a lot more
  10     #   setup to be used securely
  11     # - HTML Editors usually allow you to tweak the layout without
  12     #   garbaging the PHP code inside
  13     # - authentication is done using JavaScript+Cookies
  14     # - requires a MySQL database, just visit http://freesql.org/ and
  15     #   get happy (if your provider doesn't provide one)
  16     # - there will be no pages initially, you must first create some
  17     # - most config options are in the upper area of this file:
  18  
  19     $HOMEPAGE_TITLE    = 'MyHomepage';
  20     $LOGIN_PASSWORD    = 'ewiki';
  21     $AUTHOR_NAME        = 'your_nickname_here';
  22     $MYSQL_HOST        = 'localhost';
  23     $MYSQL_USER        = 'root';
  24     $MYSQL_PASSWORD    = '';
  25     $MYSQL_DATABASE    = 'test';
  26  
  27     #-- open database
  28     if (!@mysql_ping()) {
  29       mysql_connect($MYSQL_HOST, $MYSQL_USER, $MYSQL_PASSWORD);
  30       mysql_query("use $MYSQL_DATABASE");
  31     }
  32  
  33     #-- no errors shown from here
  34     error_reporting(0);
  35  
  36     #-- check for password
  37     if ($LOGIN_PASSWORD == "password") die("poor");
  38     if ($_COOKIE["password"]) {
  39        if ($LOGIN_PASSWORD == $_COOKIE["password"]) {
  40           $ewiki_author = $AUTHOR_NAME;
  41        }
  42        else {
  43           $page_content == "<h3>password wrong</h3>";
  44        }
  45     }
  46  
  47     #-- load ewiki
  48     define("EWIKI_EDIT_AUTHENTICATE", 1);
  49     define("EWIKI_SCRIPT", substr(__FILE__, strrpos(__FILE__, "/") + 1) . "?page=");
  50     define("EWIKI_SCRIPT_BINARY", substr(__FILE__, strrpos(__FILE__, "/") + 1) . "?binary=");
  51     define("EWIKI_PAGE_INDEX", $HOMEPAGE_TITLE);
  52     define("EWIKI_CONTROL_LINE", 0);
  53     define("EWIKI_T_CANNOTCHANGEPAGE", "You must first login to change a page.");
  54     include ("ewiki.php");
  55  
  56     #-- get current page
  57     if (empty($page_content)) {
  58        $page_content = ewiki_page();
  59     }
  60  
  61  
  62  ?><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
  63  <HTML>
  64   <HEAD>
  65   <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
  66   <title><?php echo($ewiki_title); ?></title>
  67   <meta name="GENERATOR" content="ewiki" />
  68   <meta name="ROBOTS" content="INDEX,FOLLOW" />
  69  
  70   <style type="text/css">
  71   <!--
  72     body {
  73       background-color:#6666ee;
  74       color:#000011;
  75     }
  76     .menu {
  77       background-color:#111166;
  78       color:#ffffff;
  79       border: 2px solid #000055;
  80       padding: 8px;
  81       text-align:center;
  82       width:120px;
  83     }
  84     a,a:link { color: #ffff33; text-decoration: none; }
  85     a:active { color: #FF6666; }
  86     a:visited { color: #660000; }
  87     a:hover { font-weight:900; background-color:#ffff00; color:#000000; }
  88     .menu a { color:#ffffff; }
  89     .menu a:hover { color:#000000; }
  90   //-->
  91   </style>
  92  
  93   <script type="text/javascript">
  94   <!--
  95  
  96     function login()
  97     {
  98        var password = window.prompt("Please enter the administrator password:");
  99        window.document.cookie = "password=" + password;
 100        window.document.location.reload();
 101     }
 102  
 103     function logout()
 104     {
 105        window.document.cookie = "password=";
 106     }
 107  
 108   //-->
 109   </script>
 110  
 111  </HEAD>
 112  
 113  <BODY>
 114  
 115  <CENTER>
 116  <TABLE BORDER="0" CELLPADDING="0" CELLSPACING="10" WIDTH="90%">
 117  <TR>
 118  
 119  <TD WIDTH="120" VALIGN="TOP">
 120  
 121  <DIV CLASS="menu">
 122  
 123  <h3>Welcome to my Homepage!</h3>
 124  
 125  
 126   <A HREF=".">Startpage</A> <BR>
 127  
 128   <A HREF="?page=EMailMe">EMailMe</A> <BR>
 129  
 130   <A HREF="?page=MyLinks">MyLinks</A> <BR>
 131  
 132   <BR>
 133  
 134  
 135  <?php
 136  
 137  
 138   if ($ewiki_author) {
 139  
 140      echo "<A HREF=\"javascript:logout()\">Logout</A><BR>";
 141      echo "<A HREF=\"?page=edit/$ewiki_title\">EditThisPage</A><BR>";
 142      echo "<A HREF=\"?page=info/$ewiki_title\">PageInfo</A><BR>";
 143  
 144   }
 145   else {
 146  
 147      echo "<A HREF=\"?page=links/$ewiki_title\">Links to here</A><BR><BR>";
 148  
 149      echo "<SMALL><A HREF=\"javascript:login()\">EditorLogin</A><BR></SMALL>";
 150   }
 151  
 152  
 153  ?>
 154  
 155  </DIV>
 156  </TD>
 157  
 158  <TD VALIGN="TOP" WIDTH="90%">
 159  <DIV CLASS="content">
 160  <?php
 161  
 162  
 163   echo($page_content);
 164  
 165  
 166  ?>
 167  </TR>
 168  </TABLE>
 169  </CENTER>
 170  
 171  </BODY>
 172  </HTML>


Generated: Wed Jan 14 11:33:29 2009 Cross-referenced by PHPXref 0.7