Exemple #1
0
 /**
  * Check by name if a page exists.
  *
  * @author		{@link http://wikkawiki.org/JavaWoman JavaWoman}
  * @copyright	Copyright © 2004, Marjolein Katsma
  * @license		http://www.gnu.org/copyleft/lesser.html GNU Lesser General Public License
  * @version		1.1
  *
  * NOTE: v. 1.0 -> 1.1
  *		- name changed from ExistsPage() to existsPage() !!!
  *		- added $prefix param so it can be used from installer
  *		- added $current param so it checks by default for a current page only
  *
  * @access	public
  * @uses	Query()
  *
  * @param	string	$page  page name to check
  * @param	string	$prefix	optional: table prefix to use
  *					pass NULL if you need to override the $active parameter
  *					default: prefix as in configuration file
  * @param	mixed	$dblink	optional: connection resource, or NULL to get
  *					object's connection
  * @param	string	$active	optional: if TRUE, check for actgive page only
  *					default: TRUE
  * @return	boolean	TRUE if page exists, FALSE otherwise
  */
 function existsPage($page, $prefix = '', $dblink = NULL, $active = TRUE)
 {
     // Always replace '_' with ws
     $page = preg_replace('/_+/', ' ', $page);
     // init
     $count = 0;
     $table_prefix = empty($prefix) && isset($this) ? $this->GetConfigValue('table_prefix') : $prefix;
     if (is_null($dblink)) {
         $dblink = $this->dblink;
     }
     // build query
     $query = "SELECT COUNT(tag)\n\t\t\t\tFROM " . $table_prefix . "pages\n\t\t\t\tWHERE tag='" . mysql_real_escape_string($page) . "'";
     if ($active) {
         $query .= "\t\tAND latest='Y'";
     }
     // do query
     if ($r = Wakka::Query($query, $dblink)) {
         $count = mysql_result($r, 0);
         mysql_free_result($r);
     }
     // report
     return $count > 0 ? TRUE : FALSE;
 }
Exemple #2
0
// try to write configuration file
print "<h2>Writing configuration</h2>\n";
test("Writing configuration file <tt>" . $wakkaConfigLocation . "</tt>...", $fp = @fopen($wakkaConfigLocation, "w"), "", 0);
if ($fp) {
    fwrite($fp, $configCode);
    // write
    fclose($fp);
    if ($config2['wakka_version'] <= '1.3.2') {
        print "<p>Almost done! A maintenance operation is needed due to a change in the database structure. This maintenance can be resource consuming if you had many pages. Click on the following link and refresh the page until you see only the text \"Done...\". <a style=\"font-size: 24pt;\" href=\"" . WIKKA_BASE_URL . "/wikka.php?wakka=Do/maintenance.xml\" target=\"_blank\">Do maintenance.</a></p>";
    }
    print "<p>That's all! You can now <a href=\"" . WIKKA_BASE_URL . "\">return to your Wikka site</a>. However, you are advised to remove write access to <tt>wikka.config.php</tt> again now that it's been written. Leaving the file writable can be a security risk!</p>";
} else {
    // complain
    print "<p><span class=\"failed\">WARNING:</span> The configuration file <tt>" . $wakkaConfigLocation . "</tt> could not be written. You will need to give your web server temporary write access to either your wakka directory, or a blank file called <tt>wikka.config.php</tt> (<tt>touch wikka.config.php ; chmod 666 wikka.config.php</tt>; don't forget to remove write access again later, ie <tt>chmod 644 wikka.config.php</tt>). If, for any reason, you can't do this, you'll have to copy the text below into a new file and save/upload it as <tt>wikka.config.php</tt> into the Wikka directory. Once you've done this, your Wikka site should work. If not, please visit <a href=\"http://docs.wikkawiki.org/WikkaInstallation\">WikkaInstallation</a>.</p>\n";
    ?>
	<form action="<?php 
    echo myLocation();
    ?>
?installAction=writeconfig" method="post">
	<input type="hidden" name="config" value="<?php 
    echo Wakka::hsc_secure(serialize($config2));
    ?>
" /><?php 
    /*  #427 */
    ?>
	<input type="submit" value="Try again" />
	</form>	
	<?php 
    print "<xmp>" . $configCode . "</xmp>\n";
    //TODO: replace xmp and make code block downloadable
}
Exemple #3
0
<?php

/**
 * Plain text language file for Wikka highlighting (or unknown language).
 * 
 * @package	Formatters
 * @version	$Id$
 * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License
 * @filesource
 * 
 * @uses	Wakka::hsc_secure()
 */
echo '<pre>' . Wakka::hsc_secure($text, ENT_QUOTES) . '</pre>';
#427
Exemple #4
0
            // display form
            if (!empty($error)) {
                if ($error == ERROR_OVERWRITE_ALERT) {
                    $output .= '<!-- <wiki-error>overwritten alert</wiki-error> -->';
                }
                $output .= '<em class="error">' . $error . '</em>' . "\n";
            }
            // append a comment?
            // TODO not clear if this is/was intended as a URL parameter (GET), or a check box on the edito form (POST) ....
            // would be nice as a checkbox, provided it is acted upon only when user is actually submitting - NOT on preview or re-edit
            if (isset($_POST['appendcomment'])) {
                $body = trim($body) . "\n\n----\n\n-- " . $this->GetUserName() . ' ' . sprintf("(%s)", strftime("%c")) . ')';
            }
            $edit_buttons = '<fieldset><legend>' . T_("Store page") . '</legend>' . "\n" . $edit_note_field . '<input name="submit" type="submit" value="' . T_("Store") . '" accesskey="' . "s" . '" />' . "\n" . '<input name="submit" type="submit" value="' . T_("Preview") . '" accesskey="' . "p" . '" />' . "\n" . '<input type="submit" value="' . T_("Cancel") . '" name="cancel" />' . "\n" . '</fieldset>' . "\n";
            $output .= $this->FormOpen('edit');
            $output .= '<input type="hidden" name="previous" value="' . $previous . '" />' . "\n" . '<div id="textarea_container">' . "\n" . '<textarea id="body" name="body" rows="20" cols="100">' . Wakka::hsc_secure($body) . '</textarea>' . "\n" . '</div>' . "\n";
            $output .= $edit_buttons;
            $output .= $this->FormClose();
            if ($this->GetConfigValue('gui_editor') == 1) {
                $output .= '<script type="text/javascript" src="3rdparty/plugins/wikkaedit/wikkaedit_data.js"></script>' . "\n";
                $output .= '<script type="text/javascript" src="3rdparty/plugins/wikkaedit/wikkaedit_search.js"></script>' . "\n";
                $output .= '<script type="text/javascript" src="3rdparty/plugins/wikkaedit/wikkaedit.js"></script>' . "\n";
            }
        }
        echo $output;
    } else {
        $message = '<!-- <wiki-error>forbidden</wiki-error> --><em class="error">' . sprintf(T_("You don't have write access to this page. You might need to <a href=\"%s\">login</a> or <a href=\"%s\">register an account</a> to be able to edit this page."), $this->Href('', 'UserSettings'), $this->Href('', 'UserSettings')) . '</em><br />' . "\n" . "<br />\n" . '<a href="' . $this->Href('showcode') . '" title="' . T_("Click to view page formatting code") . '">' . T_("View formatting code for this page") . '</a>' . "<br />\n";
        echo $message;
    }
}
?>
Exemple #5
0
 function htmlspecialchars_ent($text, $quote_style = ENT_COMPAT, $doctype = 'HTML')
 {
     // re-establish default if overwritten because of third parameter
     // [ENT_COMPAT] => 2
     // [ENT_QUOTES] => 3
     // [ENT_NOQUOTES] => 0
     if (!in_array($quote_style, array(ENT_COMPAT, ENT_QUOTES, ENT_NOQUOTES))) {
         $quote_style = ENT_COMPAT;
     }
     // define patterns
     $terminator = ';|(?=($|[\\n<]|&lt;))';
     // semicolon; or end-of-string, newline or tag
     $numdec = '#[0-9]+';
     // numeric character reference (decimal)
     $numhex = '#x[0-9a-f]+';
     // numeric character reference (hexadecimal)
     if ($doctype == 'XML') {
         // only valid named entities in XML (case-sensitive)
         $named = 'lt|gt|quot|apos|amp';
         $ignore_case = '';
         $entitystring = $named . '|' . $numdec . '|' . $numhex;
     } else {
         $alpha = '[a-z]+';
         // character entity reference TODO $named='eacute|egrave|ccirc|...'
         $ignore_case = 'i';
         // names can consist of upper and lower case letters
         $entitystring = $alpha . '|' . $numdec . '|' . $numhex;
     }
     $escaped_entity = '&amp;(' . $entitystring . ')(' . $terminator . ')';
     $output = Wakka::hsc_secure($text, $quote_style);
     // "repair" escaped entities
     // modifiers: s = across lines, i = case-insensitive
     $output = preg_replace('/' . $escaped_entity . '/s' . $ignore_case, "&\$1;", $output);
     // return output
     return $output;
 }
Exemple #6
0
<?php

/**
 * INI language file for Wikka highlighting (configuration file).
 * 
 * @package	Formatters
 * @version	$Id$
 * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License
 * @filesource
 * 
 * @uses	Wakka::hsc_secure()
 */
$text = Wakka::hsc_secure($text, ENT_QUOTES);
#427
$text = preg_replace("/([=,\\|]+)/m", "<span style=\"color:#4400DD\">\\1</span>", $text);
$text = preg_replace("/^([;#].+)\$/m", "<span style=\"color:#226622\">\\1</span>", $text);
$text = preg_replace("/([^\\d\\w#;:>])([;#].+)\$/m", "<span style=\"color:#226622\">\\2</span>", $text);
$text = preg_replace("/^(\\[.*\\])/m", "<strong style=\"color:#AA0000;background:#EEE0CC\">\\1</strong>", $text);
print "<pre>" . $text . "</pre>";
Exemple #7
0
   "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html>
   <head>
      <title>mind map fullscreen</title>
      <style type="text/css">
	   html, body {height: 100%}
	   .floatright {float: right; width: 48%; margin: 0.5%; padding: 0.5%; background: #EEE;}
      </style>
   </head>
   <body>

<?php 
$mindmap_url = Wakka::hsc_secure(preg_replace('/&amp;/', '&', trim($_GET['url'])));
#312 // duplicates Wakka::cleanUrl()
if (isset($_GET['height'])) {
    $height = Wakka::hsc_secure(trim($_GET['height']));
}
#312 // more or less equivalent to Wakka::GetSafeVar()
if ($mindmap_url) {
    if (!isset($height)) {
        $height = "100%";
    }
    $output = "<span class=\"floatright\"> <a href=\"#\" onclick=\"window.close('fullmindmap')\">Close Window</a> </span> <br /> <div class=\"mindmap\" style=\"height: 100%; clear:both;\"><script type=\"text/javascript\">\n" . "<!--\n" . "    if(!navigator.javaEnabled()) {\n" . "        document.write('Please install a <a href=\"http://www.java.com\">Java Runtime Environment<\\/a> on your computer.');\n" . "    }\n" . "//-->\n" . "</script>\n" . "<applet code=\"freemind.main.FreeMindApplet.class\" archive=\"freemindbrowser.jar\" width=\"100%\" height=\"{$height}\">\n" . "  <param name=\"type\" value=\"application/x-java-applet;version=1.4\" />\n" . "  <param name=\"scriptable\" value=\"false\" />\n" . "  <param name=\"modes\" value=\"freemind.modes.browsemode.BrowseMode\" />\n" . "  <param name=\"browsemode_initial_map\" value=\"{$mindmap_url}\" />\n" . "  <param name=\"initial_mode\" value=\"Browse\" />\n" . "  <param name=\"selection_method\" value=\"selection_method_direct\" />\n" . "</applet>\n" . "<br />\n" . "<span class=\"floatright\"> <a href=\"{$mindmap_url}\">Download this mind map</a> :: Use <a href=\"http://freemind.sourceforge.net/\">Freemind</a> to edit it :: <A HREF=\"#\" onclick=\"window.close('fullmindmap')\">Close Window</A></span>\n" . "<br /><strong>NOTE:</strong>Java 1.4.1 (or later) Plug-in is needed to run this applet,<br /> so if it does not work,\n" . "<a href=\"http://java.com/\"> get the latest Java Plug-in here.</a>\n</div>";
    print $output;
} else {
    echo "<em class='error'>Error: Invalid MindMap action syntax. <br /> Proper usage: {{mindmap http://domain.com/MapName/mindmap.mm}} or {{mindmap url=\"http://domain.com/MapName/mindmap.mm\"}}</em>";
}
?>

   </body>
</html>