syntax error, unexpected

All about webserver configurations, PHP and databases.

Moderator: Thorsten

Post Reply
jefferson
Posts: 7
Joined: Wed Jan 20, 2010 4:55 pm

syntax error, unexpected

Post by jefferson »

Hallo

bin neu hier und habe folgendes probelm. bekomme die phpmyfaq ohne probleme lokal unter xampp installiert und eingerichtet. wenn ich versuche die seite bei 1und1 hochzulanden bekomme ich folgende fehlermeldung beim versuch die seite einzurichten " Parse error: syntax error, unexpected '=', expecting ')' in /homepages/33/d190864777/htdocs/phpmyfaq/install/setup.php on line 85 ". kann jemand was damit anfangen? :cry:

bin für jede hilfe dankbar

gruss jeff
Thorsten
Posts: 15560
Joined: Tue Sep 25, 2001 11:14 am
Location: #phpmyfaq
Contact:

Re: syntax error, unexpected

Post by Thorsten »

Hi,

kannst du deine Datei hier mal reinpasten?

Danke!

bye
Thorsten
phpMyFAQ Maintainer and Lead Developer
amazon.de Wishlist
jefferson
Posts: 7
Joined: Wed Jan 20, 2010 4:55 pm

Re: syntax error, unexpected

Post by jefferson »

Hallo hier die setup.php bekomme aber auch beim aufruf der index.php den selben Fehler in einer anderen Zeile.

zeile 85 ist hier: function extension_check($enabledExtensions, &$output = NULL)

<?php
/**
* The main phpMyFAQ Setup
*
* This script checks the complete environment, writes the database connection
* parameters into the file config/database.php and the configuration into the database.
*
* PHP Version 5.2
*
* The contents of this file are subject to the Mozilla Public License
* Version 1.1 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS"
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
* License for the specific language governing rights and limitations
* under the License.
*
* @category phpMyFAQ
* @package Setup
* @author Thorsten Rinne <thorsten@phpmyfaq.de>
* @author Tom Rochester <tom.rochester@gmail.com>
* @author Johannes Schlueter <johannes@php.net>
* @author Uwe Pries <uwe.pries@digartis.de>
* @author Matteo Scaramuccia <matteo@phpmyfaq.de>
* @copyright 2002-2010 phpMyFAQ Team
* @license http://www.mozilla.org/MPL/MPL-1.1.html Mozilla Public License Version 1.1
* @link http://www.phpmyfaq.de
* @since 2002-08-20
*/

define('VERSION', '2.6.0');
define('APIVERSION', 1);
define('COPYRIGHT', '&copy; 2001-2010 <a href="http://www.phpmyfaq.de/">phpMyFAQ Team</a> | All rights reserved.');
define('SAFEMODE', @ini_get('safe_mode'));
define('PMF_ROOT_DIR', dirname(dirname(__FILE__)));

require PMF_ROOT_DIR . '/config/constants.php';
require PMF_ROOT_DIR . '/inc/autoLoader.php';
require PMF_ROOT_DIR . '/inc/functions.php';
require PMF_ROOT_DIR . '/install/questionnaire.php';

$query = $uninst = array();

// permission levels
$permLevels = array(
'basic' => 'Basic (no group support)',
'medium' => 'Medium (with group support)');

$enabledExtensions = array(
'gd',
'json',
'xmlwriter',
'filter');

/**
* Lookup for installed database extensions
* If the first supported extension is enabled, return true.
*
* @param array $supported_databases Array of supported databases
* @return boolean
* @access public
* @author Thorsten Rinne <thorsten@phpmyfaq.de>
*/
function db_check($supported_databases)
{
foreach ($supported_databases as $extension => $database) {
if (extension_loaded($extension)) {
return true;
}
}

return false;
}

/**
* Lookup for installed PHP extensions
*
* @param array $enabledExtensions enabled Extensions
* @return boolean
* @access public
* @author Thorsten Rinne <thorsten@phpmyfaq.de>
*/
function extension_check($enabledExtensions, &$output = NULL)
{
$missing_extensions = array();
foreach ($enabledExtensions as $extension) {

if (!extension_loaded($extension)) {
$missing_extensions[] = $extension;
}
}

if (count($missing_extensions) > 0) {
$output = $missing_extensions;
return false;
}
return true;
}

/**
* Checks for an installed phpMyFAQ version
*
* @return boolean
* @access public
* @author Thorsten Rinne <thorsten@phpmyfaq.de>
*/
function phpmyfaq_check()
{
if (is_file(PMF_ROOT_DIR.'/inc/data.php') || is_file(PMF_ROOT_DIR . '/config/database.php')) {
return false;
} else {
return true;
}
}

/**
* Executes the uninstall set of queries
*
* @return void
* @access public
* @author Thorsten Rinne <thorsten@phpmyfaq.de>
*/
function db_uninstall()
{
global $uninst, $db;

while ($each_query = each($uninst)) {
$db->query($each_query[1]);
}
}

/**
* Print out the XHTML Footer
*
* @return void
* @access public
* @author Thorsten Rinne <thorsten@phpmyfaq.de>
*/
function HTMLFooter()
{
printf('<p class="center">%s</p></body></html>', COPYRIGHT);
}

/**
* Removes the data.php and the dataldap.php if an installation failed
*
* @return void
* @access public
* @author Thorsten Rinne <thorsten@phpmyfaq.de>
*/
function cleanInstallation()
{
// Remove 'database.php' file: no need of prompt anything to the user
if (file_exists(PMF_ROOT_DIR.'/config/database.php')) {
@unlink(PMF_ROOT_DIR.'/config/database.php');
}
// Remove 'dataldap.php' file: no need of prompt anything to the user
if (file_exists(PMF_ROOT_DIR.'/config/ldap.php')) {
@unlink(PMF_ROOT_DIR.'/config/ldap.php');
}
}

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>phpMyFAQ <?php print VERSION; ?> Setup</title>
<meta http-equiv="Content-Type" content="application/xhtml+xml; charset=iso-8859-1" />
<link rel="shortcut icon" href="../template/default/favicon.ico" type="image/x-icon" />
<link rel="icon" href="../template/default/favicon.ico" type="image/x-icon" />
<script language="javascript" type="text/javascript">
/*<![CDATA[*/
// <!--
function cssAddClass(ele, className) {
if (typeof ele == 'string') {
ele = document.getElementById(ele);
}

ele.className += ' ' + className;
}

function cssDelClass(ele, className) {
if (typeof ele == 'string') {
ele = document.getElementById(ele);
}

var regexp = new RegExp(
'^'+className+'\\b\\s*|\\s*\\b'+className+'\\b', 'ig'
);
ele.className = ele.className.replace(regexp, '');
}

function select_database(field) {
switch (field.value) {
case 'sqlite':
cssDelClass('dbsqlite', 'collapsed');
cssAddClass('dbdatafull', 'collapsed');
break;
default:
cssAddClass('dbsqlite', 'collapsed');
cssDelClass('dbdatafull', 'collapsed');
break;
}
}
// -->
/*]]>*/
</script>
<style media="screen" type="text/css">@import url(style/setup.css);</style>
</head>
<body>

<h1 id="header">phpMyFAQ <?php print VERSION; ?> Setup</h1>

<?php

if (version_compare(PHP_VERSION, '5.2.0', '<')) {
print "<p class=\"center\">You need PHP 5.2.0 or later!</p>\n";
HTMLFooter();
die();
}

if (!db_check($supported_databases)) {
print '<p class="center">No supported database detected! Please install one of the following' .
' database systems and enable the corresponding PHP extension:</p>';
print '<ul>';
foreach ($supported_databases as $database) {
printf(' <li>%s</li>', $database[1]);
}
print '</ul>';
HTMLFooter();
die();
}

$missing = array();
if (!extension_check($enabledExtensions, $missing)) {
print "<p class=\"center\">The following extensions are missing! Please enable the PHP extension:</p>\n";
print "<ul>\n";
foreach ($missing as $extension) {
printf(' <li>ext/%s</li>', $extension);
}
print "</ul>\n";
HTMLFooter();
die();
}

if (!phpmyfaq_check()) {
print '<p class="center">It seems you\'re already running a version of phpMyFAQ.<br />Please use the <a href="update.php">update script</a>.</p>';
HTMLFooter();
die();
}

$dirs = array('/attachments', '/config', '/data');
$faileddirs = array();

foreach ($dirs as $dir) {
if (!@is_dir(PMF_ROOT_DIR . $dir)) {
if (!@mkdir (PMF_ROOT_DIR . $dir, 0755)) {
$faileddirs[] = $dir;
}
} else if (!@is_writable(PMF_ROOT_DIR . $dir)) {
$faileddirs[] = $dir;
} else {
@copy('index.html', PMF_ROOT_DIR . $dir . '/index.html');
}
}

if (sizeof($faileddirs)) {
print '<p class="center">The following directory/-ies could not be created or are not writable:</p><ul>';
foreach ($faileddirs as $dir) {
print "<li>$dir</li>\n";
}
print '</ul><p class="center">Please create it manually and/or change access to chmod 755 (or greater if necessary).</p>';
HTMLFooter();
die();
}

if (!isset($_POST["sql_server"]) && !isset($_POST["sql_user"]) && !isset($_POST["sql_db"])) {
?>

<p class="center">Your PHP version: <strong>PHP <?php print PHP_VERSION; ?></strong></p>

<?php
if (SAFEMODE == 1) {
print '<p class="center">The PHP safe mode is enabled. You may have problems when phpMyFAQ writes in some directories.</p>';
}
if (!extension_loaded('gd')) {
print '<p class="center">You don\'t have GD support enabled in your PHP installation. Please enabled GD support in your php.ini file otherwise you can\'t use Captchas for spam protection.</p>';
}
if (!function_exists('imagettftext')) {
print '<p class="center">You don\'t have Freetype support enabled in the GD extension of your PHP installation. Please enabled Freetype support in GD extension otherwise the Captchas for spam protection will be quite easy to break.</p>';
}
?>
<p class="center">
Did you already read the <a href="../docs/documentation.en.html">documentation</a> carefully before
starting the phpMyFAQ setup?</p>

<form action="setup.php" method="post">
<fieldset class="installation">
<legend class="installation">Please add your database connection setup information</legend>

<label class="left">SQL server:</label>
<select class="input" name="sql_type" id="sql_selector" size="1" onchange="select_database(this);">
<?php
// check what extensions are loaded in PHP
foreach ($supported_databases as $extension => $database) {
if (extension_loaded($extension) && version_compare(PHP_VERSION, $database[0]) >= 0) {
// prevent MySQLi with zend.ze1_compatibility_mode enabled due to a few cloning isssues
if (($extension == 'mysqli') && ini_get('zend.ze1_compatibility_mode')) {
continue;
}

printf('<option value="%s">%s</option>', $extension, $database[1]);
}
}
?>
</select><br />

<div id="dbdatafull">
<label class="left">SQL server host:</label>
<input class="input" type="text" name="sql_server" title="Please enter the host of your SQL server here." /><br />

<label class="left">SQL username:</label>
<input class="input" type="text" name="sql_user" title="Please enter your SQL username here." /><br />

<label class="left">SQL password:</label>
<input class="input" name="sql_passwort" type="password" title="Please enter your SQL password here." /><br />

<label class="left">SQL database:</label>
<input class="input" type="text" name="sql_db" title="Please enter your SQL database name here." /><br />
</div>

<div id="dbsqlite" class="collapsed">
<label class="left">SQLite database file:</label>
<input class="input" type="text" name="sql_sqlitefile" value="<?php print dirname(dirname(__FILE__)); ?>" title="Please enter the full path to your SQLite datafile which should be outside your documentation root." /><br />
</div>

<label class="left">Table prefix:</label>
<input class="input" type="text" name="sqltblpre" title="Please enter a table prefix here if you want to install more phpMyFAQ installations on one database." />

</fieldset>
<script language="javascript" type="text/javascript">
obj = document.getElementById("sql_selector");
if (obj.options.length > obj.selectedIndex) {
select_database(obj.options[obj.selectedIndex]);
}
</script>
<br />
<?php
if (extension_loaded('ldap')) {
?>
<fieldset class="installation">
<legend class="installation">LDAP information</legend>

<label class="left">Enable LDAP support?</label>
<input class="checkbox" type="checkbox" name="ldap_enabled" value="yes" /><br />

<label class="left">LDAP server host:</label>
<input class="input" type="text" name="ldap_server" title="Please enter the host of your LDAP server here." /><br />

<label class="left">LDAP server port:</label>
<input class="input" type="text" name="ldap_port" value="389" title="Please enter the port of your LDAP server here." /><br />

<label class="left">LDAP username:</label>
<input class="input" type="text" name="ldap_user" title="Please enter your specified RDN username here." /><br />

<label class="left">LDAP password:</label>
<input class="input" name="ldap_password" type="password" title="Please enter your LDAP password here." /><br />

<label class="left">Distinguished name (dn):</label>
<input class="input" type="text" name="ldap_base" title="Please enter your distinguished name, e.g. 'cn=John Smith,ou=Accounts,o=My Company,c=US' here." />

</fieldset>
<br />
<?php
}
?>

<fieldset class="installation">
<legend class="installation">phpMyFAQ information</legend>

<label class="left">Default language:</label>
<select class="input" name="language" size="1" title="Please select your default language.">
<?php
if ($dir = @opendir(PMF_ROOT_DIR . '/lang')) {
while ($dat = @readdir($dir)) {
if (substr($dat, -4) == '.php') {
printf('<option value="%s"', $dat);
if ($dat == "language_en.php") {
print ' selected="selected"';
}
print '>' . $languageCodes[substr(strtoupper($dat), 9, 2)] . '</option>';
}
}
} else {
print '<option>english</option>';
}
?>
</select><br />

<label class="left">Permission level:</label>
<select class="input" name="permLevel" size="1" title="Complexity of user and right administration. Basic: users may have user-rights. Medium: users may have user-rights; group administration; groups may have group-rights; user have group-rights via group-memberships.">
<?php
foreach ($permLevels as $level => $desc) {
printf(' <option value="%s">%s</option>', $level, $desc);
}
?>
</select><br />

<label class="left">Admin's real name:</label>
<input class="input" type="text" name="realname" title="Please enter your real name here." /><br />

<label class="left">Admin's e-mail address:</label>
<input class="input" type="text" name="email" title="Please enter your email adress here." /><br />

<label class="left">Admin's username:</label>
<input class="input" type="text" name="username" title="You don't have to do anything here." value="admin" readonly="readonly" /><br />

<label class="left">Admin's password:</label>
<input class="input" type="password" name="password" title="Please enter your password for the admin area." /><br />

<label class="left">Retype password:</label>
<input class="input" type="password" name="password_retyped" title="Please retype your password for checkup." /><br />

</fieldset>


<p class="center"><strong>Do not use it if you're already running a version of phpMyFAQ!</strong></p>

<p class="center"><input type="submit" value="Click to install phpMyFAQ <?php print VERSION; ?>" class="button" /></p>

</form>
<?php
HTMLFooter();
} else {

// Ckeck table prefix
$sqltblpre = PMF_Filter::filterInput(INPUT_POST, 'sqltblpre', FILTER_SANITIZE_STRING, '');
if (!defined('SQLPREFIX')) {
define('SQLPREFIX', $sqltblpre);
}

// check database entries
$sql_type = PMF_Filter::filterInput(INPUT_POST, 'sql_type', FILTER_SANITIZE_STRING);
if (!is_null($sql_type)) {
$sql_type = trim($sql_type);
if (file_exists(PMF_ROOT_DIR . '/install/' . $sql_type . '.sql.php')) {
require PMF_ROOT_DIR . '/install/' . $sql_type . '.sql.php';
} else {
print '<p class="error"><strong>Error:</strong> Invalid server type.</p>';
HTMLFooter();
die();
}
} else {
print "<p class=\"error\"><strong>Error:</strong> There's no DB server input.</p>\n";
HTMLFooter();
die();
}

$sql_server = PMF_Filter::filterInput(INPUT_POST, 'sql_server', FILTER_SANITIZE_STRING);
if (is_null($sql_server) && $sql_type != 'sqlite') {
print "<p class=\"error\"><strong>Error:</strong> There's no DB server input.</p>\n";
HTMLFooter();
die();
}

$sql_user = PMF_Filter::filterInput(INPUT_POST, 'sql_user', FILTER_SANITIZE_STRING);
if (is_null($sql_user) && $sql_type != 'sqlite') {
print "<p class=\"error\"><strong>Error:</strong> There's no DB username input.</p>\n";
HTMLFooter();
die();
}

$sql_passwort = PMF_Filter::filterInput(INPUT_POST, 'sql_passwort', FILTER_SANITIZE_STRING);
if (is_null($sql_passwort) && $sql_type == 'sqlite') {
// Password can be empty...
$sql_passwort = '';
}

$sql_db = PMF_Filter::filterInput(INPUT_POST, 'sql_db', FILTER_SANITIZE_STRING);
if (is_null($sql_db) && $sql_type != 'sqlite') {
print "<p class=\"error\"><strong>Error:</strong> There's no DB database input.</p>\n";
HTMLFooter();
die();
}

if ($sql_type == 'sqlite') {
$sql_sqllitefile = PMF_Filter::filterInput(INPUT_POST, 'sql_sqlitefile', FILTER_SANITIZE_STRING);
if (!is_null($sql_sqllitefile)) {
$sql_server = $sql_sqllitefile; // We're using $sql_server, too!
} else {
print "<p class=\"error\"><strong>Error:</strong> There's no SQLite database filename input.</p>\n";
HTMLFooter();
die();
}
}

// check database connection
require PMF_ROOT_DIR . "/inc/Db.php";
require PMF_ROOT_DIR . "/inc/PMF_DB/Driver.php";
$db = PMF_Db::dbSelect($sql_type);
$db->connect($sql_server, $sql_user, $sql_passwort, $sql_db);
if (!$db) {
print "<p class=\"error\"><strong>DB Error:</strong> ".$db->error()."</p>\n";
HTMLFooter();
die();
}

// check LDAP if available
$ldap_enabled = PMF_Filter::filterInput(INPUT_POST, 'ldap_enabled', FILTER_SANITIZE_STRING);
if (extension_loaded('ldap') && !is_null($ldap_enabled)) {

// check LDAP entries
$ldap_server = PMF_Filter::filterInput(INPUT_POST, 'ldap_server', FILTER_SANITIZE_STRING);
if (is_null($ldap_server)) {
print "<p class=\"error\"><strong>Error:</strong> There's no LDAP server input.</p>\n";
HTMLFooter();
die();
}

$ldap_port = PMF_Filter::filterInput(INPUT_POST, 'ldap_port', FILTER_VALIDATE_INT);
if (is_null($ldap_port)) {
print "<p class=\"error\"><strong>Error:</strong> There's no LDAP port input.</p>\n";
HTMLFooter();
die();
}

$ldap_user = PMF_Filter::filterInput(INPUT_POST, 'ldap_user', FILTER_SANITIZE_STRING);
if (is_null($ldap_user)) {
print "<p class=\"error\"><strong>Error:</strong> There's no LDAP username input.</p>\n";
HTMLFooter();
die();
}

$ldap_password = PMF_Filter::filterInput(INPUT_POST, 'ldap_password', FILTER_SANITIZE_STRING);
if (is_null($ldap_password)) {
print "<p class=\"error\"><strong>Error:</strong> There's no LDAP password input.</p>\n";
HTMLFooter();
die();
}

$ldap_base = PMF_Filter::filterInput(INPUT_POST, 'ldap_base', FILTER_SANITIZE_STRING);
if (is_null($ldap_base)) {
print "<p class=\"error\"><strong>Error:</strong> There's no distinguished name input for LDAP.</p>\n";
HTMLFooter();
die();
}

// check LDAP connection
require PMF_ROOT_DIR . "/inc/Ldap.php";
$ldap = new PMF_Ldap($ldap_server, $ldap_port, $ldap_base, $ldap_user, $ldap_password);
if (!$ldap) {
print "<p class=\"error\"><strong>LDAP Error:</strong> ".$ldap->error()."</p>\n";
HTMLFooter();
die();
}
}

// check user entries
$password = PMF_Filter::filterInput(INPUT_POST, 'password', FILTER_SANITIZE_STRING);
if (is_null($password)) {
print "<p class=\"error\"><strong>Error:</strong> There's no password for the administrator's account. Please set your password.</p>\n";
HTMLFooter();
die();
}

$password_retyped = PMF_Filter::filterInput(INPUT_POST, 'password_retyped', FILTER_SANITIZE_STRING);
if (is_null($password_retyped)) {
print "<p class=\"error\"><strong>Error:</strong> There's no retyped password. Please set your retyped password.</p>\n";
HTMLFooter();
die();
}

if (strlen($password) <= 5 || strlen($password_retyped) <= 5) {
print "<p class=\"error\"><strong>Error:</strong> Your password and retyped password are too short. Please set your password and your retyped password with a minimum of 6 characters.</p>\n";
HTMLFooter();
die();
}
if ($password != $password_retyped) {
print "<p class=\"error\"><strong>Error:</strong> Your password and retyped password are not equal. Please check your password and your retyped password.</p>\n";
HTMLFooter();
die();
}

$language = PMF_Filter::filterInput(INPUT_POST, 'language', FILTER_SANITIZE_STRING, 'en');
$realname = PMF_Filter::filterInput(INPUT_POST, 'realname', FILTER_SANITIZE_STRING, '');
$email = PMF_Filter::filterInput(INPUT_POST, 'email', FILTER_SANITIZE_EMAIL, '');
$permLevel = PMF_Filter::filterInput(INPUT_POST, 'permLevel', FILTER_SANITIZE_STRING, 'basic');

// Write the DB variables in database.php
$datafile = PMF_ROOT_DIR . '/config/database.php';
$ret = file_put_contents($datafile, "<?php\n\$DB[\"server\"] = '".$sql_server."';\n\$DB[\"user\"] = '".$sql_user."';\n\$DB[\"password\"] = '".$sql_passwort."';\n\$DB[\"db\"] = '".$sql_db."';\n\$DB[\"prefix\"] = '".$sqltblpre."';\n\$DB[\"type\"] = '".$sql_type."';", LOCK_EX);
if (!$ret) {
print "<p class=\"error\"><strong>Error:</strong> Cannot write to data.php.</p>";
HTMLFooter();
cleanInstallation();
die();
}

// check LDAP if available
if (extension_loaded('ldap') && !is_null($ldap_enabled)) {
$datafile = PMF_ROOT_DIR . '/config/ldap.php';
$ret = file_put_contents($datafile, "<?php\n\$PMF_LDAP[\"ldap_server\"] = '".$ldap_server."';\n\$PMF_LDAP[\"ldap_port\"] = '".$ldap_port."';\n\$PMF_LDAP[\"ldap_user\"] = '".$ldap_user."';\n\$PMF_LDAP[\"ldap_password\"] = '".$ldap_password."';\n\$PMF_LDAP[\"ldap_base\"] = '".$ldap_base."';", LOCK_EX);
if (!$ret) {
print "<p class=\"error\"><strong>Error:</strong> Cannot write to dataldap.php.</p>";
HTMLFooter();
cleanInstallation();
die();
}
}

// connect to the database using inc/data.php
require PMF_ROOT_DIR . '/config/database.php';
$db = PMF_Db::dbSelect($sql_type);
$db->connect($DB['server'], $DB['user'], $DB['password'], $DB['db']);
if (!$db) {
print "<p class=\"error\"><strong>DB Error:</strong> ".$db->error()."</p>\n";
HTMLFooter();
cleanInstallation();
die();
}

require_once $sql_type . '.sql.php'; // CREATE TABLES
require_once 'config.sql.php'; // INSERTs for configuration
require_once 'stopwords.sql.php'; // INSERTs for stopwords

print '<p class="center">';
@ob_flush();
flush();

// Erase any table before starting creating the required ones
db_uninstall();
// Start creating the required tables
$count = 0;
while ($each_query = each($query)) {
$result = @$db->query($each_query[1]);
if (!$result) {
print "\n<div class=\"error\">\n";
print "<p><strong>Error:</strong> Please install your version of phpMyFAQ once again or send us a <a href=\"http://bugs.phpmyfaq.de\" target=\"_blank\">bug report</a>.</p>";
print "<p><strong>DB error:</strong> ".$db->error()."</p>\n";
print "<div style=\"text-align: left;\"><p>Query:\n";
print "<pre>".htmlentities($each_query[1])."</pre></p></div>\n";
print "</div>";
db_uninstall();
cleanInstallation();
HTMLFooter();
die();
}
wait(25);
$count++;
if (!($count % 10)) {
print '| ';
@ob_flush();
flush();
}
}
@ob_flush();
flush();

// add admin account and rights
$admin = new PMF_User();
$admin->createUser('admin', $password, 1);
$admin->setStatus('protected');
$adminData = array(
'display_name' => $realname,
'email' => $email);
$admin->setUserData($adminData);
$adminID = $admin->getUserId();
// add rights
$rights = array(
//1 => "adduser",
array(
'name' => 'adduser',
'description' => 'Right to add user accounts',
'for_users' => 1,
'for_groups' => 1
),
//2 => "edituser",
array(
'name' => 'edituser',
'description' => 'Right to edit user accounts',
'for_users' => 1,
'for_groups' => 1
),
//3 => "deluser",
array(
'name' => 'deluser',
'description' => 'Right to delete user accounts',
'for_users' => 1,
'for_groups' => 1
),
//4 => "addbt",
array(
'name' => 'addbt',
'description' => 'Right to add faq entries',
'for_users' => 1,
'for_groups' => 1
),
//5 => "editbt",
array(
'name' => 'editbt',
'description' => 'Right to edit faq entries',
'for_users' => 1,
'for_groups' => 1
),
//6 => "delbt",
array(
'name' => 'delbt',
'description' => 'Right to delete faq entries',
'for_users' => 1,
'for_groups' => 1
),
//7 => "viewlog",
array(
'name' => 'viewlog',
'description' => 'Right to view logfiles',
'for_users' => 1,
'for_groups' => 1
),
//8 => "adminlog",
array(
'name' => 'adminlog',
'description' => 'Right to view admin log',
'for_users' => 1,
'for_groups' => 1
),
//9 => "delcomment",
array(
'name' => 'delcomment',
'description' => 'Right to delete comments',
'for_users' => 1,
'for_groups' => 1
),
//10 => "addnews",
array(
'name' => 'addnews',
'description' => 'Right to add news',
'for_users' => 1,
'for_groups' => 1
),
//11 => "editnews",
array(
'name' => 'editnews',
'description' => 'Right to edit news',
'for_users' => 1,
'for_groups' => 1
),
//12 => "delnews",
array(
'name' => 'delnews',
'description' => 'Right to delete news',
'for_users' => 1,
'for_groups' => 1
),
//13 => "addcateg",
array(
'name' => 'addcateg',
'description' => 'Right to add categories',
'for_users' => 1,
'for_groups' => 1
),
//14 => "editcateg",
array(
'name' => 'editcateg',
'description' => 'Right to edit categories',
'for_users' => 1,
'for_groups' => 1
),
//15 => "delcateg",
array(
'name' => 'delcateg',
'description' => 'Right to delete categories',
'for_users' => 1,
'for_groups' => 1
),
//16 => "passwd",
array(
'name' => 'passwd',
'description' => 'Right to change passwords',
'for_users' => 1,
'for_groups' => 1
),
//17 => "editconfig",
array(
'name' => 'editconfig',
'description' => 'Right to edit configuration',
'for_users' => 1,
'for_groups' => 1
),
//18 => "addatt",
array(
'name' => 'addatt',
'description' => 'Right to add attachments',
'for_users' => 1,
'for_groups' => 1
),
//19 => "delatt",
array(
'name' => 'delatt',
'description' => 'Right to delete attachments',
'for_users' => 1,
'for_groups' => 1
),
//20 => "backup",
array(
'name' => 'backup',
'description' => 'Right to save backups',
'for_users' => 1,
'for_groups' => 1
),
//21 => "restore",
array(
'name' => 'restore',
'description' => 'Right to load backups',
'for_users' => 1,
'for_groups' => 1
),
//22 => "delquestion",
array(
'name' => 'delquestion',
'description' => 'Right to delete questions',
'for_users' => 1,
'for_groups' => 1
),
//23 => 'addglossary',
array(
'name' => 'addglossary',
'description' => 'Right to add glossary entries',
'for_users' => 1,
'for_groups' => 1
),
//24 => 'editglossary',
array(
'name' => 'editglossary',
'description' => 'Right to edit glossary entries',
'for_users' => 1,
'for_groups' => 1
),
//25 => 'delglossary'
array(
'name' => 'delglossary',
'description' => 'Right to delete glossary entries',
'for_users' => 1,
'for_groups' => 1
),
//26 => 'changebtrevs'
array(
'name' => 'changebtrevs',
'description' => 'Right to edit revisions',
'for_users' => 1,
'for_groups' => 1
),
//27 => "addgroup",
array(
'name' => 'addgroup',
'description' => 'Right to add group accounts',
'for_users' => 1,
'for_groups' => 1
),
//28 => "editgroup",
array(
'name' => 'editgroup',
'description' => 'Right to edit group accounts',
'for_users' => 1,
'for_groups' => 1
),
//29 => "delgroup",
array(
'name' => 'delgroup',
'description' => 'Right to delete group accounts',
'for_users' => 1,
'for_groups' => 1
),
//30 => "addtranslation",
array(
'name' => 'addtranslation',
'description' => 'Right to add translation',
'for_users' => 1,
'for_groups' => 1
),
//31 => "edittranslation",
array(
'name' => 'edittranslation',
'description' => 'Right to edit translations',
'for_users' => 1,
'for_groups' => 1
),
//32 => "deltranslation",
array(
'name' => 'deltranslation',
'description' => 'Right to delete translations',
'for_users' => 1,
'for_groups' => 1
),
// 33 => 'approverec'
array(
'name' => 'approverec',
'description' => 'Right to approve records',
'for_users' => 1,
'for_groups' => 1
),
);
foreach ($rights as $right) {
$rightID = $admin->perm->addRight($right);
$admin->perm->grantUserRight($adminID, $rightID);
}
// Add anonymous user account
$anonymous = new PMF_User();
$anonymous->createUser('anonymous', null, -1);
$anonymous->setStatus('protected');
$anonymousData = array(
'display_name' => 'Anonymous User',
'email' => null);
$anonymous->setUserData($anonymousData);

$oConf = PMF_Configuration::getInstance();
$oConf->getAll();
$configs = $oConf->config;

$configs['spam.enableCaptchaCode'] = (extension_loaded('gd') ? 'true' : 'false');
$configs['main.referenceURL'] = PMF_Link::getSystemUri('/install/setup.php');
$configs['main.phpMyFAQToken'] = md5(uniqid(rand()));

$oConf->update($configs);

print "</p>\n";
print "<p class=\"center\">All database tables were successfully created.</p>\n";
print "<p class=\"center\">Congratulation! Everything seems to be okay.</p>\n";
?>
<script type="text/javascript">
//<![CDATA[
var iframect = 0;

function iframeUpdated() {
if (iframect++ == 0) {
return;
}

$('#questionnaireForm').hide();
$('#questionnaireThanks').show();
}

function hide(item) {
cssAddClass(item, 'collapsed');
}

function show(item) {
cssDelClass(item, 'collapsed');
}
//]]>
</script>
<iframe onload="iframeUpdated();" name="questionaireResult" style="display:none"></iframe>
<form action="http://www.phpmyfaq.de/stats/getstatdata.php" method="post" target="questionaireResult" id="questionnaireForm">

<p class="center">For further development we would like to get some feedback from our users.<br />Therefore we'd ask you to take a few minutes of your time to answer a few questions.</p>
<p class="center">If you don't want to participate in the survey, you can directly visit <a href="../index.php">your version of phpMyFAQ</a> or login into your <a href="../admin/index.php">admin section</a>.</p>

<fieldset class="installation">
<legend class="installation">General questions</legend>
<label class="leftquestionaire">How do you act like?</label>
<select name="q[individual]">
<option>as an individual</option>
<option>as an organisation</option>
</select>
<br/>
<label class="leftquestionaire">What kind of organisation is that?</label>
<select name="q[organisation]">
<option>private held</option>
<option>public held</option>
<option>government organisation</option>
<option>foundation</option>
<option>other</option>
</select>
</fieldset>
<br />

<fieldset class="installation">
<legend class="installation">Technical questions</legend>
<label class="leftquestionaire">Where did you installed phpMyFAQ?</label>
<select name="q[server]">
<option>server run by a hosting company</option>
<option>public server run by you/your organisation</option>
<option>private server run by you/your organisation</option>
<option>Don't know</option>
</select>
</fieldset>
<br />

<fieldset class="installation">
<legend class="installation">Beyond our own nose</legend>
<label class="leftquestionaire">Which PHP software do you also use?</label>
<input name="q[other]" /><br />

<label class="leftquestionaire">Are you using other web technologies?</label>
<input type="checkbox" name="q[other][]" value="ASP" />ASP
<input type="checkbox" name="q[other][]" value="ASP.NET" />ASP.NET
<input type="checkbox" name="q[other][]" value="jsp" />JAVA JSP
<input type="checkbox" name="q[other][]" value="perl" />Perl
<input type="checkbox" name="q[other][]" value="ruby" />Ruby / Ruby on Rails
<input type="checkbox" name="q[other][]" value="python" />Python
</fieldset>
<br />

<p class="center">Additional to your input we're going to submit some information about your system setup for statstic purpose.</p>
<p class="center">We are not storing any personal information. You can see the data by clicking <a href="#" onclick="show('configliste');return false;">here</a>.</p>

<div id="configliste" class="collapsed">
<a href="#" onclick="hide('configliste'); return false;">hide again</a>
<dl>
<?php
$q = new PMF_Questionnaire_Data($configs);
$options = $q->get();
array_walk($options, 'data_printer');
echo '</dl><input type="hidden" name="systemdata" value="'.PMF_String::htmlspecialchars(serialize($q->get()), ENT_QUOTES).'" />';
?>
</div>
<p class="center"><input type="submit" value="Click here to submit the data and fnish the installation process" /></p>
</form>
<div id="questionnaireThanks" style="display:none;">
<p class="center"><b>Thank you for giving your feedback!</b></p>
<p class="center">You can visit <a href="../index.php">your version of phpMyFAQ</a> or</p>
<p class="center">login into your <a href="../admin/index.php">admin section</a>.</p>
</div>
<br />
<?php

// Remove 'scripts' folder: no need of prompt anything to the user
if (file_exists(PMF_ROOT_DIR."/scripts") && is_dir(PMF_ROOT_DIR."/scripts")) {
@rmdir(PMF_ROOT_DIR."/scripts");
}
// Remove 'phpmyfaq.spec' file: no need of prompt anything to the user
if (file_exists(PMF_ROOT_DIR."/phpmyfaq.spec")) {
@unlink(PMF_ROOT_DIR."/phpmyfaq.spec");
}

// Remove 'setup.php' file
if (@unlink(basename($_SERVER["PHP_SELF"]))) {
print "<p class=\"center\">The file <em>./install/setup.php</em> was deleted automatically.</p>\n";
} else {
print "<p class=\"center\">Please delete the file <em>./install/setup.php</em> manually.</p>\n";
}
// Remove 'update.php' file
if (@unlink(dirname($_SERVER["PATH_TRANSLATED"])."/update.php")) {
print "<p class=\"center\">The file <em>./install/update.php</em> was deleted automatically.</p>\n";
} else {
print "<p class=\"center\">Please delete the file <em>./install/update.php</em> manually.</p>\n";
}

HTMLFooter();

}


Danke vorab

Gruss Jefferson
Thorsten
Posts: 15560
Joined: Tue Sep 25, 2001 11:14 am
Location: #phpmyfaq
Contact:

Re: syntax error, unexpected

Post by Thorsten »

Hi,

ändere mal bitte

Code: Select all

function extension_check($enabledExtensions, &$output = NULL)
zu

Code: Select all

function extension_check($enabledExtensions, &$output)
bye
Thorsten
phpMyFAQ Maintainer and Lead Developer
amazon.de Wishlist
jefferson
Posts: 7
Joined: Wed Jan 20, 2010 4:55 pm

Re: syntax error, unexpected

Post by jefferson »

danke für den tipp.

kam aber gleich die nächste fehlermeldung in der constans.php in der lezten zeile.

nachdem ich diese augeblendet habe kam der nächste fehler in der funktions.php in zeile 265. warum kommen nur die fehler unter xampp war die instllation doch kein prob. und auf den webspace habe ich auch schon wordpress zum laufen gebracht. gibt es vieleich eine komplettlösung? oder liegt das am webspace? geht vieleicht ?1und1 nicht? am code habe ich nichts geändert. gibt es eine mpfehlung welcher anbieter porblemlos geht

danke

gruss jefferson
Thorsten
Posts: 15560
Joined: Tue Sep 25, 2001 11:14 am
Location: #phpmyfaq
Contact:

Re: syntax error, unexpected

Post by Thorsten »

Hi,

welche Fehlermeldung kommt denn da? Kannst du mir mal eine phpinfo() Seite von 1und1 zeigen?

bye
Thorsten
phpMyFAQ Maintainer and Lead Developer
amazon.de Wishlist
jefferson
Posts: 7
Joined: Wed Jan 20, 2010 4:55 pm

Re: syntax error, unexpected

Post by jefferson »

die fehlermeldung in der funktions.php


Parse error: syntax error, unexpected T_OBJECT_OPERATOR in /homepages/33/d190864777/htdocs/phpmyfaq/inc/functions.php on line 265

<?php
/**
* This is the main functions file.
*
* PHP Version 5.2
*
* The contents of this file are subject to the Mozilla Public License
* Version 1.1 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS"
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
* License for the specific language governing rights and limitations
* under the License.
*
* Portions created by Matthias Sommerfeld are Copyright (c) 2001-2010 blue
* birdy, Berlin (http://bluebirdy.de). All Rights Reserved.
*
* @category phpMyFAQ
* @package Core
* @author Thorsten Rinne <thorsten@phpmyfaq.de>
* @author Matthias Sommerfeld <phlymail@phlylabs.de>
* @author Bastian Poettner <bastian@poettner.net>
* @author Meikel Katzengreis <meikel@katzengreis.com>
* @author Robin Wood <robin@digininja.org>
* @author Matteo Scaramuccia <matteo@phpmyfaq.de>
* @author Adrianna Musiol <musiol@imageaccess.de>
* @license http://www.mozilla.org/MPL/MPL-1.1.html Mozilla Public License Version 1.1
* @link http://www.phpmyfaq.de
* @copyright 2001-2010 phpMyFAQ Team
* @since 2001-02-18
*/

//
// DEBUGGING FUNCTIONS
//

/**
* Function to get a pretty formatted output of a variable
*
* NOTE: Just for debugging!
*
* @param object
* @return void
* @access public
* @since 2004-11-27
* @author Thorsten Rinne <thorsten@phpmyfaq.de>
*/
function dump($var)
{
print '<pre>';
var_dump($var);
print '</pre>';
}

/**
* debug_backtrace() wrapper function
*
* @param $string
* @return string
* @access public
* @since 2006-06-24
* @author Thorsten Rinne <thorsten@phpmyfaq.de>
*/
function pmf_debug($string)
{
// sometimes Zend Optimizer causes segfaults with debug_backtrace()
if (extension_loaded('Zend Optimizer')) {
$ret = "<pre>" . $string . "</pre><br />\n";
} else {
$debug = debug_backtrace();
$ret = '';
if (isset($debug[2]['class'])) {
$ret = $debug[2]['file'] . ":<br />";
$ret .= $debug[2]['class'].$debug[1]['type'];
$ret .= $debug[2]['function'] . '() in line ' . $debug[2]['line'];
$ret .= ": <pre>" . $string . "</pre><br />\n";
}
}
return $ret;
}

/**
* phpMyFAQ custom error handler function, also to prevent the disclosure of
* potential sensitive data.
*
* @access public
* @param int $level The level of the error raised.
* @param string $message The error message.
* @param string $filename The filename that the error was raised in.
* @param int $line The line number the error was raised at.
* @param mixed $context It optionally contains an array of every variable
* that existed in the scope the error was triggered in.
* @since 2009-02-01
* @author Matteo Scaramuccia <matteo@phpmyfaq.de>
*/
function pmf_error_handler($level, $message, $filename, $line, $context)
{
// Sanity check
// Note: when DEBUG mode is true we want to track any error!
if (
// 1. the @ operator sets the PHP's error_reporting() value to 0
(!DEBUG && (0 == error_reporting()))
// 2. Honor the value of PHP's error_reporting() function
|| (!DEBUG && (0 == ($level & error_reporting())))
) {
// Do nothing
return true;
}

// Cleanup potential sensitive data
$filename = (DEBUG ? $filename : basename($filename));

// Give an alias name to any PHP error level number
// PHP 5.3.0+
if (!defined('E_DEPRECATED')) {
define('E_DEPRECATED', 8192);
}
// PHP 5.3.0+
if (!defined('E_USER_DEPRECATED')) {
define('E_USER_DEPRECATED', 16384);
}
$errorTypes = array(
E_ERROR => 'error',
E_WARNING => 'warning',
E_PARSE => 'parse error',
E_NOTICE => 'notice',
E_CORE_ERROR => 'code error',
E_CORE_WARNING => 'core warning',
E_COMPILE_ERROR => 'compile error',
E_COMPILE_WARNING => 'compile warning',
E_USER_ERROR => 'user error',
E_USER_WARNING => 'user warning',
E_USER_NOTICE => 'user notice',
E_STRICT => 'strict warning',
E_RECOVERABLE_ERROR => 'recoverable error',
E_DEPRECATED => 'deprecated warning',
E_USER_DEPRECATED => 'user deprecated warning',
);
$errorType = 'unknown error';
if (isset($errorTypes[$level])) {
$errorType = $errorTypes[$level];
}

// Custom error message
$errorMessage = <<<EOD
<br />
<b>phpMyFAQ $errorType</b> [$level]: $message in <b>$filename</b> on line <b>$line</b><br />
EOD;

switch ($level) {
// Blocking errors
case E_ERROR:
case E_PARSE:
case E_CORE_ERROR:
case E_COMPILE_ERROR:
case E_USER_ERROR:
// Clear any output that has already been generated
// TBD: it generally seems not useful unless when errors appear on
// coded HTTP streaming e.g. when creating PDF to be sent to users
if (ob_get_length()) {
//ob_clean();
}
// Output the error message
echo $errorMessage;
// Prevent processing any more PHP scripts
exit();
break;
// Not blocking errors
default:
// Output the error message
echo $errorMessage;
break;
}

return true;
}

//
// GENERAL FUNCTIONS
//

/**
* Returns all sorting possibilities for FAQ records
*
* @param string $current
* @return string
* @access public
* @since 2007-03-10
* @author Thorsten Rinne <thorsten@phpmyfaq.de>
*/
function sortingOptions($current)
{
global $PMF_LANG;

$options = array('id', 'thema', 'visits', 'datum', 'author');
$output = '';

foreach ($options as $value) {
printf('<option value="%s"%s>%s</option>',
$value,
($value == $current) ? ' selected="selected"' : '',
$PMF_LANG['ad_conf_order_'.$value]);
}

return $output;
}

/**
* Checks for an address match (IPv4 or Network)
*
* @param string IP Address
* @param string Network Address (e.g.: a.b.c.d/255.255.255.0 or a.b.c.d/24) or IP Address
* @return boolean
* @since 2006-01-23
* @author Matteo Scaramuccia <matteo@phpmyfaq.de>
* @author Kenneth Shaw <ken@expitrans.com>
*/
function checkForAddrMatchIpv4($ip, $network)
{
// See also ip2long PHP online manual: Kenneth Shaw
// coded a network matching function called net_match.
// We use here his way of doing bit-by-bit network comparison
$matched = false;

// Start applying the discovering of the network mask
$ip_arr = explode('/', $network);

$network_long = ip2long($ip_arr[0]);
$ip_long = ip2long($ip);

if (!isset($ip_arr[1])) {
// $network seems to be a simple ip address, instead of a network address
$matched = ($network_long == $ip_long);
} else {
// $network seems to be a real network address
$x = ip2long($ip_arr[1]);
// Evaluate the netmask: <Network Mask> or <CIDR>
$mask = ( long2ip($x) == $ip_arr[1] ? $x : 0xffffffff << (32 - $ip_arr[1]));
$matched = ( ($ip_long & $mask) == ($network_long & $mask) );
}

return $matched;
}

/**
* Performs a check if an IPv4 is banned
*
* NOTE: This function does not support IPv6
*
* @param string IP
* @return boolean
* @since 2003-06-06
* @access public
* @author Thorsten Rinne <thorsten@phpmyfaq.de>
*/
function IPCheck($ip)
{
if (strstr($ip, '::')) {
// currently we cannot handle IPv6
return true;
}

$bannedIPs = explode(' ', PMF_Configuration::getInstance()->get('main.bannedIPs'));

foreach ($bannedIPs as $oneIPorNetwork) {
if (checkForAddrMatchIpv4($ip, $oneIPorNetwork)) {
return false;
}
}
return true;
}

/**
* This function returns the banned words dictionary as an array.
*
* @return array
* @access public
* @author Matteo Scaramuccia <matteo@phpmyfaq.de>
*/
function getBannedWords()
{
$bannedTrimmedWords = array();
$bannedWordsFile = dirname(__FILE__).'/blockedwords.txt';
$bannedWords = array();

// Read the dictionary
if (file_exists($bannedWordsFile) && is_readable($bannedWordsFile)) {
$bannedWords = file_get_contents($bannedWordsFile);
}

// Trim it
foreach (explode("\n", $bannedWords) as $word) {
$bannedTrimmedWords[] = trim($word);
}

return $bannedTrimmedWords;
}

/**
* This function checks the content against a dab word list
* if the banned word spam protection has been activated from the general PMF configuration.
*
* @param string $content
* @return bool
* @access public
* @author Katherine A. Bouton
* @author Thorsten Rinne <thorsten@phpmyfaq.de>
* @author Matteo Scaramuccia <matteo@phpmyfaq.de>
* @author Peter Beauvain <pbeauvain@web.de>
*/
function checkBannedWord($content)
{
// Sanity checks
$content = trim($content);
if (('' == $content) && (!PMF_Configuration::getInstance()->get('spam.checkBannedWords'))) {
return true;
}

$bannedWords = getBannedWords();
// We just search a match of, at least, one banned word into $content
$content = PMF_String::strtolower($content);
if (is_array($bannedWords)) {
foreach ($bannedWords as $bannedWord) {
if (PMF_String::strpos($content, PMF_String::strtolower($bannedWord)) !== false) {
return false;
}
}
}

return true;
}

/**
* Get out the HTML code for the fieldset that insert the captcha code in a (public) form
*
* @param string Text of the HTML Legend element
* @param string HTML code for the Captcha image
* @param string Length of the Captcha code
* @return string
* @since 2006-04-25
* @author Matteo Scaramuccia <matteo@phpmyfaq.de>
*/
function printCaptchaFieldset($legend, $img, $length, $error = '')
{
$html = '';

if (PMF_Configuration::getInstance()->get('spam.enableCaptchaCode')) {
$html = sprintf('<fieldset><legend>%s</legend>', $legend);
$html .= '<div style="text-align:left;">';
if ($error != '') {
$html .= '<div class="error">' . $error . '</div>';
}
$html .= $img;
$html .= '&nbsp; &nbsp;<input class="inputfield" type="text" name="captcha" id="captcha" value="" size="7" style="vertical-align: top; height: 35px; text-valign: middle; font-size: 20pt;" />';
$html .= '</div></fieldset>';
}

return $html;
}

/**
* This function returns the passed content with HTML hilighted banned words.
*
* @param string $content
* @return string
* @access public
* @author Matteo Scaramuccia <matteo@phpmyfaq.de>
*/
function getHighlightedBannedWords($content)
{
$bannedHTMLHiliWords = array();
$bannedWords = getBannedWords();

// Build the RegExp array
foreach ($bannedWords as $word) {
$bannedHTMLHiliWords[] = "/(".quotemeta($word).")/ism";
}
// Use the CSS "highlight" class to highlight the banned words
if (count($bannedHTMLHiliWords)>0) {
return PMF_String::preg_replace($bannedHTMLHiliWords, "<span class=\"highlight\">\\1</span>", $content);
} else {
return $content;
}
}

/**
* An OS independent function like usleep
*
* @param integer
* @return void
* @since 2004-05-30
* @author Thorsten Rinne <thorsten@phpmyfaq.de>
*/
function wait($usecs)
{
$temp = gettimeofday();
$start = (int)$temp["usec"];
while(1) {
$temp = gettimeofday();
$stop = (int)$temp["usec"];
if ($stop - $start >= $usecs) {
break;
}
}
}

/**
* Returns the number of anonymous users and registered ones.
* These are the numbers of unique users who have perfomed
* some activities within the last five minutes
*
* @param integer $activityTimeWindow Optionally set the time window size in sec.
* Default: 300sec, 5 minutes
* @return array
*/
function getUsersOnline($activityTimeWindow = 300)
{
$users = array(0 ,0);
$db = PMF_Db::getInstance();

if (PMF_Configuration::getInstance()->get('main.enableUserTracking')) {
$timeNow = ($_SERVER['REQUEST_TIME'] - $activityTimeWindow);
// Count all sids within the time window
// TODO: add a new field in faqsessions in order to find out only sids of anonymous users
$result = $db->query("
SELECT
count(sid) AS anonymous_users
FROM
".SQLPREFIX."faqsessions
WHERE
user_id = -1
AND time > ".$timeNow);
if (isset($result)) {
$row = $db->fetch_object($result);
$users[0] = $row->anonymous_users;
}
// Count all faquser records within the time window
$result = $db->query("
SELECT
count(session_id) AS registered_users
FROM
".SQLPREFIX."faquser
WHERE
session_timestamp > ".$timeNow);
if (isset($result)) {
$row = $db->fetch_object($result);
$users[1] = $row->registered_users;
}
}

return $users;
}


/******************************************************************************
* Funktionen fuer Artikelseiten
******************************************************************************/

/**
* Macht an den String nen / dran, falls keiner da ist
* @@ Bastian, 2002-01-06
*/
function EndSlash($string)
{
if (PMF_String::substr($string, PMF_String::strlen($string)-1, 1) != "/" ) {
$string .= "/";
}
return $string;
}

/**
* Decode MIME header elements in e-mails | @@ Matthias Sommerfeld
* (c) 2001-2004 blue birdy, Berlin (http://bluebirdy.de)
* used with permission
* Last Update: @@ Thorsten, 2004-07-17
*/
if (!function_exists('quoted_printable_encode')) {
function quoted_printable_encode($return = '')
{
// Ersetzen der lt. RFC 1521 noetigen Zeichen
$return = PMF_String::preg_replace('/([^\t\x20\x2E\041-\074\076-\176])/ie', "sprintf('=%2X',ord('\\1'))", $return);
$return = PMF_String::preg_replace('!=\ ([A-F0-9])!', '=0\\1', $return);
// Einfuegen von QP-Breaks (=\r\n)
if (PMF_String::strlen($return) > 75) {
$length = PMF_String::strlen($return); $offset = 0;
do {
$step = 76;
$add_mode = (($offset+$step) < $length) ? 1 : 0;
$auszug = PMF_String::substr($return, $offset, $step);
if (PMF_String::preg_match('!\=$!', $auszug)) {
$step = 75;
}
if (PMF_String::preg_match('!\=.$!', $auszug)) {
$step = 74;
}
if (PMF_String::preg_match('!\=..$!', $auszug)) {
$step = 73;
}

$auszug = PMF_String::substr($return, $offset, $step);
$offset += $step;
$schachtel .= $auszug;
if (1 == $add_mode) $schachtel.= '='."\r\n";
} while ($offset < $length);

$return = $schachtel;
}

$return = PMF_String::preg_replace('!\.$!', '. ', $return);
return PMF_String::preg_replace('!(\r\n|\r|\n)$!', '', $return)."\r\n";
}
}


/**
* Get search data weither as array or resource
*
* @param string $searchterm
* @param boolean $asResource
* @param string $cat
* @param boolean $allLanguages
*
* @return array|resource
*/
function getSearchData($searchterm, $asResource = false, $cat = '%', $allLanguages = true)
{
$db = PMF_Db::getInstance();
$LANGCODE = PMF_Language::$language;
$result = null;
$num = 0;
$cond = array(SQLPREFIX."faqdata.active" => "'yes'");

if ($cat != '%') {
$cond = array_merge(array(SQLPREFIX."faqcategoryrelations.category_id" => $cat), $cond);
}

if ((!$allLanguages) && (!is_numeric($searchterm))) {
$cond = array_merge(array(SQLPREFIX."faqdata.lang" => "'".$LANGCODE."'"), $cond);
}

if (is_numeric($searchterm)) {
// search for the solution_id
$result = $db->search(SQLPREFIX.'faqdata',
array(SQLPREFIX.'faqdata.id AS id',
SQLPREFIX.'faqdata.lang AS lang',
SQLPREFIX.'faqdata.solution_id AS solution_id',
SQLPREFIX.'faqcategoryrelations.category_id AS category_id',
SQLPREFIX.'faqdata.thema AS thema',
SQLPREFIX.'faqdata.content AS content'),
SQLPREFIX.'faqcategoryrelations',
array(SQLPREFIX.'faqdata.id = '.SQLPREFIX.'faqcategoryrelations.record_id',
SQLPREFIX.'faqdata.lang = '.SQLPREFIX.'faqcategoryrelations.record_lang'),
array(SQLPREFIX.'faqdata.solution_id'),
$searchterm,
$cond);
} else {
$result = $db->search(SQLPREFIX."faqdata",
array(SQLPREFIX."faqdata.id AS id",
SQLPREFIX."faqdata.lang AS lang",
SQLPREFIX."faqcategoryrelations.category_id AS category_id",
SQLPREFIX."faqdata.thema AS thema",
SQLPREFIX."faqdata.content AS content"),
SQLPREFIX."faqcategoryrelations",
array(SQLPREFIX."faqdata.id = ".SQLPREFIX."faqcategoryrelations.record_id",
SQLPREFIX."faqdata.lang = ".SQLPREFIX."faqcategoryrelations.record_lang"),
array(SQLPREFIX."faqdata.thema",
SQLPREFIX."faqdata.content",
SQLPREFIX."faqdata.keywords"),
$searchterm,
$cond);
}

if ($result) {
$num = $db->num_rows($result);
}

// Show the record with the solution ID directly
// Sanity checks: if a valid Solution ID has been provided the result set
// will measure 1: this is true ONLY if the faq is not
// classified among more than 1 category
if (is_numeric($searchterm) && ($searchterm >= PMF_SOLUTION_ID_START_VALUE) && ($num > 0)) {
// Hack: before a redirection we must force the PHP session update for preventing data loss
session_write_close();
if (PMF_Configuration::getInstance()->get('main.enableRewriteRules')) {
header('Location: '.PMF_Link::getSystemUri('/index.php').'/solution_id_'.$searchterm.'.html');
} else {
header('Location: '.PMF_Link::getSystemUri('/index.php').'/index.php?solution_id='.$searchterm);
}
exit();
}

if (0 == $num) {
$keys = PMF_String::preg_split("/\s+/", $searchterm);
$numKeys = count($keys);
$where = '';
for ($i = 0; $i < $numKeys; $i++) {
if (PMF_String::strlen($where) != 0 ) {
$where = $where." OR ";
}
$where = $where.'('.SQLPREFIX."faqdata.thema LIKE '%".$keys[$i]."%' OR ".SQLPREFIX."faqdata.content LIKE '%".$keys[$i]."%' OR ".SQLPREFIX."faqdata.keywords LIKE '%".$keys[$i]."%')";
if (is_numeric($cat)) {
$where .= ' AND '.SQLPREFIX.'faqcategoryrelations.category_id = '.$cat;
}
if (!$allLanguages) {
$where .= ' AND '.SQLPREFIX."faqdata.lang = '".$LANGCODE."'";
}
}

$where = " WHERE (".$where.") AND ".SQLPREFIX."faqdata.active = 'yes'";
$query = 'SELECT '.SQLPREFIX.'faqdata.id AS id, '.SQLPREFIX.'faqdata.lang AS lang, '.SQLPREFIX.'faqcategoryrelations.category_id AS category_id, '.SQLPREFIX.'faqdata.thema AS thema, '.SQLPREFIX.'faqdata.content AS content FROM '.SQLPREFIX.'faqdata LEFT JOIN '.SQLPREFIX.'faqcategoryrelations ON '.SQLPREFIX.'faqdata.id = '.SQLPREFIX.'faqcategoryrelations.record_id AND '.SQLPREFIX.'faqdata.lang = '.SQLPREFIX.'faqcategoryrelations.record_lang '.$where;
$result = $db->query($query);
}

return $asResource ? $result : $db->fetchAll($result);
}

/**
* The main search function for the full text search
*
* TODO: add filter for (X)HTML tag names and attributes!
*
* @param string Text/Number (solution id)
* @param string '%' to avoid any category filtering
* @param boolean true to search over all languages
* @param boolean true to disable the results paging
* @param boolean true to use it for Instant Response
* @return string
* @access public
* @author Thorsten Rinne <thorsten@phpmyfaq.de>
* @author Matteo Scaramuccia <matteo@phpmyfaq.de>
* @author Adrianna Musiol <musiol@imageaccess.de>
* @since 2002-09-16
*/
function searchEngine($searchterm, $cat = '%', $allLanguages = true, $hasMore = false, $instantRespnse = false)
{
global $sids, $category, $PMF_LANG, $plr, $LANGCODE, $faq, $current_user, $current_groups;

$_searchterm = PMF_htmlentities(stripslashes($searchterm), ENT_QUOTES, 'utf-8');
$seite = 1;
$output = '';
$num = 0;
$searchItems = array();
$langs = (true == $allLanguages) ? '&langs=all' : '';
$seite = PMF_Filter::filterInput(INPUT_GET, 'seite', FILTER_VALIDATE_INT, 1);
$db = PMF_Db::getInstance();
$faqconfig = PMF_Configuration::getInstance();

$result = getSearchData(htmlentities($searchterm, ENT_COMPAT, 'utf-8'), true, $cat, $allLanguages);
$num = $db->num_rows($result);

if (0 == $num) {
$output = $PMF_LANG['err_noArticles'];
}

$confPerPage = $faqconfig->get('main.numberOfRecordsPerPage');

$pages = ceil($num / $confPerPage);
$last = $seite * $confPerPage;
$first = $last - $confPerPage;
if ($last > $num) {
$last = $num;
}

if ($num > 0) {
$output .= '<p>'.$plr->GetMsg('plmsgSearchAmount', $num);
if ($hasMore && ($pages > 1)) {
$output .= sprintf($PMF_LANG['msgInstantResponseMaxRecords'], $confPerPage);
}
$output .= "</p>\n";
if (!$hasMore && ($pages > 1)) {
$output .= "<p><strong>".$PMF_LANG["msgPage"].$seite." ".$PMF_LANG["msgVoteFrom"]." ".$plr->GetMsg('plmsgPagesTotal',$pages)."</strong></p>";
}
$output .= "<ul class=\"phpmyfaq_ul\">\n";

$counter = 0;
$displayedCounter = 0;
while (($row = $db->fetch_object($result)) && $displayedCounter < $confPerPage) {
$counter ++;
if ($counter <= $first) {
continue;
}
$displayedCounter++;

$b_permission = false;
//Groups Permission Check
if ($faqconfig->get('main.permLevel') == 'medium') {
$perm_group = $faq->getPermission('group', $row->id);
foreach ($current_groups as $index => $value){
if (in_array($value, $perm_group)) {
$b_permission = true;
}
}
}
if ($faqconfig->get('main.permLevel') == 'basic' || $b_permission) {
$perm_user = $faq->getPermission('user', $row->id);
foreach ($perm_user as $index => $value) {
if ($value == -1) {
$b_permission = true;
break;
} elseif (((int)$value == $current_user)) {
$b_permission = true;
break;
} else {
$b_permission = false;
}
}
}

if ($b_permission) {
$rubriktext = $category->getPath($row->category_id);
$thema = chopString($row->thema, 15);
$content = chopString(strip_tags($row->content), 25);
$searchterm = str_replace(array('^', '.', '?', '*', '+', '{', '}', '(', ')', '[', ']', '"'), '', $searchterm);
$searchterm = preg_quote($searchterm, '/');
$searchItems = explode(' ', $searchterm);

if (PMF_String::strlen($searchItems[0]) > 1) {
foreach ($searchItems as $item) {
if (PMF_String::strlen($item) > 2) {
$thema = PMF_String::preg_replace_callback('/'
.'('.$item.'="[^"]*")|'
.'((href|src|title|alt|class|style|id|name|dir|onclick|ondblclick|onmousedown|onmouseup|onmouseover|onmousemove|onmouseout|onkeypress|onkeydown|onkeyup)="[^"]*'.$item.'[^"]*")|'
.'('.$item.')'
.'/mis',
"highlight_no_links",
$thema );
$content = PMF_String::preg_replace_callback('/'
.'('.$item.'="[^"]*")|'
.'((href|src|title|alt|class|style|id|name|dir|onclick|ondblclick|onmousedown|onmouseup|onmouseover|onmousemove|onmouseout|onkeypress|onkeydown|onkeyup)="[^"]*'.$item.'[^"]*")|'
.'('.$item.')'
.'/mis',
"highlight_no_links",
$content);
}
}
}

// Print the link to the faq record
$url = sprintf(
'?%saction=artikel&cat=%d&id=%d&artlang=%s&highlight=%s',
$sids,
$row->category_id,
$row->id,
$row->lang,
urlencode($_searchterm));

if ($instantRespnse) {
$currentUrl = PMF_Link::getSystemRelativeUri('ajaxresponse.php').'index.php';
} else {
$currentUrl = PMF_Link::getSystemRelativeUri();
}
$oLink = new PMF_Link($currentUrl.$url);
$oLink->itemTitle = $row->thema;
$oLink->text = $thema;
$oLink->tooltip = $row->thema;
$output .=
'<li><strong>'.$rubriktext.'</strong>: '.$oLink->toHtmlAnchor().'<br />'
.'<div class="searchpreview"><strong>'.$PMF_LANG['msgSearchContent'].'</strong> '.$content.'...</div>'
.'<br /></li>'."\n";
}
}
$output .= "</ul>\n";
} else {
$output = $PMF_LANG["err_noArticles"];
}

if (!$hasMore && ($num > $confPerPage)) {
if ($faqconfig->get('main.enableRewriteRules')) {
$baseUrl = sprintf("search.html?search=%s&seite=%d%s&searchcategory=%d",
urlencode($_searchterm),
$seite,
$langs,
$cat);
} else {
$baseUrl = PMF_Link::getSystemRelativeUri() . '?'
. (empty($sids) ? '' : "$sids&")
. 'action=search&search=' . urlencode($_searchterm)
. '&seite=' . $seite . $langs
. "&searchcategory=" . $cat;
}

$options = array('baseUrl' => $baseUrl,
'total' => $num,
'perPage' => $confPerPage,
'pageParamName' => 'seite',
'nextPageLinkTpl' => '<a href="{LINK_URL}">' . $PMF_LANG["msgNext"] . '</a>',
'prevPageLinkTpl' => '<a href="{LINK_URL}">' . $PMF_LANG["msgPrevious"] . '</a>',
'layoutTpl' => '<p align="center"><strong>{LAYOUT_CONTENT}</strong></p>');

$pagination = new PMF_Pagination($options);
$output .= $pagination->render();
}

return $output;
}

/**
* Callback function for filtering HTML from URLs and images
*
* @param array
* @access public
* @return string
* @author Thorsten Rinne <thorsten@phpmyfaq.de>
* @author Matthias Sommerfeld <phlymail@phlylabs.de>
* @author Johannes Schlueter <johannes@php.net>
* @since 2003-07-14
*/
function highlight_no_links(Array $matches)
{
$itemAsAttrName = $matches[1];
$itemInAttrValue = $matches[2]; // $matches[3] is the attribute name
$prefix = isset($matches[3]) ? $matches[3] : '';
$item = isset($matches[4]) ? $matches[4] : '';
$postfix = isset($matches[5]) ? $matches[5] : '';

if (!empty($item)) {
return '<span class="highlight">'.$prefix.$item.$postfix.'</span>';
}

// Fallback: the original matched string
return $matches[0];
}

/**
* This functions chops a string | @@ Thorsten, 2003-12-16
* Last Update: @@ Thorsten, 2003-12-16
*/
function chopString($string, $words)
{
$str = "";
$pieces = explode(" ", $string);
$num = count($pieces);
if ($words > $num) {
$words = $num;
}
for ($i = 0; $i < $words; $i++) {
$str .= $pieces[$i]." ";
}
return $str;
}

//
// Various functions
//

/**
* This is a wrapper for htmlspecialchars() with a check on valid charsets.
*
* @param string $string String
* @param string $quote_style Quote style
* @param string $charset Charset
* @return string
*/
function PMF_htmlentities($string, $quote_style = ENT_QUOTES, $charset = 'UTF-8')
{
return htmlspecialchars($string, $quote_style, $charset);
}

/**
* Build url for attachment download
*
* @param int $recordId
* @param int $filename
* @param bool $forHtml if the url will be used in html
* @return string
*/
function buildAttachmentUrl($recordId, $filename, $forHtml = true)
{
$amp = $forHtml ? '&' : '&';

return sprintf('index.php?action=attachment%sid=%s%sfile=%s', $amp, $recordId, $amp, $filename);
}

/**
* Check if an attachment dir is valid
*
* @param int $id
* @return boolean
*/
function isAttachmentDirOk($id)
{
if ($id == null) {
return false;
}

$recordAttachmentsDir = PMF_ATTACHMENTS_DIR . DIRECTORY_SEPARATOR . $id;

return false !== PMF_ATTACHMENTS_DIR && file_exists(PMF_ATTACHMENTS_DIR) && is_dir(PMF_ATTACHMENTS_DIR) &&
file_exists($recordAttachmentsDir) && is_dir($recordAttachmentsDir);
}

/******************************************************************************
* Funktionen fuer die Benutzerauthentifizierung und Rechtevergabe
******************************************************************************/

/**
* Adds a menu entry according to user permissions.
* ',' stands for 'or', '*' stands for 'and'
*
* @param string $restrictions Restrictions
* @param string $action Action parameter
* @param string $caption Caption
* @param string $active Active
* @access public
* @author Thorsten Rinne <thorsten@phpmyfaq.de>
*
* @return string
*/
function addMenuEntry($restrictions = '', $action = '', $caption = '', $active = '')
{
global $PMF_LANG;

$class = '';
if ($active == $action) {
$class = ' class="current"';
}

if ($action != '') {
$action = "action=".$action;
}

if (isset($PMF_LANG[$caption])) {
$_caption = $PMF_LANG[$caption];
} else {
$_caption = 'No string for '.$caption;
}

$output = sprintf(' <li><a%s href="?%s">%s</a></li>%s',
$class,
$action,
$_caption,
"\n");

return evalPermStr($restrictions) ? $output : '';
}

/**
* Parse and check a permission string
*
* Permissions are glued with each other as follows
* - '+' stands for 'or'
* - '*' stands for 'and'
*
* No braces will be parsed, only simple expressions
* @example right1*right2+right3+right4*right5
*
* @author Anatoliy Belsky <anatoliy.belsky@mayflower.de>
* @param string $restrictions
*
* @return boolean
*/
function evalPermStr($restrictions)
{
global $permission;

if(false !== strpos($restrictions, '+')) {
$retval = false;
foreach (explode('+', $restrictions) as $_restriction) {
$retval = $retval || evalPermStr($_restriction);
if($retval) {
break;
}
}
} else if(false !== strpos($restrictions, '*')) {
$retval = true;
foreach (explode('*', $restrictions) as $_restriction) {
if(!isset($permission[$_restriction]) || !$permission[$_restriction]) {
$retval = false;
break;
}
}
} else {
$retval = strlen($restrictions) > 0 && isset($permission[$restrictions]) && $permission[$restrictions];
}

return $retval;
}

/******************************************************************************
* Funktionen fuer den Adminbereich
******************************************************************************/

/**
* Funktion zum generieren vom "Umblaettern" | @@ Bastian, 2002-01-03
* Last Update: @@ Thorsten, 2004-05-07
*/
function PageSpan($code, $start, $end, $akt)
{
global $PMF_LANG;
if ($akt > $start) {
$out = str_replace("<NUM>", $akt-1, $code).$PMF_LANG["msgPreviusPage"]."</a> | ";
} else {
$out = "";
}
for ($h = $start; $h<=$end; $h++) {
if ($h > $start) {
$out .= ", ";
}
if ($h != $akt) {
$out .= str_replace("<NUM>", $h, $code).$h."</a>";
} else {
$out .= $h;
}
}
if ($akt < $end) {
$out .= " | ".str_replace("<NUM>", $akt+1, $code).$PMF_LANG["msgNextPage"]."</a>";
}
$out = $PMF_LANG["msgPageDoublePoint"].$out;
return $out;
}


//
// Functions for backup
//

/**
* This function builds the the queries for the backup
*
* @param string query
* @param string table name
* @return array
* @access public
* @author Meikel Katzengreis <meikel@katzengreis.com>
* @author Thorsten Rinne <thorsten@phpmyfaq.de>
* @since 2003-03-24
*/
function build_insert($query, $table)
{
$db = PMF_Db::getInstance();

if (!$result = $db->query($query)) {
return;
}
$ret = array();

$ret[] = "\n-- Table: ".$table;

while ($row = $db->fetch_assoc($result)) {
$p1 = array();
$p2 = array();
foreach ($row as $key => $val) {
$p1[] = $key;
if ('rights' != $key && is_numeric($val)) {
$p2[] = $val;
} else {
if (is_null($val)) {
$p2[] = 'NULL';
} else {
$p2[] = sprintf("'%s'", $db->escape_string($val));
}
}
}
$ret[] = "INSERT INTO ".$table." (".implode(",", $p1).") VALUES (".implode(",", $p2).");";
}

return $ret;
}

/**
* Align the prefix of the table name used in the PMF backup file,
* from the (old) value of the system upon which the backup was performed
* to the (new) prefix of the system upon which the backup will be restored.
* This alignment will be perfomed ONLY upon those given SQL queries starting
* with the given pattern.
*
* @param $query string
* @param $start_pattern string
* @param $oldvalue string
* @param $newvalue string
* @return string
* @access public
* @author Matteo Scaramuccia <matteo@phpmyfaq.de>
*/
function alignTablePrefixByPattern($query, $start_pattern, $oldvalue, $newvalue)
{
$ret = $query;

preg_match_all("/^".$start_pattern."\s+(\w+)(\s+|$)/i", $query, $matches);
if (isset($matches[1][0])) {
$oldtablefullname = $matches[1][0];
$newtablefullname = $newvalue.substr($oldtablefullname, strlen($oldvalue));
$ret = str_replace($oldtablefullname, $newtablefullname, $query);
}

return $ret;
}

/**
* Align the prefix of the table name used in the PMF backup file,
* from the (old) value of the system upon which the backup was performed
* to the (new) prefix of the system upon which the backup will be restored
* This alignment will be performed upon all of the SQL query "patterns"
* provided within the PMF backup file.
*
* @param $query string
* @param $oldvalue string
* @param $newvalue string
* @return string
* @access public
* @author Matteo Scaramuccia <matteo@phpmyfaq.de>
*/
function alignTablePrefix($query, $oldvalue, $newvalue)
{
// Align DELETE FROM <prefix.tablename>
$query = alignTablePrefixByPattern($query, "DELETE FROM", $oldvalue, $newvalue);
// Align INSERT INTO <prefix.tablename>
$query = alignTablePrefixByPattern($query, "INSERT INTO", $oldvalue, $newvalue);

return $query;
}

zeile 265 ist: $bannedIPs = explode(' ', PMF_Configuration::getInstance()->get('main.bannedIPs'));

danke Gruss Jeff
Thorsten
Posts: 15560
Joined: Tue Sep 25, 2001 11:14 am
Location: #phpmyfaq
Contact:

Re: syntax error, unexpected

Post by Thorsten »

Hi,

ändere mal bitte

Code: Select all

$bannedIPs = explode(' ', PMF_Configuration::getInstance()->get('main.bannedIPs'));
in

Code: Select all

    $listBannedIPs = PMF_Configuration::getInstance()->get('main.bannedIPs');
    $bannedIPs     = explode(' ', $listBannedIPs);
bye
Thorsten
phpMyFAQ Maintainer and Lead Developer
amazon.de Wishlist
jefferson
Posts: 7
Joined: Wed Jan 20, 2010 4:55 pm

Re: syntax error, unexpected

Post by jefferson »

nun kommt folgender fehler

Parse error: syntax error, unexpected T_STRING in /homepages/33/d190864777/htdocs/phpmyfaq/index.php on line 162

<?php
/**
* This is the main public frontend page of phpMyFAQ. It detects the browser's
* language, gets and sets all cookie, post and get informations and includes
* the templates we need and set all internal variables to the template
* variables. That's all.
*
* PHP Version 5.2
*
* The contents of this file are subject to the Mozilla Public License
* Version 1.1 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS"
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
* License for the specific language governing rights and limitations
* under the License.
*
* @category phpMyFAQ
* @package Frontend
* @author Thorsten Rinne <thorsten@phpmyfaq.de>
* @author Lars Tiedemann <php@larstiedemann.de>
* @author Matteo Scaramuccia <matteo@phpmyfaq.de>
* @copyright 2001-2010 phpMyFAQ Team
* @license http://www.mozilla.org/MPL/MPL-1.1.html Mozilla Public License Version 1.1
* @link http://www.phpmyfaq.de
* @since 2001-02-12
*/

//
// Check if config/database.php exist -> if not, redirect to installer
//
if (!file_exists('config/database.php')) {
header("Location: install/setup.php");
exit();
}

//
// Define the named constant used as a check by any included PHP file
//
define('IS_VALID_PHPMYFAQ', null);

//
// Autoload classes, prepend and start the PHP session
//
require_once 'inc/Init.php';
PMF_Init::cleanRequest();
session_name(PMF_COOKIE_NAME_AUTH . trim($faqconfig->get('main.phpMyFAQToken')));
session_start();

//
// Get language (default: english)
//
$Language = new PMF_Language();
$LANGCODE = $Language->setLanguage($faqconfig->get('main.languageDetection'), $faqconfig->get('main.language'));
// Preload English strings
require_once 'lang/language_en.php';


$showCaptcha = PMF_Filter::filterInput(INPUT_GET, 'gen', FILTER_SANITIZE_STRING);
if (isset($LANGCODE) && PMF_Language::isASupportedLanguage($LANGCODE) && is_null($showCaptcha)) {
// Overwrite English strings with the ones we have in the current language,
// but don't include UTF-8 encoded files, these will break the captcha images
require_once 'lang/language_'.$LANGCODE.'.php';
} else {
$LANGCODE = 'en';
}

//Load plurals support for selected language
$plr = new PMF_Language_Plurals($PMF_LANG);

//
// Initalizing static string wrapper
//
PMF_String::init($LANGCODE);

/**
* Initialize attachment factory
*/
PMF_Attachment_Factory::init($faqconfig->get('main.attachmentsStorageType'),
$faqconfig->get('main.defaultAttachmentEncKey'),
$faqconfig->get('main.enableAttachmentEncryption'));

//
// Get user action
//
$action = PMF_Filter::filterInput(INPUT_GET, 'action', FILTER_SANITIZE_STRING, 'main');

//
// Authenticate current user
//
$auth = null;
$error = '';
$faqusername = PMF_Filter::filterInput(INPUT_POST, 'faqusername', FILTER_SANITIZE_STRING);
$faqpassword = PMF_Filter::filterInput(INPUT_POST, 'faqpassword', FILTER_SANITIZE_STRING);
if (!is_null($faqusername) && !is_null($faqpassword)) {
$user = new PMF_User_CurrentUser();
if ($faqconfig->get('main.ldapSupport')) {
$authLdap = new PMF_Auth_AuthLdap();
$user->addAuth($authLdap, 'ldap');
}
if ($user->login($faqusername, $faqpassword)) {
if ($user->getStatus() != 'blocked') {
$auth = true;
} else {
$error = $PMF_LANG["ad_auth_fail"]." (".$faqusername." / *)";
$user = null;
}
} else {
// error
$error = sprintf(
'%s<br /><a href="admin/password.php" title="%s">%s</a>',
$PMF_LANG['ad_auth_fail'],
$PMF_LANG['lostPassword'],
$PMF_LANG['lostPassword']
);
$user = null;
}
$action = 'main';
} else {
// authenticate with session information
$user = PMF_User_CurrentUser::getFromSession($faqconfig->get('main.ipCheck'));
if ($user) {
$auth = true;
} else {
$user = null;
}
}

//
// Get current user rights
//
$permission = array();
if (isset($auth)) {
// read all rights, set them FALSE
$allRights = $user->perm->getAllRightsData();
foreach ($allRights as $right) {
$permission[$right['name']] = false;
}
// check user rights, set them TRUE
$allUserRights = $user->perm->getAllUserRights($user->getUserId());
foreach ($allRights as $right) {
if (in_array($right['right_id'], $allUserRights))
$permission[$right['name']] = true;
}
}

//
// Logout
//
if ('logout' === $action && isset($auth)) {
$user->deleteFromSession();
$user = null;
$auth = null;
$action = 'main';
}

//
// Get current user and group id - default: -1
//
if (!is_null($user) && $user instanceof PMF_User_CurrentUser) {
$current_user = $user->getUserId();
if ($user->perm instanceof PMF_Perm_PermMedium) {
$current_groups = $user->perm->getUserGroups($current_user);
} else {
$current_groups = array(-1);
}
if (0 == count($current_groups)) {
$current_groups = array(-1);
}
} else {
$current_user = -1;
$current_groups = array(-1);
}

//
// Use mbstring extension if available and when possible
//
$valid_mb_strings = array('ja', 'en', 'uni');
$mbLanguage = ($PMF_LANG['metaLanguage'] != 'ja') ? 'uni' : $PMF_LANG['metaLanguage'];
if (function_exists('mb_language') && in_array($mbLanguage, $valid_mb_strings)) {
mb_language($mbLanguage);
mb_internal_encoding('utf-8');
}

//
// Found a session ID in _GET or _COOKIE?
//
$sid = null;
$sid_get = PMF_Filter::filterInput(INPUT_GET, PMF_GET_KEY_NAME_SESSIONID, FILTER_VALIDATE_INT);
$sid_cookie = PMF_Filter::filterInput(INPUT_COOKIE, PMF_COOKIE_NAME_SESSIONID, FILTER_VALIDATE_INT);
$faqsession = new PMF_Session();
// Note: do not track internal calls
$internal = false;
if (isset($_SERVER['HTTP_USER_AGENT'])) {
$internal = (strpos($_SERVER['HTTP_USER_AGENT'], 'phpMyFAQ%2F') === 0);
}
if (!$internal) {
if (is_null($sid_get) && is_null($sid_cookie)) {
// Create a per-site unique SID
$faqsession->userTracking('new_session', 0);
} else {
if (!is_null($sid_cookie)) {
$faqsession->checkSessionId($sid_cookie, $_SERVER['REMOTE_ADDR']);
} else {
$faqsession->checkSessionId($sid_get, $_SERVER['REMOTE_ADDR']);
}
}
}

//
// Is user tracking activated?
//
$sids = '';
if ($faqconfig->get('main.enableUserTracking')) {
if (isset($sid)) {
PMF_Session::setCookie($sid);
if (is_null($sid_cookie)) {
$sids = sprintf('sid=%d&lang=%s&', $sid, $LANGCODE);
}
} elseif (is_null($sid_get) || is_null($sid_cookie)) {
if (is_null($sid_cookie)) {
if (!is_null($sid_get)) {
$sids = sprintf('sid=%d&lang=%s&', $sid_get, $LANGCODE);
}
}
}
} else {
if (!setcookie(PMF_GET_KEY_NAME_LANGUAGE, $LANGCODE, $_SERVER['REQUEST_TIME'] + PMF_LANGUAGE_EXPIRED_TIME)) {
$sids = sprintf('lang=%s&', $LANGCODE);
}
}

//
// Found a article language?
//
$lang = PMF_Filter::filterInput(INPUT_POST, 'artlang', FILTER_SANITIZE_STRING);
if (is_null($lang) && !PMF_Language::isASupportedLanguage($lang) ) {
$lang = $LANGCODE;
}

//
// Create a new FAQ object
//
$faq = new PMF_Faq($current_user, $current_groups);

//
// Create a new Category object
//
$category = new PMF_Category($current_user, $current_groups);

//
// Create a new Tags object
//
$oTag = new PMF_Tags();

//
// Found a record ID?
//
$id = PMF_Filter::filterInput(INPUT_GET, 'id', FILTER_VALIDATE_INT);
if (!is_null($id)) {
$title = ' - ' . $faq->getRecordTitle($id);
$keywords = ' ' . $faq->getRecordKeywords($id);
$metaDescription = $faq->getRecordPreview($id);
} else {
$id = '';
$title = ' - powered by phpMyFAQ ' . $faqconfig->get('main.currentVersion');
$keywords = '';
$metaDescription = $faqconfig->get('main.metaDescription');
}

//
// found a solution ID?
//
$solution_id = PMF_Filter::filterInput(INPUT_GET, 'solution_id', FILTER_VALIDATE_INT);
if (!is_null($solution_id)) {
$title = ' - powered by phpMyFAQ ' . $faqconfig->get('main.currentVersion');
$keywords = '';
$faqData = $faq->getIdFromSolutionId($solution_id);
if (is_array($faqData)) {
$id = $faqData['id'];
$lang = $faqData['lang'];
$title = ' - ' . $faq->getRecordTitle($id);
$keywords = ' ' . $faq->getRecordKeywords($id);
$metaDescription = PMF_Utils::makeShorterText($faqData['content'], 12);
}
}

//
// Handle the Tagging ID
//
$tag_id = PMF_Filter::filterInput(INPUT_GET, 'tagging_id', FILTER_VALIDATE_INT);
if (!is_null($tag_id)) {
$title = ' - ' . $oTag->getTagNameById($tag_id);
$keywords = '';
}

//
// Found a category ID?
//
$cat = PMF_Filter::filterInput(INPUT_GET, 'cat', FILTER_VALIDATE_INT, 0);
$cat_from_id = -1;
if (is_numeric($id) && $id > 0) {
$cat_from_id = $category->getCategoryIdFromArticle($id);
}
if ($cat_from_id != -1 && $cat == 0) {
$cat = $cat_from_id;
}
$category->transform(0);
$category->collapseAll();
if ($cat != 0) {
$category->expandTo($cat);
}
if (isset($cat) && ($cat != 0) && ($id == '') && isset($category->categoryName[$cat]['name'])) {
$title = ' - '.$category->categoryName[$cat]['name'];
}

//
// Found an action request?
//
if (!isset($allowedVariables[$action])) {
$action = 'main';
}

//
// Select the template for the requested page
//
if (isset($auth)) {
$login_tpl = 'loggedin.tpl';
} else {
if (isset($_SERVER['HTTPS']) || !$faqconfig->get('main.useSslForLogins')) {
$login_tpl = 'loginbox.tpl';
} else {
$login_tpl = 'secureswitch.tpl';
}
}

if ($action != 'main') {
$inc_tpl = $action . '.tpl';
$inc_php = $action . ".php";
$writeLangAdress = "?" . PMF_Filter::getFilteredQueryString();
} else {
if (isset($solution_id) && is_numeric($solution_id)) {
// show the record with the solution ID
$inc_tpl = 'artikel.tpl';
$inc_php = 'artikel.php';
} else {
$inc_tpl = 'main.tpl';
$inc_php = 'main.php';
}
$writeLangAdress = '?'.(int)$sids;
}

//
// Set right column
//
// Check in any tags with at leat one entry exist
$hasTags = $oTag->existTagRelations();
if ($hasTags && (($action == 'artikel') || ($action == 'show'))) {
$right_tpl = $action == 'artikel' ? 'catandtag.tpl' : 'tagcloud.tpl';
} else {
$right_tpl = 'startpage.tpl';
}

//
// Load template files and set template variables
// Check on mobile devices first, if iPhone detected, switch to iPhone layout
//
/*
if (stristr($_SERVER['HTTP_USER_AGENT'], 'iPhone')) {
$templateSet = 'mobile';
} else {
$templateSet = $faqconfig->get('main.templateSet');
}
*/
$tpl = new PMF_Template(array('index' => 'index.tpl',
'loginBox' => $login_tpl,
'rightBox' => $right_tpl,
'writeContent' => $inc_tpl),
$faqconfig->get('main.templateSet'));

$usersOnLine = getUsersOnline();
$totUsersOnLine = $usersOnLine[0] + $usersOnLine[1];
$systemUri = PMF_Link::getSystemUri('index.php');

$helper = PMF_Helper_Category::getInstance();
$helper->setCategory($category);

$main_template_vars = array(
'title' => $faqconfig->get('main.titleFAQ').$title,
'baseHref' => $systemUri,
'version' => $faqconfig->get('main.currentVersion'),
'header' => str_replace('"', '', $faqconfig->get('main.titleFAQ')),
'metaTitle' => str_replace('"', '', $faqconfig->get('main.titleFAQ')),
'metaDescription' => $metaDescription,
'metaKeywords' => $faqconfig->get('main.metaKeywords').$keywords,
'metaPublisher' => $faqconfig->get('main.metaPublisher'),
'metaLanguage' => $PMF_LANG['metaLanguage'],
'metaCharset' => 'utf-8', // backwards compability
'phpmyfaqversion' => $faqconfig->get('main.currentVersion'),
'stylesheet' => $PMF_LANG['dir'] == 'rtl' ? 'style.rtl' : 'style',
'action' => $action,
'dir' => $PMF_LANG['dir'],
'msgCategory' => $PMF_LANG['msgCategory'],
'showCategories' => $helper->renderCategoryNavigation($cat),
'languageBox' => $PMF_LANG['msgLangaugeSubmit'],
'writeLangAdress' => $writeLangAdress,
'switchLanguages' => PMF_Language::selectLanguages($LANGCODE, true),
'userOnline' => $plr->getMsg('plmsgUserOnline', $totUsersOnLine) .
$plr->getMsg('plmsgGuestOnline', $usersOnLine[0]) .
$plr->getMsg('plmsgRegisteredOnline',$usersOnLine[1]),
'stickyRecordsHeader' => $PMF_LANG['stickyRecordsHeader'],
'copyright' => 'powered by <a href="http://www.phpmyfaq.de" target="_blank">phpMyFAQ</a> ' .
$faqconfig->get('main.currentVersion'));

if ('main' == $action || 'show' == $action) {
if ('main' == $action && PMF_Configuration::getInstance()->get('main.useAjaxSearchOnStartpage')) {
$tpl->processBlock('index', 'globalSuggestBox', array(
'ajaxlanguage' => $LANGCODE,));
} else {
$tpl->processBlock('index', 'globalSearchBox', array(
'writeSendAdress' => '?'.$sids.'action=search',
'searchBox' => $PMF_LANG['msgSearch'],
'categoryId' => $cat));
}
}

$stickyRecordsParams = $faq->getStickyRecords();
if (!isset($stickyRecordsParams['error'])) {
$tpl->processBlock('index', 'stickyRecordsList', array(
'stickyRecordsUrl' => $stickyRecordsParams['url'],
'stickyRecordsTitle' => $stickyRecordsParams['title']));
}

if ($faqconfig->get('main.enableRewriteRules')) {
$links_template_vars = array(
"faqHome" => $faqconfig->get('main.referenceURL'),
"msgSearch" => '<a href="' . $systemUri . 'search.html">'.$PMF_LANG["msgAdvancedSearch"].'</a>',
'msgAddContent' => '<a href="' . $systemUri . 'addcontent.html">'.$PMF_LANG["msgAddContent"].'</a>',
"msgQuestion" => '<a href="' . $systemUri . 'ask.html">'.$PMF_LANG["msgQuestion"].'</a>',
"msgOpenQuestions" => '<a href="' . $systemUri . 'open.html">'.$PMF_LANG["msgOpenQuestions"].'</a>',
'msgHelp' => '<a href="' . $systemUri . 'help.html">'.$PMF_LANG["msgHelp"].'</a>',
"msgContact" => '<a href="' . $systemUri . 'contact.html">'.$PMF_LANG["msgContact"].'</a>',
"backToHome" => '<a href="' . $systemUri . 'index.html">'.$PMF_LANG["msgHome"].'</a>',
"allCategories" => '<a href="' . $systemUri . 'showcat.html">'.$PMF_LANG["msgShowAllCategories"].'</a>',
'showInstantResponse' => '<a href="' . $systemUri . 'instantresponse.html">'.$PMF_LANG['msgInstantResponse'].'</a>',
'showSitemap' => '<a href="' . $systemUri . 'sitemap/A/'.$LANGCODE.'.html">'.$PMF_LANG['msgSitemap'].'</a>',
'opensearch' => $systemUri . 'search.html');
} else {
$links_template_vars = array(
"faqHome" => $faqconfig->get('main.referenceURL'),
"msgSearch" => '<a href="index.php?'.$sids.'action=search">'.$PMF_LANG["msgAdvancedSearch"].'</a>',
"msgAddContent" => '<a href="index.php?'.$sids.'action=add">'.$PMF_LANG["msgAddContent"].'</a>',
"msgQuestion" => '<a href="index.php?'.$sids.'action=ask">'.$PMF_LANG["msgQuestion"].'</a>',
"msgOpenQuestions" => '<a href="index.php?'.$sids.'action=open">'.$PMF_LANG["msgOpenQuestions"].'</a>',
"msgHelp" => '<a href="index.php?'.$sids.'action=help">'.$PMF_LANG["msgHelp"].'</a>',
"msgContact" => '<a href="index.php?'.$sids.'action=contact">'.$PMF_LANG["msgContact"].'</a>',
"allCategories" => '<a href="index.php?'.$sids.'action=show">'.$PMF_LANG["msgShowAllCategories"].'</a>',
"backToHome" => '<a href="index.php?'.$sids.'">'.$PMF_LANG["msgHome"].'</a>',
'showInstantResponse' => '<a href="index.php?'.$sids.'action=instantresponse">'.$PMF_LANG['msgInstantResponse'].'</a>',
'showSitemap' => '<a href="index.php?'.$sids.'action=sitemap&lang='.$LANGCODE.'">'.$PMF_LANG['msgSitemap'].'</a>',
'opensearch' => '?'.$sids.'action=search');
}

//
// Add debug info if needed
//
if (DEBUG) {
$debug_template_vars = array(
'debugMessages' => "\n".'<div id="debug_main">DEBUG INFORMATION:<br />'.$db->sqllog().'</div>'
);
} else {
$debug_template_vars = array('debugMessages' => '');
}

//
// Get main template, set main variables
//
$tpl->processTemplate('index', array_merge($main_template_vars, $links_template_vars, $debug_template_vars));

//
// Show login box or logged-in user information
//
if (isset($auth)) {
$tpl->processTemplate('loginBox', array(
'loggedinas' => $PMF_LANG['ad_user_loggedin'],
'currentuser' => $user->getUserData('display_name'),
'printAdminPath' => (in_array(true, $permission)) ? 'admin/index.php' : '#',
'adminSection' => $PMF_LANG['adminSection'],
'printLogoutPath' => '?action=logout',
'logout' => $PMF_LANG['ad_menu_logout']));
} else {
if (isset($_SERVER['HTTPS']) || !$faqconfig->get('main.useSslForLogins')) {
$tpl->processTemplate('loginBox', array(
'writeLoginPath' => '?action=login',
'login' => $PMF_LANG['ad_auth_ok'],
'username' => $PMF_LANG['ad_auth_user'],
'password' => $PMF_LANG['ad_auth_passwd'],
'msgRegisterUser' => '<a href="?' . $sids . 'action=register">' . $PMF_LANG['msgRegisterUser'] . '</a>',
'msgLoginFailed' => $error));
} else {
$tpl->processTemplate('loginBox', array(
'secureloginurl' => sprintf('https://%s%s', $_SERVER['HTTP_HOST'], $_SERVER['REQUEST_URI']),
'securelogintext' => $PMF_LANG['msgSecureSwitch']));
}
}
$tpl->includeTemplate('loginBox', 'index');

// generate top ten list
if ($faqconfig->get('main.orderingPopularFaqs') == 'visits') {

// top ten list for most viewed entries
$toptenParams = $faq->getTopTen('visits');
if (!isset($toptenParams['error'])) {
$tpl->processBlock('rightBox', 'toptenList', array(
'toptenUrl' => $toptenParams['url'],
'toptenTitle' => $toptenParams['title'],
'toptenVisits' => $toptenParams['visits'])
);
} else {
$tpl->processBlock('rightBox', 'toptenListError', array(
'errorMsgTopTen' => $toptenParams['error'])
);
}
} else {

// top ten list for most voted entries
$toptenParams = $faq->getTopTen('voted');
if (!isset($toptenParams['error'])) {
$tpl->processBlock('rightBox', 'toptenList', array(
'toptenUrl' => $toptenParams['url'],
'toptenTitle' => $toptenParams['title'],
'toptenVisits' => $toptenParams['voted'])
);
} else {
$tpl->processBlock('rightBox', 'toptenListError', array(
'errorMsgTopTen' => $toptenParams['error'])
);
}
}

$latestEntriesParams = $faq->getLatest();
if (!isset($latestEntriesParams['error'])) {
$tpl->processBlock('rightBox', 'latestEntriesList', array(
'latestEntriesUrl' => $latestEntriesParams['url'],
'latestEntriesTitle' => $latestEntriesParams['title'],
'latestEntriesDate' => $latestEntriesParams['date'])
);
} else {
$tpl->processBlock('rightBox', 'latestEntriesListError', array(
'errorMsgLatest' => $latestEntriesParams['error'])
);
}

$tpl->processTemplate('rightBox', array(
'writeTopTenHeader' => $PMF_LANG['msgTopTen'],
'writeNewestHeader' => $PMF_LANG['msgLatestArticles'],
'writeTagCloudHeader' => $PMF_LANG['msg_tags'],
'writeTags' => $oTag->printHTMLTagsCloud(),
'msgAllCatArticles' => $PMF_LANG['msgAllCatArticles'],
'allCatArticles' => $faq->showAllRecordsWoPaging($cat))
);
$tpl->includeTemplate('rightBox', 'index');

//
// Include requested PHP file
//
require_once $inc_php;

//
// Send headers and print template
//
header("Expires: Thu, 07 Apr 1977 14:47:00 GMT");
header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
header("Content-type: text/html; charset=utf-8");
header("Vary: Negotiate,Accept");

$tpl->printTemplate();

//
// Disconnect from database
//
$db->dbclose();


Zeile 162: if (!is_null($user) && $user instanceof PMF_User_CurrentUser) {

DAnke

Gruss Dennis
Thorsten
Posts: 15560
Joined: Tue Sep 25, 2001 11:14 am
Location: #phpmyfaq
Contact:

Re: syntax error, unexpected

Post by Thorsten »

Hi Dennis,

den Fehler kann ich nicht nachvollziehen... kannst du mir mal deine FAQ zeigen? Welche PHP Version läuft da?

bye
Thorsten
phpMyFAQ Maintainer and Lead Developer
amazon.de Wishlist
jefferson
Posts: 7
Joined: Wed Jan 20, 2010 4:55 pm

Re: syntax error, unexpected

Post by jefferson »

laut 1und1 ist die php version 4.4.9 und 5.2.12

die faq selbst läuft bis jetzt garnicht. kann sie ja nicht konfigurieren weil auf wirklich jeder seite die beim aufruf der setup.php einen fehler bringt. wenn dir was bringt würde ich dir einen ftp zugang zukommen lassen.

wie oben schon gesagt läuft auf dem webspace schon eine htlm homepage und eine wordpress seite die ja auch unter php mit mysql datenbank.

gruss jefferson
Thorsten
Posts: 15560
Joined: Tue Sep 25, 2001 11:14 am
Location: #phpmyfaq
Contact:

Re: syntax error, unexpected

Post by Thorsten »

Hi,

du lässt das aber schon mit PHP 5.2.12 laufen, oder? Der letzte von dir gemeldete Fehler sieht eher nach PHP 4 aus...

bye
Thorsten
phpMyFAQ Maintainer and Lead Developer
amazon.de Wishlist
jefferson
Posts: 7
Joined: Wed Jan 20, 2010 4:55 pm

Re: syntax error, unexpected

Post by jefferson »

da ist eigentlich nichts einzustellen,werde das aber mal prüfen

danke erstmal

jefferson
Thorsten
Posts: 15560
Joined: Tue Sep 25, 2001 11:14 am
Location: #phpmyfaq
Contact:

Re: syntax error, unexpected

Post by Thorsten »

Hi,

wie ist denn nun der Stand?

bye
Thorsten
phpMyFAQ Maintainer and Lead Developer
amazon.de Wishlist
Post Reply