Beispiel #1
0
 /**
  * Initalizing factory with global attachment settings
  * 
  * @param int     $storageType       Storage type   
  * @param string  $defaultKey        Default key
  * @param boolean $encryptionEnabled Enabled encryption?
  * 
  * @return null
  */
 public static function init($storageType, $defaultKey, $encryptionEnabled)
 {
     if (null === self::$storageType) {
         self::$storageType = $storageType;
     }
     if (null === self::$defaultKey) {
         self::$defaultKey = $defaultKey;
     }
     if (null === self::$encryptionEnabled) {
         self::$encryptionEnabled = $encryptionEnabled;
     }
 }
Beispiel #2
0
    // 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($PMF_LANG["metaCharset"], $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();
Beispiel #3
0
 * @author    Anatoliy Belsky <*****@*****.**>
 * @copyright 2010-2014 phpMyFAQ Team
 * @license   http://www.mozilla.org/MPL/2.0/ Mozilla Public License Version 2.0
 * @link      http://www.phpmyfaq.de
 * @since     2010-12-20
 */
use Symfony\Component\HttpFoundation\Response;
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;
}
$ajaxAction = PMF_Filter::filterInput(INPUT_GET, 'ajaxaction', FILTER_SANITIZE_STRING);
$attId = PMF_Filter::filterInput(INPUT_GET, 'attId', FILTER_VALIDATE_INT);
$att = PMF_Attachment_Factory::create($attId);
$response = new Response();
if ($att) {
    switch ($ajaxAction) {
        case 'delete':
            if ($att->delete()) {
                $response->setContent($PMF_LANG['msgAttachmentsDeleted']);
            } else {
                $response->setContent($PMF_LANG['ad_att_delfail']);
            }
            break;
    }
}
$response->send();
Beispiel #4
0
    $switchLanguage .= "<p>\n";
    $switchLanguage .= "<fieldset>\n";
    $switchLanguage .= "<legend>" . $PMF_LANG["msgLangaugeSubmit"] . "</legend>\n";
    $switchLanguage .= "<form action=\"" . $changeLanguagePath . "\" method=\"post\" style=\"display: inline;\">\n";
    $switchLanguage .= "<select name=\"language\" size=\"1\">\n";
    $switchLanguage .= $check4Lang;
    $switchLanguage .= "</select>\n";
    $switchLanguage .= "&nbsp;\n";
    $switchLanguage .= "<input class=\"submit\" type=\"submit\" name=\"submit\" value=\"" . $PMF_LANG["msgLangaugeSubmit"] . "\" />\n";
    $switchLanguage .= "</fieldset>\n";
    $switchLanguage .= "</form>\n";
    $switchLanguage .= "</p>\n";
}
// List all faq attachments
if ($faqconfig->get('main.disableAttachments') && 'yes' == $faq->faqRecord['active']) {
    $attList = PMF_Attachment_Factory::fetchByRecordId($record_id);
    $outstr = "";
    while (list(, $att) = each($attList)) {
        $outstr .= sprintf('<a href="%s">%s</a>, ', $att->buildUrl(), $att->getFilename());
    }
    if (count($attList) > 0) {
        $content .= '<p>' . $PMF_LANG['msgAttachedFiles'] . ' ' . PMF_String::substr($outstr, 0, -2) . '</p>';
    }
}
// List all categories for this faq
$writeMultiCategories = '';
$multiCategories = array();
$categoryRelations = new PMF_Category_Relations();
foreach ($categoryRelations->fetchAll() as $relation) {
    if ($relation->record_id == $record_id) {
        $multiCategories[] = $relation->category_id;
Beispiel #5
0
 /**
  * Migrate
  * 
  * @param integer $migrationType how to migrate
  * @param array   $options       migration options
  * 
  * @return boolean
  */
 public function doMigrate($migrationType, $options)
 {
     switch ($migrationType) {
         case PMF_Attachment_Migration::MIGRATION_TYPE1:
             PMF_Attachment_Factory::init(PMF_Attachment::STORAGE_TYPE_FILESYSTEM, '', false);
             $this->migrateFromOldFormatToFs();
             // FIXME should attachment settings update be triggered here?
             break;
         case PMF_Attachment_Migration::MIGRATION_TYPE2:
             /**
              * Awaiting new default key here
              */
             if (isset($options['defaultKey']) && !empty($options['defaultKey'])) {
                 PMF_Attachment_Factory::init(PMF_Attachment::STORAGE_TYPE_FILESYSTEM, $options['defaultKey'], true);
                 $this->migrateFromOldFormatToFs();
             } else {
                 $this->error[] = 'Default key required to be set for this option';
             }
             break;
         case PMF_Attachment_Migration::MIGRATION_TYPE3:
             // TODO implement this
             $this->error[] = 'not implemented';
             break;
         case PMF_Attachment_Migration::MIGRATION_TYPE4:
             //TODO implenemt this
             $this->error[] = 'not implemented';
             break;
         default:
             $this->error[] = 'Nothing to do';
             break;
     }
     return empty($this->error);
 }
Beispiel #6
0
    require PMF_ROOT_DIR . '/lang/language_' . $LANGCODE . '.php';
} else {
    $LANGCODE = 'en';
}
//
// Initalizing static string wrapper
//
PMF_String::init($LANGCODE);
//
// Set actual template set name
//
PMF_Template::setTplSetName($faqConfig->get('main.templateSet'));
//
// Initialize attachment factory
//
PMF_Attachment_Factory::init($faqConfig->get('records.attachmentsStorageType'), $faqConfig->get('records.defaultAttachmentEncKey'), $faqConfig->get('records.enableAttachmentEncryption'));
//
// Create a new phpMyFAQ system object
//
$faqSystem = new PMF_System();
//
// Create a new FAQ object
//
$faq = new PMF_Faq($faqConfig);
//
// use mbstring extension if available and when possible
//
$validMbStrings = array('ja', 'en', 'uni');
$mbLanguage = $PMF_LANG['metaLanguage'] != 'ja' ? 'uni' : $PMF_LANG['metaLanguage'];
if (function_exists('mb_language') && in_array($mbLanguage, $validMbStrings)) {
    mb_language($mbLanguage);
Beispiel #7
0
    header('Location: http://' . $_SERVER['HTTP_HOST'] . dirname($_SERVER['SCRIPT_NAME']));
    exit;
}
set_time_limit(0);
if (headers_sent()) {
    die;
}
$attachmentErrors = array();
// authenticate with session information
$user = PMF_User_CurrentUser::getFromSession($faqconfig->get('security.ipCheck'));
if (!$user instanceof PMF_User_CurrentUser) {
    $user = new PMF_User_CurrentUser();
    // user not logged in -> empty user object
}
$id = PMF_Filter::filterInput(INPUT_GET, 'id', FILTER_VALIDATE_INT);
$attachment = PMF_Attachment_Factory::create($id);
$userPermission = $faq->getPermission('user', $attachment->getRecordId());
$groupPermission = $faq->getPermission('group', $attachment->getRecordId());
// Check on group permissions
if ($user->perm instanceof PMF_Perm_PermMedium) {
    if (count($groupPermission) && in_array($groupPermission[0], $user->perm->getUserGroups($user->getUserId()))) {
        $groupPermission = true;
    } else {
        $groupPermission = false;
    }
} else {
    $groupPermission = true;
}
// Check in user's permissions
if (in_array($user->getUserId(), $userPermission)) {
    $userPermission = true;
Beispiel #8
0
    if ($action == 'copyentry') {
        $faqData['lang'] = PMF_Filter::filterInput(INPUT_GET, 'lang', FILTER_SANITIZE_STRING);
    }
    if ($permission['addattachment']) {
        ?>
                <p>
                    <label><?php 
        print $PMF_LANG['ad_menu_attachments'];
        ?>
:</label>
<?php 
        if (isset($faqData['id']) && $faqData['id'] != "") {
            ?>
                    <ul class="adminAttachments">
<?php 
            $attList = PMF_Attachment_Factory::fetchByRecordId($faqData['id']);
            foreach ($attList as $att) {
                printf('<li><a href="../%s">%s</a> ', $att->buildUrl(), $att->getFilename());
                if ($permission['delattachment']) {
                    printf('[ <a href="?action=delatt&amp;record_id=%d&amp;id=%d&amp;lang=%s">%s</a> ]', $faqData['id'], $att->getId(), $faqData['lang'], $PMF_LANG['ad_att_del']);
                }
                print "</li>\n";
            }
            printf('<li><a href="#;" onclick="addAttachment(\'attachment.php?record_id=%d&amp;record_lang=%s&amp;rubrik=%d\', \'Attachment\', 550, 130); return false;">%s</a></li>', $faqData['id'], $faqData['lang'], $selectedCategory, $PMF_LANG['ad_att_add']);
            ?>
                    </ul>
<?php 
        } else {
            print $PMF_LANG['ad_att_nope'];
        }
        ?>
 /**
  * Deletes a record and all the dependencies
  *
  * @param integer $recordId   Record id
  * @param string  $recordLang Record language
  *
  * @return boolean
  */
 public function deleteRecord($recordId, $recordLang)
 {
     $queries = array(sprintf("DELETE FROM %sfaqchanges WHERE beitrag = %d AND lang = '%s'", PMF_Db::getTablePrefix(), $recordId, $recordLang), sprintf("DELETE FROM %sfaqcategoryrelations WHERE record_id = %d AND record_lang = '%s'", PMF_Db::getTablePrefix(), $recordId, $recordLang), sprintf("DELETE FROM %sfaqdata WHERE id = %d AND lang = '%s'", PMF_Db::getTablePrefix(), $recordId, $recordLang), sprintf("DELETE FROM %sfaqdata_revisions WHERE id = %d AND lang = '%s'", PMF_Db::getTablePrefix(), $recordId, $recordLang), sprintf("DELETE FROM %sfaqvisits WHERE id = %d AND lang = '%s'", PMF_Db::getTablePrefix(), $recordId, $recordLang), sprintf("DELETE FROM %sfaqdata_user WHERE record_id = %d", PMF_Db::getTablePrefix(), $recordId, $recordLang), sprintf("DELETE FROM %sfaqdata_group WHERE record_id = %d", PMF_Db::getTablePrefix(), $recordId, $recordLang), sprintf("DELETE FROM %sfaqdata_tags WHERE record_id = %d", PMF_Db::getTablePrefix(), $recordId), sprintf('DELETE FROM %sfaqdata_tags WHERE %sfaqdata_tags.record_id NOT IN (SELECT %sfaqdata.id FROM %sfaqdata)', PMF_Db::getTablePrefix(), PMF_Db::getTablePrefix(), PMF_Db::getTablePrefix(), PMF_Db::getTablePrefix()), sprintf("DELETE FROM %sfaqcomments WHERE id = %d", PMF_Db::getTablePrefix(), $recordId), sprintf("DELETE FROM %sfaqvoting WHERE artikel = %d", PMF_Db::getTablePrefix(), $recordId));
     foreach ($queries as $query) {
         $this->_config->getDb()->query($query);
     }
     // Delete possible attachments
     $attId = PMF_Attachment_Factory::fetchByRecordId($this->_config, $recordId);
     $attachment = PMF_Attachment_Factory::create($attId);
     $attachment->delete();
     return true;
 }
Beispiel #10
0
    foreach ($arrLanguage as $language) {
        $check4Lang .= "<option value=\"" . $language . "\"";
        $check4Lang .= $lang == $language ? ' selected="selected"' : '';
        $check4Lang .= ">" . $languageCodes[strtoupper($language)] . "</option>\n";
    }
    $switchLanguage .= "<form accept-charset=\"utf-8\" action=\"" . $changeLanguagePath . "\" method=\"post\" style=\"display: inline;\">\n";
    $switchLanguage .= "<select name=\"artlang\" size=\"1\">\n";
    $switchLanguage .= $check4Lang;
    $switchLanguage .= "</select>\n";
    $switchLanguage .= "&nbsp;\n";
    $switchLanguage .= "<input class=\"submit\" type=\"submit\" name=\"submit\" value=\"" . $PMF_LANG["msgLangaugeSubmit"] . "\" />\n";
    $switchLanguage .= "</form>\n";
}
// List all faq attachments
if ($faqConfig->get('records.disableAttachments') && 'yes' == $faq->faqRecord['active']) {
    $attList = PMF_Attachment_Factory::fetchByRecordId($faqConfig, $recordId);
    $outstr = '';
    while (list(, $att) = each($attList)) {
        $outstr .= sprintf('<a href="%s">%s</a>, ', $att->buildUrl(), $att->getFilename());
    }
    if (count($attList) > 0) {
        $answer .= '<p>' . $PMF_LANG['msgAttachedFiles'] . ' ' . PMF_String::substr($outstr, 0, -2) . '</p>';
    }
}
// List all categories for this faq
$htmlAllCategories = '';
$multiCategories = $category->getCategoriesFromArticle($recordId);
if (count($multiCategories) > 1) {
    foreach ($multiCategories as $multiCat) {
        $path = $category->getPath($multiCat['id'], ' &raquo; ', true, 'breadcrumb-related-categories');
        if ('' === trim($path)) {