Ejemplo n.º 1
0
 /**
  * Get the content at the given URL using an HTTP GET call.
  *
  * @param string $url URL of the content
  *
  * @return string
  */
 public static function getHTTPContent($url)
 {
     // Sanity check
     if (empty($url)) {
         return false;
     }
     // Create the HTTP options for the HTTP stream context, see below
     // Set phpMyFAQ agent related data
     $agent = 'phpMyFAQ/' . PMF_System::getVersion() . ' on PHP/' . PHP_VERSION;
     $opts = array('header' => 'User-Agent: ' . $agent . "\r\n", 'method' => 'GET');
     // HTTP 1.1 Virtual Host
     $urlParts = @parse_url($url);
     if (isset($urlParts['host'])) {
         $opts['header'] = $opts['header'] . 'Host: ' . $urlParts['host'] . "\r\n";
     }
     // Socket timeout
     $opts['timeout'] = 5;
     // Create the HTTP stream context
     $ctx = stream_context_create(array('http' => $opts));
     return file_get_contents($url, null, $ctx);
 }
 * @author    Matteo Scaramuccia <*****@*****.**>
 * @copyright 2013-2015 phpMyFAQ Team
 * @license   http://www.mozilla.org/MPL/2.0/ Mozilla Public License Version 2.0
 * @link      http://www.phpmyfaq.de
 * @since     2013-01-02
 */
if (!defined('IS_VALID_PHPMYFAQ')) {
    $protocol = 'http';
    if (isset($_SERVER['HTTPS']) && strtoupper($_SERVER['HTTPS']) === 'ON') {
        $protocol = 'https';
    }
    header('Location: ' . $protocol . '://' . $_SERVER['HTTP_HOST'] . dirname($_SERVER['SCRIPT_NAME']));
    exit;
}
if ($permission['editconfig']) {
    $faqSystem = new PMF_System();
    ?>
<header>
    <h2><i class="icon-wrench"></i> <?php 
    echo $PMF_LANG['ad_system_info'];
    ?>
</h2>
</header>

<table class="table table-striped">
    <tbody>
    <?php 
    $systemInformation = array('phpMyFAQ Version' => $faqSystem->getVersion(), 'Server Software' => $_SERVER['SERVER_SOFTWARE'], 'Server Document root' => $_SERVER['DOCUMENT_ROOT'], 'phpMyFAQ installation path' => dirname(dirname($_SERVER['SCRIPT_FILENAME'])), 'PHP Version' => PHP_VERSION, 'Webserver Interface' => strtoupper(PHP_SAPI), 'PHP Extensions' => implode(', ', get_loaded_extensions()), 'PHP Session path' => session_save_path(), 'Database Server' => PMF_Db::getType(), 'Database Server Version' => $faqConfig->getDb()->serverVersion(), 'Database Client Version' => $faqConfig->getDb()->clientVersion());
    foreach ($systemInformation as $name => $info) {
        ?>
    <tr>
Ejemplo n.º 3
0
                printf('<p class="error"><strong>DB error:</strong> %s</p>', $faqConfig->getDb()->error());
                printf('<code>%s</code>', htmlentities($executeQuery));
                PMF_System::renderFooter();
            }
            usleep(10000);
        }
        echo "</div>";
    }
    echo "</p>\n";
    echo '<p class="alert alert-success">The database was updated successfully. Thank you very much for updating.</p>';
    echo '<h3>Back to your updated <a href="../index.php">phpMyFAQ installation</a> and have fun! :-)</h3>';
    // Remove backup files
    foreach (glob(PMF_ROOT_DIR . '/config/*.bak.php') as $filename) {
        if (!@unlink($filename)) {
            printf("<p class=\"alert alert-info\">Please remove the backup file %s manually.</p>\n", $filename);
        }
    }
    // Remove 'setup.php' file
    if (is_writeable(__DIR__ . '/setup.php') && @unlink(__DIR__ . '/setup.php')) {
        echo "<p class=\"alert alert-success\">The file <em>./setup/index.php</em> was deleted automatically.</p>\n";
    } else {
        echo "<p class=\"alert alert-danger\">Please delete the file <em>./setup/index.php</em> manually.</p>\n";
    }
    // Remove 'update.php' file
    if (is_writeable(__DIR__ . '/update.php') && @unlink(__DIR__ . '/update.php')) {
        echo "<p class=\"alert alert-success\">The file <em>./setup/update.php</em> was deleted automatically.</p>\n";
    } else {
        echo "<p class=\"alert alert-danger\">Please delete the file <em>./setup/update.php</em> manually.</p>\n";
    }
    PMF_System::renderFooter();
}
Ejemplo n.º 4
0
 /**
  * Starts the installation
  *
  * @param array $DB
  */
 public function startInstall(array $DB = null)
 {
     $query = $uninst = $dbSetup = [];
     // Check table prefix
     $dbSetup['dbPrefix'] = $sqltblpre = PMF_Filter::filterInput(INPUT_POST, 'sqltblpre', FILTER_SANITIZE_STRING, '');
     if ('' !== $dbSetup['dbPrefix']) {
         PMF_Db::setTablePrefix($dbSetup['dbPrefix']);
     }
     // Check database entries
     $dbSetup['dbType'] = PMF_Filter::filterInput(INPUT_POST, 'sql_type', FILTER_SANITIZE_STRING);
     if (!is_null($dbSetup['dbType'])) {
         $dbSetup['dbType'] = trim($dbSetup['dbType']);
         if (!file_exists(PMF_ROOT_DIR . '/setup/assets/sql/' . $dbSetup['dbType'] . '.sql.php')) {
             printf('<p class="alert alert-danger"><strong>Error:</strong> Invalid server type: %s</p>', $dbSetup['dbType']);
             PMF_System::renderFooter(true);
         }
     } else {
         echo "<p class=\"alert alert-danger\"><strong>Error:</strong> Please select a database type.</p>\n";
         PMF_System::renderFooter(true);
     }
     $dbSetup['dbServer'] = PMF_Filter::filterInput(INPUT_POST, 'sql_server', FILTER_SANITIZE_STRING);
     if (is_null($dbSetup['dbServer']) && !PMF_System::isSqlite($dbSetup['dbType'])) {
         echo "<p class=\"alert alert-danger\"><strong>Error:</strong> Please add a database server.</p>\n";
         PMF_System::renderFooter(true);
     }
     $dbSetup['dbPort'] = PMF_Filter::filterInput(INPUT_POST, 'sql_port', FILTER_VALIDATE_INT);
     if (is_null($dbSetup['dbPort']) && !PMF_System::isSqlite($dbSetup['dbType'])) {
         echo "<p class=\"alert alert-error\"><strong>Error:</strong> Please add a valid database port.</p>\n";
         PMF_System::renderFooter(true);
     }
     $dbSetup['dbUser'] = PMF_Filter::filterInput(INPUT_POST, 'sql_user', FILTER_SANITIZE_STRING);
     if (is_null($dbSetup['dbUser']) && !PMF_System::isSqlite($dbSetup['dbType'])) {
         echo "<p class=\"alert alert-danger\"><strong>Error:</strong> Please add a database username.</p>\n";
         PMF_System::renderFooter(true);
     }
     $dbSetup['dbPassword'] = PMF_Filter::filterInput(INPUT_POST, 'sql_passwort', FILTER_UNSAFE_RAW);
     if (is_null($dbSetup['dbPassword']) && !PMF_System::isSqlite($dbSetup['dbType'])) {
         // Password can be empty...
         $dbSetup['dbPassword'] = '';
     }
     $dbSetup['dbDatabaseName'] = PMF_Filter::filterInput(INPUT_POST, 'sql_db', FILTER_SANITIZE_STRING);
     if (is_null($dbSetup['dbDatabaseName']) && !PMF_System::isSqlite($dbSetup['dbType'])) {
         echo "<p class=\"alert alert-danger\"><strong>Error:</strong> Please add a database name.</p>\n";
         PMF_System::renderFooter(true);
     }
     if (PMF_System::isSqlite($dbSetup['dbType'])) {
         $dbSetup['dbServer'] = PMF_Filter::filterInput(INPUT_POST, 'sql_sqlitefile', FILTER_SANITIZE_STRING);
         if (is_null($dbSetup['dbServer'])) {
             echo "<p class=\"alert alert-danger\"><strong>Error:</strong> Please add a SQLite database filename.</p>\n";
             PMF_System::renderFooter(true);
         }
     }
     // check database connection
     PMF_Db::setTablePrefix($dbSetup['dbPrefix']);
     $db = PMF_Db::factory($dbSetup['dbType']);
     $db->connect($dbSetup['dbServer'], $dbSetup['dbUser'], $dbSetup['dbPassword'], $dbSetup['dbDatabaseName']);
     if (!$db) {
         printf("<p class=\"alert alert-danger\"><strong>DB Error:</strong> %s</p>\n", $db->error());
         PMF_System::renderFooter(true);
     }
     $configuration = new PMF_Configuration($db);
     // check LDAP if available
     $ldapEnabled = PMF_Filter::filterInput(INPUT_POST, 'ldap_enabled', FILTER_SANITIZE_STRING);
     if (extension_loaded('ldap') && !is_null($ldapEnabled)) {
         $ldapSetup = [];
         // check LDAP entries
         $ldapSetup['ldapServer'] = PMF_Filter::filterInput(INPUT_POST, 'ldap_server', FILTER_SANITIZE_STRING);
         if (is_null($ldapSetup['ldapServer'])) {
             echo "<p class=\"alert alert-danger\"><strong>Error:</strong> Please add a LDAP server.</p>\n";
             PMF_System::renderFooter(true);
         }
         $ldapSetup['ldapPort'] = PMF_Filter::filterInput(INPUT_POST, 'ldap_port', FILTER_VALIDATE_INT);
         if (is_null($ldapSetup['ldapPort'])) {
             echo "<p class=\"alert alert-danger\"><strong>Error:</strong> Please add a LDAP port.</p>\n";
             PMF_System::renderFooter(true);
         }
         $ldapSetup['ldapBase'] = PMF_Filter::filterInput(INPUT_POST, 'ldap_base', FILTER_SANITIZE_STRING);
         if (is_null($ldapSetup['ldapBase'])) {
             echo "<p class=\"alert alert-danger\"><strong>Error:</strong> Please add a LDAP base search DN.</p>\n";
             PMF_System::renderFooter(true);
         }
         // LDAP User and LDAP password are optional
         $ldapSetup['ldapUser'] = PMF_Filter::filterInput(INPUT_POST, 'ldap_user', FILTER_SANITIZE_STRING, '');
         $ldapSetup['ldapPassword'] = PMF_Filter::filterInput(INPUT_POST, 'ldap_password', FILTER_SANITIZE_STRING, '');
         // check LDAP connection
         require PMF_ROOT_DIR . "/inc/PMF/Ldap.php";
         $ldap = new PMF_Ldap($configuration);
         $ldap->connect($ldapSetup['ldapServer'], $ldapSetup['ldapPort'], $ldapSetup['ldapBase'], $ldapSetup['ldapUser'], $ldapSetup['ldapPassword']);
         if (!$ldap) {
             echo "<p class=\"alert alert-danger\"><strong>LDAP Error:</strong> " . $ldap->error() . "</p>\n";
             PMF_System::renderFooter(true);
         }
     }
     // check loginname
     $loginname = PMF_Filter::filterInput(INPUT_POST, 'loginname', FILTER_SANITIZE_STRING);
     if (is_null($loginname)) {
         echo '<p class="alert alert-danger"><strong>Error:</strong> Please add a loginname for your account.</p>';
         PMF_System::renderFooter(true);
     }
     // check user entries
     $password = PMF_Filter::filterInput(INPUT_POST, 'password', FILTER_SANITIZE_STRING);
     if (is_null($password)) {
         echo '<p class="alert alert-danger"><strong>Error:</strong> Please add a password for the your account.</p>';
         PMF_System::renderFooter(true);
     }
     $password_retyped = PMF_Filter::filterInput(INPUT_POST, 'password_retyped', FILTER_SANITIZE_STRING);
     if (is_null($password_retyped)) {
         echo '<p class="alert alert-danger"><strong>Error:</strong> Please add a retyped password.</p>';
         PMF_System::renderFooter(true);
     }
     if (strlen($password) <= 5 || strlen($password_retyped) <= 5) {
         echo '<p class="alert alert-danger"><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>';
         PMF_System::renderFooter(true);
     }
     if ($password != $password_retyped) {
         echo '<p class="alert alert-danger"><strong>Error:</strong> Your password and retyped password are not equal.' . ' Please check your password and your retyped password.</p>';
         PMF_System::renderFooter(true);
     }
     $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');
     $instanceSetup = new PMF_Instance_Setup();
     $instanceSetup->setRootDir(PMF_ROOT_DIR);
     // Write the DB variables in database.php
     if (!$instanceSetup->createDatabaseFile($dbSetup)) {
         echo "<p class=\"alert alert-danger\"><strong>Error:</strong> Setup cannot write to ./config/database.php.</p>";
         $this->_system->cleanInstallation();
         PMF_System::renderFooter(true);
     }
     // check LDAP if available
     if (extension_loaded('ldap') && !is_null($ldapEnabled)) {
         if (!$instanceSetup->createLdapFile($ldapSetup, '')) {
             echo "<p class=\"alert alert-danger\"><strong>Error:</strong> Setup cannot write to ./config/ldap.php.</p>";
             $this->_system->cleanInstallation();
             PMF_System::renderFooter(true);
         }
     }
     // connect to the database using config/database.php
     require PMF_ROOT_DIR . '/config/database.php';
     $db = PMF_Db::factory($dbSetup['dbType']);
     $db->connect($DB['server'], $DB['user'], $DB['password'], $DB['db']);
     if (!$db) {
         echo "<p class=\"alert alert-danger\"><strong>DB Error:</strong> " . $db->error() . "</p>\n";
         $this->_system->cleanInstallation();
         PMF_System::renderFooter(true);
     }
     require PMF_ROOT_DIR . '/setup/assets/sql/' . $dbSetup['dbType'] . '.sql.php';
     // CREATE TABLES
     require PMF_ROOT_DIR . '/setup/assets/sql/stopwords.sql.php';
     // INSERTs for stopwords
     $this->_system->setDatabase($db);
     echo '<p>';
     // Erase any table before starting creating the required ones
     if (!PMF_System::isSqlite($dbSetup['dbType'])) {
         $this->_system->dropTables($uninst);
     }
     // Start creating the required tables
     $count = 0;
     foreach ($query as $executeQuery) {
         $result = @$db->query($executeQuery);
         if (!$result) {
             echo '<p class="alert alert-danger"><strong>Error:</strong> Please install your version of phpMyFAQ once again or send
         us a <a href=\\"http://www.phpmyfaq.de\\" target=\\"_blank\\">bug report</a>.</p>';
             printf('<p class="alert alert-danger"><strong>DB error:</strong> %s</p>', $db->error());
             printf('<code>%s</code>', htmlentities($executeQuery));
             $this->_system->dropTables($uninst);
             $this->_system->cleanInstallation();
             PMF_System::renderFooter(true);
         }
         usleep(2500);
         $count++;
         if (!($count % 10)) {
             echo '| ';
         }
     }
     $link = new PMF_Link(null, $configuration);
     // add main configuration, add personal settings
     $this->_mainConfig['main.metaPublisher'] = $realname;
     $this->_mainConfig['main.administrationMail'] = $email;
     $this->_mainConfig['main.language'] = $language;
     $this->_mainConfig['security.permLevel'] = $permLevel;
     foreach ($this->_mainConfig as $name => $value) {
         $configuration->add($name, $value);
     }
     $configuration->update(array('main.referenceURL' => $link->getSystemUri('/setup/index.php')));
     $configuration->add('security.salt', md5($configuration->get('main.referenceURL')));
     // add admin account and rights
     $admin = new PMF_User($configuration);
     if (!$admin->createUser($loginname, $password, 1)) {
         printf("<p class=\"alert alert-danger\"><strong>Fatal installation error:</strong><br>" . "Couldn't create the admin user: %s</p>\n", $admin->error());
         $this->_system->cleanInstallation();
         PMF_System::renderFooter(true);
     }
     $admin->setStatus('protected');
     $adminData = array('display_name' => $realname, 'email' => $email);
     $admin->setUserData($adminData);
     // add default rights
     foreach ($this->_mainRights as $right) {
         $admin->perm->grantUserRight(1, $admin->perm->addRight($right));
     }
     // Add anonymous user account
     $instanceSetup->createAnonymousUser($configuration);
     // Add master instance
     $instanceData = array('url' => $link->getSystemUri($_SERVER['SCRIPT_NAME']), 'instance' => $link->getSystemRelativeUri('setup/index.php'), 'comment' => 'phpMyFAQ ' . PMF_System::getVersion());
     $faqInstance = new PMF_Instance($configuration);
     $faqInstance->addInstance($instanceData);
     $faqInstanceMaster = new PMF_Instance_Master($configuration);
     $faqInstanceMaster->createMaster($faqInstance);
     echo '</p>';
 }
Ejemplo n.º 5
0
<?php

/**
 * This scripts iterates recursively through the whole phpMyFAQ project and
 * creates SHA-1 keys for all files
 *
 * PHP Version 5.2.3
 *
 * This Source Code Form is subject to the terms of the Mozilla Public License,
 * v. 2.0. If a copy of the MPL was not distributed with this file, You can
 * obtain one at http://mozilla.org/MPL/2.0/.
 *
 * @category  phpMyFAQ
 * @package   Scripts
 * @author    Thorsten Rinne <*****@*****.**>
 * @copyright 2012 phpMyFAQ Team
 * @license   http://www.mozilla.org/MPL/2.0/ Mozilla Public License Version 2.0
 * @link      http://www.phpmyfaq.de
 * @since     2012-04-11
 */
require dirname(__FILE__) . '/../inc/System.php';
$system = new PMF_System();
print $system->createHashes();
Ejemplo n.º 6
0
/**
 * @param mixed $key
 * @param string $type
 *
 * @return void
 */
function renderInputForm($key, $type)
{
    global $PMF_LANG, $faqConfig;
    switch ($type) {
        case 'area':
            printf('<textarea name="edit[%s]" rows="4" class="form-control">%s</textarea>', $key, str_replace('<', '&lt;', str_replace('>', '&gt;', $faqConfig->get($key))));
            printf("</div>\n");
            break;
        case 'input':
            if ('' == $faqConfig->get($key) && 'socialnetworks.twitterAccessTokenKey' == $key && isset($_SESSION['access_token'])) {
                $value = $_SESSION['access_token']['oauth_token'];
            } elseif ('' == $faqConfig->get($key) && 'socialnetworks.twitterAccessTokenSecret' == $key && isset($_SESSION['access_token'])) {
                $value = $_SESSION['access_token']['oauth_token_secret'];
            } else {
                $value = str_replace('"', '&quot;', $faqConfig->get($key));
            }
            printf('<input class="form-control" type="%s" name="edit[%s]" value="%s" step="1" min="0">', is_numeric($value) ? 'number' : 'text', $key, $value);
            echo "</div>\n";
            break;
        case 'select':
            printf('<select name="edit[%s]" size="1" class="form-control">', $key);
            switch ($key) {
                case 'main.language':
                    $languages = PMF_Language::getAvailableLanguages();
                    if (count($languages) > 0) {
                        echo PMF_Language::languageOptions(str_replace(array('language_', '.php'), '', $faqConfig->get('main.language')), false, true);
                    } else {
                        echo '<option value="language_en.php">English</option>';
                    }
                    break;
                case 'records.orderby':
                    echo PMF_Configuration::sortingOptions($faqConfig->get($key));
                    break;
                case 'records.sortby':
                    printf('<option value="DESC"%s>%s</option>', 'DESC' == $faqConfig->get($key) ? ' selected' : '', $PMF_LANG['ad_conf_desc']);
                    printf('<option value="ASC"%s>%s</option>', 'ASC' == $faqConfig->get($key) ? ' selected' : '', $PMF_LANG['ad_conf_asc']);
                    break;
                case 'security.permLevel':
                    echo PMF_Perm::permOptions($faqConfig->get($key));
                    break;
                case 'main.templateSet':
                    $faqSystem = new PMF_System();
                    $templates = $faqSystem->getAvailableTemplates();
                    foreach ($templates as $template => $selected) {
                        printf("<option%s>%s</option>", $selected === true ? ' selected' : '', $template);
                    }
                    break;
                case "records.attachmentsStorageType":
                    foreach ($PMF_LANG['att_storage_type'] as $i => $item) {
                        $selected = $faqConfig->get($key) == $i ? ' selected' : '';
                        printf('<option value="%d"%s>%s</option>', $i, $selected, $item);
                    }
                    break;
                case "records.orderingPopularFaqs":
                    printf('<option value="visits"%s>%s</option>', 'visits' == $faqConfig->get($key) ? ' selected' : '', $PMF_LANG['records.orderingPopularFaqs.visits']);
                    printf('<option value="voting"%s>%s</option>', 'voting' == $faqConfig->get($key) ? ' selected' : '', $PMF_LANG['records.orderingPopularFaqs.voting']);
                    break;
                case "search.relevance":
                    printf('<option value="thema,content,keywords"%s>%s</option>', 'thema,content,keywords' == $faqConfig->get($key) ? ' selected' : '', $PMF_LANG['search.relevance.thema-content-keywords']);
                    printf('<option value="thema,keywords,content"%s>%s</option>', 'thema,keywords,content' == $faqConfig->get($key) ? ' selected' : '', $PMF_LANG['search.relevance.thema-keywords-content']);
                    printf('<option value="content,thema,keywords"%s>%s</option>', 'content,thema,keywords' == $faqConfig->get($key) ? ' selected' : '', $PMF_LANG['search.relevance.content-thema-keywords']);
                    printf('<option value="content,keywords,thema"%s>%s</option>', 'content,keywords,thema' == $faqConfig->get($key) ? ' selected' : '', $PMF_LANG['search.relevance.content-keywords-thema']);
                    printf('<option value="keywords,content,thema"%s>%s</option>', 'keywords,content,thema' == $faqConfig->get($key) ? ' selected' : '', $PMF_LANG['search.relevance.keywords-content-thema']);
                    printf('<option value="keywords,thema,content"%s>%s</option>', 'keywords,thema,content' == $faqConfig->get($key) ? ' selected' : '', $PMF_LANG['search.relevance.keywords-thema-content']);
                    break;
            }
            echo "</select>\n</div>\n";
            break;
        case 'checkbox':
            printf('<div class="checkbox"><input type="checkbox" name="edit[%s]" value="true"', $key);
            if ($faqConfig->get($key)) {
                echo ' checked';
            }
            if ('security.ldapSupport' === $key && !extension_loaded('ldap')) {
                echo ' disabled';
            }
            if ('security.useSslOnly' === $key && empty($_SERVER['HTTPS'])) {
                echo ' disabled';
            }
            if ('security.ssoSupport' === $key && empty($_SERVER['REMOTE_USER'])) {
                echo ' disabled';
            }
            echo ">\n</div></div>\n";
            break;
        case 'print':
            printf('<input type="text" readonly name="edit[%s]" class="form-control" value="%s"></div>', $key, str_replace('"', '&quot;', $faqConfig->get($key)), $faqConfig->get($key));
            break;
    }
}
Ejemplo n.º 7
0
//
if ($faqConfig->get('main.maintenanceMode')) {
    $indexSet = 'indexMaintenance.tpl';
}
//
// Load template files and set template variables
//
$tpl = new PMF_Template(array('index' => $indexSet, 'rightBox' => $rightSidebarTemplate, 'writeContent' => $includeTemplate), $faqConfig->get('main.templateSet'));
if ($faqConfig->get('main.enableUserTracking')) {
    $users = $faqsession->getUsersOnline();
    $totUsers = $users[0] + $users[1];
    $usersOnline = $plr->getMsg('plmsgUserOnline', $totUsers) . ' | ' . $plr->getMsg('plmsgGuestOnline', $users[0]) . $plr->getMsg('plmsgRegisteredOnline', $users[1]);
} else {
    $usersOnline = '';
}
$faqSystem = new PMF_System();
$categoryHelper = new PMF_Helper_Category();
$categoryHelper->setCategory($category);
$categoryHelper->setConfiguration($faqConfig);
$keywordsArray = array_merge(explode(',', $keywords), explode(',', $faqConfig->get('main.metaKeywords')));
$keywordsArray = array_filter($keywordsArray, 'strlen');
shuffle($keywordsArray);
$keywords = implode(',', $keywordsArray);
$faqLink = new PMF_Link($faqSystem->getSystemUri($faqConfig), $faqConfig);
$currentPageUrl = $faqLink->getCurrentUrl();
if (is_null($error)) {
    $loginMessage = '<p>' . $PMF_LANG['ad_auth_insert'] . '</p>';
} else {
    $loginMessage = '<p class="error">' . $error . '</p>';
}
$tplMainPage = array('msgLoginUser' => $PMF_LANG['msgLoginUser'], 'title' => $faqConfig->get('main.titleFAQ') . $title, 'baseHref' => $faqSystem->getSystemUri($faqConfig), 'version' => $faqConfig->get('main.currentVersion'), 'header' => str_replace('"', '', $faqConfig->get('main.titleFAQ')), 'metaTitle' => str_replace('"', '', $faqConfig->get('main.titleFAQ') . $title), 'metaDescription' => $metaDescription, 'metaKeywords' => $keywords, 'metaPublisher' => $faqConfig->get('main.metaPublisher'), 'metaLanguage' => $PMF_LANG['metaLanguage'], 'metaCharset' => 'utf-8', 'phpmyfaqversion' => $faqConfig->get('main.currentVersion'), 'stylesheet' => $PMF_LANG['dir'] == 'rtl' ? 'style.rtl' : 'style', 'currentPageUrl' => $currentPageUrl, 'action' => $action, 'dir' => $PMF_LANG['dir'], 'headerCategories' => $PMF_LANG['msgFullCategories'], 'msgCategory' => $PMF_LANG['msgCategory'], 'msgExportAllFaqs' => $PMF_LANG['msgExportAllFaqs'], 'languageBox' => $PMF_LANG['msgLangaugeSubmit'], 'writeLangAdress' => $writeLangAdress, 'switchLanguages' => PMF_Language::selectLanguages($LANGCODE, true), 'userOnline' => $usersOnline, 'copyright' => 'powered by <a href="http://www.phpmyfaq.de" target="_blank">phpMyFAQ</a> ' . $faqConfig->get('main.currentVersion'), 'registerUser' => '<a href="?action=register">' . $PMF_LANG['msgRegistration'] . '</a>', 'sendPassword' => '<a href="?action=password">' . $PMF_LANG['lostPassword'] . '</a>', 'loginHeader' => $PMF_LANG['msgLoginUser'], 'loginMessage' => $loginMessage, 'writeLoginPath' => $faqSystem->getSystemUri($faqConfig) . '?' . PMF_Filter::getFilteredQueryString(), 'faqloginaction' => $action, 'login' => $PMF_LANG['ad_auth_ok'], 'username' => $PMF_LANG['ad_auth_user'], 'password' => $PMF_LANG['ad_auth_passwd'], 'rememberMe' => $PMF_LANG['rememberMe'], 'headerChangePassword' => $PMF_LANG['ad_passwd_cop'], 'msgUsername' => $PMF_LANG['ad_auth_user'], 'msgEmail' => $PMF_LANG['ad_entry_email'], 'msgSubmit' => $PMF_LANG['msgNewContentSubmit']);
Ejemplo n.º 8
0
        ?>
            
            </p>
        </section>

        <section>
            <header>
                <h3><?php 
        print $PMF_LANG["ad_online_verification"];
        ?>
</h3>
            </header>
            <?php 
        $getJson = PMF_Filter::filterInput(INPUT_POST, 'getJson', FILTER_SANITIZE_STRING);
        if (!is_null($getJson) && 'verify' === $getJson) {
            $faqSystem = new PMF_System();
            $localHashes = $faqSystem->createHashes();
            $remoteHashes = file_get_contents('http://www.phpmyfaq.de/api/verify/' . $faqconfig->get('main.currentVersion'));
            $diff = array_diff(json_decode($localHashes, true), json_decode($remoteHashes, true));
            if (1 !== count($diff)) {
                printf('<p class="error">%s</p>', $PMF_LANG["ad_verification_notokay"]);
                print '<ul>';
                foreach ($diff as $file => $hash) {
                    if ('created' === $file) {
                        continue;
                    }
                    printf('<li><span title="%s">%s</span></li>', $hash, $file);
                }
                print '</ul>';
            } else {
                printf('<p class="success">%s</p>', $PMF_LANG["ad_verification_okay"]);
Ejemplo n.º 9
0
        $installed = $faqConfig->get('main.currentVersion');
        $available = $result->stable;
        $templateVars['updateCheckActive'] = true;
        $templateVars['updateAvailable'] = -1 == version_compare($installed, $available);
        $templateVars['lastestVersion'] = $available;
    }
}
unset($json, $result, $installed, $available, $version);
// Perform online verification
$getJson = PMF_Filter::filterInput(INPUT_POST, 'getJson', FILTER_SANITIZE_STRING);
if (!is_null($getJson) && 'verify' === $getJson) {
    $templateVars['onlineVerificationActive'] = true;
    set_error_handler(function ($severity, $message, $file, $line) {
        throw new ErrorException($message, $severity, $severity, $file, $line);
    });
    $faqSystem = new PMF_System();
    $localHashes = $faqSystem->createHashes();
    $versionCheckError = true;
    try {
        $remoteHashes = file_get_contents('http://www.phpmyfaq.de/api/verify/' . $faqConfig->get('main.currentVersion'));
        if (!is_array(json_decode($remoteHashes, true))) {
            $versionCheckError = true;
        } else {
            $versionCheckError = false;
        }
    } catch (ErrorException $e) {
        $templateVars['onlineVerificationError'] = true;
    }
    restore_error_handler();
    if ($versionCheckError) {
        $templateVars['onlineVerificationError'] = true;
            <?php 
    }
    ?>
            </p>
        </div>
        <div class="span6">
            <header>
                <h3><?php 
    print $PMF_LANG['ad_online_verification'];
    ?>
</h3>
            </header>
            <?php 
    $getJson = PMF_Filter::filterInput(INPUT_POST, 'getJson', FILTER_SANITIZE_STRING);
    if (!is_null($getJson) && 'verify' === $getJson) {
        $faqSystem = new PMF_System();
        $localHashes = $faqSystem->createHashes();
        $remoteHashes = file_get_contents('http://api.phpmyfaq.de/verify/' . $faqConfig->get('main.currentVersion'));
        if (!is_array(json_decode($remoteHashes, true))) {
            echo '<p class="alert alert-danger">phpMyFAQ version mismatch - no verification possible.</p>';
        } else {
            $diff = array_diff(json_decode($localHashes, true), json_decode($remoteHashes, true));
            if (1 < count($diff)) {
                printf('<p class="alert alert-danger">%s</p>', $PMF_LANG["ad_verification_notokay"]);
                print '<ul>';
                foreach ($diff as $file => $hash) {
                    if ('created' === $file) {
                        continue;
                    }
                    printf('<li><span class="pmf-popover" data-original-title="SHA-1" data-content="%s">%s</span></li>', $hash, $file);
                }
Ejemplo n.º 11
0
        }
    }
    // -->
    /*]]>*/
    </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 
$system = new PMF_System();
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 (!$system->checkDatabase($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;
}
Ejemplo n.º 12
0
require PMF_ROOT_DIR . '/config/constants.php';
//
// Setting up PSR-0 autoloader for Symfony Components
//
require PMF_INCLUDE_DIR . '/libs/Symfony/Component/ClassLoader/UniversalClassLoader.php';
$loader = new UniversalClassLoader();
$loader->registerNamespace('Symfony', PMF_INCLUDE_DIR . '/libs');
$loader->registerPrefix('PMF_', PMF_INCLUDE_DIR);
$loader->registerPrefix('Twig_', PMF_INCLUDE_DIR . '/libs');
$loader->register();
//
// Initialize static string wrapper
//
PMF_String::init('en');
$installer = new PMF_Installer();
$system = new PMF_System();
//
// Initializing Twig
//
$twig = new Twig_Environment(new Twig_Loader_Filesystem(PMF_ROOT_DIR . '/setup/assets/twig'));
$tplLayoutVars = array('version' => PMF_System::getVersion(), 'currentYear' => date('Y'), 'criticalErrors' => $installer->checkBasicStuff(), 'filePermErrors' => $installer->checkFilesystemPermissions(), 'nonCriticalErrors' => $installer->checkNoncriticalSettings());
$twig->loadTemplate('layout.twig')->display($tplLayoutVars);
// not yet POSTed
if (!isset($_POST['sql_server']) && !isset($_POST['sql_user']) && !isset($_POST['sql_db'])) {
    $tplDatabaseVars = array('databases' => $system->getSupportedSafeDatabases(true), 'dirname' => dirname(__DIR__));
    ?>

    <form class="form-horizontal" action="index.php" method="post">
        <div class="row">
            <div class="col-xs-6 col-sm-6 col-md-6 col-lg-6">
                <?php