# HG changeset patch
# User dan@scribus.fuhry.local.fuhry.local
# Date 1181768340 14400
# Node ID 2b2084ca1e607c722b3e477deaa55aa40383179c
# Parent 0931d60f5bdbef52933c9a318e0ab9a1ae0a6ed5
Final commit for initial branch
diff -r 0931d60f5bdb -r 2b2084ca1e60 includes/clientside/css/enano-shared.css~
--- a/includes/clientside/css/enano-shared.css~ Wed Jun 13 16:32:27 2007 -0400
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,401 +0,0 @@
-/*
- * Shared stuff that all Enano themes (should) use
- */
-
-/* Information, warning, question, error, and wait boxes */
-div.error-box { background-image: url(../../../images/error.png); background-repeat: no-repeat; background-color: #FFF4F4; border: 1px dashed #406080; padding: 10px 10px 10px 50px; margin: 1em 0 0 0; min-height: 25px; }
-div.info-box { background-image: url(../../../images/info.png); background-repeat: no-repeat; background-color: #F4F4FF; border: 1px dashed #406080; padding: 10px 10px 10px 50px; margin: 1em 0 0 0; min-height: 25px; }
-div.warning-box { background-image: url(../../../images/warning.png); background-repeat: no-repeat; background-color: #FFFFF4; border: 1px dashed #406080; padding: 10px 10px 10px 50px; margin: 1em 0 0 0; min-height: 25px; }
-div.question-box { background-image: url(../../../images/question.png); background-repeat: no-repeat; background-color: #F4FFF4; border: 1px dashed #406080; padding: 10px 10px 10px 50px; margin: 1em 0 0 0; min-height: 25px; }
-div.wait-box { background-image: url(../../../images/wait.png); background-repeat: no-repeat; background-color: #FFF4FF; border: 1px dashed #406080; padding: 10px 10px 10px 50px; margin: 1em 0 0 0; min-height: 25px; }
-
-/* toolbar */
-div.toolbar {
- border-bottom: 1px solid #909090;
- background-color: #D0D0D0;
- padding: 2px 0;
- height: 22px;
- font-family: arial, sans-serif;
- font-size: 8pt;
-}
-div.toolbar ul {
- margin: 0;
- padding: 0;
-}
-div.toolbar ul li {
- list-style: none;
- margin: 0;
- float: left;
-}
-div.toolbar a img {
- opacity: 0.6;
- /*filter: alpha(opacity=60);*/
-}
-div.toolbar a:hover img {
- opacity: 1;
- /*filter: alpha(opacity=100);*/
-}
-div.toolbar a {
- display: block;
- padding: 2px;
- border: 1px solid transparent;
- cursor: default;
- width: auto;
- color: #000000;
- margin: 0 2px;
- max-height: 16px;
- text-decoration: none;
-}
-div.toolbar a:hover {
- border: 1px solid #202090;
- background-color: #ceceed;
- color: #000000;
- text-decoration: none;
-}
-div.toolbar a:active {
- border: 1px solid #A0A0A0;
- background-color: #E0E0E0;
-}
-div.toolbar img {
- margin: 0;
- padding: 0;
- display: inline;
- border-width: 0px;
-}
-div.toolbar a span {
- position: relative;
- top: -4px;
-}
-div.toolbar li span {
- padding-left: 2px;
- padding-right: 5px;
-}
-
-/* vertical toolbar */
-div.toolbar_vert {
- border: 1px solid #909090;
- background-color: #D0D0D0;
- padding: 2px 0;
-}
-div.toolbar_vert ul {
- margin: 0;
- padding: 0;
-}
-div.toolbar_vert ul li {
- list-style: none;
- margin: 0;
-}
-div.toolbar_vert a img {
- opacity: 0.6;
- /*filter: alpha(opacity=60);*/
-}
-div.toolbar_vert a:hover img {
- opacity: 1;
- /*filter: alpha(opacity=100);*/
-}
-div.toolbar_vert a {
- display: block;
- padding: 2px;
- border: 1px solid transparent;
- cursor: default;
- width: auto;
- color: #000000;
- margin: 0 2px;
- max-height: 16px;
- text-decoration: none;
-}
-div.toolbar_vert a:hover {
- border: 1px solid #202090;
- background-color: #ceceed;
- color: #000000;
- text-decoration: none;
-}
-div.toolbar_vert a:active {
- border: 1px solid #A0A0A0;
- background-color: #E0E0E0;
-}
-div.toolbar_vert img {
- margin: 0;
- padding: 0;
- display: inline;
- border-width: 0px;
-}
-div.toolbar_vert a span {
- position: relative;
- top: -4px;
-}
-div.toolbar_vert li span {
- padding-left: 2px;
- padding-right: 5px;
-}
-
-/* Tables */
-.tblholder { margin: 10px 0 0 0; padding: 0; border: 1px solid #AAAAAA; background-color: #E8E8E8; }
-
-/* The beautiful tables inside what may not obviously be mdg-comment divs */
-div.tblholder td.row1 { padding: 4px; background-color: #E0E0E0; }
-div.tblholder td.row2 { padding: 4px; background-color: #F0F0F0; }
-div.tblholder td.row3 { padding: 4px; background-color: #E8E8E8; }
-div.tblholder th { padding: 4px; background-color: #7080A0; font-weight: bold; text-align: center; color: #FFFFFF; }
-div.tblholder th.subhead { padding: 4px; background-color: #90A0B0; font-weight: bold; text-align: center; color: #FFFFFF; }
-div.tblholder table { background-color: #FFFFFF; width: 100%; }
-
-/* Well, not Midget and not comments (usually), but that's what the class is called ;-). Basically an informational window or used as a wrapper for tables. */
-.mdg-comment, .mdg-infobox { margin-left: 1em; padding: 7px; border: 1px solid #AAAAAA; background-color: #E8E8E8; }
-
-/* JWS window theming */
-div.jswindow { border: 2px solid #7090B0; border-top: 5px solid #7090B0; padding: 0px; font-family: Trebuchet MS, tahoma, verdana, arial, sans-serif; font-size: 9pt; display: none; position: absolute; background-color: #FFFFFF; }
-div.titlebar { background-color: #7090B0; color: #FFFFFF; font-family: Trebuchet MS, tahoma, verdana, arial, sans-serif; font-size: 9pt; padding-bottom: 4px; cursor: default; }
-div.titlebar div.closebtn { width: 16px; height: 16px; border: 1px solid #B0D0F0; background-color: #90B0D0; display: block; }
-div.titlebar div.closebtn:hover { width: 16px; height: 16px; border: 1px solid #FFFFFF; background-color: #B0D0F0; display: block; }
-div.titlebar table, div.titlebar td { margin: 0; padding: 0; }
-div.jswindow div.content { padding: 10px; margin: 0; background-color: #FFFFFF; }
-
-/* Search results */
-div.search-result h3 { font-size: 14pt; margin: 10px 0 0 0; }
-div.search-result h3 a { color: blue !important; font-weight: normal; padding-bottom: 0; }
-div.search-result p { margin: 10px 0 0 0 !important; font-family: arial, helvetica, sans-serif; font-size: 10pt; }
-div.search-result span.search-result-info { color: green; }
-div.search-result span.search-term, div.search-result span.title-search-term { background-color: #FFFFC0; font-weight: bold; }
-
-/*
- * Search box
- */
-
-input.js-search-box {
- font-size: 13px;
- margin: 0;
- padding: 1px !important;
- background-image: url(../../../images/search-box-normal.gif);
- height: 15px;
- background-repeat: repeat-x;
- border-width: 1px;
- border-style: solid;
- border-color: #6c6c6c;
- color: #C0C0C0;
-}
-
-input.js-search-box:focus {
- background-image: url(../../../images/search-box-hilite.gif);
- color: #666;
-}
-
-div.js-search-submit {
- display: block;
- position: absolute;
- width: 24px;
- height: 19px;
- font-size: 1px;
- line-height: 19px;
- clip: rect(0px, 24px, 19px, 0px);
- overflow: hidden;
- margin: 0;
- padding: 0;
- background: transparent url(../../../images/search-btn-normal.png) no-repeat !important;
- background-repeat: no-repeat;
- cursor: pointer;
-}
-
-div.js-search-submit:hover {
- background-image: url(../../../images/search-btn-hilite.png);
-}
-
-input[type ^="text"].username, input[type ^="password"].password {
- padding: 2px 2px 2px 27px;
- width: 96px;
- height: 15px;
- border: 0px none #000;
- font-size: 11px;
-}
-input[type ^="text"].username {
- background-image: url(../../../images/login-username.png);
-}
-input[type ^="password"].password {
- background-image: url(../../../images/login-password.png);
-}
-
-/*
- * jBox menu system
- */
-
-div.menu, div.menu_nojs {
- background-color: #D0D0D0;
- border: 1px solid #A0A0A0;
- font-size: 9pt;
-}
-div.menu a, div.menu div.label {
- padding: 2pt 5px;
- text-decoration: none;
- display: block;
- float: left;
- color: #404040;
-}
-div.menu_nojs a, div.menu_nojs div.label {
- padding: 2pt 5px;
- text-decoration: none;
- display: block;
- color: #404040;
-}
-div.menu div.label, div.menu_nojs div.label {
- color: #101010;
-}
-div.menu span.sep, div.menu_nojs span.sep {
- display: block;
- float: left;
- width: 5px;
-}
-div.menu div.multopts, div.menu_nojs div.multopts {
- line-height: 17pt;
-}
-div.menu div.multopts a, div.menu div.multopts div.label, div.menu_nojs div.multopts a, div.menu_nojs div.multopts div.label {
- float: none;
- display: inline;
-}
-div.menu a:hover, div.menu_nojs a:hover {
- color: #FFFFFF;
- background-color: #808080;
-}
-div.menu input[type ^="text"], div.menu input[type ^="password"], div.menu_nojs input[type ^="text"], div.menu_nojs input[type ^="password"] {
- border-width: 0;
- font-size: 9pt;
- padding: 4px 5px;
- max-width: 70px;
- background-color: #E0E0E0;
-}
-div.menu input[type ^="text"]:hover, div.menu input[type ^="password"]:hover, div.menu_nojs input[type ^="text"]:hover, div.menu_nojs input[type ^="password"]:hover {
- background-color: #E8E8E8;
-}
-div.menu input[type ^="text"]:focus, div.menu input[type ^="password"]:focus, div.menu_nojs input[type ^="text"]:focus, div.menu_nojs input[type ^="password"]:focus {
- background-color: #F0F0F0;
-}
-div.menu input[type ^="button"], div.menu input[type ^="submit"], div.menu_nojs input[type ^="button"], div.menu_nojs input[type ^="submit"] {
- border-width: 0;
- font-size: 9pt;
- padding: 3px 5px;
- max-width: 70px;
-}
-div.menu a.current, div.menu a.current:hover, div.menu_nojs a.current, div.menu_nojs a.current:hover {
- color: #FFFFFF;
- background-color: #505050;
-}
-div.menu ul {
- display: none;
- position: absolute;
- padding: 0;
- margin: 0;
- background-color: #D0D0D0;
- border: 1px solid #A0A0A0;
- min-width: 120px;
-}
-div.menu_nojs ul {
- display: block;
- clear: both;
-}
-div.menu ul li, div.menu_nojs ul li {
- list-style: none;
-}
-div.menu ul a, div.menu_nojs ul a {
- float: none;
- margin: 0;
-}
-span.menuclear {
- font-size: 1px;
- height: 0px;
- width: 0px;
- clear: left;
- line-height: 0px;
- display: block;
-}
-
-/*
- * Docking Boxes code (for the sidebar editor)
- */
-
-/* group container(s) */
-#sbedit {
- margin: 0;
- padding: 0;
- /* position:relative; /* additional outer containers must also have position:relative */
-}
-/* keyboard navigation tooltip */
-.dbx-tooltip {
- display:block;
- position:absolute;
- margin:36px 0 0 125px;
- width:185px;
- border:1px solid #000;
- background:#ffd;
- color:#000;
- font:normal normal normal 0.85em tahoma, arial, sans-serif;
- padding:2px 4px 3px 5px;
- text-align:left;
- }
-* html .dbx-tooltip { width:195px; }
-
-/* use CSS2 system colors in CSS2 browsers
- but not safari, which doesn't support them */
-*[class="dbx-tooltip"]:lang(en) {
- border-color:InfoText;
- background:InfoBackground;
- color:InfoText;
- font:small-caption;
- font-weight:normal;
- }
-/* additional clone styles */
-.dbx-clone {
- opacity: 0.8;
-}
-.dbx-content ul {
- margin: 0; padding: 0;
- list-style: none;
-}
-.dbx-content li a, .dbx-content li a:hover {
- text-decoration: none; color: #666;
-}
-.dbx-content2 {
- margin: 0px 1px 0px 1px;
-}
-
-/* Progress bars */
-div.progressbar {
- padding: 2px;
- background-color: #90A0B0;
- width: 308px;
-}
-div.progressbar_inner {
- min-width: 30px;
- color: white;
- background-color: #7080A0;
- padding: 4px;
-}
-/* User notification - courtest of wikipedia.org (not sure if this is included with MediaWiki) */
-/* user notification thing */
-
-.usermessage {
- background-color: #ffce7b;
- border: 1px solid #ffa500;
- color: black;
- margin: 10px 0 1em;
- padding: .5em 1em;
- vertical-align: middle;
-}
-.usermessage a:link, .usermessage a:active, .usermessage a:visited {
- color: #CA7520;
-}
-.usermessage a:hover {
- color: #AA5500 !important;
-}
-div.thumbnail {
- display: table;
- border: 1px solid #AAAAAA;
- background-color: #F0F0F0;
- padding: 4px;
- margin-bottom: 10px;
- padding-bottom: 0;
-}
-div.thumbnail-inner {
- background-image: url(../../../images/thumbnail.png);
- background-position: top right;
- background-repeat: no-repeat;
-}
-
diff -r 0931d60f5bdb -r 2b2084ca1e60 includes/clientside/static/faders.js~
--- a/includes/clientside/static/faders.js~ Wed Jun 13 16:32:27 2007 -0400
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,393 +0,0 @@
-// Message box system
-
-function darken(nofade)
-{
- if(IE)
- nofade = true;
- if(document.getElementById('specialLayer_darkener'))
- {
- document.getElementById('specialLayer_darkener').style.display = 'block';
- if(nofade)
- {
- document.getElementById('specialLayer_darkener').style.opacity = '0.7';
- document.getElementById('specialLayer_darkener').style.filter = 'alpha(opacity=70)';
- }
- else
- {
- opacity('specialLayer_darkener', 0, 70, 1000);
- }
- } else {
- w = getWidth();
- h = getHeight();
- var thediv = document.createElement('div');
- if(IE)
- thediv.style.position = 'absolute';
- else
- thediv.style.position = 'fixed';
- thediv.style.top = '0px';
- thediv.style.left = '0px';
- thediv.style.opacity = '0';
- thediv.style.filter = 'alpha(opacity=0)';
- thediv.style.backgroundColor = '#000000';
- thediv.style.width = '100%';
- thediv.style.height = '100%';
- thediv.zIndex = getHighestZ() + 5;
- thediv.id = 'specialLayer_darkener';
- if(nofade)
- {
- thediv.style.opacity = '0.7';
- thediv.style.filter = 'alpha(opacity=70)';
- body = document.getElementsByTagName('body');
- body = body[0];
- body.appendChild(thediv);
- } else {
- body = document.getElementsByTagName('body');
- body = body[0];
- body.appendChild(thediv);
- opacity('specialLayer_darkener', 0, 70, 1000);
- }
- }
-}
-
-function enlighten(nofade)
-{
- if(IE)
- nofade = true;
- if(document.getElementById('specialLayer_darkener'))
- {
- if(nofade)
- {
- document.getElementById('specialLayer_darkener').style.display = 'none';
- }
- opacity('specialLayer_darkener', 70, 0, 1000);
- setTimeout("document.getElementById('specialLayer_darkener').style.display = 'none';", 1000);
- }
-}
-
-/**
- * The ultimate message box framework for Javascript
- * Syntax is (almost) identical to the MessageBox command in NSIS
- * @param int type - a bitfield consisting of the MB_* constants
- * @param string title - the blue text at the top of the window
- * @param string text - HTML for the body of the message box
- * Properties:
- * onclick - an array of functions to be called on button click events
- * NOTE: key names are to be strings, and they must be the value of the input, CaSe-SeNsItIvE
- * onbeforeclick - same as onclick but called before the messagebox div is destroyed
- * Example:
- * var my_message = new messagebox(MB_OK|MB_ICONSTOP, 'Error logging in', 'The username and/or password is incorrect. Please check the username and retype your password');
- * my_message.onclick['OK'] = function() {
- * document.getElementById('password').value = '';
- * };
- * Deps:
- * Modern browser that supports DOM
- * darken() and enlighten() (above)
- * opacity() - required for darken() and enlighten()
- * MB_* constants are defined in enano-lib-basic.js
- */
-
-var mb_current_obj;
-
-function messagebox(type, title, message)
-{
- var y = getScrollOffset();
- if(document.getElementById('messageBox')) return;
- darken(true);
- var master_div = document.createElement('div');
- var mydiv = document.createElement('div');
- mydiv.style.width = '400px';
- mydiv.style.height = '200px';
- w = getWidth();
- h = getHeight();
- //master_div.style.left = (w / 2) - 200+'px';
- //master_div.style.top = (h / 2) + y - 120+'px';
- master_div.style.top = '-10000px';
- master_div.style.position = ( IE ) ? 'absolute' : 'fixed';
- z = getHighestZ(); // document.getElementById('specialLayer_darkener').style.zIndex;
- mydiv.style.zIndex = parseInt(z) + 1;
- mydiv.style.backgroundColor = '#FFFFFF';
- mydiv.style.padding = '10px';
- mydiv.style.marginBottom = '1px';
- mydiv.id = 'messageBox';
- mydiv.style.overflow = 'auto';
-
- var buttondiv = document.createElement('div');
- buttondiv.style.width = '400px';
- w = getWidth();
- h = getHeight();
- // buttondiv.style.left = (w / 2) - 200+'px';
- // buttondiv.style.top = (h / 2) + y + 101+'px';
- // buttondiv.style.position = ( IE ) ? 'absolute' : 'fixed';
- z = getHighestZ(); // document.getElementById('specialLayer_darkener').style.zIndex;
- buttondiv.style.zIndex = parseInt(z) + 1;
- buttondiv.style.backgroundColor = '#C0C0C0';
- buttondiv.style.padding = '10px';
- buttondiv.style.textAlign = 'right';
- buttondiv.style.verticalAlign = 'middle';
- buttondiv.id = 'messageBoxButtons';
-
- this.clickHandler = function() { messagebox_click(this, mb_current_obj); };
-
- if(type & MB_ICONINFORMATION || type & MB_ICONSTOP || type & MB_ICONQUESTION || type & MB_ICONEXCLAMATION || type & MB_ICONLOCK)
- {
- mydiv.style.paddingLeft = '50px';
- mydiv.style.width = '360px';
- mydiv.style.backgroundRepeat = 'no-repeat';
- }
-
- if(type & MB_ICONINFORMATION)
- {
- mydiv.style.backgroundImage = 'url(\''+scriptPath+'/images/info.png\')';
- }
-
- if(type & MB_ICONQUESTION)
- {
- mydiv.style.backgroundImage = 'url(\''+scriptPath+'/images/question.png\')';
- }
-
- if(type & MB_ICONSTOP)
- {
- mydiv.style.backgroundImage = 'url(\''+scriptPath+'/images/error.png\')';
- }
-
- if(type & MB_ICONEXCLAMATION)
- {
- mydiv.style.backgroundImage = 'url(\''+scriptPath+'/images/warning.png\')';
- }
-
- if(type & MB_ICONLOCK)
- {
- mydiv.style.backgroundImage = 'url(\''+scriptPath+'/images/lock.png\')';
- }
-
- if(type & MB_OK)
- {
- btn = document.createElement('input');
- btn.type = 'button';
- btn.value = 'OK';
- btn.onclick = this.clickHandler;
- btn.style.margin = '0 3px';
- buttondiv.appendChild(btn);
- }
-
- if(type & MB_OKCANCEL)
- {
- btn = document.createElement('input');
- btn.type = 'button';
- btn.value = 'OK';
- btn.onclick = this.clickHandler;
- btn.style.margin = '0 3px';
- buttondiv.appendChild(btn);
-
- btn = document.createElement('input');
- btn.type = 'button';
- btn.value = 'Cancel';
- btn.onclick = this.clickHandler;
- btn.style.margin = '0 3px';
- buttondiv.appendChild(btn);
- }
-
- if(type & MB_YESNO)
- {
- btn = document.createElement('input');
- btn.type = 'button';
- btn.value = 'Yes';
- btn.onclick = this.clickHandler;
- btn.style.margin = '0 3px';
- buttondiv.appendChild(btn);
-
- btn = document.createElement('input');
- btn.type = 'button';
- btn.value = 'No';
- btn.onclick = this.clickHandler;
- btn.style.margin = '0 3px';
- buttondiv.appendChild(btn);
- }
-
- if(type & MB_YESNOCANCEL)
- {
- btn = document.createElement('input');
- btn.type = 'button';
- btn.value = 'Yes';
- btn.onclick = this.clickHandler;
- btn.style.margin = '0 3px';
- buttondiv.appendChild(btn);
-
- btn = document.createElement('input');
- btn.type = 'button';
- btn.value = 'No';
- btn.onclick = this.clickHandler;
- btn.style.margin = '0 3px';
- buttondiv.appendChild(btn);
-
- btn = document.createElement('input');
- btn.type = 'button';
- btn.value = 'Cancel';
- btn.onclick = this.clickHandler;
- btn.style.margin = '0 3px';
- buttondiv.appendChild(btn);
- }
-
- heading = document.createElement('h2');
- heading.innerHTML = title;
- heading.style.color = '#50A0D0';
- heading.style.fontFamily = 'trebuchet ms, verdana, arial, helvetica, sans-serif';
- heading.style.fontSize = '12pt';
- heading.style.fontWeight = 'lighter';
- heading.style.textTransform = 'lowercase';
- heading.style.marginTop = '0';
- mydiv.appendChild(heading);
-
- var text = document.createElement('div');
- text.innerHTML = String(message);
- this.text_area = text;
- mydiv.appendChild(text);
-
- this.updateContent = function(text)
- {
- this.text_area.innerHTML = text;
- };
-
- //domObjChangeOpac(0, mydiv);
- //domObjChangeOpac(0, master_div);
-
- body = document.getElementsByTagName('body');
- body = body[0];
- master_div.appendChild(mydiv);
- master_div.appendChild(buttondiv);
-
- body.appendChild(master_div);
-
- setTimeout('mb_runFlyIn();', 100);
-
- this.onclick = new Array();
- this.onbeforeclick = new Array();
- mb_current_obj = this;
-}
-
-function mb_runFlyIn()
-{
- var mydiv = document.getElementById('messageBox');
- var maindiv = mydiv.parentNode;
- fly_in_top(maindiv, true, false);
-}
-
-function messagebox_click(obj, mb)
-{
- val = obj.value;
- if(typeof mb.onbeforeclick[val] == 'function')
- {
- var o = mb.onbeforeclick[val];
- var resp = o();
- if ( resp )
- return false;
- o = false;
- }
-
- var mydiv = document.getElementById('messageBox');
- var maindiv = mydiv.parentNode;
- var to = fly_out_top(maindiv, true, false);
-
- setTimeout("var mbdiv = document.getElementById('messageBox'); mbdiv.parentNode.removeChild(mbdiv.nextSibling); mbdiv.parentNode.removeChild(mbdiv); enlighten(true);", to);
- if(typeof mb.onclick[val] == 'function')
- {
- o = mb.onclick[val];
- o();
- o = false;
- }
-}
-
-function testMessageBox()
-{
- mb = new messagebox(MB_OKCANCEL|MB_ICONINFORMATION, 'Javascripted dynamic message boxes', 'This is soooooo coool, now if only document.createElement() worked in IE!
this is some more text
this is some more text
this is some more text
this is some more text
this is some more text
this is some more text
this is some more text
this is some more text');
- mb.onclick['OK'] = function()
- {
- alert('You clicked OK!');
- }
- mb.onbeforeclick['Cancel'] = function()
- {
- alert('You clicked Cancel!');
- }
-}
-
-// Function to fade classes info-box, warning-box, error-box, etc.
-
-function fadeInfoBoxes()
-{
- var divs = new Array();
- d = document.getElementsByTagName('div');
- j = 0;
- for(var i in d)
- {
- if ( !d[i].tagName )
- continue;
- if(d[i].className=='info-box' || d[i].className=='error-box' || d[i].className=='warning-box' || d[i].className=='question-box')
- {
- divs[j] = d[i];
- j++;
- }
- }
- if(divs.length < 1) return;
- for(i in divs)
- {
- if(!divs[i].id) divs[i].id = 'autofade_'+Math.floor(Math.random() * 100000);
- switch(divs[i].className)
- {
- case 'info-box':
- default:
- from = '#3333FF';
- break;
- case 'error-box':
- from = '#FF3333';
- break;
- case 'warning-box':
- from = '#FFFF33';
- break;
- case 'question-box':
- from = '#33FF33';
- break;
- }
- Fat.fade_element(divs[i].id,30,2000,from,Fat.get_bgcolor(divs[i].id));
- }
-}
-
-// Alpha fades
-
-function opacity(id, opacStart, opacEnd, millisec) {
- //speed for each frame
- var speed = Math.round(millisec / 100);
- var timer = 0;
-
- //determine the direction for the blending, if start and end are the same nothing happens
- if(opacStart > opacEnd) {
- for(i = opacStart; i >= opacEnd; i--) {
- setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
- timer++;
- }
- } else if(opacStart < opacEnd) {
- for(i = opacStart; i <= opacEnd; i++)
- {
- setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
- timer++;
- }
- }
-}
-
-//change the opacity for different browsers
-function changeOpac(opacity, id) {
- var object = document.getElementById(id).style;
- object.opacity = (opacity / 100);
- object.MozOpacity = (opacity / 100);
- object.KhtmlOpacity = (opacity / 100);
- object.filter = "alpha(opacity=" + opacity + ")";
-}
-
-function mb_logout()
-{
- var mb = new messagebox(MB_YESNO|MB_ICONQUESTION, 'Are you sure you want to log out?', 'If you log out, you will no longer be able to access your user preferences, certain areas of this site, and this awesome logout confirmation screen until you login again.
OK, not funny. I\'ll remove the bad humor in Banshee.');
- mb.onclick['Yes'] = function()
- {
- window.location = makeUrlNS('Special', 'Logout/' + title);
- }
-}
-
diff -r 0931d60f5bdb -r 2b2084ca1e60 includes/clientside/static/misc.js~
--- a/includes/clientside/static/misc.js~ Wed Jun 13 16:32:27 2007 -0400
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,563 +0,0 @@
-// Some additional DHTML functions
-
-function fetch_offset(obj) {
- var left_offset = obj.offsetLeft;
- var top_offset = obj.offsetTop;
- while ((obj = obj.offsetParent) != null) {
- left_offset += obj.offsetLeft;
- top_offset += obj.offsetTop;
- }
- return { 'left' : left_offset, 'top' : top_offset };
-}
-
-function fetch_dimensions(o) {
- var w = o.offsetWidth;
- var h = o.offsetHeight;
- return { 'w' : w, 'h' : h };
-}
-
-function findParentForm(o)
-{
- // Not implemented - someone please let me know how to do this, what I need to do is
- // find the first parent
Hacking attempt using PHP $GLOBALS overwrite vulnerability detected, reported to admin
You're worse than this guy! Unless you are this guy...
Powered by Enano and valid XHTML 1.1
- Powered by debugConsole'); -dc_here('common: including files'); -require_once(ENANO_ROOT.'/includes/functions.php'); -require_once(ENANO_ROOT.'/includes/dbal.php'); -require_once(ENANO_ROOT.'/includes/paths.php'); -require_once(ENANO_ROOT.'/includes/sessions.php'); -require_once(ENANO_ROOT.'/includes/template.php'); -require_once(ENANO_ROOT.'/includes/plugins.php'); -require_once(ENANO_ROOT.'/includes/comment.php'); -require_once(ENANO_ROOT.'/includes/wikiformat.php'); -require_once(ENANO_ROOT.'/includes/diff.php'); -require_once(ENANO_ROOT.'/includes/render.php'); -require_once(ENANO_ROOT.'/includes/stats.php'); -require_once(ENANO_ROOT.'/includes/pageutils.php'); -require_once(ENANO_ROOT.'/includes/js-compressor.php'); -require_once(ENANO_ROOT.'/includes/rijndael.php'); -require_once(ENANO_ROOT.'/includes/email.php'); -require_once(ENANO_ROOT.'/includes/search.php'); -require_once(ENANO_ROOT.'/includes/json.php'); -require_once(ENANO_ROOT.'/includes/wikiengine/Tables.php'); - -strip_magic_quotes_gpc(); - -// Enano has five parts: the database abstraction layer (DBAL), the session manager, the path/URL manager, the template engine, and the plugin manager. -// Each part has its own class and a global var; nearly all Enano functions are handled by one of these five components. - -global $db, $session, $paths, $template, $plugins; // Common objects -global $enano_config; // A global used to cache config information without making loads of queries ;-) - // In addition, $enano_config is used to fetch config information if die_semicritical() is called. - -global $email; - -if(!isset($_SERVER['HTTP_HOST'])) grinding_halt('Cannot get hostname', 'Your web browser did not provide the HTTP Host: field. This site requires a modern browser that supports the HTTP 1.1 standard.
'); - -$db = new mysql(); -dc_here('common: calling $db->connect();'); -$db->connect(); // Redirects to install.php if an installation is not detected - -if(strstr(contentPath, '?')) $sep = '&'; -else $sep = '?'; -define('urlSeparator', $sep); -unset($sep); // save 10 bytes of memory... - -// See if any diagnostic actions have been requested -if ( isset($_GET['do']) && $_GET['do'] == 'diag' && isset($_GET['sub']) ) -{ - switch($_GET['sub']) - { - case 'cookie_destroy': - unset($_COOKIE['sid']); - setcookie('sid', '', time()-3600*24, scriptPath); - setcookie('sid', '', time()-3600*24, scriptPath.'/'); - die('Session cookie cleared. Continue'); - break; - } -} - -// Select and fetch the site configuration -dc_here('common: selecting global config data'); -$e = $db->sql_query('SELECT config_name, config_value FROM '.table_prefix.'config;'); -if(!$e) $db->_die('Some critical configuration information could not be selected.'); -else define('ENANO_CONFIG_FETCHED', ''); // Used in die_semicritical to figure out whether to call getConfig() or not - -dc_here('common: fetching $enano_config'); -$enano_config = Array(); -while($r = $db->fetchrow()) -{ - $enano_config[$r['config_name']] = $r['config_value']; -} - -$db->free_result(); - -if(enano_version(false, true) != $version) -{ - grinding_halt('Version mismatch', 'It seems that the Enano release we\'re trying to run ('.$version.') is different from the version specified in your database ('.enano_version().'). Perhaps you need to upgrade?
'); -} - -// Our list of tables included in Enano -$system_table_list = Array( - table_prefix.'categories', - table_prefix.'comments', - table_prefix.'config', - table_prefix.'logs', - table_prefix.'page_text', - table_prefix.'session_keys', - table_prefix.'pages', - table_prefix.'users', - table_prefix.'themes', - table_prefix.'buddies', - table_prefix.'banlist', - table_prefix.'files', - table_prefix.'privmsgs', - table_prefix.'sidebar', - table_prefix.'hits', - table_prefix.'search_index', - table_prefix.'groups', - table_prefix.'group_members', - table_prefix.'acl', - table_prefix.'search_cache' - ); - -dc_here('common: initializing base classes'); -$plugins = new pluginLoader(); - -// So where does the majority of Enano get executed? How about the next nine lines of code :) -dc_here('common: ok, we\'re set up, starting mainstream execution'); - -$plugins->loadAll(); -dc_here('common: loading plugins'); - global $plugins; - foreach($plugins->load_list as $f) { include_once $f; } // Can't be in object context when this is done - -$session = new sessionManager(); -$paths = new pathManager(); -$template = new template(); -$email = new EmailEncryptor(); - -define('ENANO_BASE_CLASSES_INITIALIZED', ''); - -$code = $plugins->setHook('base_classes_initted'); -foreach ( $code as $cmd ) -{ - eval($cmd); -} - -$p = RenderMan::strToPageId($paths->get_pageid_from_url()); -if( ( $p[1] == 'Admin' || $p[1] == 'Special' ) && function_exists('page_'.$p[1].'_'.$p[0].'_preloader')) -{ - @call_user_func('page_'.$p[1].'_'.$p[0].'_preloader'); -} - -$session->start(); -$paths->init(); - -define('ENANO_MAINSTREAM', ''); - -// If the site is disabled, bail out, unless we're trying to log in or administer the site -if(getConfig('site_disabled') == '1') -{ - if ( $paths->namespace == 'Admin' || ( $paths->namespace == 'Special' && ( $paths->cpage['urlname_nons'] == 'CSS' || $paths->cpage['urlname_nons'] == 'Administration' || $paths->cpage['urlname_nons'] == 'Login' ) ) ) - { - // do nothing; allow execution to continue - } - else - { - if(!$n = getConfig('site_disabled_notice')) $n = 'The administrator has disabled the site. Please check back later.'; - - $text = RenderMan::render($n) . ' -' . $message . '
If you are not redirected within ' . ( $timeout + 1 ) . ' seconds, please click here.
'; - $template->footer(true); - - $db->close(); - exit(0); - -} - -// Removed wikiFormat() from here, replaced with RenderMan::render - -function isPage($p) { - global $db, $session, $paths, $template, $plugins; // Common objects - if(isset($paths->pages[$p])) return true; - $d = RenderMan::strToPageID($p); - if($d[1] != 'Special' && $d[1] != 'Template' && $d[1] != 'Admin') return false; - $a = explode('/', $p); - if(isset($paths->pages[$a[0]])) return true; - else return false; -} - -function arrayItemUp($arr, $keyname) { - $keylist = array_keys($arr); - $keyflop = array_flip($keylist); - $idx = $keyflop[$keyname]; - $idxm = $idx - 1; - $temp = $arr[$keylist[$idxm]]; - if($arr[$keylist[0]] == $arr[$keyname]) return $arr; - $arr[$keylist[$idxm]] = $arr[$keylist[$idx]]; - $arr[$keylist[$idx]] = $temp; - return $arr; -} - -function arrayItemDown($arr, $keyname) { - $keylist = array_keys($arr); - $keyflop = array_flip($keylist); - $idx = $keyflop[$keyname]; - $idxm = $idx + 1; - $temp = $arr[$keylist[$idxm]]; - $sz = sizeof($arr); $sz--; - if($arr[$keylist[$sz]] == $arr[$keyname]) return $arr; - $arr[$keylist[$idxm]] = $arr[$keylist[$idx]]; - $arr[$keylist[$idx]] = $temp; - return $arr; -} - -function arrayItemTop($arr, $keyname) { - $keylist = array_keys($arr); - $keyflop = array_flip($keylist); - $idx = $keyflop[$keyname]; - while( $orig != $arr[$keylist[0]] ) { - // echo 'Keyname: '.$keylist[$idx] . ''; - print_r($arr); - echo '
'; - print_r($arr); - echo '
There are no subcategories in this category.
'; - echo ''.$paths->pages[$paths->nslist[$row['namespace']].$row['page_id']]['name'].' | '; - if($ticker==2) echo '
There are no pages in this category.
'; - echo ''.$paths->pages[$paths->nslist[$row['namespace']].$row['page_id']]['name'].' | '; - if($ticker==2) echo '
There are no files uploaded with this name yet. Upload a file...
Type: '.$r['mimetype'].'
Size: ';
- $fs = $r['size'];
- echo $fs.' bytes';
- $fs = (int)$fs;
- if($fs >= 1048576)
- {
- $fs = round($fs / 1048576, 1);
- echo ' ('.$fs.' MB)';
- } elseif($fs >= 1024) {
- $fs = round($fs / 1024, 1);
- echo ' ('.$fs.' KB)';
- }
- echo '
Uploaded: '.$datestring.'
Download this file'; - if(!$paths->page_protected && ( $paths->wiki_mode || $session->get_permissions('upload_new_version') )) - { - echo ' | Upload new version'; - } - echo '
'; - if($db->numrows() > 1) - { - echo '';
- while($r = $db->fetchrow())
- {
- echo '(this ver) ';
- if($session->get_permissions('history_rollback'))
- echo ' (revert) ';
- $mimetype = $r['mimetype'];
- $datestring = date('F d, Y h:i a', (int)$r['time_id']);
- echo $datestring.': '.$r['mimetype'].', ';
- $fs = $r['size'];
- $fs = (int)$fs;
- if($fs >= 1048576)
- {
- $fs = round($fs / 1048576, 1);
- echo ' '.$fs.' MB';
- } elseif($fs >= 1024) {
- $fs = round($fs / 1024, 1);
- echo ' '.$fs.' KB';
- } else {
- echo ' '.$fs.' bytes';
- }
- echo '
';
- }
- echo '
You must supply a password to access this page.
'; - - $cont = ob_get_contents(); - ob_end_clean(); - return Array($cont, $_ob); - } - - /** - * Saves category information - * WARNING: If $which_cats is empty, all the category information for the selected page will be nuked! - * @param $page_id string the page ID - * @param $namespace string the namespace - * @param $which_cats array associative array of categories to put the page in - * @return string "GOOD" on success, error string on failure - */ - - function catsave($page_id, $namespace, $which_cats) - { - global $db, $session, $paths, $template, $plugins; // Common objects - if(!$session->get_permissions('edit_cat')) return('Insufficient privileges to change category information'); - - $page_perms = $session->fetch_page_acl($page_id, $namespace); - $page_data =& $paths->pages[$paths->nslist[$namespace].$page_id]; - - $cat_all = Array(); - for($i=0;$iComparing revisions: {$time1} → {$time2}
- "; - // Free some memory - unset($row1, $row2, $q1, $q2); - - $_ob .= RenderMan::diff($text1, $text2); - return $_ob; - } - - /** - * Gets ACL information about the selected page for target type X and target ID Y. - * @param string $page_id The page ID - * @param string $namespace The namespace - * @param array $parms What to select. This is an array purely for JSON compatibility. It should be an associative array with keys target_type and target_id. - * @return array - */ - - function acl_editor($parms = Array()) - { - global $db, $session, $paths, $template, $plugins; // Common objects - if(!$session->get_permissions('edit_acl') && $session->user_level < USER_LEVEL_ADMIN) - return 'Access is denied.'; - $parms['page_id'] = ( isset($parms['page_id']) ) ? $parms['page_id'] : false; - $parms['namespace'] = ( isset($parms['namespace']) ) ? $parms['namespace'] : false; - $page_id =& $parms['page_id']; - $namespace =& $parms['namespace']; - $page_where_clause = ( empty($page_id) || empty($namespace) ) ? 'AND a.page_id IS NULL AND a.namespace IS NULL' : 'AND a.page_id=\''.$db->escape($page_id).'\' AND a.namespace=\''.$db->escape($namespace).'\''; - $page_where_clause_lite = ( empty($page_id) || empty($namespace) ) ? 'AND page_id IS NULL AND namespace IS NULL' : 'AND page_id=\''.$db->escape($page_id).'\' AND namespace=\''.$db->escape($namespace).'\''; - //die(print_r($page_id,true)); - $template->load_theme(); - // $perms_obj = $session->fetch_page_acl($page_id, $namespace); - $perms_obj =& $session; - $return = Array(); - if ( !file_exists(ENANO_ROOT . '/themes/' . $session->theme . '/acledit.tpl') ) - { - return Array( - 'mode' => 'error', - 'error' => 'It seems that (a) the file acledit.tpl is missing from these theme, and (b) the JSON response is working.', - ); - } - $return['template'] = $template->extract_vars('acledit.tpl'); - $return['page_id'] = $page_id; - $return['namespace'] = $namespace; - if(isset($parms['mode'])) - { - switch($parms['mode']) - { - case 'listgroups': - $return['groups'] = Array(); - $q = $db->sql_query('SELECT group_id,group_name FROM '.table_prefix.'groups ORDER BY group_name ASC;'); - while($row = $db->fetchrow()) - { - $return['groups'][] = Array( - 'id' => $row['group_id'], - 'name' => $row['group_name'], - ); - } - $db->free_result(); - break; - case 'seltarget': - $return['mode'] = 'seltarget'; - $return['acl_types'] = $perms_obj->acl_types; - $return['acl_deps'] = $perms_obj->acl_deps; - $return['acl_descs'] = $perms_obj->acl_descs; - $return['target_type'] = $parms['target_type']; - $return['target_id'] = $parms['target_id']; - switch($parms['target_type']) - { - case ACL_TYPE_USER: - $q = $db->sql_query('SELECT a.rules,u.user_id FROM '.table_prefix.'users AS u - LEFT JOIN '.table_prefix.'acl AS a - ON a.target_id=u.user_id - WHERE a.target_type='.ACL_TYPE_USER.' - AND u.username=\''.$db->escape($parms['target_id']).'\' - '.$page_where_clause.';'); - if(!$q) - return(Array('mode'=>'error','error'=>mysql_error())); - if($db->numrows() < 1) - { - $return['type'] = 'new'; - $q = $db->sql_query('SELECT user_id FROM '.table_prefix.'users WHERE username=\''.$db->escape($parms['target_id']).'\';'); - if(!$q) - return(Array('mode'=>'error','error'=>mysql_error())); - if($db->numrows() < 1) - return Array('mode'=>'error','error'=>'The username you entered was not found.'); - $row = $db->fetchrow(); - $return['target_name'] = $return['target_id']; - $return['target_id'] = intval($row['user_id']); - $return['current_perms'] = $session->acl_types; - } - else - { - $return['type'] = 'edit'; - $row = $db->fetchrow(); - $return['target_name'] = $return['target_id']; - $return['target_id'] = intval($row['user_id']); - $return['current_perms'] = $session->acl_merge($perms_obj->acl_types, $session->string_to_perm($row['rules'])); - } - $db->free_result(); - // Eliminate types that don't apply to this namespace - if ( $namespace ) - { - foreach ( $return['current_perms'] AS $i => $perm ) - { - if ( ( $page_id != null && $namespace != null ) && ( !in_array ( $namespace, $session->acl_scope[$i] ) && !in_array('All', $session->acl_scope[$i]) ) ) - { - // echo "// SCOPE CONTROL: eliminating: $i\n"; - unset($return['current_perms'][$i]); - unset($return['acl_types'][$i]); - unset($return['acl_descs'][$i]); - unset($return['acl_deps'][$i]); - } - } - } - break; - case ACL_TYPE_GROUP: - $q = $db->sql_query('SELECT a.rules,g.group_name,g.group_id FROM '.table_prefix.'groups AS g - LEFT JOIN '.table_prefix.'acl AS a - ON a.target_id=g.group_id - WHERE a.target_type='.ACL_TYPE_GROUP.' - AND g.group_id=\''.intval($parms['target_id']).'\' - '.$page_where_clause.';'); - if(!$q) - return(Array('mode'=>'error','error'=>mysql_error())); - if($db->numrows() < 1) - { - $return['type'] = 'new'; - $q = $db->sql_query('SELECT group_id,group_name FROM '.table_prefix.'groups WHERE group_id=\''.intval($parms['target_id']).'\';'); - if(!$q) - return(Array('mode'=>'error','error'=>mysql_error())); - if($db->numrows() < 1) - return Array('mode'=>'error','error'=>'The group ID you submitted is not valid.'); - $row = $db->fetchrow(); - $return['target_name'] = $row['group_name']; - $return['target_id'] = intval($row['group_id']); - $return['current_perms'] = $session->acl_types; - } - else - { - $return['type'] = 'edit'; - $row = $db->fetchrow(); - $return['target_name'] = $row['group_name']; - $return['target_id'] = intval($row['group_id']); - $return['current_perms'] = $session->acl_merge($session->acl_types, $session->string_to_perm($row['rules'])); - } - $db->free_result(); - // Eliminate types that don't apply to this namespace - if ( $namespace ) - { - foreach ( $return['current_perms'] AS $i => $perm ) - { - if ( ( $page_id != false && $namespace != false ) && ( !in_array ( $namespace, $session->acl_scope[$i] ) && !in_array('All', $session->acl_scope[$i]) ) ) - { - // echo "// SCOPE CONTROL: eliminating: $i\n"; //; ".print_r($namespace,true).":".print_r($page_id,true)."\n"; - unset($return['current_perms'][$i]); - unset($return['acl_types'][$i]); - unset($return['acl_descs'][$i]); - unset($return['acl_deps'][$i]); - } - } - } - //return Array('mode'=>'debug','text'=>print_r($return, true)); - break; - default: - return Array('mode'=>'error','error','Invalid ACL type ID'); - break; - } - return $return; - break; - case 'save_new': - case 'save_edit': - $q = $db->sql_query('DELETE FROM '.table_prefix.'acl WHERE target_type='.intval($parms['target_type']).' AND target_id='.intval($parms['target_id']).' - '.$page_where_clause_lite.';'); - if(!$q) - return Array('mode'=>'error','error'=>mysql_error()); - $rules = $session->perm_to_string($parms['perms']); - if ( sizeof ( $rules ) < 1 ) - { - return array( - 'mode' => 'error', - 'error' => 'Supplied rule list has a length of zero' - ); - } - $q = ($page_id && $namespace) ? 'INSERT INTO '.table_prefix.'acl ( target_type, target_id, page_id, namespace, rules ) - VALUES( '.intval($parms['target_type']).', '.intval($parms['target_id']).', \''.$db->escape($page_id).'\', \''.$db->escape($namespace).'\', \''.$db->escape($rules).'\' )' : - 'INSERT INTO '.table_prefix.'acl ( target_type, target_id, rules ) - VALUES( '.intval($parms['target_type']).', '.intval($parms['target_id']).', \''.$db->escape($rules).'\' )'; - if(!$db->sql_query($q)) return Array('mode'=>'error','error'=>mysql_error()); - return Array( - 'mode' => 'success', - 'target_type' => $parms['target_type'], - 'target_id' => $parms['target_id'], - 'target_name' => $parms['target_name'], - 'page_id' => $page_id, - 'namespace' => $namespace, - ); - break; - case 'delete': - $q = $db->sql_query('DELETE FROM '.table_prefix.'acl WHERE target_type='.intval($parms['target_type']).' AND target_id='.intval($parms['target_id']).' - '.$page_where_clause_lite.';'); - if(!$q) - return Array('mode'=>'error','error'=>mysql_error()); - return Array( - 'mode' => 'delete', - 'target_type' => $parms['target_type'], - 'target_id' => $parms['target_id'], - 'target_name' => $parms['target_name'], - 'page_id' => $page_id, - 'namespace' => $namespace, - ); - break; - default: - return Array('mode'=>'error','error'=>'Hacking attempt'); - break; - } - } - return $return; - } - - /** - * Same as PageUtils::acl_editor(), but the parms are a JSON string instead of an array. This also returns a JSON string. - * @param string $parms Same as PageUtils::acl_editor/$parms, but should be a valid JSON string. - * @return string - */ - - function acl_json($parms = '{ }') - { - global $db, $session, $paths, $template, $plugins; // Common objects - $json = new Services_JSON(SERVICES_JSON_LOOSE_TYPE); - $parms = $json->decode($parms); - $ret = PageUtils::acl_editor($parms); - $ret = $json->encode($ret); - return $ret; - } - - /** - * A non-Javascript frontend for the ACL API. - * @param array The request data, if any, this should be in the format required by PageUtils::acl_editor() - */ - - function aclmanager($parms) - { - global $db, $session, $paths, $template, $plugins; // Common objects - ob_start(); - // Convenience - $formstart = '' . htmlspecialchars(print_r($response, true)) . ''); - - switch($response['mode']) - { - case 'debug': - echo '
' . htmlspecialchars($response['text']) . ''; - break; - case 'stage1': - echo '
Please select who should be affected by this access rule.
'; - echo $formstart; - echo ' - - -' . $template->username_field('data[target_id_user]') . '
-What should this access rule control?
- - -Error returned by permissions API:
' . htmlspecialchars($response['error']) . ''); - break; - } - $ret = ob_get_contents(); - ob_end_clean(); - echo - $template->getHeader() . - $ret . - $template->getFooter(); - } - - /** - * Preprocessor to turn the form-submitted data from the ACL editor into something the backend can handle - * @param array The posted data - * @return array - * @access private - */ - - function acl_preprocess($parms) - { - if ( !isset($parms['mode']) ) - // Nothing to do - return $parms; - switch ( $parms['mode'] ) - { - case 'seltarget': - - // Who's affected? - $parms['target_type'] = intval( $parms['target_type'] ); - $parms['target_id'] = ( $parms['target_type'] == ACL_TYPE_GROUP ) ? $parms['target_id_grp'] : $parms['target_id_user']; - - case 'save_edit': - case 'save_new': - if ( isset($parms['act_delete_rule']) ) - { - $parms['mode'] = 'delete'; - } - - // Scope (just this page or entire site?) - if ( $parms['scope'] == 'entire_site' || ( $parms['page_id'] == 'false' && $parms['namespace'] == 'false' ) ) - { - $parms['page_id'] = false; - $parms['namespace'] = false; - } - - break; - } - - if ( isset($parms['act_go_stage1']) ) - { - $parms = array( - 'mode' => 'listgroups' - ); - } - - return $parms; - } - - function acl_postprocess($response) - { - if(!isset($response['mode'])) - { - if ( isset($response['groups']) ) - $response['mode'] = 'stage1'; - else - $response = Array( - 'mode' => 'error', - 'error' => 'Invalid action passed by API backend.', - ); - } - return $response; - } - -} - -?> diff -r 0931d60f5bdb -r 2b2084ca1e60 includes/paths.php~ --- a/includes/paths.php~ Wed Jun 13 16:32:27 2007 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,808 +0,0 @@ -pages = Array(); - - dc_here('paths: setting up namespaces, admin nodes'); - - // DEFINE NAMESPACES HERE - // The key names should NOT EVER be changed, or Enano will be very broken - $this->nslist = Array( - 'Article' =>'', - 'User' =>'User:', - 'File' =>'File:', - 'Help' =>'Help:', - 'Admin' =>'Admin:', - 'Special' =>'Special:', - 'System' =>'Enano:', - 'Template'=>'Template:', - 'Category'=>'Category:', - 'Project' =>str_replace(' ', '_', getConfig('site_name')).':', - ); - - // ACL types - // Note: you can set any of these to AUTH_DENY to universally and unconditionally deny access to the selected action. - // These can also be added from within plugins - - $session->register_acl_type('read', AUTH_ALLOW, 'Read page(s)'); - $session->register_acl_type('post_comments', AUTH_ALLOW, 'Post comments', Array('read'), 'Article|User|Project|Template|File|Help|System|Category'); - $session->register_acl_type('edit_comments', AUTH_ALLOW, 'Edit own comments', Array('post_comments'), 'Article|User|Project|Template|File|Help|System|Category'); - $session->register_acl_type('edit_page', AUTH_WIKIMODE, 'Edit page', Array('view_source'), 'Article|User|Project|Template|File|Help|System|Category'); - $session->register_acl_type('view_source', AUTH_WIKIMODE, 'View source', Array('read'), 'Article|User|Project|Template|File|Help|System|Category'); // Only used if the page is protected - $session->register_acl_type('mod_comments', AUTH_DISALLOW, 'Moderate comments', Array('edit_comments'), 'Article|User|Project|Template|File|Help|System|Category'); - $session->register_acl_type('history_view', AUTH_WIKIMODE, 'View history/diffs', Array('read'), 'Article|User|Project|Template|File|Help|System|Category'); - $session->register_acl_type('history_rollback', AUTH_DISALLOW, 'Rollback history', Array('history_view'), 'Article|User|Project|Template|File|Help|System|Category'); - $session->register_acl_type('history_rollback_extra', AUTH_DISALLOW, 'Undelete page(s)', Array('history_rollback'), 'Article|User|Project|Template|File|Help|System|Category'); - $session->register_acl_type('protect', AUTH_DISALLOW, 'Protect page(s)', Array('read'), 'Article|User|Project|Template|File|Help|System|Category'); - $session->register_acl_type('rename', AUTH_WIKIMODE, 'Rename page(s)', Array('read'), 'Article|User|Project|Template|File|Help|System|Category'); - $session->register_acl_type('clear_logs', AUTH_DISALLOW, 'Clear page logs (dangerous)', Array('read', 'protect', 'even_when_protected'), 'Article|User|Project|Template|File|Help|System|Category'); - $session->register_acl_type('vote_delete', AUTH_ALLOW, 'Vote to delete', Array('read'), 'Article|User|Project|Template|File|Help|System|Category'); - $session->register_acl_type('vote_reset', AUTH_DISALLOW, 'Reset delete votes', Array('read'), 'Article|User|Project|Template|File|Help|System|Category'); - $session->register_acl_type('delete_page', AUTH_DISALLOW, 'Delete page(s)', Array(), 'Article|User|Project|Template|File|Help|System|Category'); - $session->register_acl_type('set_wiki_mode', AUTH_DISALLOW, 'Set per-page wiki mode', Array('read'), 'Article|User|Project|Template|File|Help|System|Category'); - $session->register_acl_type('password_set', AUTH_DISALLOW, 'Set password', Array('read'), 'Article|User|Project|Template|File|Help|System|Category'); - $session->register_acl_type('password_reset', AUTH_DISALLOW, 'Disable/reset password', Array('read'), 'Article|User|Project|Template|File|Help|System|Category'); - $session->register_acl_type('mod_misc', AUTH_DISALLOW, 'Super moderator (generate SQL backtraces, view IP addresses, and send large numbers of private messages)', Array(), 'All'); - $session->register_acl_type('edit_cat', AUTH_WIKIMODE, 'Edit categorization', Array('read'), 'Article|User|Project|Template|File|Help|System|Category'); - $session->register_acl_type('even_when_protected', AUTH_DISALLOW, 'Allow editing, renaming, and categorization even when protected', Array('edit_page', 'rename', 'mod_comments', 'edit_cat'), 'Article|User|Project|Template|File|Help|System|Category'); - $session->register_acl_type('upload_files', AUTH_DISALLOW, 'Upload files', Array('create_page'), 'Article|User|Project|Template|File|Help|System|Category|Special'); - $session->register_acl_type('upload_new_version', AUTH_WIKIMODE, 'Upload new versions of files', Array('upload_files'), 'Article|User|Project|Template|File|Help|System|Category|Special'); - $session->register_acl_type('create_page', AUTH_WIKIMODE, 'Create pages', Array(), 'Article|User|Project|Template|File|Help|System|Category|Special'); - $session->register_acl_type('php_in_pages', AUTH_DISALLOW, 'Embed PHP code in pages', Array('edit_page'), 'Article|User|Project|Template|File|Help|System|Category'); - $session->register_acl_type('edit_acl', AUTH_DISALLOW, 'Edit access control lists', Array('read', 'post_comments', 'edit_comments', 'edit_page', 'view_source', 'mod_comments', 'history_view', 'history_rollback', 'history_rollback_extra', 'protect', 'rename', 'clear_logs', 'vote_delete', 'vote_reset', 'delete_page', 'set_wiki_mode', 'password_set', 'password_reset', 'mod_misc', 'edit_cat', 'even_when_protected', 'upload_files', 'upload_new_version', 'create_page', 'php_in_pages')); - - // DO NOT add new admin pages here! Use a plugin to call $paths->addAdminNode(); - $this->addAdminNode('General', 'General Configuration', 'GeneralConfig'); - $this->addAdminNode('General', 'File uploads', 'UploadConfig'); - $this->addAdminNode('General', 'Allowed file types', 'UploadAllowedMimeTypes'); - $this->addAdminNode('General', 'Manage Plugins', 'PluginManager'); - $this->addAdminNode('General', 'Backup database', 'DBBackup'); - $this->addAdminNode('Content', 'Manage Pages', 'PageManager'); - $this->addAdminNode('Content', 'Edit page content', 'PageEditor'); - $this->addAdminNode('Appearance', 'Manage themes', 'ThemeManager'); - $this->addAdminNode('Users', 'Manage users', 'UserManager'); - $this->addAdminNode('Users', 'Edit groups', 'GroupManager'); - $this->addAdminNode('Users', 'Ban control', 'BanControl'); - $this->addAdminNode('Users', 'Mass e-mail', 'MassEmail'); - - $code = $plugins->setHook('acl_rule_init'); - foreach ( $code as $cmd ) - { - eval($cmd); - } - - $this->wiki_mode = (int)getConfig('wiki_mode')=='1'; - $this->template_cache = Array(); - } - function pathManager() - { - $this->__construct(); - } - function init() - { - global $db, $session, $paths, $template, $plugins; // Common objects - - dc_here('paths: selecting master page data'); - - $code = $plugins->setHook('paths_init_before'); - foreach ( $code as $cmd ) - { - eval($cmd); - } - - $e = $db->sql_query('SELECT name,urlname,namespace,special,visible,comments_on,protected,delvotes,delvote_ips,wiki_mode,password FROM '.table_prefix.'pages ORDER BY name;'); - if( !$e ) - { - $db->_die('The error seems to have occured while selecting the page information. File: includes/paths.php; line: '.__LINE__); - } - while($r = $db->fetchrow()) - { - - $r['urlname_nons'] = $r['urlname']; - $r['urlname'] = $this->nslist[$r['namespace']] . $r['urlname']; // Applies the User:/File:/etc prefixes to the URL names - - if ( $r['delvotes'] == null) - { - $r['delvotes'] = 0; - } - if ( $r['protected'] == 0 || $r['protected'] == 1 ) - { - $r['really_protected'] = (int)$r['protected']; - } - else if ( $r['protected'] == 2 && getConfig('wiki_mode') == '1') - { - $r['really_protected'] = 1; - } - else if ( $r['protected'] == 2 && getConfig('wiki_mode') == '0' ) - { - $r['really_protected'] = 0; - } - - $this->pages[$r['urlname']] = $r; - $this->pages[] =& $this->pages[$r['urlname']]; - - } - $db->free_result(); - dc_here('paths: determining page ID'); - if( isset($_GET['title']) ) - { - if ( $_GET['title'] == '' && getConfig('main_page') != '' ) - { - $this->main_page(); - } - if(strstr($_GET['title'], ' ')) - { - $loc = urldecode(rawurldecode($_SERVER['REQUEST_URI'])); - $loc = str_replace(' ', '_', $loc); - $loc = str_replace('+', '_', $loc); - $loc = str_replace('%20', '_', $loc); - redirect($loc, 'Redirecting...', 'Space detected in the URL, please wait whilst you are redirected', 0); - exit; - } - $url_namespace_special = substr($_GET['title'], 0, strlen($this->nslist['Special']) ); - $url_namespace_template = substr($_GET['title'], 0, strlen($this->nslist['Template']) ); - if($url_namespace_special == $this->nslist['Special'] || $url_namespace_template == $this->nslist['Template'] ) - { - $ex = explode('/', $_GET['title']); - $this->page = $ex[0]; - } - else - { - $this->page = $_GET['title']; - } - $this->fullpage = $_GET['title']; - } - elseif( isset($_SERVER['PATH_INFO']) ) - { - $pi = explode('/', $_SERVER['PATH_INFO']); - - if( !isset($pi[1]) || (isset($pi[1]) && $pi[1] == '' && getConfig('main_page') != '') ) - { - $this->main_page(); - } - if( strstr($pi[1], ' ') ) - { - $loc = str_replace(' ', '_', urldecode(rawurldecode($_SERVER['REQUEST_URI']))); - $loc = str_replace('+', '_', $loc); - $loc = str_replace('%20', '_', $loc); - redirect($loc, 'Redirecting...', 'Please wait whilst you are redirected', 3); - exit; - } - unset($pi[0]); - if( substr($pi[1], 0, strlen($this->nslist['Special'])) == $this->nslist['Special'] || substr($pi[1], 0, strlen($this->nslist['Template'])) == $this->nslist['Template'] ) - { - $pi2 = $pi[1]; - } - else - { - $pi2 = implode('/', $pi); - } - $this->page = $pi2; - $this->fullpage = implode('/', $pi); - } - else - { - $k = array_keys($_GET); - foreach($k as $c) - { - if(substr($c, 0, 1) == '/') - { - $this->page = substr($c, 1, strlen($c)); - - // Bugfix for apache somehow passing dots as underscores - global $mime_types; - $exts = array_keys($mime_types); - $exts = '(' . implode('|', $exts) . ')'; - if ( preg_match( '#_'.$exts.'#i', $this->page ) ) - $this->page = preg_replace( '#_'.$exts.'#i', '.\\1', $this->page ); - - $this->fullpage = $this->page; - - if(substr($this->page, 0, strlen($this->nslist['Special']))==$this->nslist['Special'] || substr($this->page, 0, strlen($this->nslist['Template']))==$this->nslist['Template']) - { - $ex = explode('/', $this->page); - $this->page = $ex[0]; - } - if(strstr($this->page, ' ')) - { - $loc = str_replace(' ', '_', urldecode(rawurldecode($_SERVER['REQUEST_URI']))); - $loc = str_replace('+', '_', $loc); - $loc = str_replace('%20', '_', $loc); - redirect($loc, 'Redirecting...', 'Space in the URL detected, please wait whilst you are redirected', 0); - exit; - } - break; - } - } - if(!$this->page && !($this->page == '' && getConfig('main_page') == '')) - { - $this->main_page(); - } - } - - dc_here('paths: setting $paths->cpage'); - - if(isset($this->pages[$this->page])) - { - dc_here('paths: page existence verified, our page ID is: '.$this->page); - $this->page_exists = true; - $this->cpage = $this->pages[$this->page]; - $this->namespace = $this->cpage['namespace']; - if(!isset($this->cpage['wiki_mode'])) $this->cpage['wiki_mode'] = 2; - - // Determine the wiki mode for this page, now that we have this->cpage established - if($this->cpage['wiki_mode'] == 2) - { - $this->wiki_mode = (int)getConfig('wiki_mode'); - } - else - { - $this->wiki_mode = $this->cpage['wiki_mode']; - } - // Allow the user to create/modify his user page uncondtionally (admins can still protect the page) - if($this->page == $this->nslist['User'].str_replace(' ', '_', $session->username)) - { - $this->wiki_mode = true; - } - // And above all, if the site requires wiki mode to be off for non-logged-in users, disable it now - if(getConfig('wiki_mode_require_login')=='1' && !$session->user_logged_in) - { - $this->wiki_mode = false; - } - if($this->cpage['protected'] == 2) - { - // The page is semi-protected, determine permissions - if($session->user_logged_in && $session->reg_time + 60*60*24*4 < time()) - { - $this->page_protected = 0; - } - else - { - $this->page_protected = 1; - } - } - else - { - $this->page_protected = $this->cpage['protected']; - } - } - else - { - dc_here('paths: page doesn\'t exist, creating new page in memory
'.print_r($search->index, true).''; - // return; - $q = $db->sql_query('DELETE FROM '.table_prefix.'search_index'); - if(!$q) return false; - $secs = Array(); - $q = 'INSERT INTO '.table_prefix.'search_index(word,page_names) VALUES'; - foreach($search->index as $word => $pages) - { - $secs[] = '(\''.$db->escape($word).'\', \''.$db->escape($pages).'\')'; - } - $q .= implode(',', $secs); - unset($secs); - $q .= ';'; - $result = $db->sql_query($q); - $db->free_result(); - if($result) - return true; - else - $db->_die('The search index was trying to rebuild itself when the error occured.'); - } - - /** - * Partially rebuilds the search index, removing/inserting entries only for the current page - * @param string $page_id - * @param string $namespace - */ - - function rebuild_page_index($page_id, $namespace) - { - global $db, $session, $paths, $template, $plugins; // Common objects - if(!$db->sql_query('SELECT page_text FROM '.table_prefix.'page_text - WHERE page_id=\''.$db->escape($page_id).'\' AND namespace=\''.$db->escape($namespace).'\';')) - { - return $db->get_error(); - } - $row = $db->fetchrow(); - $db->free_result(); - $search = new Searcher(); - $search->buildIndex(Array("ns={$namespace};pid={$page_id}"=>$row['page_text'])); - $new_index = $search->index; - - $keys = array_keys($search->index); - foreach($keys as $i => $k) - { - $c =& $keys[$i]; - $c = hexencode($c, '', ''); - } - $keys = "word=0x" . implode ( " OR word=0x", $keys ) . ""; - - // Zap the cache - $cache = array_keys($search->index); - if ( count($cache) < 1 ) - { - return false; - } - $cache = "query LIKE '%" . implode ( "%' OR query LIKE '%", $cache ) . "%'"; - $db->sql_query('DELETE FROM '.table_prefix.'search_cache WHERE '.$cache); - - $query = $db->sql_query('SELECT word,page_names FROM '.table_prefix.'search_index WHERE '.$keys.';'); - - while($row = $db->fetchrow()) - { - $row['word'] = rtrim($row['word'], "\0"); - $new_index[ $row['word'] ] = $row['page_names'] . ',' . $search->index[ $row['word'] ]; - } - $db->free_result(); - - $db->sql_query('DELETE FROM '.table_prefix.'search_index WHERE '.$keys.';'); - - $secs = Array(); - $q = 'INSERT INTO '.table_prefix.'search_index(word,page_names) VALUES'; - foreach($new_index as $word => $pages) - { - $secs[] = '(\''.$db->escape($word).'\', \''.$db->escape($pages).'\')'; - } - $q .= implode(',', $secs); - unset($secs); - $q .= ';'; - if(!$db->check_query($q)) - { - die('BUG: PathManager::rebuild_page_index: Query rejected by SQL parser:
'.$q.''); - } - $result = $db->sql_query($q); - if($result) - return true; - else - $db->_die('The search index was trying to rebuild itself when the error occured.'); - - } - - /** - * Creates an instance of the Searcher class, including index info - * @return object - */ - - function makeSearcher($match_case = false) - { - global $db, $session, $paths, $template, $plugins; // Common objects - $search = new Searcher(); - $q = $db->sql_query('SELECT word,page_names FROM '.table_prefix.'search_index;'); - if(!$q) - { - echo $db->get_error(); - return false; - } - $idx = Array(); - while($row = $db->fetchrow($q)) - { - $row['word'] = rtrim($row['word'], "\0"); - $idx[$row['word']] = $row['page_names']; - } - $db->free_result(); - $search->index = $idx; - if($match_case) - $search->match_case = true; - return $search; - } - - /** - * Creates an associative array filled with the values of all the page titles - * @return array - */ - - function get_page_titles() - { - $texts = Array(); - for ( $i = 0; $i < sizeof($this->pages) / 2; $i++ ) - { - $texts[$this->pages[$i]['urlname']] = $this->pages[$i]['name']; - } - return $texts; - } - - /** - * Creates an instance of the Searcher class, including index info for page titles - * @return object - */ - - function makeTitleSearcher($match_case = false) - { - global $db, $session, $paths, $template, $plugins; // Common objects - $search = new Searcher(); - $texts = $this->get_page_titles(); - $search->buildIndex($texts); - if($match_case) - $search->match_case = true; - return $search; - } - -} - -?> diff -r 0931d60f5bdb -r 2b2084ca1e60 includes/render.php~ --- a/includes/render.php~ Wed Jun 13 16:32:27 2007 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,792 +0,0 @@ -nslist); - for($i=0;$i
'.print_r($paths->cpage,true).''); - - dc_here('render: wreckin\' $template, and reloading the theme vars to match the new page
This page is a redirector. This means that this page will not show its own content by default. Instead it will display the contents of the page it redirects to. To create a redirect page, make the first characters in the page content #redirect [[Page_ID]]. For more information, see the Enano Wiki formatting guide. This page redirects to '.$paths->pages[$m[1]]['name'].'. |
'.print_r($nowiki,true).''; - - for($i=0;$i
'.htmlspecialchars($message).''; - - $j = preg_match_all('#\[\[:'.$paths->nslist['File'].'([\w\s0-9_\(\)!@%\^\+\|\.-]+?)\|([0-9]+)\|([0-9]+)\]\]#is', $message, $matchlist); - $matches = Array(); - $matches['images'] = $matchlist[1]; - $matches['widths'] = $matchlist[2]; - $matches['heights'] = $matchlist[3]; - for($i=0;$i
'.htmlspecialchars($message2).''; - //$message = str_replace(array('
([\s]*?)<\/p>#is', '', $result);
- $result = preg_replace('#
([\s]*?)
'.print_r($linklist, true).''; - for($i=0;$i
- $text = '{{Template
- parm1 = Foo
- parm2 = Bar
- }}';
- $text = include_templates($text);
- *
- */
-
- function include_templates($text)
- {
- global $db, $session, $paths, $template, $plugins; // Common objects
- $template_regex = "/\{\{([A-z0-9_-]+?)((\n([ ]*?)[A-z0-9]+([ ]*?)=([ ]*?)(.+?))*)\}\}/is";
- if ( $count = preg_match_all($template_regex, $text, $matches) )
- {
- for ( $i = 0; $i < $count; $i++ )
- {
- $parmsection = trim($matches[2][$i]);
- if ( !empty($parmsection) )
- {
- $parms = parse_template_vars($parmsection);
- foreach ( $parms as $j => $parm )
- {
- $parms[$j] = $parm;
- }
- }
- else
- {
- $parms = Array();
- }
- if ( $tpl_code = RenderMan::fetch_template_text($matches[1][$i]) )
- {
- $parser = $template->makeParserText($tpl_code);
- $parser->assign_vars($parms);
- $text = str_replace($matches[0][$i], $parser->run(), $text);
- }
- }
- }
- return $text;
- }
-
- /**
- * Preprocesses an HTML text string prior to being sent to MySQL.
- * @param string $text
- * @param bool $strip_all_php - if true, strips all PHP regardless of user permissions. Else, strips PHP only if user level < USER_LEVEL_ADMIN.
- */
- function preprocess_text($text, $strip_all_php = true, $sqlescape = true)
- {
- global $db, $session, $paths, $template, $plugins; // Common objects
- $random_id = md5( time() . mt_rand() );
-
- $can_do_php = ( $session->get_permissions('php_in_pages') && !$strip_all_php );
-
- $text = sanitize_html($text, ( !$can_do_php ));
-
- if ( !$can_do_php )
- {
- // If we can't do PHP, we can't do Javascript either.
- $text = RenderMan::destroy_javascript($text);
- }
-
- // Strip out '.htmlspecialchars(print_r($phpsec, true))."\n".htmlspecialchars(print_r($text, true)).''); - - for($i=0;$i
'.htmlspecialchars($text).''; - $nw = preg_match_all('#
No private key was found in the config file, and we can\'t generate one because we don\'t have write access to the config file. Please CHMOD config.php to 666 or 777 and reload this page.
'); - } - } - // Check for compatibility mode - if(defined('IN_ENANO_INSTALL')) - { - $q = $db->sql_query('SELECT old_encryption FROM '.table_prefix.'users LIMIT 1;'); - if(!$q) - { - $error = mysql_error(); - if(strstr($error, "Unknown column 'old_encryption'")) - $this->compat = true; - else - $db->_die('This should never happen and is a bug - the only error that was supposed to happen here didn\'t happen. (sessions.php in constructor, during compat mode check)'); - } - $db->free_result(); - } - } - - /** - * PHP 4 compatible constructor. - */ - - function sessionManager() - { - $this->__construct(); - } - - /** - * Wrapper function to sanitize strings for MySQL and HTML - * @param string $text The text to sanitize - * @return string - */ - - function prepare_text($text) - { - global $db; - return $db->escape(htmlspecialchars($text)); - } - - /** - * Makes a SQL query and handles error checking - * @param string $query The SQL query to make - * @return resource - */ - - function sql($query) - { - global $db, $session, $paths, $template, $plugins; // Common objects - $result = $db->sql_query($query); - if(!$result) - { - $db->_die('The error seems to have occurred somewhere in the session management code.'); - } - return $result; - } - - # Session restoration and permissions - - /** - * Initializes the basic state of things, including most user prefs, login data, cookie stuff - */ - - function start() - { - global $db, $session, $paths, $template, $plugins; // Common objects - if($this->started) return; - $this->started = true; - $user = false; - if(isset($_COOKIE['sid'])) - { - if($this->compat) - { - $userdata = $this->compat_validate_session($_COOKIE['sid']); - } - else - { - $userdata = $this->validate_session($_COOKIE['sid']); - } - if(is_array($userdata)) - { - $data = RenderMan::strToPageID($paths->get_pageid_from_url()); - - if(!$this->compat && $userdata['account_active'] != 1 && $data[1] != 'Special' && $data[1] != 'Admin') - { - $this->logout(); - $a = getConfig('account_activation'); - switch($a) - { - case 'none': - default: - $solution = 'Your account was most likely deactivated by an administrator. Please contact the site administration for further assistance.'; - break; - case 'user': - $solution = 'Please check your e-mail; you should have been sent a message with instructions on how to activate your account. If you do not receive an e-mail from this site within 24 hours, please contact the site administration for further assistance.'; - break; - case 'admin': - $solution = 'This website has been configured so that all user accounts must be activated by the administrator before they can be used, so your account will most likely be activated the next time the one of the administrators visits the site.'; - break; - } - die_semicritical('Account error', 'It appears that your user account has not yet been activated. '.$solution.'
'); - } - - $this->sid = $_COOKIE['sid']; - $this->user_logged_in = true; - $this->user_id = intval($userdata['user_id']); - $this->username = $userdata['username']; - $this->password_hash = $userdata['password']; - $this->user_level = intval($userdata['user_level']); - $this->real_name = $userdata['real_name']; - $this->email = $userdata['email']; - $this->unread_pms = $userdata['num_pms']; - if(!$this->compat) - { - $this->theme = $userdata['theme']; - $this->style = $userdata['style']; - $this->signature = $userdata['signature']; - $this->reg_time = $userdata['reg_time']; - } - // Small security risk here - it allows someone who has already authenticated as an administrator to store the "super" key in - // the cookie. Change this to USER_LEVEL_MEMBER to override that. The same 15-minute restriction applies to this "exploit". - $this->auth_level = $userdata['auth_level']; - if(!isset($template->named_theme_list[$this->theme])) - { - if($this->compat || !is_object($template)) - { - $this->theme = 'oxygen'; - $this->style = 'bleu'; - } - else - { - $this->theme = $template->default_theme; - $this->style = $template->default_style; - } - } - $user = true; - - if(isset($_REQUEST['auth']) && !$this->sid_super) - { - // Now he thinks he's a moderator. Or maybe even an administrator. Let's find out if he's telling the truth. - if($this->compat) - { - $key = $_REQUEST['auth']; - $super = $this->compat_validate_session($key); - } - else - { - $key = strrev($_REQUEST['auth']); - $super = $this->validate_session($key); - } - if(is_array($super)) - { - $this->auth_level = intval($super['auth_level']); - $this->sid_super = $_REQUEST['auth']; - } - } - } - } - if(!$user) - { - //exit; - $this->register_guest_session(); - } - if(!$this->compat) - { - // init groups - $q = $this->sql('SELECT g.group_name,g.group_id,m.is_mod FROM '.table_prefix.'groups AS g - LEFT JOIN '.table_prefix.'group_members AS m - ON g.group_id=m.group_id - WHERE ( m.user_id='.$this->user_id.' - OR g.group_name=\'Everyone\') - ' . ( enano_version() == '1.0RC1' ? '' : 'AND ( m.pending != 1 OR m.pending IS NULL )' ) . ' - ORDER BY group_id ASC;'); // Make sure "Everyone" comes first so the permissions can be overridden - if($row = $db->fetchrow()) - { - do { - $this->groups[$row['group_id']] = $row['group_name']; - $this->group_mod[$row['group_id']] = ( intval($row['is_mod']) == 1 ); - } while($row = $db->fetchrow()); - } - else - { - die('No group info'); - } - } - $this->check_banlist(); - - if ( isset ( $_GET['printable'] ) ) - { - $this->theme = 'printable'; - $this->style = 'default'; - } - - } - - # Logins - - /** - * Attempts to perform a login using crypto functions - * @param string $username The username - * @param string $aes_data The encrypted password, hex-encoded - * @param string $aes_key The MD5 hash of the encryption key, hex-encoded - * @param string $challenge The 256-bit MD5 challenge string - first 128 bits should be the hash, the last 128 should be the challenge salt - * @param int $level The privilege level we're authenticating for, defaults to 0 - * @return string 'success' on success, or error string on failure - */ - - function login_with_crypto($username, $aes_data, $aes_key, $challenge, $level = USER_LEVEL_MEMBER) - { - global $db, $session, $paths, $template, $plugins; // Common objects - - $privcache = $this->private_key; - - // Instanciate the Rijndael encryption object - $aes = new AESCrypt(AES_BITS, AES_BLOCKSIZE); - - // Fetch our decryption key - - $aes_key = $this->fetch_public_key($aes_key); - if(!$aes_key) - return 'Couldn\'t look up public key "'.$aes_key.'" for decryption'; - - // Convert the key to a binary string - $bin_key = hexdecode($aes_key); - - if(strlen($bin_key) != AES_BITS / 8) - return 'The decryption key is the wrong length'; - - // Decrypt our password - $password = $aes->decrypt($aes_data, $bin_key, ENC_HEX); - - // Initialize our success switch - $success = false; - - // Select the user data from the table, and decrypt that so we can verify the password - $this->sql('SELECT password,old_encryption,user_id,user_level,theme,style,temp_password,temp_password_time FROM '.table_prefix.'users WHERE lcase(username)=\''.$this->prepare_text(strtolower($username)).'\';'); - if($db->numrows() < 1) - return 'The username and/or password is incorrect.'; - $row = $db->fetchrow(); - - // Check to see if we're logging in using a temporary password - - if((intval($row['temp_password_time']) + 3600*24) > time() ) - { - $temp_pass = $aes->decrypt( $row['temp_password'], $this->private_key, ENC_HEX ); - if( $temp_pass == $password ) - { - $url = makeUrlComplete('Special', 'PasswordReset/stage2/' . $row['user_id'] . '/' . $row['temp_password']); - redirect($url, 'Login sucessful', 'Please wait while you are transferred to the Password Reset form.'); - exit; - } - } - - if($row['old_encryption'] == 1) - { - // The user's password is stored using the obsolete and insecure MD5 algorithm, so we'll update the field with the new password - if(md5($password) == $row['password']) - { - $pass_stashed = $aes->encrypt($password, $this->private_key, ENC_HEX); - $this->sql('UPDATE '.table_prefix.'users SET password=\''.$pass_stashed.'\',old_encryption=0 WHERE user_id='.$row['user_id'].';'); - $success = true; - } - } - else - { - // Our password field is up-to-date with the >=1.0RC1 encryption standards, so decrypt the password in the table and see if we have a match; if so then do challenge authentication - $real_pass = $aes->decrypt(hexdecode($row['password']), $this->private_key, ENC_BINARY); - if($password == $real_pass) - { - // Yay! We passed AES authentication, now do an MD5 challenge check to make sure we weren't spoofed - $chal = substr($challenge, 0, 32); - $salt = substr($challenge, 32, 32); - $correct_challenge = md5( $real_pass . $salt ); - if($chal == $correct_challenge) - $success = true; - } - } - if($success) - { - if($level > $row['user_level']) - return 'You are not authorized for this level of access.'; - - $sess = $this->register_session(intval($row['user_id']), $username, $password, $level); - if($sess) - { - $this->username = $username; - $this->user_id = intval($row['user_id']); - $this->theme = $row['theme']; - $this->style = $row['style']; - - if($level > USER_LEVEL_MEMBER) - $this->sql('INSERT INTO '.table_prefix.'logs(log_type,action,time_id,date_string,author,edit_summary,page_text) VALUES(\'security\', \'admin_auth_good\', '.time().', \''.date('d M Y h:i a').'\', \''.$db->escape($username).'\', \''.$db->escape($_SERVER['REMOTE_ADDR']).'\', ' . intval($level) . ')'); - else - $this->sql('INSERT INTO '.table_prefix.'logs(log_type,action,time_id,date_string,author,edit_summary) VALUES(\'security\', \'auth_good\', '.time().', \''.date('d M Y h:i a').'\', \''.$db->escape($username).'\', \''.$db->escape($_SERVER['REMOTE_ADDR']).'\')'); - - $code = $plugins->setHook('login_success'); - foreach ( $code as $cmd ) - { - eval($cmd); - } - return 'success'; - } - else - return 'Your login credentials were correct, but an internal error occurred while registering the session key in the database.'; - } - else - { - if($level > USER_LEVEL_MEMBER) - $this->sql('INSERT INTO '.table_prefix.'logs(log_type,action,time_id,date_string,author,edit_summary,page_text) VALUES(\'security\', \'admin_auth_bad\', '.time().', \''.date('d M Y h:i a').'\', \''.$db->escape($username).'\', \''.$db->escape($_SERVER['REMOTE_ADDR']).'\', ' . intval($level) . ')'); - else - $this->sql('INSERT INTO '.table_prefix.'logs(log_type,action,time_id,date_string,author,edit_summary) VALUES(\'security\', \'auth_bad\', '.time().', \''.date('d M Y h:i a').'\', \''.$db->escape($username).'\', \''.$db->escape($_SERVER['REMOTE_ADDR']).'\')'); - - return 'The username and/or password is incorrect.'; - } - } - - /** - * Attempts to login without using crypto stuff, mainly for use when the other side doesn't like Javascript - * This method of authentication is inherently insecure, there's really nothing we can do about it except hope and pray that everyone moves to Firefox - * Technically it still uses crypto, but it only decrypts the password already stored, which is (obviously) required for authentication - * @param string $username The username - * @param string $password The password -OR- the MD5 hash of the password if $already_md5ed is true - * @param bool $already_md5ed This should be set to true if $password is an MD5 hash, and should be false if it's plaintext. Defaults to false. - * @param int $level The privilege level we're authenticating for, defaults to 0 - */ - - function login_without_crypto($username, $password, $already_md5ed = false, $level = USER_LEVEL_MEMBER) - { - global $db, $session, $paths, $template, $plugins; // Common objects - - $pass_hashed = ( $already_md5ed ) ? $password : md5($password); - - // Perhaps we're upgrading Enano? - if($this->compat) - { - return $this->login_compat($username, $pass_hashed, $level); - } - - // Instanciate the Rijndael encryption object - $aes = new AESCrypt(AES_BITS, AES_BLOCKSIZE); - - // Initialize our success switch - $success = false; - - // Retrieve the real password from the database - $this->sql('SELECT password,old_encryption,user_id,user_level,temp_password,temp_password_time FROM '.table_prefix.'users WHERE lcase(username)=\''.$this->prepare_text(strtolower($username)).'\';'); - if($db->numrows() < 1) - return 'The username and/or password is incorrect.'; - $row = $db->fetchrow(); - - // Check to see if we're logging in using a temporary password - - if((intval($row['temp_password_time']) + 3600*24) > time() ) - { - $temp_pass = $aes->decrypt( $row['temp_password'], $this->private_key, ENC_HEX ); - if( md5($temp_pass) == $pass_hashed ) - { - header('Location: ' . makeUrlComplete('Special', 'PasswordReset/stage2/' . $row['user_id'] . '/' . $row['temp_password']) ); - exit; - } - } - - if($row['old_encryption'] == 1) - { - // The user's password is stored using the obsolete and insecure MD5 algorithm - we'll update the field with the new password - if($pass_hashed == $row['password'] && !$already_md5ed) - { - $pass_stashed = $aes->encrypt($password, $this->private_key, ENC_HEX); - $this->sql('UPDATE '.table_prefix.'users SET password=\''.$pass_stashed.'\',old_encryption=0 WHERE user_id='.$row['user_id'].';'); - $success = true; - } - elseif($pass_hashed == $row['password'] && $already_md5ed) - { - // We don't have the real password so don't bother with encrypting it, just call it success and get out of here - $success = true; - } - } - else - { - // Our password field is up-to-date with the >=1.0RC1 encryption standards, so decrypt the password in the table and see if we have a match - $real_pass = $aes->decrypt($row['password'], $this->private_key); - if($pass_hashed == md5($real_pass)) - { - $success = true; - } - } - if($success) - { - if((int)$level > (int)$row['user_level']) - return 'You are not authorized for this level of access.'; - $sess = $this->register_session(intval($row['user_id']), $username, $real_pass, $level); - if($sess) - { - if($level > USER_LEVEL_MEMBER) - $this->sql('INSERT INTO '.table_prefix.'logs(log_type,action,time_id,date_string,author,edit_summary,page_text) VALUES(\'security\', \'admin_auth_good\', '.time().', \''.date('d M Y h:i a').'\', \''.$db->escape($username).'\', \''.$db->escape($_SERVER['REMOTE_ADDR']).'\', ' . intval($level) . ')'); - else - $this->sql('INSERT INTO '.table_prefix.'logs(log_type,action,time_id,date_string,author,edit_summary) VALUES(\'security\', \'auth_good\', '.time().', \''.date('d M Y h:i a').'\', \''.$db->escape($username).'\', \''.$db->escape($_SERVER['REMOTE_ADDR']).'\')'); - - $code = $plugins->setHook('login_success'); - foreach ( $code as $cmd ) - { - eval($cmd); - } - return 'success'; - } - else - return 'Your login credentials were correct, but an internal error occured while registering the session key in the database.'; - } - else - { - if($level > USER_LEVEL_MEMBER) - $this->sql('INSERT INTO '.table_prefix.'logs(log_type,action,time_id,date_string,author,edit_summary,page_text) VALUES(\'security\', \'admin_auth_bad\', '.time().', \''.date('d M Y h:i a').'\', \''.$db->escape($username).'\', \''.$db->escape($_SERVER['REMOTE_ADDR']).'\', ' . intval($level) . ')'); - else - $this->sql('INSERT INTO '.table_prefix.'logs(log_type,action,time_id,date_string,author,edit_summary) VALUES(\'security\', \'auth_bad\', '.time().', \''.date('d M Y h:i a').'\', \''.$db->escape($username).'\', \''.$db->escape($_SERVER['REMOTE_ADDR']).'\')'); - - return 'The username and/or password is incorrect.'; - } - } - - /** - * Attempts to log in using the old table structure and algorithm. - * @param string $username - * @param string $password This should be an MD5 hash - * @return string 'success' if successful, or error message on failure - */ - - function login_compat($username, $password, $level = 0) - { - global $db, $session, $paths, $template, $plugins; // Common objects - $pass_hashed =& $password; - $this->sql('SELECT password,user_id,user_level FROM '.table_prefix.'users WHERE username=\''.$this->prepare_text($username).'\';'); - if($db->numrows() < 1) - return 'The username and/or password is incorrect.'; - $row = $db->fetchrow(); - if($row['password'] == $password) - { - if((int)$level > (int)$row['user_level']) - return 'You are not authorized for this level of access.'; - $sess = $this->register_session_compat(intval($row['user_id']), $username, $password, $level); - if($sess) - return 'success'; - else - return 'Your login credentials were correct, but an internal error occured while registering the session key in the database.'; - } - else - { - return 'The username and/or password is incorrect.'; - } - } - - /** - * Registers a session key in the database. This function *ASSUMES* that the username and password have already been validated! - * Basically the session key is a base64-encoded cookie (encrypted with the site's private key) that says "u=[username];p=[sha1 of password]" - * @param int $user_id - * @param string $username - * @param string $password - * @param int $level The level of access to grant, defaults to USER_LEVEL_MEMBER - * @return bool - */ - - function register_session($user_id, $username, $password, $level = USER_LEVEL_MEMBER) - { - $salt = md5(microtime() . mt_rand()); - $passha1 = sha1($password); - $session_key = "u=$username;p=$passha1;s=$salt"; - $aes = new AESCrypt(AES_BITS, AES_BLOCKSIZE); - $session_key = $aes->encrypt($session_key, $this->private_key, ENC_HEX); - if($level > USER_LEVEL_MEMBER) - { - $hexkey = strrev($session_key); - $this->sid_super = $hexkey; - $_GET['auth'] = $hexkey; - } - else - { - setcookie( 'sid', $session_key, time()+315360000, scriptPath.'/' ); - $_COOKIE['sid'] = $session_key; - } - $keyhash = md5($session_key); - $ip = ip2hex($_SERVER['REMOTE_ADDR']); - if(!$ip) - die('$session->register_session: Remote-Addr was spoofed'); - $time = time(); - if(!is_int($user_id)) - die('Somehow an SQL injection attempt crawled into our session registrar! (1)'); - if(!is_int($level)) - die('Somehow an SQL injection attempt crawled into our session registrar! (2)'); - - $query = $this->sql('INSERT INTO '.table_prefix.'session_keys(session_key, salt, user_id, auth_level, source_ip, time) VALUES(\''.$keyhash.'\', \''.$salt.'\', '.$user_id.', '.$level.', \''.$ip.'\', '.$time.');'); - return true; - } - - /** - * Identical to register_session in nature, but uses the old login/table structure. DO NOT use this. - * @see sessionManager::register_session() - * @access private - */ - - function register_session_compat($user_id, $username, $password, $level = 0) - { - $salt = md5(microtime() . mt_rand()); - $thekey = md5($password . $salt); - if($level > 0) - { - $this->sid_super = $thekey; - } - else - { - setcookie( 'sid', $thekey, time()+315360000, scriptPath.'/' ); - $_COOKIE['sid'] = $thekey; - } - $ip = ip2hex($_SERVER['REMOTE_ADDR']); - if(!$ip) - die('$session->register_session: Remote-Addr was spoofed'); - $time = time(); - if(!is_int($user_id)) - die('Somehow an SQL injection attempt crawled into our session registrar! (1)'); - if(!is_int($level)) - die('Somehow an SQL injection attempt crawled into our session registrar! (2)'); - $query = $this->sql('INSERT INTO '.table_prefix.'session_keys(session_key, salt, user_id, auth_level, source_ip, time) VALUES(\''.$thekey.'\', \''.$salt.'\', '.$user_id.', '.$level.', \''.$ip.'\', '.$time.');'); - return true; - } - - /** - * Creates/restores a guest session - * @todo implement real session management for guests - */ - - function register_guest_session() - { - global $db, $session, $paths, $template, $plugins; // Common objects - $this->username = $_SERVER['REMOTE_ADDR']; - $this->user_level = USER_LEVEL_GUEST; - if($this->compat || defined('IN_ENANO_INSTALL')) - { - $this->theme = 'oxygen'; - $this->style = 'bleu'; - } - else - { - $this->theme = ( isset($_GET['theme']) && isset($template->named_theme_list[$_GET['theme']])) ? $_GET['theme'] : $template->default_theme; - $this->style = ( isset($_GET['style']) && file_exists(ENANO_ROOT.'/themes/'.$this->theme . '/css/'.$_GET['style'].'.css' )) ? $_GET['style'] : substr($template->named_theme_list[$this->theme]['default_style'], 0, strlen($template->named_theme_list[$this->theme]['default_style'])-4); - } - $this->user_id = 1; - } - - /** - * Validates a session key, and returns the userdata associated with the key or false - * @param string $key The session key to validate - * @return array Keys are 'user_id', 'username', 'email', 'real_name', 'user_level', 'theme', 'style', 'signature', 'reg_time', 'account_active', 'activation_key', and 'auth_level' or bool false if validation failed. The key 'auth_level' is the maximum authorization level that this key provides. - */ - - function validate_session($key) - { - global $db, $session, $paths, $template, $plugins; // Common objects - $aes = new AESCrypt(AES_BITS, AES_BLOCKSIZE, true); - $decrypted_key = $aes->decrypt($key, $this->private_key, ENC_HEX); - - if ( !$decrypted_key ) - { - die_semicritical('AES encryption error', 'Something went wrong during the AES decryption process.
'.print_r($decrypted_key, true).''); - } - - $n = preg_match('/^u='.$this->valid_username.';p=([A-Fa-f0-9]+?);s=([A-Fa-f0-9]+?)$/', $decrypted_key, $keydata); - if($n < 1) - { - // echo '(debug) $session->validate_session: Key does not match regex
'.print_r($keydata, true).''); - if(sha1($real_pass) != $keydata[2]) - { - // Failed password check - // echo '(debug) $session->validate_session: encrypted password is wrong
'.print_r($keydata, true).''); - if($real_key != $key) - { - // Failed password check - // echo '(debug) $session->validate_session: supplied password is wrong
'.print_r($deps, true).''); - foreach($deps as $d) - { - if ( !$this->get_permissions($d) ) - { - return false; - } - } - return true; - } - - /** - * Makes a CAPTCHA code and caches the code in the database - * @param int $len The length of the code, in bytes - * @return string A unique identifier assigned to the code. This hash should be passed to sessionManager::getCaptcha() to retrieve the code. - */ - - function make_captcha($len = 7) - { - $chars = array('A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '1', '2', '3', '4', '5', '6', '7', '8', '9'); - $s = ''; - for($i=0;$i<$len;$i++) $s .= $chars[mt_rand(0, count($chars)-1)]; - $hash = md5(microtime() . mt_rand()); - $this->sql('INSERT INTO '.table_prefix.'session_keys(session_key,salt,auth_level,source_ip,user_id) VALUES(\''.$hash.'\', \''.$s.'\', -1, \''.ip2hex($_SERVER['REMOTE_ADDR']).'\', -2);'); - return $hash; - } - - /** - * For the given code ID, returns the correct CAPTCHA code, or false on failure - * @param string $hash The unique ID assigned to the code - * @return string The correct confirmation code - */ - - function get_captcha($hash) - { - global $db, $session, $paths, $template, $plugins; // Common objects - $s = $this->sql('SELECT salt FROM '.table_prefix.'session_keys WHERE session_key=\''.$db->escape($hash).'\' AND source_ip=\''.ip2hex($_SERVER['REMOTE_ADDR']).'\';'); - if($db->numrows() < 1) return false; - $r = $db->fetchrow(); - return $r['salt']; - } - - /** - * Deletes all CAPTCHA codes cached in the DB for this user. - */ - - function kill_captcha() - { - $this->sql('DELETE FROM '.table_prefix.'session_keys WHERE user_id=-2 AND source_ip=\''.ip2hex($_SERVER['REMOTE_ADDR']).'\';'); - } - - /** - * Generates a random password. - * @param int $length Optional - length of password - * @return string - */ - - function random_pass($length = 10) - { - $valid_chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_+@#%&<>'; - $valid_chars = enano_str_split($valid_chars); - $ret = ''; - for ( $i = 0; $i < $length; $i++ ) - { - $ret .= $valid_chars[mt_rand(0, count($valid_chars)-1)]; - } - return $ret; - } - - /** - * Generates some Javascript that calls the AES encryption library. - * @param string The name of the form - * @param string The name of the password field - * @param string The name of the field that switches encryption on or off - * @param string The name of the field that contains the encryption key - * @param string The name of the field that will contain the encrypted password - * @param string The name of the field that handles MD5 challenge data - * @return string - */ - - function aes_javascript($form_name, $pw_field, $use_crypt, $crypt_key, $crypt_data, $challenge) - { - $code = ' - - '; - return $code; - } - -} - -/** - * Class used to fetch permissions for a specific page. Used internally by SessionManager. - * @package Enano - * @subpackage Session manager - * @license http://www.gnu.org/copyleft/gpl.html - * @access private - */ - -class Session_ACLPageInfo { - - /** - * The page ID of this ACL info package - * @var string - */ - - var $page_id; - - /** - * The namespace of the page being checked - * @var string - */ - - var $namespace; - - /** - * Our list of permission types. - * @access private - * @var array - */ - - var $acl_types = Array(); - - /** - * The list of descriptions for the permission types - * @var array - */ - - var $acl_descs = Array(); - - /** - * A list of dependencies for ACL types. - * @var array - */ - - var $acl_deps = Array(); - - /** - * Our tell-all list of permissions. - * @access private - or, preferably, protected...too bad this has to be PHP4 compatible - * @var array - */ - - var $perms = Array(); - - /** - * Constructor. - * @param string $page_id The ID of the page to check - * @param string $namespace The namespace of the page to check. - * @param array $acl_types List of ACL types - * @param array $acl_descs List of human-readable descriptions for permissions (associative) - * @param array $acl_deps List of dependencies for permissions. For example, viewing history/diffs depends on the ability to read the page. - * @param array $base What to start with - this is an attempt to reduce the number of SQL queries. - */ - - function Session_ACLPageInfo($page_id, $namespace, $acl_types, $acl_descs, $acl_deps, $base) - { - global $db, $session, $paths, $template, $plugins; // Common objects - - $this->perms = $session->acl_merge_complete($acl_types, $base); - $this->acl_deps = $acl_deps; - $this->acl_types = $acl_types; - $this->acl_descs = $acl_descs; - - // Build a query to grab ACL info - $bs = 'SELECT rules FROM '.table_prefix.'acl WHERE ( '; - $q = Array(); - $q[] = '( target_type='.ACL_TYPE_USER.' AND target_id='.$session->user_id.' )'; - if(count($session->groups) > 0) - { - foreach($session->groups as $g_id => $g_name) - { - $q[] = '( target_type='.ACL_TYPE_GROUP.' AND target_id='.intval($g_id).' )'; - } - } - // The reason we're using an ORDER BY statement here is because ACL_TYPE_GROUP is less than ACL_TYPE_USER, causing the user's individual - // permissions to override group permissions. - $bs .= implode(' OR ', $q) . ' ) AND ( page_id=\''.$db->escape($page_id).'\' AND namespace=\''.$db->escape($namespace).'\' ) - ORDER BY target_type ASC, page_id ASC, namespace ASC;'; - $q = $session->sql($bs); - if ( $row = $db->fetchrow() ) - { - do { - $rules = $session->string_to_perm($row['rules']); - $this->perms = $session->acl_merge($this->perms, $rules); - } while ( $row = $db->fetchrow() ); - } - - $this->page_id = $page_id; - $this->namespace = $namespace; - } - - /** - * Tells us whether permission $type is allowed or not based on the current rules. - * @param string $type The permission identifier ($acl_type passed to sessionManager::register_acl_type()) - * @param bool $no_deps If true, disables dependency checking - * @return bool True if allowed, false if denied or if an error occured - */ - - function get_permissions($type, $no_deps = false) - { - global $db, $session, $paths, $template, $plugins; // Common objects - if ( isset( $this->perms[$type] ) ) - { - if ( $this->perms[$type] == AUTH_DENY ) - $ret = false; - else if ( $this->perms[$type] == AUTH_WIKIMODE && - ( isset($paths->pages[$paths->nslist[$this->namespace].$this->page_id]) && - ( $paths->pages[$paths->nslist[$this->namespace].$this->page_id]['wiki_mode'] == '1' || - ( $paths->pages[$paths->nslist[$this->namespace].$this->page_id]['wiki_mode'] == '2' - && getConfig('wiki_mode') == '1' - ) ) ) ) - $ret = true; - else if ( $this->perms[$type] == AUTH_WIKIMODE && ( - !isset($paths->pages[$paths->nslist[$this->namespace].$this->page_id]) - || ( - isset($paths->pages[$paths->nslist[$this->namespace].$this->page_id]) && ( - $paths->pages[$paths->nslist[$this->namespace].$this->page_id]['wiki_mode'] == '0' - || ( - $paths->pages[$paths->nslist[$this->namespace].$this->page_id]['wiki_mode'] == '2' && getConfig('wiki_mode') != '1' - ) ) ) ) ) - $ret = false; - else if ( $this->perms[$type] == AUTH_ALLOW ) - $ret = true; - else if ( $this->perms[$type] == AUTH_DISALLOW ) - $ret = false; - } - else if(isset($this->acl_types[$type])) - { - if ( $this->acl_types[$type] == AUTH_DENY ) - $ret = false; - else if ( $this->acl_types[$type] == AUTH_WIKIMODE && $paths->wiki_mode ) - $ret = true; - else if ( $this->acl_types[$type] == AUTH_WIKIMODE && !$paths->wiki_mode ) - $ret = false; - else if ( $this->acl_types[$type] == AUTH_ALLOW ) - $ret = true; - else if ( $this->acl_types[$type] == AUTH_DISALLOW ) - $ret = false; - } - else - { - // ACL type is undefined - trigger_error('Unknown access type "' . $type . '"', E_USER_WARNING); - return false; // Be on the safe side and deny access - } - if ( !$no_deps ) - { - if ( !$this->acl_check_deps($type) ) - return false; - } - return $ret; - } - - /** - * Tell us if the dependencies for a given permission are met. - * @param string The ACL permission ID - * @return bool - */ - - function acl_check_deps($type) - { - if(!isset($this->acl_deps[$type])) // This will only happen if the permissions table is hacked or improperly accessed - return true; - if(sizeof($this->acl_deps[$type]) < 1) - return true; - $deps = $this->acl_deps[$type]; - while(true) - { - $full_resolved = true; - $j = sizeof($deps); - for ( $i = 0; $i < $j; $i++ ) - { - $b = $deps; - $deps = array_merge($deps, $this->acl_deps[$deps[$i]]); - if( $b == $deps ) - { - break 2; - } - $j = sizeof($deps); - } - } - //die('
'.print_r($deps, true).''); - foreach($deps as $d) - { - if ( !$this->get_permissions($d) ) - { - return false; - } - } - return true; - } - -} - -?> diff -r 0931d60f5bdb -r 2b2084ca1e60 includes/template.php~ --- a/includes/template.php~ Wed Jun 13 16:32:27 2007 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1785 +0,0 @@ -tpl_bool = Array(); - $this->tpl_strings = Array(); - $this->sidebar_extra = ''; - $this->toolbar_menu = ''; - $this->additional_headers = ''; - $this->plugin_blocks = Array(); - $this->theme_loaded = false; - - $this->theme_list = Array(); - $this->named_theme_list = Array(); - $e = $db->sql_query('SELECT theme_id,theme_name,enabled,default_style FROM '.table_prefix.'themes WHERE enabled=1 ORDER BY theme_order;'); - if(!$e) $db->_die('The list of themes could not be selected.'); - for($i=0;$i < $db->numrows(); $i++) - { - $this->theme_list[$i] = $db->fetchrow(); - $this->named_theme_list[$this->theme_list[$i]['theme_id']] = $this->theme_list[$i]; - } - $db->free_result(); - $this->default_theme = $this->theme_list[0]['theme_id']; - $dir = ENANO_ROOT.'/themes/'.$this->default_theme.'/css/'; - $list = Array(); - // Open a known directory, and proceed to read its contents - if (is_dir($dir)) { - if ($dh = opendir($dir)) { - while (($file = readdir($dh)) !== false) { - if(preg_match('#^(.*?)\.css$#i', $file) && $file != '_printable.css') { - $list[] = substr($file, 0, strlen($file)-4); - } - } - closedir($dh); - } - } - - $def = ENANO_ROOT.'/themes/'.$this->default_theme.'/css/'.$this->named_theme_list[$this->default_theme]['default_style']; - if(file_exists($def)) - { - $this->default_style = substr($this->named_theme_list[$this->default_theme]['default_style'], 0, strlen($this->named_theme_list[$this->default_theme]['default_style'])-4); - } else { - $this->default_style = $list[0]; - } - - $this->style_list = $list; - - } - function template() - { - $this->__construct(); - } - function sidebar_widget($t, $h) - { - global $db, $session, $paths, $template, $plugins; // Common objects - if(!defined('ENANO_TEMPLATE_LOADED')) - { - $this->load_theme($session->theme, $session->style); - } - if(!$this->sidebar_widgets) - $this->sidebar_widgets = ''; - $tplvars = $this->extract_vars('elements.tpl'); - $parser = $this->makeParserText($tplvars['sidebar_section_raw']); - $parser->assign_vars(Array('TITLE'=>$t,'CONTENT'=>$h)); - $this->plugin_blocks[$t] = $h; - $this->sidebar_widgets .= $parser->run(); - } - function add_header($html) - { - $this->additional_headers .= "\n" . $html; - } - function get_css($s = false) - { - global $db, $session, $paths, $template, $plugins; // Common objects - if(!defined('ENANO_TEMPLATE_LOADED')) - $this->load_theme($session->theme, $session->style); - $path = ( $s ) ? 'css/'.$s : 'css/'.$this->style.'.css'; - if ( !file_exists(ENANO_ROOT . '/themes/' . $this->theme . '/' . $path) ) - { - echo "/* WARNING: Falling back to default file because file $path does not exist */\n"; - $path = 'css/' . $this->style_list[0] . '.css'; - } - return $this->process_template($path); - } - function load_theme($name = false, $css = false) - { - global $db, $session, $paths, $template, $plugins; // Common objects - $this->theme = ( $name ) ? $name : $session->theme; - $this->style = ( $css ) ? $css : $session->style; - if ( !$this->theme ) - { - $this->theme = $this->theme_list[0]['theme_id']; - $this->style = substr($this->theme_list[0]['default_style'], 0, strlen($this->theme_list[0]['default_style'])-4); - } - $this->theme_loaded = true; - } - - function init_vars() - { - global $db, $session, $paths, $template, $plugins; // Common objects - global $email; - - dc_here("template: initializing all variables"); - - if(!$this->theme || !$this->style) - { - $this->load_theme(); - } - - if(defined('ENANO_TEMPLATE_LOADED')) - { - dc_here('template: access denied to call template::init_vars(), bailing out'); - die_semicritical('Illegal call', '
$template->load_theme was called multiple times, this is not supposed to happen. Exiting with fatal error.
'); - } - - define('ENANO_TEMPLATE_LOADED', ''); - - $tplvars = $this->extract_vars('elements.tpl'); - - dc_here('template: setting all template vars'); - - if(isset($_SERVER['HTTP_USER_AGENT']) && strstr($_SERVER['HTTP_USER_AGENT'], 'MSIE')) - { - $this->add_header(' - - '); - } - - // Get the "article" button text (depends on namespace) - switch($paths->namespace) { - case "Article": - default: - $ns = 'article'; - break; - case "Admin": - $ns = 'administration page'; - break; - case "System": - $ns = 'system message'; - break; - case "File": - $ns = 'uploaded file'; - break; - case "Help": - $ns = 'documentation page'; - break; - case "User": - $ns = 'user page'; - break; - case "Special": - $ns = 'special page'; - break; - case "Template": - $ns = 'template'; - break; - case "Project": - $ns = 'project page'; - break; - case "Category": - $ns = 'category'; - break; - } - $this->namespace_string = $ns; - $code = $plugins->setHook('page_type_string_set'); - foreach ( $code as $cmd ) - { - eval($cmd); - } - $ns =& $this->namespace_string; - - // Initialize the toolbar - $tb = ''; - - // Create "xx page" button - - $btn_selected = ( isset($tplvars['toolbar_button_selected'])) ? $tplvars['toolbar_button_selected'] : $tplvars['toolbar_button']; - $parser = $this->makeParserText($btn_selected); - - $parser->assign_vars(array( - 'FLAGS' => 'onclick="void(ajaxReset()); return false;" title="View the page contents, all of the page contents, and nothing but the page contents (alt-a)" accesskey="a"', - 'PARENTFLAGS' => 'id="mdgToolbar_article"', - 'HREF' => makeUrl($paths->page, null, true), - 'TEXT' => $this->namespace_string - )); - - $tb .= $parser->run(); - - $button = $this->makeParserText($tplvars['toolbar_button']); - - // Page toolbar - // Comments button - if ( $session->get_permissions('read') && getConfig('enable_comments')=='1' && $paths->namespace != 'Special' && $paths->namespace != 'Admin' && $paths->cpage['comments_on'] == 1 ) - { - - $e = $db->sql_query('SELECT approved FROM '.table_prefix.'comments WHERE page_id=\''.$paths->cpage['urlname_nons'].'\' AND namespace=\''.$paths->namespace.'\';'); - if ( !$e ) - { - $db->_die(); - } - $nc = $db->numrows(); - $nu = 0; - $na = 0; - - while ( $r = $db->fetchrow() ) - { - if ( !$r['approved'] ) - { - $nu++; - } - else - { - $na++; - } - } - - $db->free_result(); - $n = ( $session->get_permissions('mod_comments') ) ? (string)$nc : (string)$na; - if ( $session->get_permissions('mod_comments') && $nu > 0 ) - { - $n .= ' total/'.$nu.' unapp.'; - } - - $button->assign_vars(array( - 'FLAGS' => 'onclick="void(ajaxComments()); return false;" title="View the comments that other users have posted about this page (alt-c)" accesskey="c"', - 'PARENTFLAGS' => 'id="mdgToolbar_discussion"', - 'HREF' => makeUrl($paths->page, 'do=comments', true), - 'TEXT' => 'discussion ('.$n.')', - )); - - $tb .= $button->run(); - } - // Edit button - if($session->get_permissions('read') && ($paths->namespace != 'Special' && $paths->namespace != 'Admin') && ( $session->get_permissions('edit_page') && ( ( $paths->page_protected && $session->get_permissions('even_when_protected') ) || !$paths->page_protected ) ) ) - { - $button->assign_vars(array( - 'FLAGS' => 'onclick="void(ajaxEditor()); return false;" title="Edit the contents of this page (alt-e)" accesskey="e"', - 'PARENTFLAGS' => 'id="mdgToolbar_edit"', - 'HREF' => makeUrl($paths->page, 'do=edit', true), - 'TEXT' => 'edit this page' - )); - $tb .= $button->run(); - // View source button - } - else if($session->get_permissions('view_source') && ( !$session->get_permissions('edit_page') || !$session->get_permissions('even_when_protected') && $paths->page_protected ) && $paths->namespace != 'Special' && $paths->namespace != 'Admin') - { - $button->assign_vars(array( - 'FLAGS' => 'onclick="void(ajaxViewSource()); return false;" title="View the source code (wiki markup) that this page uses (alt-e)" accesskey="e"', - 'PARENTFLAGS' => 'id="mdgToolbar_edit"', - 'HREF' => makeUrl($paths->page, 'do=viewsource', true), - 'TEXT' => 'view source' - )); - $tb .= $button->run(); - } - // History button - if ( $session->get_permissions('read') /* && $paths->wiki_mode */ && $paths->page_exists && $paths->namespace != 'Special' && $paths->namespace != 'Admin' && $session->get_permissions('history_view') ) - { - $button->assign_vars(array( - 'FLAGS' => 'onclick="void(ajaxHistory()); return false;" title="View a log of actions taken on this page (alt-h)" accesskey="h"', - 'PARENTFLAGS' => 'id="mdgToolbar_history"', - 'HREF' => makeUrl($paths->page, 'do=history', true), - 'TEXT' => 'history' - )); - $tb .= $button->run(); - } - - $menubtn = $this->makeParserText($tplvars['toolbar_menu_button']); - - // Additional actions menu - // Rename button - if ( $session->get_permissions('read') && $paths->page_exists && ( $session->get_permissions('rename') && ( $paths->page_protected && $session->get_permissions('even_when_protected') || !$paths->page_protected ) ) && $paths->namespace != 'Special' && $paths->namespace != 'Admin' ) - { - $menubtn->assign_vars(array( - 'FLAGS' => 'onclick="void(ajaxRename()); return false;" title="Change the display name of this page (alt-r)" accesskey="r"', - 'HREF' => makeUrl($paths->page, 'do=rename', true), - 'TEXT' => 'rename', - )); - $this->toolbar_menu .= $menubtn->run(); - } - - // Vote-to-delete button - if ( $paths->wiki_mode && $session->get_permissions('vote_delete') && $paths->page_exists && $paths->namespace != 'Special' && $paths->namespace != 'Admin') - { - $menubtn->assign_vars(array( - 'FLAGS' => 'onclick="void(ajaxDelVote()); return false;" title="Vote to have this page deleted (alt-d)" accesskey="d"', - 'HREF' => makeUrl($paths->page, 'do=delvote', true), - 'TEXT' => 'vote to delete this page', - )); - $this->toolbar_menu .= $menubtn->run(); - } - - // Clear-votes button - if ( $session->get_permissions('read') && $paths->wiki_mode && $paths->page_exists && $paths->namespace != 'Special' && $paths->namespace != 'Admin' && $session->get_permissions('vote_reset') && $paths->cpage['delvotes'] > 0) - { - $menubtn->assign_vars(array( - 'FLAGS' => 'onclick="void(ajaxResetDelVotes()); return false;" title="Vote to have this page deleted (alt-y)" accesskey="y"', - 'HREF' => makeUrl($paths->page, 'do=resetvotes', true), - 'TEXT' => 'reset deletion votes', - )); - $this->toolbar_menu .= $menubtn->run(); - } - - // Printable page button - if ( $paths->page_exists && $paths->namespace != 'Special' && $paths->namespace != 'Admin' ) - { - $menubtn->assign_vars(array( - 'FLAGS' => 'title="View a version of this page that is suitable for printing"', - 'HREF' => makeUrl($paths->page, 'printable=yes', true), - 'TEXT' => 'view printable version', - )); - $this->toolbar_menu .= $menubtn->run(); - } - - // Protect button - if($session->get_permissions('read') && $paths->wiki_mode && $paths->page_exists && $paths->namespace != 'Special' && $paths->namespace != 'Admin' && $session->get_permissions('protect')) - { - - $label = $this->makeParserText($tplvars['toolbar_label']); - $label->assign_vars(array('TEXT' => 'protection:')); - $t0 = $label->run(); - - $ctmp = ''; - if ( $paths->cpage['protected'] == 1 ) - { - $ctmp=' style="text-decoration: underline;"'; - } - $menubtn->assign_vars(array( - 'FLAGS' => 'accesskey="i" onclick="ajaxProtect(1); return false;" id="protbtn_1" title="Prevents all non-administrators from editing this page. [alt-i]"'.$ctmp, - 'HREF' => makeUrl($paths->page, 'do=protect&level=1', true), - 'TEXT' => 'on' - )); - $t1 = $menubtn->run(); - - $ctmp = ''; - if ( $paths->cpage['protected'] == 0 ) - { - $ctmp=' style="text-decoration: underline;"'; - } - $menubtn->assign_vars(array( - 'FLAGS' => 'accesskey="o" onclick="ajaxProtect(0); return false;" id="protbtn_0" title="Allows everyone to edit this page. [alt-o]"'.$ctmp, - 'HREF' => makeUrl($paths->page, 'do=protect&level=0', true), - 'TEXT' => 'off' - )); - $t2 = $menubtn->run(); - - $ctmp = ''; - if ( $paths->cpage['protected'] == 2 ) - { - $ctmp = ' style="text-decoration: underline;"'; - } - $menubtn->assign_vars(array( - 'FLAGS' => 'accesskey="p" onclick="ajaxProtect(2); return false;" id="protbtn_2" title="Allows only users who have been registered for 4 days to edit this page. [alt-p]"'.$ctmp, - 'HREF' => makeUrl($paths->page, 'do=protect&level=2', true), - 'TEXT' => 'semi' - )); - $t3 = $menubtn->run(); - - $this->toolbar_menu .= ''.$t0.' | -'.$t1.' | -'.$t2.' | -'.$t3.' | -
'.$t0.' | -'.$t1.' | -'.$t2.' | -'.$t3.' | -
'.$t0.' | '.$t.' |
'; - echo $db->sql_backtrace(); - echo ''; - } - - $f = microtime_float(); - $f = $f - $_starttime; - $f = round($f, 4); - $dbg = 'Time: '.$f.'s | Queries: '.$db->num_queries; - $t = ( $simple ) ? $this->process_template('simple-footer.tpl') : $this->process_template('footer.tpl'); - $t = str_replace('[[Stats]]', $dbg, $t); - $t = str_replace('[[NumQueries]]', (string)$db->num_queries, $t); - $t = str_replace('[[GenTime]]', (string)$f, $t); - echo $t; - - ob_end_flush(); - } - else return ''; - } - function getHeader() - { - $headers_sent = true; - dc_here('template: generating and sending the page header'); - if(!defined('ENANO_HEADERS_SENT')) - define('ENANO_HEADERS_SENT', ''); - if(!$this->no_headers) return $this->process_template('header.tpl'); - } - function getFooter() - { - global $db, $session, $paths, $template, $plugins; // Common objects - dc_here('template: generating and sending the page footer'); - if(!$this->no_headers) { - global $_starttime; - $t = ''; - - if(isset($_GET['sqldbg']) && $session->get_permissions('mod_misc')) - { - $t .= '
'; - $t .= $db->sql_backtrace(); - $t .= ''; - } - - $f = microtime_float(); - $f = $f - $_starttime; - $f = round($f, 4); - $dbg = 'Time: '.$f.'s | Queries: '.$db->num_queries; - $t.= $this->process_template('footer.tpl'); - $t = str_replace('[[Stats]]', $dbg, $t); - $t = str_replace('[[NumQueries]]', (string)$db->num_queries, $t); - $t = str_replace('[[GenTime]]', (string)$f, $t); - return $t; - } - else return ''; - } - - function process_template($file) { - global $db, $session, $paths, $template, $plugins; // Common objects - if(!defined('ENANO_TEMPLATE_LOADED')) - { - $this->load_theme(); - $this->init_vars(); - } - eval($this->compile_template($file)); - return $tpl_code; - } - - function extract_vars($file) { - global $db, $session, $paths, $template, $plugins; // Common objects - if(!$this->theme) - { - die('$template->extract_vars(): theme not yet loaded, so we can\'t open template files yet...this is a bug and should be reported.
'.enano_debug_print_backtrace(true).''); - } - if(!is_file(ENANO_ROOT . '/themes/'.$this->theme.'/'.$file)) die('Cannot find '.$file.' file for style "'.$this->theme.'", exiting'); - $text = file_get_contents(ENANO_ROOT . '/themes/'.$this->theme.'/'.$file); - preg_match_all('#<\!-- VAR ([A-z0-9_-]*) -->(.*?)<\!-- ENDVAR \\1 -->#is', $text, $matches); - $tplvars = Array(); - for($i=0;$i
'.htmlspecialchars(print_r($m, true)).''); - for($i = 0; $i < sizeof($m[1]); $i++) - { - $text = str_replace("", "{PHPCODE:{$i}:{$seed}}", $text); - } - //die('
'.htmlspecialchars($text).''); - $text = 'ob_start(); echo \''.str_replace('\'', '\\\'', $text).'\'; $tpl_code = ob_get_contents(); ob_end_clean();'; - $text = preg_replace('##is', '\'; if(isset($this->tpl_bool[\'\\1\']) && $this->tpl_bool[\'\\1\']) { echo \'', $text); - $text = preg_replace('##is', '\'; if(isset($this->tpl_strings[\'\\1\'])) { echo \'', $text); - $text = preg_replace('##is', '\'; if(getConfig(\'plugin_\\1\')==\'1\') { echo \'', $text); - $text = preg_replace('##is', '\'; echo $template->tplWikiFormat($paths->sysMsg(\'\\1\')); echo \'', $text); - $text = preg_replace('##is', '\'; if(!$this->tpl_bool[\'\\1\']) { echo \'', $text); - $text = preg_replace('##is', '\'; } else { echo \'', $text); - $text = preg_replace('##is', '\'; } echo \'', $text); - $text = preg_replace('#\{([A-z0-9]*)\}#is', '\'.$this->tpl_strings[\'\\1\'].\'', $text); - for($i = 0; $i < sizeof($m[1]); $i++) - { - $text = str_replace("{PHPCODE:{$i}:{$seed}}", "'; {$m[1][$i]} echo '", $text); - } - if(is_writable(ENANO_ROOT.'/cache/') && getConfig('cache_thumbs')=='1') - { - //die($tpl_filename); - $h = fopen($tpl_filename, 'w'); - if(!$h) return $text; - $t = addslashes($text); - fwrite($h, ''); - fclose($h); - } - return $text; //('
'.htmlspecialchars($text).''); - } - - function compile_template_text($text) { - $seed = md5 ( microtime() . mt_rand() ); - preg_match_all("/<\?php(.*?)\?>/is", $text, $m); - //die('
'.htmlspecialchars(print_r($m, true)).''); - for($i = 0; $i < sizeof($m[1]); $i++) - { - $text = str_replace("", "{PHPCODE:{$i}:{$seed}}", $text); - } - //die('
'.htmlspecialchars($text).''); - $text = 'ob_start(); echo \''.str_replace('\'', '\\\'', $text).'\'; $tpl_code = ob_get_contents(); ob_end_clean(); return $tpl_code;'; - $text = preg_replace('##is', '\'; if(isset($this->tpl_bool[\'\\1\']) && $this->tpl_bool[\'\\1\']) { echo \'', $text); - $text = preg_replace('##is', '\'; if(isset($this->tpl_strings[\'\\1\'])) { echo \'', $text); - $text = preg_replace('##is', '\'; if(getConfig(\'plugin_\\1\')==\'1\') { echo \'', $text); - $text = preg_replace('##is', '\'; echo $template->tplWikiFormat($paths->sysMsg(\'\\1\')); echo \'', $text); - $text = preg_replace('##is', '\'; if(!$this->tpl_bool[\'\\1\']) { echo \'', $text); - $text = preg_replace('##is', '\'; } else { echo \'', $text); - $text = preg_replace('##is', '\'; } echo \'', $text); - $text = preg_replace('#\{([A-z0-9]*)\}#is', '\'.$this->tpl_strings[\'\\1\'].\'', $text); - for($i = 0; $i < sizeof($m[1]); $i++) - { - $text = str_replace("{PHPCODE:{$i}:{$seed}}", "'; {$m[1][$i]} echo '", $text); - } - return $text; //('
'.htmlspecialchars($text).''); - } - - function parse($text) - { - $text = $this->compile_template_text($text); - return eval($text); - } - - // Steps to turn this: - // [[Project:Community Portal]] - // into this: - // Community Portal - // Must be done WITHOUT creating eval'ed code!!! - - // 1. preg_replace \[\[([a-zA-Z0-9 -_:]*?)\]\] with \\1 - // 2. preg_match_all - // 3. For each match, replace matches with identifiers - // 4. For each match, str_replace ' ' with '_' - // 5. For each match, str_replace match_id:random_val with $matches[$match_id] - - // The template language is really a miniature programming language; with variables, conditionals, everything! - // So you can implement custom logic into your sidebar if you wish. - // "Real" PHP support coming soon :-D - - function tplWikiFormat($message, $filter_links = false, $filename = 'elements.tpl') { - global $db, $session, $paths, $template, $plugins; // Common objects - $filter_links = false; - $tplvars = $this->extract_vars($filename); - if($session->sid_super) $as = htmlspecialchars(urlSeparator).'auth='.$session->sid_super; - else $as = ''; - error_reporting(E_ALL); - $random_id = sha1(microtime().''); // A temp value - - /* - * PREPROCESSOR - */ - - // Variables - - preg_match_all('#\$([A-Z_-]+)\$#', $message, $links); - $links = $links[1]; - - for($i=0;$i
Error: Syntax error (possibly XSS attack) caught in template code:
'; - echo '';
- echo '{if '.$links[1][$i].'}';
- echo "\n ";
- for($k=0;$k<$j;$k++) echo " ";
- echo '^';
- echo '
';
- continue 2;
- }
- if($current_var != '')
- {
- $cd = '( isset($this->tpl_bool[\''.$current_var.'\']) && $this->tpl_bool[\''.$current_var.'\'] )';
- $cvt = substr($links[1][$i], 0, $current_var_start_pos) . $cd . substr($links[1][$i], $current_var_end_pos, strlen($links[1][$i]));
- $j = $j + strlen($cd) - strlen($current_var);
- $current_var = '';
- $links[1][$i] = $cvt;
- $d = strlen($links[1][$i]);
- }
- }
- $links[1][$i] = substr($links[1][$i], 0, strlen($links[1][$i])-1);
- $links[1][$i] = '$chk = ( '.$links[1][$i].' ) ? true : false;';
- eval($links[1][$i]);
-
- if($chk) { // isset($this->tpl_bool[$links[1][$i]]) && $this->tpl_bool[$links[1][$i]]
- if(strstr($links[2][$i], '{else}')) $c = substr($links[2][$i], 0, strpos($links[2][$i], '{else}'));
- else $c = $links[2][$i];
- $message = str_replace('{CONDITIONAL:'.$i.':'.$random_id.'}', $c, $message);
- } else {
- if(strstr($links[2][$i], '{else}')) $c = substr($links[2][$i], strpos($links[2][$i], '{else}')+6, strlen($links[2][$i]));
- else $c = '';
- $message = str_replace('{CONDITIONAL:'.$i.':'.$random_id.'}', $c, $message);
- }
- }
-
- preg_match_all('#\{!if ([A-Za-z_-]*)\}(.*?)\{\/if\}#is', $message, $links);
-
- for($i=0;$i'.htmlspecialchars($message).''); - //eval($message); exit; - return $message; - } - - /** - * Print a text field that auto-completes a username entered into it. - * @param string $name - the name of the form field - * @return string - */ - - function username_field($name, $value = false) - { - $randomid = md5( time() . microtime() . mt_rand() ); - $text = ''; - return $text; - } - - /** - * Sends a textarea that can be converted to and from a TinyMCE widget on the fly. - * @param string The name of the form element - * @param string The initial content. Optional, defaults to blank - * @param int Rows in textarea - * @param int Columns in textarea - * @return string HTML and Javascript code. - */ - - function tinymce_textarea($name, $content = '', $rows = 20, $cols = 60) - { - $randomid = md5(microtime() . mt_rand()); - $html = ''; - $html .= ''; - $html .= '
'.htmlspecialchars($text).''); - } - - function compile_template_text($text) { - global $sideinfo; - $text = str_replace('', '', $text); // Remove the AJAX code - we don't need it, and it requires a database connection - $text = '$tpl_code = \''.str_replace('\'', '\\\'', $text).'\'; return $tpl_code;'; - $text = preg_replace('##is', '\'; if($this->tpl_bool[\'\\1\']) { $tpl_code .= \'', $text); - $text = preg_replace('##is', '\'; if(getConfig(\'plugin_\\1\')==\'1\') { $tpl_code .= \'', $text); - if(defined('IN_ENANO_INSTALL')) $text = str_replace('', ' ', $text); - else $text = str_replace('', ' ', $text); - $text = preg_replace('##is', '', $text); - $text = preg_replace('##is', '\'; if(!$this->tpl_bool[\'\\1\']) { $tpl_code .= \'', $text); - $text = preg_replace('##is', '\'; } else { $tpl_code .= \'', $text); - $text = preg_replace('##is', '\'; } $tpl_code .= \'', $text); - $text = preg_replace('#{([A-z0-9]*)}#is', '\'.$this->tpl_strings[\'\\1\'].\'', $text); - return $text; //('
'.htmlspecialchars($text).''); - } - - /** - * Allows individual parsing of template files. Similar to phpBB but follows the spirit of object-oriented programming ;) - * Returns on object of class templateIndividual. Usage instructions can be found in the inline docs for that class. - * @param $filename the filename of the template to be parsed - * @return object - */ - - function makeParser($filename) - { - $filename = ENANO_ROOT.'/themes/'.$this->theme.'/'.$filename; - if(!file_exists($filename)) die('templateIndividual: file '.$filename.' does not exist'); - $code = file_get_contents($filename); - $parser = new templateIndividualSafe($code, $this); - return $parser; - } - - /** - * Same as $template->makeParser(), but takes a string instead of a filename. - * @param $text the text to parse - * @return object - */ - - function makeParserText($code) - { - $parser = new templateIndividualSafe($code, $this); - return $parser; - } - -} // class template_nodb - -/** - * Identical to templateIndividual, except extends template_nodb instead of template - * @see class template - */ - -class templateIndividualSafe extends template_nodb { - var $tpl_strings, $tpl_bool, $tpl_code; - var $compiled = false; - /** - * Constructor. - */ - function __construct($text, $parent) - { - global $db, $session, $paths, $template, $plugins; // Common objects - $this->tpl_code = $text; - $this->tpl_strings = $parent->tpl_strings; - $this->tpl_bool = $parent->tpl_bool; - } - /** - * PHP 4 constructor. - */ - function templateIndividual($text) - { - $this->__construct($text); - } - /** - * Assigns an array of string values to the template. Strings can be accessed from the template by inserting {KEY_NAME} in the template file. - * @param $vars array - */ - function assign_vars($vars) - { - if(is_array($this->tpl_strings)) - $this->tpl_strings = array_merge($this->tpl_strings, $vars); - else - $this->tpl_strings = $vars; - } - /** - * Assigns an array of boolean values to the template. These can be used for statements. - * @param $vars array - */ - function assign_bool($vars) - { - $this->tpl_bool = array_merge($this->tpl_bool, $vars); - } - /** - * Compiles and executes the template code. - * @return string - */ - function run() - { - global $db, $session, $paths, $template, $plugins; // Common objects - if(!$this->compiled) - { - $this->tpl_code = $this->compile_template_text($this->tpl_code); - $this->compiled = true; - } - return eval($this->tpl_code); - } -} - -?> diff -r 0931d60f5bdb -r 2b2084ca1e60 plugins/#Untitled-1# --- a/plugins/#Untitled-1# Wed Jun 13 16:32:27 2007 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ - MAUMEE, OH, US 06/12/2007 11:26 P.M. ARRIVAL SCAN diff -r 0931d60f5bdb -r 2b2084ca1e60 plugins/SpecialAdmin.php~ --- a/plugins/SpecialAdmin.php~ Wed Jun 13 16:32:27 2007 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,2722 +0,0 @@ -attachHook('base_classes_initted', ' - global $paths; - $paths->add_page(Array( - \'name\'=>\'Administration\', - \'urlname\'=>\'Administration\', - \'namespace\'=>\'Special\', - \'special\'=>0,\'visible\'=>0,\'comments_on\'=>0,\'protected\'=>1,\'delvotes\'=>0,\'delvote_ips\'=>\'\', - )); - - $paths->add_page(Array( - \'name\'=>\'Manage the Sidebar\', - \'urlname\'=>\'EditSidebar\', - \'namespace\'=>\'Special\', - \'special\'=>0,\'visible\'=>0,\'comments_on\'=>0,\'protected\'=>1,\'delvotes\'=>0,\'delvote_ips\'=>\'\', - )); - '); - -// function names are IMPORTANT!!! The name pattern is: page_
It looks like your administration session is invalid or you are not authorized to access this administration page. Please re-authenticate to continue.
'; - return; - } - - - // Basic information - echo RenderMan::render( -'== Welcome to Runt, the Enano administration panel. == - -Thank you for choosing Enano as your CMS. This screen allows you to see some information about your website, plus some details about how your site is doing statistically. - -Using the links on the left you can control every aspect of your website\'s look and feel, plus you can manage users, work with pages, and install plugins to make your Enano installation even better.'); - - // Check for the installer scripts - if(file_exists(ENANO_ROOT.'/install.php') || file_exists(ENANO_ROOT.'/schema.sql')) - { - echo 'Page | Hits |
---|---|
'.$paths->pages[$page]['name'].' | '.$count.' | '; - echo '
Type | Date | Username | IP Address |
---|---|---|---|
';
- switch($r['action']) {
- case "admin_auth_good": echo 'Successful elevated authentication'; if ( !empty($r['page_text']) ) { $level = $session->userlevel_to_string( intval($r['page_text']) ); echo " Authentication level: $level"; } break; - case "admin_auth_bad": echo 'Failed administration logon'; break; - case "activ_good": echo 'Successful account activation'; break; - case "auth_good": echo 'Successful regular user logon'; break; - case "activ_bad": echo 'Failed account activation'; break; - case "auth_bad": echo 'Failed regular user logon'; break; - case "sql_inject": echo 'SQL injection attempt Offending query: ' . htmlspecialchars($r['page_text']) . ' '; break;
- case "db_backup": echo 'Database backup createdTables: ' . $r['page_text'] . ''; break; - case "install_enano": echo "Installed Enano version {$r['page_text']}"; break; - } - echo ' | '.date('d M Y h:i a', $r['time_id']).' | '.$r['author'].' | '.$r['edit_summary'].' |
It looks like your administration session is invalid or you are not authorized to access this administration page. Please re-authenticate to continue.
'; - return; - } - - if(isset($_POST['submit'])) { - - // Global site options - setConfig('site_name', $_POST['site_name']); - setConfig('site_desc', $_POST['site_desc']); - setConfig('main_page', str_replace(' ', '_', $_POST['main_page'])); - setConfig('copyright_notice', $_POST['copyright']); - setConfig('contact_email', $_POST['contact_email']); - - // Wiki mode - if(isset($_POST['wikimode'])) setConfig('wiki_mode', '1'); - else setConfig('wiki_mode', '0'); - if(isset($_POST['wiki_mode_require_login'])) setConfig('wiki_mode_require_login', '1'); - else setConfig('wiki_mode_require_login', '0'); - if(isset($_POST['editmsg'])) setConfig('wiki_edit_notice', '1'); - else setConfig('wiki_edit_notice', '0'); - setConfig('wiki_edit_notice_text', $_POST['editmsg_text']); - - // Stats - if(isset($_POST['log_hits'])) setConfig('log_hits', '1'); - else setConfig('log_hits', '0'); - - // Disablement - if(isset($_POST['site_disabled'])) { setConfig('site_disabled', '1'); setConfig('site_disabled_notice', $_POST['site_disabled_notice']); } - else setConfig('site_disabled', '0'); - - // Account activation - setConfig('account_activation', $_POST['account_activation']); - - // W3C compliance buttons - if(isset($_POST['w3c-vh32'])) setConfig("w3c_vh32", "1"); - else setConfig("w3c_vh32", "0"); - if(isset($_POST['w3c-vh40'])) setConfig("w3c_vh40", "1"); - else setConfig("w3c_vh40", "0"); - if(isset($_POST['w3c-vh401'])) setConfig("w3c_vh401", "1"); - else setConfig("w3c_vh401", "0"); - if(isset($_POST['w3c-vxhtml10'])) setConfig("w3c_vxhtml10", "1"); - else setConfig("w3c_vxhtml10", "0"); - if(isset($_POST['w3c-vxhtml11'])) setConfig("w3c_vxhtml11", "1"); - else setConfig("w3c_vxhtml11", "0"); - if(isset($_POST['w3c-vcss'])) setConfig("w3c_vcss", "1"); - else setConfig("w3c_vcss", "0"); - - // SourceForge.net logo - if(isset($_POST['showsf'])) setConfig('sflogo_enabled', '1'); - else setConfig('sflogo_enabled', '0'); - setConfig('sflogo_groupid', $_POST['sfgroup']); - setConfig('sflogo_type', $_POST['sflogo']); - - // Comment options - if(isset($_POST['comment-approval'])) setConfig('approve_comments', '1'); - else setConfig('approve_comments', '0'); - if(isset($_POST['enable-comments'])) setConfig('enable_comments', '1'); - else setConfig('enable_comments', '0'); - setConfig('comments_need_login', $_POST['comments_need_login']); - - // Powered by link - if ( isset($_POST['enano_powered_link']) ) setConfig('powered_btn', '1'); - else setConfig('powered_btn', '0'); - - if(isset($_POST['dbdbutton'])) setConfig('dbd_button', '1'); - else setConfig('dbd_button', '0'); - - if($_POST['emailmethod'] == 'phpmail') setConfig('smtp_enabled', '0'); - else setConfig('smtp_enabled', '1'); - - setConfig('smtp_server', $_POST['smtp_host']); - setConfig('smtp_user', $_POST['smtp_user']); - if($_POST['smtp_pass'] != 'XXXXXXXXXXXX') setConfig('smtp_password', $_POST['smtp_pass']); - - echo 'Global site options | |
---|---|
These options control the entire site. | |
Site name: | |
Site description: | |
Main page: | pagename_field('main_page', str_replace('_', ' ', getConfig('main_page'))); ?> |
Copyright notice shown on pages: | |
Hint: If you're using Windows, you can make a "©" symbol by holding ALT and pressing 0169 on the numeric keypad. | |
Contact e-mail All e-mail sent from this site will appear to have come from the address shown here. | |
Wiki mode | |
- Enano can also act as a wiki, meaning anyone can edit and create pages. To enable Wiki Mode, check the box to the right. - In Wiki Mode, certain HTML tags such as <script> and <object> are disabled, and all PHP code is disabled, except if the person editing the page is an administrator. - Also, Enano keeps complete page history, which makes restoring vandalized pages easy. You can also protect pages so that they cannot be edited. - |
- - /> - | -
- Edit page notice - When Wiki Mode is enabled, anyone can edit pages. Check the box below and enter a message to display it whenever the page editor is opened. - |
- - /> - | -
- - | -|
Statistics and hit counting | |
Enano has the ability to show statistics for every page on the site. This allows you to keep very close track of who is visiting your site, and from where. Unfortunately, some users don't like being logged. For this reason, you should state clearly what is logged (usually the username or IP address, current time, page name, and referer URL) in your privacy policy. |
- This excludes special and administration pages. |
-
Comment system | |
/> | |
/> | |
Guest comment posting allowed | - - |
Promote Enano | -|
- If you think Enano is nice, or if you want to show your support for the Enano team, you can do so by placing a link to the Enano - homepage in your Links sidebar block. You absolutely don't have to do this, and you won't get degraded support if you don't. Because - Enano is still relatively new in the CMS world, it needs all the attention it can get - and you can easily help to spread the word - using this link. - | -- - | -
Disable all site access | |
Disabling the site allows you to work on the site without letting non-administrators see or use it. | -- |
-
- Message to show to users:
- - - |
- |
User account activation | |
- If you would like to require users to confirm their e-mail addresses by way of account activation, you can enable this behavior here. If this option is set to "None", users will be able to register and use this site without confirming their e-mail addresses. If this option is set to "User", users will automatically be sent e-mails upon registration with a link to activate their accounts. And lastly, if this option is set to "Admin", users' accounts will not be active until an administrator activates the account. - You may also disable registration completely if needed. - Note: because of abuse by project administrators, sending account activation e-mails will not work on SourceForge.net servers. - |
- |
Account activation: |
- Disable registration '; - echo ''; - echo ''; - echo ''; - ?> - |
-
E-mail sent from the site | |
E-mail sending method: Try using the built-in e-mail method first. If that doesn't work, you will need to enter valid SMTP information here. |
- - |
-
SMTP hostname: This option only applies to the external SMTP mode. |
- - |
SMTP credentials: This option only applies to the external SMTP mode. |
- Username: - Password: |
-
SourceForge.net logo | |
- All projects hosted by SourceForge.net are required to display an official SourceForge.net logo on their pages. If you want - to display a SourceForge.net logo on the sidebar, check the box below, enter your group ID, and select an image type. - | -|
Display the SourceForge.net logo on the right sidebar | -/> | -
Group ID: | -- |
Logo style: | -- - | -
W3C compliance logos | |
Enano generates (by default) Valid XHTML 1.1 code, plus valid CSS. If you want to show this off, check the appropriate boxes below. | |
id="w3c-vh32" name="w3c-vh32" /> | |
id="w3c-vh40" name="w3c-vh40" /> | |
id="w3c-vh401" name="w3c-vh401" /> | |
id="w3c-vxhtml10" name="w3c-vxhtml10" /> | |
id="w3c-vxhtml11" name="w3c-vxhtml11" /> | |
id="w3c-vcss" name="w3c-vcss" /> | |
Defective By Design Anti-DRM button | |
The Enano project is strongly against Digital Restrictions Management. DRM removes the freedoms that every consumer should have: to freely copy and use digital media items they legally purchased to their own devices. Showing your opposition to DRM is as easy as checking the box below to place a link to DefectiveByDesign.org on your sidebar. | |
/> | |
It looks like your administration session is invalid or you are not authorized to access this administration page. Please re-authenticate to continue.
'; - return; - } - - if(isset($_POST['save'])) - { - if(isset($_POST['enable_uploads'])) setConfig('enable_uploads', '1'); else setConfig('enable_uploads', '0'); - if(isset($_POST['enable_imagemagick'])) setConfig('enable_imagemagick', '1'); else setConfig('enable_imagemagick', '0'); - if(isset($_POST['cache_thumbs'])) setConfig('cache_thumbs', '1'); else setConfig('cache_thumbs', '0'); - if(isset($_POST['file_history'])) setConfig('file_history', '1'); else setConfig('file_history', '0'); - if(file_exists($_POST['imagemagick_path'])) setConfig('imagemagick_path', $_POST['imagemagick_path']); - else echo 'Warning: the file "'.$_POST['imagemagick_path'].'" was not found, and the ImageMagick file path was not updated.'; - $max_upload = floor((float)$_POST['max_file_size'] * (int)$_POST['fs_units']); - setConfig('max_file_size', $max_upload.''); - } - echo 'Enano supports the ability to upload files to your website and store the files in the database. This enables you to embed images - and such into pages without manually writing the HTML. However, the upload feature can sometimes pose a risk to your site, as viruses - and executable files can sometimes be uploaded.
- -Maximum file size:
-You can allow Enano to generate thumbnails of images automatically. This feature requires ImageMagick to work properly. If your server - does not have ImageMagick on it, Enano will simply make your users' browsers scale the images. In most cases this is fine, but if you - are uploading large (>100KB) images and embedding them inside of pages, you should try to enable ImageMagick because transferring these - large images many times can cost you quite a lot of bandwidth.
-
- Path to ImageMagick:
- On Linux and Unix servers, the most likely options here are /usr/bin/convert and /usr/local/bin/convert. If you server runs Windows, then
- ImageMagick is most likely to be C:\Windows\Convert.exe or C:\Windows\System32\Convert.exe.
-
If you use ImageMagick to scale images, your server will be very busy constantly scaling images if your website is busy, and your site - may experience slowdowns. You can dramatically speed up this scaling process if you use a directory to cache thumbnail images.
-Please note: the cache/ directory on your server must be writable by the server. While this is not usually a problem on - Windows servers, most Linux/Unix servers will require you to CHMOD the cache/ directory to 777. See your FTP client's user guide for - more information on how to do this.At present, it seems that the cache directory - is not writable. The checkbox below has been disabled to maintain the stability of Enano.'; ?>
- -Lastly, you can choose whether file history will be saved. If this option is turned on, you will be able to roll back any malicious - changes made to uploaded files, but this requires a significant amount of database storage. You should probably leave this option - enabled unless you have less than 250MB of MySQL database space.
- -It looks like your administration session is invalid or you are not authorized to access this administration page. Please re-authenticate to continue.
'; - return; - } - - - if(isset($_GET['action'])) { - switch($_GET['action']) { - case "enable": - setConfig('plugin_'.$_GET['plugin'], '1'); - break; - case "disable": - if($_GET['plugin']!='admin.php') setConfig('plugin_'.$_GET['plugin'], '0'); - else echo('The administration panel plugin cannot be disabled.
'); - break; - } - } - $dir = './plugins/'; - $plugin_list = Array(); - $system = Array(); - if (is_dir($dir)) { - if ($dh = opendir($dir)) { - while (($file = readdir($dh)) !== false) { - if(preg_match('#^(.*?)\.php$#is', $file) && $file != 'index.php') - { - if ( in_array($file, $plugins->system_plugins) ) - { - $thelist =& $system; - continue; - } - else - { - $thelist =& $plugin_list; - } - $f = file_get_contents($dir . $file); - $f = explode("\n", $f); - $f = array_slice($f, 2, 7); - $f[0] = substr($f[0], 13, strlen($f[0])); - $f[1] = substr($f[1], 12, strlen($f[1])); - $f[2] = substr($f[2], 13, strlen($f[2])); - $f[3] = substr($f[3], 8, strlen($f[3])); - $f[4] = substr($f[4], 9, strlen($f[4])); - $f[5] = substr($f[5], 12, strlen($f[5])); - $thelist[$file] = Array(); - $thelist[$file]['name'] = $f[0]; - $thelist[$file]['uri'] = $f[1]; - $thelist[$file]['desc'] = $f[2]; - $thelist[$file]['auth'] = $f[3]; - $thelist[$file]['vers'] = $f[4]; - $thelist[$file]['aweb'] = $f[5]; - } - } - closedir($dh); - } - } - echo('Plugin filename | Plugin name | Description | Author | Version | |
---|---|---|---|---|---|
'.$plugin_files[$i].' | -'.$plugin_list[$plugin_files[$i]]['name'].' | -'.$plugin_list[$plugin_files[$i]]['desc'].' | -'.$plugin_list[$plugin_files[$i]]['auth'].' | -'.$plugin_list[$plugin_files[$i]]['vers'].' | -'; - if ( getConfig('plugin_'.$plugin_files[$i]) == '1' ) - { - echo 'Disable'; - } - else - { - echo 'Enable'; - } - echo ' |
It looks like your administration session is invalid or you are not authorized to access this administration page. Please re-authenticate to continue.
'; - return; - } - - global $mime_types, $mimetype_exps, $mimetype_extlist; - if(isset($_POST['save'])) - { - $bits = ''; - $keys = array_keys($mime_types); - foreach($keys as $i => $k) - { - if(isset($_POST['ext_'.$k])) $bits .= '1'; - else $bits .= '0'; - } - $bits = compress_bitfield($bits); - setConfig('allowed_mime_types', $bits); - echo 'Using the form below, you can decide which file types are allowed to be uploaded to this site.
- nslist['Special'].'Administration', (( isset($_GET['sqldbg'])) ? 'sqldbg&' : '') .'module='.$paths->cpage['module']).'" method="post">'; - $c = -1; - $t = -1; - $cl = 'row1'; - echo "\n".'\n \n | \n "; - } - while($c < 2) - { - $c++; - echo "\n "; - } - echo ' | |
It looks like your administration session is invalid or you are not authorized to access this administration page. Please re-authenticate to continue.
'; - return; - } - - ?> -The Enano sidebar is a versatile tool when scripted correctly. You don't have to be a programmer to enjoy the features the Sidebar - provides; however, editing the sidebar requires a small bit of programming knowledge and an understanding of Enano's system message - markup language. -
-The Enano system markup language is somewhat similar to HTML, in that it uses tags (<example>like this</example>) for the - main syntax. However, Enano uses curly brackets ({ and }) as opposed to less-than and greater-than signs (< and >).
-Programming the Enano sidebar requires the use of two tags: {slider} and {if}. The {slider} tag is used to create a new heading - on the sidebar, and all text enclosed in that tag will be collapsed when the heading is clicked. To specify the text on the heading, - use an equals sign (=) after the "slider" text. Then insert any links (they should be wiki-formatted) to internal Enano pages and - external sites.
-So here is what the language for the default sidebar's "Navigation" heading looks like:
-{slider=Navigation} - [[Main Page|Home]] - [[Enano:Sidebar|Edit the sidebar]] -{/slider}-
Pretty simple, huh? Good, now we're going to learn another common aspect of Enano programming: conditionals. The {if} tag allows you - to decide whether a portion of the sidebar will be displayed based on a template variable. Currently the only available conditions are - "user_logged_in" and "auth_admin", but more will be added soon. To use a conditional, enter {if conditional_name}, and then the - wiki-formatted text that you want to be under that condition, and then close the tag with {/if}. In the same way, you can reverse the - effect with {!if}. With {!if}, the closing tag is still {/if}, so keep that in mind. An {else} tag will be supported soon.
-Now it's time for some real fun: variables. All template variables can be accessed from the sidebar. A variable is simply the - variable name, prefixed by a dollar sign ($). Some of the most common variables are $USERNAME, $SITE_NAME, $SITE_DESC, and $PAGE_NAME. - The sidebar also has some special variables that it uses for some of its links. The logout link can be added with $LOGOUT_LINK, and - the "change theme" button can be added with $STYLE_LINK.
-So here is the Enano markup for the portion of the sidebar that contains the user tools:
-{slider=$USERNAME} - [[User:$USERNAME|User page]] - [[Special:Contributions?user=$USERNAME|My Contributions]] - {if user_logged_in} - [[Special:Preferences|Preferences]] - $THEME_LINK - {/if} - {if auth_admin} - [[Special:Administration|Administration]] - {/if} - {if user_logged_in} - $LOGOUT_LINK - {/if} - {!if user_logged_in} - Create an account - Log in - {/if} -{/slider}- auth_level < USER_LEVEL_ADMIN || $session->user_level < USER_LEVEL_ADMIN ) - { - echo '
It looks like your administration session is invalid or you are not authorized to access this administration page. Please re-authenticate to continue.
'; - return; - } - - if(isset($_POST['go'])) { - // We need the user ID before we can do anything - $q = $db->sql_query('SELECT user_id,username,email,real_name,style,user_level FROM '.table_prefix.'users WHERE username=\'' . $db->escape($_POST['username']) . '\''); - if(!$q) die('Error selecting user ID: '.mysql_error()); - if($db->numrows() < 1) { echo('User does not exist, please enter another username.'); return; } - $r = $db->fetchrow(); - $db->free_result(); - if(isset($_POST['save'])) - { - $_POST['level'] = intval($_POST['level']); - - $new_level = $_POST['level']; - $old_level = intval($r['user_level']); - - $re = $session->update_user((int)$r['user_id'], $_POST['new_username'], false, $_POST['new_pass'], $_POST['email'], $_POST['real_name'], false, $_POST['level']); - - if($re == 'success') - { - - if ( $new_level != $old_level ) - { - $user_id = intval($r['user_id']); - // We need to update group memberships - if ( $old_level == USER_LEVEL_ADMIN ) - { - $session->remove_user_from_group($user_id, GROUP_ID_ADMIN); - } - else if ( $old_level == USER_LEVEL_MOD ) - { - $session->remove_user_from_group($user_id, GROUP_ID_MOD); - } - - if ( $new_level == USER_LEVEL_ADMIN ) - { - $session->add_user_to_group($user_id, GROUP_ID_ADMIN, false); - } - else if ( $new_level == USER_LEVEL_MOD ) - { - $session->add_user_to_group($user_id, GROUP_ID_MOD, false); - } - } - - echo('Username: | |
New Password: | |
E-mail: | |
Real Name: | |
User level: | |
Delete user: | - |
- |
Username: '.$template->username_field('username').'
-It\'s a good idea to clean out your session keys table every once in a while, since this helps to reduce database size. During this process you will be logged off and (hopefully) logged back on automatically. The side effects of this include all users except you being logged off.
- -Date of request | Requested by | Requested for | Actions | ||
---|---|---|---|---|---|
'.date('F d, Y h:i a', $row['time_id']).' | '.$row['author'].' | '.$row['edit_summary'].' | Activate now | Send activation e-mail | Deny request |
It looks like your administration session is invalid or you are not authorized to access this administration page. Please re-authenticate to continue.
'; - return; - } - - if(isset($_POST['do_create_stage1'])) - { - if(!preg_match('/^([A-z0-9 -]+)$/', $_POST['create_group_name'])) - { - echo 'The group name you chose is invalid.
'; - return; - } - echo 'Creating group: '.$_POST['create_group_name'].' | |
---|---|
Group moderator | ' . $template->username_field('group_mod') . ' | -
Group status |
- - - - - |
- - - | -
The group name you chose is invalid.
'; - return; - } - if(!in_array(intval($_POST['group_status']), Array(GROUP_CLOSED, GROUP_OPEN, GROUP_HIDDEN, GROUP_REQUEST))) - { - echo 'Hacking attempt
'; - return; - } - $e = $db->sql_query('SELECT group_id FROM '.table_prefix.'groups WHERE group_name=\''.$db->escape($_POST['create_group_name']).'\';'); - if(!$e) - { - echo $db->get_error(); - return; - } - if($db->numrows() > 0) - { - echo 'The group name you entered already exists.
'; - return; - } - $db->free_result(); - $q = $db->sql_query('INSERT INTO '.table_prefix.'groups(group_name,group_type) VALUES( \''.$db->escape($_POST['create_group_name']).'\', ' . intval($_POST['group_status']) . ' )'); - if(!$q) - { - echo $db->get_error(); - return; - } - $e = $db->sql_query('SELECT user_id FROM '.table_prefix.'users WHERE username=\''.$db->escape($_POST['group_mod']).'\';'); - if(!$e) - { - echo $db->get_error(); - return; - } - if($db->numrows() < 1) - { - echo 'The username you entered could not be found.
'; - return; - } - $row = $db->fetchrow(); - $id = $row['user_id']; - $db->free_result(); - $e = $db->sql_query('SELECT group_id FROM '.table_prefix.'groups WHERE group_name=\''.$db->escape($_POST['create_group_name']).'\';'); - if(!$e) - { - echo $db->get_error(); - return; - } - if($db->numrows() < 1) - { - echo 'The group ID could not be looked up.
'; - return; - } - $row = $db->fetchrow(); - $gid = $row['group_id']; - $db->free_result(); - $e = $db->sql_query('INSERT INTO '.table_prefix.'group_members(group_id,user_id,is_mod) VALUES('.$gid.', '.$id.', 1);'); - if(!$e) - { - echo $db->get_error(); - return; - } - echo "Error: couldn\'t look up group name
'; - } - $row = $db->fetchrow(); - $name = $row['group_name']; - $db->free_result(); - if(isset($_POST['edit_do'])) - { - if(isset($_POST['edit_do']['del_group'])) - { - if ( $row['system_group'] == 1 ) - { - echo 'The group name you chose is invalid.
'; - return; - } - $q = $db->sql_query('UPDATE '.table_prefix.'groups SET group_name=\''.$db->escape($_POST['group_name']).'\' - WHERE group_id='.intval($_POST['group_edit_id']).';'); - if(!$q) - { - echo $db->get_error(); - return; - } - else - { - echo 'Edit group name |
---|
- Group name: - | -
- - - | -
Edit group members | ||
---|---|---|
This group has no members. | ||
- ' . $row['username'] . ' - | -- '.$mod.' - | -- - | -
Add a new member | -
---|
- Username: ' . $template->username_field('edit_add_username') . ' - | -
- (can add and delete other members) - | -
- - | -
Edit an existing group | -
---|
Create a new group | -|
---|---|
Group name: | |
It looks like your administration session is invalid or you are not authorized to access this administration page. Please re-authenticate to continue.
'; - return; - } - - - echo 'Namespace: | |
Page title: | |
Page URL string: No spaces, and don't enter the namespace prefix (e.g. User:). Changing this value is usually not a good idea, especially for templates and project pages. | |
name="comments_on" type="checkbox" id="cmt" /> | |
name="special" type="checkbox" id="spc" /> This option enables you to use your own HTML headers and other code. It is recommended that only advanced users enable this feature. As with other Enano pages, you may use PHP code in your pages, meaning you can use Enano's API on the page. | |
name="visible" type="checkbox" id="vis" /> Unchecking this checkbox prevents the page for being indexed for searching. The index is rebuilt each time a page is saved, and you can force an index rebuild by going to the page nslist['Special']; ?>SearchRebuild. | |
name="protected" type="checkbox" id="prt" /> This option only has an effect when Wiki Mode is enabled. | |
- - - |
Search for page title (remember prefixes like User: and File:) pagename_field('page_url'); ?>
-Select page title from a list:
- '; - - } -} - -function page_Admin_PageEditor() -{ - global $db, $session, $paths, $template, $plugins; // Common objects - if ( $session->auth_level < USER_LEVEL_ADMIN || $session->user_level < USER_LEVEL_ADMIN ) - { - echo 'It looks like your administration session is invalid or you are not authorized to access this administration page. Please re-authenticate to continue.
'; - return; - } - - - echo ''.$query.'
Reminder: This is only a preview; your changes to this page have not yet been saved.
-
- Edit summary:
-
-
- - - -
- '; - } else { - echo 'Search for page title (remember prefixes like User: and File:) pagename_field('page_url'); ?>
-Select page title from a list:
- '; - } -} - -function page_Admin_ThemeManager() -{ - - global $db, $session, $paths, $template, $plugins; // Common objects - if ( $session->auth_level < USER_LEVEL_ADMIN || $session->user_level < USER_LEVEL_ADMIN ) - { - echo 'It looks like your administration session is invalid or you are not authorized to access this administration page. Please re-authenticate to continue.
'; - return; - } - - - // Get the list of styles in the themes/ dir - $h = opendir('./themes'); - $l = Array(); - if(!$h) die('Error opening directory "./themes" for reading.'); - while(false !== ($n = readdir($h))) { - if($n != '.' && $n != '..' && is_dir('./themes/'.$n)) - $l[] = $n; - } - closedir($h); - echo(' -Install, uninstall, and manage Enano themes.
- '); - if(isset($_POST['disenable'])) { - $q = 'SELECT enabled FROM '.table_prefix.'themes WHERE theme_id=\'' . $db->escape($_POST['theme_id']) . '\''; - $s = $db->sql_query($q); - if(!$s) die('Error selecting enabled/disabled state value: '.mysql_error().'- -
-'); - echo(''); - echo(' - -
All themes are currently installed.
'); -} - -function page_Admin_BanControl() -{ - global $db, $session, $paths, $template, $plugins; // Common objects - if ( $session->auth_level < USER_LEVEL_ADMIN || $session->user_level < USER_LEVEL_ADMIN ) - { - echo 'It looks like your administration session is invalid or you are not authorized to access this administration page. Please re-authenticate to continue.
'; - return; - } - - if(isset($_GET['action']) && $_GET['action'] == 'delete' && isset($_GET['id']) && $_GET['id'] != '') - { - $e = $db->sql_query('DELETE FROM '.table_prefix.'banlist WHERE ban_id=' . $db->escape($_GET['id']) . ''); - if(!$e) $db->_die('The ban list entry was not deleted.'); - } - if(isset($_POST['create'])) - { - $q = 'INSERT INTO '.table_prefix.'banlist(ban_type,ban_value,reason,is_regex) VALUES( ' . $db->escape($_POST['type']) . ', \'' . $db->escape($_POST['value']) . '\', \''.$db->escape($_POST['reason']).'\''; - if(isset($_POST['regex'])) $q .= ', 1'; - else $q .= ', 0'; - $q .= ');'; - $e = $db->sql_query($q); - if(!$e) $db->_die('The banlist could not be updated.'); - } - $q = $db->sql_query('SELECT ban_id,ban_type,ban_value,is_regex FROM '.table_prefix.'banlist ORDER BY ban_type;'); - if(!$q) $db->_die('The banlist data could not be selected.'); - echo 'Type | Value | Regular Expression | No ban rules yet. | '; - while($r = $db->fetchrow()) - { - if($r['ban_type']==BAN_IP) $t = 'IP address'; - elseif($r['ban_type']==BAN_USER) $t = 'Username'; - elseif($r['ban_type']==BAN_EMAIL) $t = 'E-mail address'; - if($r['is_regex']) $g = 'Yes'; else $g = 'No'; - echo '
---|---|---|---|
'.$t.' | '.$r['ban_value'].' | '.$g.' | Delete |
It looks like your administration session is invalid or you are not authorized to access this administration page. Please re-authenticate to continue.
'; - return; - } - - global $enano_config; - if ( isset($_POST['do_send']) ) - { - $use_smtp = getConfig('smtp_enabled') == '1'; - - // - // Let's do some checking to make sure that mass mail functions - // are working in win32 versions of php. (copied from phpBB) - // - if ( preg_match('/[c-z]:\\\.*/i', getenv('PATH')) && !$use_smtp) - { - $ini_val = ( @phpversion() >= '4.0.0' ) ? 'ini_get' : 'get_cfg_var'; - - // We are running on windows, force delivery to use our smtp functions - // since php's are broken by default - $use_smtp = true; - $enano_config['smtp_server'] = @$ini_val('SMTP'); - } - - $mail = new emailer( !empty($use_smtp) ); - - // Validate subject/message body - $subject = stripslashes(trim($_POST['subject'])); - $message = stripslashes(trim($_POST['message'])); - - if ( empty($subject) ) - $errors[] = 'Please enter a subject.'; - if ( empty($message) ) - $errors[] = 'Please enter a message.'; - - // Get list of members - if ( !empty($_POST['userlist']) ) - { - $userlist = str_replace(', ', ',', $_POST['userlist']); - $userlist = explode(',', $userlist); - foreach ( $userlist as $k => $u ) - { - if ( $u == $session->username ) - { - // Message is automatically sent to the sender - unset($userlist[$k]); - } - else - { - $userlist[$k] = $db->escape($u); - } - } - $userlist = 'WHERE username=\'' . implode('\' OR username=\'', $userlist) . '\''; - - $q = $db->sql_query('SELECT email FROM '.table_prefix.'users ' . $userlist . ';'); - if ( !$q ) - $db->_die(); - - if ( $row = $db->fetchrow() ) - { - do { - $mail->cc($row['email']); - } while ( $row = $db->fetchrow() ); - } - - $db->free_result(); - - } - else - { - // Sending to a usergroup - - $group_id = intval($_POST['group_id']); - if ( $group_id < 1 ) - { - $errors[] = 'Invalid group ID'; - } - else - { - $q = $db->sql_query('SELECT u.email FROM '.table_prefix.'group_members AS g - LEFT JOIN '.table_prefix.'users AS u - ON (u.user_id=g.user_id) - WHERE g.group_id=' . $group_id . ';'); - if ( !$q ) - $db->_die(); - - if ( $row = $db->fetchrow() ) - { - do { - $mail->cc($row['email']); - } while ( $row = $db->fetchrow() ); - } - - $db->free_result(); - } - } - - if ( sizeof($errors) < 1 ) - { - - $mail->from(getConfig('contact_email')); - $mail->replyto(getConfig('contact_email')); - $mail->set_subject($subject); - $mail->email_address(getConfig('contact_email')); - - // Copied/modified from phpBB - $email_headers = 'X-AntiAbuse: Website server name - ' . $_SERVER['SERVER_NAME'] . "\n"; - $email_headers .= 'X-AntiAbuse: User_id - ' . $session->user_id . "\n"; - $email_headers .= 'X-AntiAbuse: Username - ' . $session->username . "\n"; - $email_headers .= 'X-AntiAbuse: User IP - ' . $_SERVER['REMOTE_ADDR'] . "\n"; - - $mail->extra_headers($email_headers); - - $tpl = 'The following message was mass-mailed by {SENDER}, one of the administrators from {SITE_NAME}. If this message contains spam or any comments which you find abusive or offensive, please contact the administration team at: - -{CONTACT_EMAIL} - -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -{MESSAGE} -'; - - $mail->use_template($tpl); - - $mail->assign_vars(array( - 'SENDER' => $session->username, - 'SITE_NAME' => getConfig('site_name'), - 'CONTACT_EMAIL' => getConfig('contact_email'), - 'MESSAGE' => $message - )); - - //echo ''.print_r($mail,true).''; - - // All done - $mail->send(); - $mail->reset(); - - echo '
Send mass e-mail | -|
---|---|
- Send message to: - - By default, this message will be sent to the group selected here. You may instead send the message to a specific - list of users by entering them in the second row, with usernames separated by a single comma (no space). - - |
- - - | -
- Usernames: - | -|
- Subject: - | -- - | -
- Message: - | -- - | -
- - Please be warned: it may take a LONG time to send this message. Please do not stop the script until the process is finished. - | -
It looks like your administration session is invalid or you are not authorized to access this administration page. Please re-authenticate to continue.
'; - return; - } - - global $system_table_list; - if(isset($_GET['submitting']) && $_GET['submitting'] == 'yes') - { - - if(defined('SQL_BACKUP_CRYPT')) - // Try to increase our time limit - @set_time_limit(300); // five minutes - // Do the actual export - $aesext = ( defined('SQL_BACKUP_CRYPT') ) ? '.tea' : ''; - $filename = 'enano_backup_' . date('dmy') . '.sql' . $aesext; - ob_start(); - header('Content-disposition: attachment, filename="'.$filename.'";'); - header('Content-type: application/transact-sql'); - // Spew some headers - $headdate = date('F d, Y \a\t h:i a'); - echo <<This page allows you to back up your Enano database should something go miserably wrong.
--
Additional tables to export:
--
-
-
-
It looks like your administration session is invalid or you are not authorized to access this administration page. Please re-authenticate to continue.
'; - return; - } - - $session->logout(USER_LEVEL_ADMIN); - echo 'You will continue to be logged into the website, but you will need to re-authenticate before you can access the administration panel again.
Return to the Main Page.
'; -} - -function page_Special_Administration() -{ - global $db, $session, $paths, $template, $plugins; // Common objects - - if($session->auth_level < USER_LEVEL_ADMIN) { - redirect(makeUrlNS('Special', 'Login/'.$paths->page, 'level='.USER_LEVEL_ADMIN), 'Not authorized', 'You need an authorization level of '.USER_LEVEL_ADMIN.' to use this page, your auth level is: ' . $session->auth_level, 0); - exit; - } - else - { - $template->load_theme('admin', 'default'); - $template->init_vars(); - if( !isset( $_GET['noheaders'] ) ) - { - $template->header(); - } - echo 'Administer your Enano website.'; - ?> - -
-
-
-
- |
-
-
- nslist);
- for ( $i = 0; $i < sizeof($paths->nslist); $i++ )
- {
- $ln = strlen( $paths->nslist[ $k[ $i ] ] );
- if ( substr($_GET['module'], 0, $ln) == $paths->nslist[$k[$i]] )
- {
- $ns = $k[$i];
- $nm = substr($_GET['module'], $ln, strlen($_GET['module']));
- }
- }
- $fname = 'page_'.$ns.'_'.$nm;
- $s = strpos($fname, '?noheaders');
- if($s) $fname = substr($fname, 0, $s);
- $paths->cpage['module'] = $_GET['module'];
- if ( function_exists($fname) && $_GET['module'] != $paths->nslist['Special'] . 'Administration' )
- {
- eval($fname.'();');
- }
- }
- else
- {
- echo '
- Please wait while the administration panel loads. You need to be using a recent browser with AJAX support in order to use Runt. ';
- }
- ?>
- |
-
- What type of block should this be? -
-- -
- -
-
- Block title:
- Which sidebar:
-
-
- Wikitext: -
-- -
-- Template code: -
-- -
-- HTML to place inside the sidebar: -
-- -
-- WARNING: If you don't know what you're doing, or if you are not fluent in PHP, stop now and choose a different block type. You will brick your Enano installation if you are not careful here. - ALWAYS remember to write secure code! The Enano team is not responsible if someone drops all your tables because of an SQL injection vulnerability in your sidebar code. You are probably better off using the template-formatted block type. -
-- - It is especially important to note that this code is NOT checked for errors! If there is a syntax error in your code here, it will prevent any pages from loading AT ALL. So you need to use an external PHP editor (like jEdit) to check your syntax before you hit save. - You have been warned. -
-- Also, you should avoid using output buffering functions (ob_[start|end|get_contents|clean]) here, because Enano uses those to track output from this script. -
-- The standard <?php and ?> tags work here. Don't use an initial "<?php" or it will cause a parse error. -
-- PHP code: -
-- -
-- Plugin: -
-- -
-- - - - -
- -';
- //if(isset($vars['sidebar_top'])) echo $template->parse($vars['sidebar_top']);
-
- // Time for the loop
- // what this loop does is fetch the row data, then send it out to the appropriate parser for formatting,
- // then puts the result into $c, which is then sent to the template compiler for insertion into the TPL code.
- while($row = $db->fetchrow())
- {
- if(isset($current_side))
- {
- if($current_side != $row['sidebar_id'])
- {
- // Time to switch!
- //if(isset($vars['sidebar_top'])) echo $template->parse($vars['sidebar_bottom']);
- echo ' | ';
- //echo ' | '; - //if(isset($vars['sidebar_top'])) echo $template->parse($vars['sidebar_top']); - $n =& $n2; - } - } - $n[] = count($n); - $current_side = $row['sidebar_id']; - switch($row['block_type']) - { - case BLOCK_WIKIFORMAT: - default: - $parser = $template->makeParserText($vars['sidebar_section']); - $c = RenderMan::render($row['block_content']); - break; - case BLOCK_TEMPLATEFORMAT: - $parser = $template->makeParserText($vars['sidebar_section']); - $c = $template->tplWikiFormat($row['block_content'], false, 'sidebar-editor.tpl'); - $c = preg_replace('#(.*?)#is', '\\2', $c); - break; - case BLOCK_HTML: - $parser = $template->makeParserText($vars['sidebar_section_raw']); - $c = $row['block_content']; - $c = preg_replace('#(.*?)#is', '\\2', $c); - break; - case BLOCK_PHP: - $parser = $template->makeParserText($vars['sidebar_section_raw']); - ob_start(); - eval($row['block_content']); - $c = ob_get_contents(); - ob_end_clean(); - $c = preg_replace('#(.*?)#is', '\\2', $c); - break; - case BLOCK_PLUGIN: - $parser = $template->makeParserText($vars['sidebar_section_raw']); - $c = ($template->fetch_block($row['block_content'])) ? $template->fetch_block($row['block_content']) : 'Can\'t find plugin block'; - break; - } - $t = $template->tplWikiFormat($row['block_name']); - if($row['item_enabled'] == 0) $t .= ' (disabled)'; - else $t .= ' '; - $side = ( $row['sidebar_id'] == SIDEBAR_LEFT ) ? SIDEBAR_RIGHT : SIDEBAR_LEFT; - $tb = ' - - - '; - $as = ''; - $ae = ' '.$tb; - $parser->assign_vars(Array('CONTENT'=>$c,'TITLE'=>$t,'ADMIN_START'=>$as,'ADMIN_END'=>$ae)); - echo $parser->run(); - unset($parser); - - } - $db->free_result(); - //if(isset($vars['sidebar_top'])) echo $template->parse($vars['sidebar_bottom']); - echo ' |
File uploads are disabled this website.
'); } - if ( !$session->get_permissions('upload_files') ) - { - die_friendly('Access denied', 'File uploads are disabled for your user account or group.
'); - } - if(isset($_POST['doit'])) - { - if(isset($_FILES['data'])) - { - $file =& $_FILES['data']; - } - else - { - $file = false; - } - if(!is_array($file)) die_friendly('Upload failed', '
The server could not retrieve the array $_FILES[\'data\'].
'); - if($file['size'] == 0 || $file['size'] > (int)getConfig('max_file_size')) die_friendly('Upload failed', 'The file you uploaded is either too large or 0 bytes in length.
'); - /* - $allowed_mime_types = Array( - 'text/plain', - 'image/png', - 'image/jpeg', - 'image/tiff', - 'image/gif', - 'text/html', // Safe because the file is stashed in the database - 'application/x-bzip2', - 'application/x-gzip', - 'text/x-c++' - ); - if(function_exists('finfo_open') && $fi = finfo_open(FILEINFO_MIME, ENANO_ROOT.'/includes/magic')) // First try to use the fileinfo extension, this is the best way to determine the mimetype - { - if(!$fi) die_friendly('Upload failed', 'Enano was unable to determine the format of the uploaded file.
'.@finfo_file($fi, $file['tmp_name']).'
'); - $type = @finfo_file($fi, $file['tmp_name']); - @finfo_close($fi); - } - elseif(function_exists('mime_content_type')) - $type = mime_content_type($file['tmp_name']); // OK, no fileinfo function. Use a (usually) built-in PHP function - elseif(isset($file['type'])) - $type = $file['type']; // LAST RESORT: use the mimetype the browser sent us, though this is likely to be spoofed - else // DANG! Not even the browser told us. Bail out. - die_friendly('Upload failed', 'Enano was unable to determine the format of the uploaded file.
'); - */ - $types = fetch_allowed_extensions(); - $ext = substr($file['name'], strrpos($file['name'], '.')+1, strlen($file['name'])); - if(!isset($types[$ext]) || ( isset($types[$ext]) && !$types[$ext] ) ) - { - die_friendly('Upload failed', 'The file type ".'.$ext.'" is not allowed.
'); - } - $type = $mime_types[$ext]; - //$type = explode(';', $type); $type = $type[0]; - //if(!in_array($type, $allowed_mime_types)) die_friendly('Upload failed', 'The file type "'.$type.'" is not allowed.
'); - if($_POST['rename'] != '') - { - $filename = $_POST['rename']; - } else { - $filename = $file['name']; - } - $bad_chars = Array(':', '\\', '/', '<', '>', '|', '*', '?', '"', '#', '+'); - foreach($bad_chars as $ch) - { - if(strstr($filename, $ch) || preg_match('/^([ ]+)$/is', $filename)) die_friendly('Upload failed', 'The filename contains invalid characters.
'); - } - - if(isset($paths->pages[$paths->nslist['File'].$filename]) && !isset($_POST['update'])) die_friendly('Upload failed', 'The file already exists. You can upload a new version of this file.
'); - elseif( isset($_POST['update']) && - (!isset($paths->pages[$paths->nslist['File'].$filename]) || - (isset($paths->pages[$paths->nslist['File'].$filename]) && - $paths->pages[$paths->nslist['File'].$filename]['protected']==1) - ) - ) - die_friendly('Upload failed', 'Either the file does not exist (and therefore cannot be updated) or the file is protected.
'); - - $utime = time(); - - $filename = $db->escape($filename); - $ext = substr($filename, strrpos($filename, '.'), strlen($filename)); - $flen = filesize($file['tmp_name']); - - $comments = $db->escape(RenderMan::strip_php($_POST['comments'])); - $chartag = sha1(microtime()); - $urln = str_replace(' ', '_', $filename); - - $key = md5($filename . '_' . file_get_contents($file['tmp_name'])); - $targetname = ENANO_ROOT . '/files/' . $key . '_' . $utime . $ext; - - if(!@move_uploaded_file($file['tmp_name'], $targetname)) - { - die_friendly('Upload failed', 'Could not move uploaded file to the new location.
'); - } - - if(getConfig('file_history') != '1') - if(!$db->sql_query('DELETE FROM '.table_prefix.'files WHERE filename=\''.$filename.'\' LIMIT 1;')) $db->_die('The old file data could not be deleted.'); - if(!$db->sql_query('INSERT INTO '.table_prefix.'files(time_id,page_id,filename,size,mimetype,file_extension,file_key) VALUES('.$utime.', \''.$urln.'\', \''.$filename.'\', '.$flen.', \''.$type.'\', \''.$ext.'\', \''.$key.'\')')) $db->_die('The file data entry could not be inserted.'); - if(!isset($_POST['update'])) - { - if(!$db->sql_query('INSERT INTO '.table_prefix.'logs(time_id,date_string,log_type,action,author,page_id,namespace) VALUES('.$utime.', \''.date('d M Y h:i a').'\', \'page\', \'create\', \''.$session->username.'\', \''.$filename.'\', \''.'File'.'\');')) $db->_die('The page log could not be updated.'); - if(!$db->sql_query('INSERT INTO '.table_prefix.'pages(name,urlname,namespace,protected,delvotes,delvote_ips) VALUES(\''.$filename.'\', \''.$urln.'\', \'File\', 0, 0, \'\')')) $db->_die('The page listing entry could not be inserted.'); - if(!$db->sql_query('INSERT INTO '.table_prefix.'page_text(page_id,namespace,page_text,char_tag) VALUES(\''.$urln.'\', \'File\', \''.$comments.'\', \''.$chartag.'\')')) $db->_die('The page text entry could not be inserted.'); - } else { - if(!$db->sql_query('INSERT INTO '.table_prefix.'logs(time_id,date_string,log_type,action,author,page_id,namespace,edit_summary) VALUES('.$utime.', \''.date('d M Y h:i a').'\', \'page\', \'reupload\', \''.$session->username.'\', \''.$filename.'\', \''.'File'.'\', \''.$comments.'\');')) $db->_die('The page log could not be updated.'); - } - die_friendly('Upload complete', 'Your file has been uploaded successfully. View the file\'s page.
'); - } else { - $template->header(); - $fn = $paths->getParam(0); - if ( $fn && !$session->get_permissions('upload_new_version') ) - { - die_friendly('Access denied', 'Uploading new versions of files has been disabled for your user account or group.
'); - } - ?> -
Using this form you can upload a file to the site.
-The maximum file size is = 1048576) - { - $fs = round($fs / 1048576, 1); - echo ' ('.$fs.' MB)'; - } elseif($fs >= 1024) { - $fs = round($fs / 1024, 1); - echo ' ('.$fs.' KB)'; - } - ?>.
-File: | |
Rename to: | /> | Comments: (can be wiki-formatted) | '; - else echo ' |
Reason for uploading the new version: | |
- '; - ?> - - |
The file "'.$filename.'" cannot be found.
'); } - $row = $db->fetchrow(); - $db->free_result(); - - // Check permissions - $perms = $session->fetch_page_acl($row['page_id'], 'File'); - if ( !$perms->get_permissions('read') ) - { - die_friendly('Access denied', 'Access to the specified file is denied.
'); - } - - $fname = ENANO_ROOT . '/files/' . $row['file_key'] . '_' . $row['time_id'] . $row['file_extension']; - $data = file_get_contents($fname); - if(isset($_GET['preview']) && getConfig('enable_imagemagick')=='1' && file_exists(getConfig('imagemagick_path')) && substr($row['mimetype'], 0, 6) == 'image/') - { - $nam = tempnam('/tmp', $filename); - $h = @fopen($nam, 'w'); - if(!$h) die('Error opening '.$nam.' for writing'); - fwrite($h, $data); - fclose($h); - /* Make sure the request doesn't contain commandline injection - yow! */ - if(!isset($_GET['width' ]) || (isset($_GET['width'] ) && !preg_match('#^([0-9]+)$#', $_GET['width'] ))) $width = '320'; else $width = $_GET['width' ]; - if(!isset($_GET['height']) || (isset($_GET['height']) && !preg_match('#^([0-9]+)$#', $_GET['height'] ))) $height = '240'; else $height = $_GET['height']; - $cache_filename=ENANO_ROOT.'/cache/'.$filename.'-'.$row['time_id'].'-'.$width.'x'.$height.$row['file_extension']; - if(getConfig('cache_thumbs')=='1' && file_exists($cache_filename) && is_writable(ENANO_ROOT.'/cache')) { - $data = file_get_contents($cache_filename); - } elseif(getConfig('enable_imagemagick')=='1' && file_exists(getConfig('imagemagick_path'))) { - // Use ImageMagick to convert the image - //unlink($nam); - error_reporting(E_ALL); - $cmd = ''.getConfig('imagemagick_path').' "'.$nam.'" -resize "'.$width.'x'.$height.'>" "'.$nam.'.scaled'.$row['file_extension'].'"'; - system($cmd, $stat); - if(!file_exists($nam.'.scaled'.$row['file_extension'])) die('Failed to call ImageMagick (return value '.$stat.'), command line was:'.$__login_status.'
'; - } - if ( $p = $paths->getAllParams() ) - { - echo ''; - } - else if ( isset($_POST['login']) && isset($_POST['return_to']) ) - { - echo ''; - } - ?> -- | ||
---|---|---|
- Logging in enables you to use your preferences and access member information. If you don\'t have a username and password here, you can create an account.';
- }
- else
- {
- echo ' You are requesting that a sensitive operation be performed. To continue, please re-enter your password to confirm your identity. '; - } - ?> - |
- ||
- Username: - | -- user_logged_in ) - { - echo 'value="' . $session->username . '"'; - } - ?> /> - | - -
- Forgot your password? No problem. - Maybe you need to create an account. - |
-
-
Password: | - | |
- Important note regarding cryptography: Some countries do not allow the import or use of cryptographic technology. If you live in one of the countries listed below, you should log in without using encryption. -This restriction applies to the following countries: Belarus, China, India, Israel, Kazakhstan, Mongolia, Pakistan, Russia, Saudi Arabia, Singapore, Tunisia, Venezuela, and Vietnam. - |
- ||
- |
'.$l.'
'; - $template->footer(); -} - -function page_Special_Register() { - global $db, $session, $paths, $template, $plugins; // Common objects - if(getConfig('account_activation') == 'disable' && ( ( $session->user_level >= USER_LEVEL_ADMIN && !isset($_GET['IWannaPlayToo']) ) || $session->user_level < USER_LEVEL_ADMIN || !$session->user_logged_in )) - { - $s = ($session->user_level >= USER_LEVEL_ADMIN) ? 'Oops...it seems that you are the administrator...hehe...you can also force account registration to work.
' : ''; - die_friendly('Registration disabled', 'The administrator has disabled new user registration on this site.
' . $s); - } - if(isset($_POST['submit'])) { - $captcharesult = $session->get_captcha($_POST['captchahash']); - if($captcharesult != $_POST['captchacode']) - $s = 'The confirmation code you entered was incorrect.'; - else - // CAPTCHA code was correct, create the account - $s = $session->create_user($_POST['username'], $_POST['password'], $_POST['email'], $_POST['real_name']); - if($s == 'success') - { - switch(getConfig('account_activation')) - { - case "none": - default: - $str = 'You may now log in with the username and password that you created.'; - break; - case "user": - $str = 'Because this site requires account activation, you have been sent an e-mail with further instructions. Please follow the instructions in that e-mail to continue your registration.'; - break; - case "admin": - $str = 'Because this site requires administrative account activation, you cannot use your account at the moment. A notice has been sent to the site administration team that will alert them that your account has been created.'; - break; - } - die_friendly('Registration successful', 'Thank you for registering, your user account has been created. '.$str.'
'); - } - } - $template->header(); - echo 'A user account enables you to have greater control over your browsing experience.'; - $session->kill_captcha(); - $captchacode = $session->make_captcha(); - ?> -Please tell us a little bit about yourself. | '.$s.' | '; ?> -|
---|---|---|
Preferred username: | ||
Password: | ||
Enter your password again to confirm. | ||
E-mail address:An e-mail with an account activation key will be sent to this address, so please ensure that it is correct. | '; ?>||
Real name: Giving your real name is totally optional. If you choose to provide your real name, it will be used to provide attribution for any edits or contributions you may make to this site. | ||
Visual confirmation Please enter the code shown in the image to the right into the text box. This process helps to ensure that this registration is not being performed by an automated bot. If the image to the right is illegible, you can generate a new image. If you are visually impaired or otherwise cannot read the text shown to the right, please contact the site management and they will create an account for you. | ||
Code: | ||
Your profile has been updated. Return to the index page.
'; - else echo $data; - } else { - echo ' -Username: | |
Current Password: | |
You only need to enter your current password if you are changing your e-mail address or changing your password. | |
New Password: | |
E-mail: | |
Real Name: | |
Signature: Your signature appears below your comment posts. | |
- |
You must be logged in to change your style. Spoofer.
'); - if(isset($_POST['theme']) && isset($_POST['style']) && isset($_POST['return_to'])) - { - $d = ENANO_ROOT . '/themes/' . $_POST['theme']; - $f = ENANO_ROOT . '/themes/' . $_POST['theme'] . '/css/' . $_POST['style'] . '.css'; - if(!file_exists($d) || !is_dir($d)) die('The directory "'.$d.'" does not exist.'); - if(!file_exists($f)) die('The file "'.$f.'" does not exist.'); - $d = $db->escape($_POST['theme']); - $f = $db->escape($_POST['style']); - $q = 'UPDATE '.table_prefix.'users SET theme=\''.$d.'\',style=\''.$f.'\' WHERE username=\''.$session->username.'\''; - if(!$db->sql_query($q)) - { - $db->_die('Your theme/style preferences were not updated.'); - } - else - { - redirect(makeUrl($_POST['return_to']), '', '', 0); - } - } - else - { - $template->header(); - $ret = ( isset($_POST['return_to']) ) ? $_POST['return_to'] : $paths->getParam(0); - if(!$ret) $ret = getConfig('main_page'); - ?> -- -
--
- -- -
-- -
- -The URL was incorrect.
'); - $key = $paths->getParam(1); - if(!$key) die_friendly('Account activation error', 'The URL was incorrect.
'); - $s = $session->activate_account(str_replace('_', ' ', $user), $key); - if($s > 0) die_friendly('Activation successful', 'Your account is now active. Thank you for registering.
'); - else die_friendly('Activation failed', 'The activation key was probably incorrect.
'); -} - -function page_Special_Captcha() -{ - global $db, $session, $paths, $template, $plugins; // Common objects - if($paths->getParam(0) == 'make') - { - $session->kill_captcha(); - echo $session->make_captcha(); - return; - } - $hash = $paths->getParam(0); - if(!$hash || !preg_match('#^([0-9a-f]*){32,32}$#i', $hash)) $paths->main_page(); - $code = $session->get_captcha($hash); - if(!$code) die('Invalid hash or IP address incorrect.'); - require(ENANO_ROOT.'/includes/captcha.php'); - $captcha = new captcha($code); - //header('Content-disposition: attachment; filename=autocaptcha.png'); - $captcha->make_image(); - exit; -} - -function page_Special_PasswordReset() -{ - global $db, $session, $paths, $template, $plugins; // Common objects - $template->header(); - if($paths->getParam(0) == 'stage2') - { - $user_id = intval($paths->getParam(1)); - $encpass = $paths->getParam(2); - if ( $user_id < 2 ) - { - echo 'Hacking attempt
'; - $template->footer(); - return false; - } - if(!preg_match('#^([a-f0-9]+)$#i', $encpass)) - { - echo 'Hacking attempt
'; - $template->footer(); - return false; - } - - $q = $db->sql_query('SELECT username,temp_password_time FROM '.table_prefix.'users WHERE user_id='.$user_id.' AND temp_password=\'' . $encpass . '\';'); - if($db->numrows() < 1) - { - echo 'Invalid credentials
'; - $template->footer(); - return false; - } - $row = $db->fetchrow(); - $db->free_result(); - - if ( ( intval($row['temp_password_time']) + 3600 * 24 ) < time() ) - { - echo 'Password has expired
'; - $template->footer(); - return false; - } - - if ( isset($_POST['do_stage2']) ) - { - $aes = new AESCrypt(AES_BITS, AES_BLOCKSIZE); - if($_POST['use_crypt'] == 'yes') - { - $crypt_key = $session->fetch_public_key($_POST['crypt_key']); - if(!$crypt_key) - { - echo 'ERROR: Couldn\'t look up public key for decryption.'; - $template->footer(); - return false; - } - $crypt_key = hexdecode($crypt_key); - $data = $aes->decrypt($_POST['crypt_data'], $crypt_key, ENC_HEX); - if(strlen($data) < 6) - { - echo 'ERROR: Your password must be six characters or greater in length.'; - $template->footer(); - return false; - } - } - else - { - $data = $_POST['pass']; - $conf = $_POST['pass_confirm']; - if($data != $conf) - { - echo 'ERROR: The passwords you entered do not match.'; - $template->footer(); - return false; - } - if(strlen($data) < 6) - { - echo 'ERROR: Your password must be six characters or greater in length.'; - $template->footer(); - return false; - } - } - if(empty($data)) - { - echo 'ERROR: Sanity check failed!'; - $template->footer(); - return false; - } - $encpass = $aes->encrypt($data, $session->private_key, ENC_HEX); - $q = $db->sql_query('UPDATE '.table_prefix.'users SET password=\'' . $encpass . '\',temp_password=\'\',temp_password_time=0 WHERE user_id='.$user_id.';'); - - if($q) - { - $session->login_without_crypto($row['username'], $data); - echo 'Your password has been reset. Return to the main page.
'; - } - else - { - echo $db->get_error(); - } - - $template->footer(); - return false; - } - - // Password reset form - $pubkey = $session->rijndael_genkey(); - - ?> -Reset password | |
---|---|
Password: | |
Confirm: | |
- - - - - | -
An e-mail has been sent to the e-mail address on file for your username with a new password in it. Please check your e-mail for further instructions.
'; - } - else - { - echo 'Error occured, your new password was not sent.
'; - } - $template->footer(); - return true; - } - echo 'Don\'t worry, it happens to the best of us.
-To reset your password, just enter your username below, and a new password will be e-mailed to you.
-Username: '.$template->username_field('username').'
- -