コード例 #1
0
 /**
  * Gets the name of the range. Copied somewhere from Stud.IP...
  * @access  public
  * @param   string   $rangeID         the rangeID
  * @param   boolean  $html_decode     (optional)
  * @return  string                    The name of the range
  */
 function getRangename($rangeID, $html_decode = true)
 {
     global $user;
     if ($rangeID == "studip") {
         return _("Systemweite Evaluationen");
     }
     $o_type = get_object_type($rangeID, array('sem', 'user', 'inst'));
     if (in_array($o_type, array('sem', 'inst', 'fak'))) {
         $name = getHeaderLine($rangeID);
         if ($name != NULL) {
             if ($html_decode) {
                 $rangename = decodeHTML($name);
             } else {
                 $rangename = $name;
             }
         } else {
             $rangename = _("Kein Titel gefunden.");
         }
         return $rangename;
     }
     if ($o_type != 'user') {
         $user_id = get_userid($rangeID);
     } else {
         $user_id = $rangeID;
     }
     if ($user_id != $user->id) {
         $rangename = _("Profil: ") . get_fullname($user_id, 'full', 1) . " (" . get_username($user_id) . ")";
     } else {
         $rangename = _("Profil");
     }
     return $rangename;
 }
コード例 #2
0
ファイル: SkipLinks.php プロジェクト: ratbird/hope
 /**
  * Adds a link to the list of skip links.
  *
  * @param string $name the displayed name of the links
  * @param string $url the url of the links
  * @param integer $position the position of the link in the list
  * @param boolean $overwriteable false if position is not overwritable by another link
  */
 public static function addLink($name, $url, $position = null, $overwriteable = false)
 {
     $position = is_null($position) || $position < 1 ? sizeof(self::$links) + 100 : intval($position);
     $new_link = array('name' => $name, 'url' => decodeHTML($url), 'position' => $position, 'overwriteable' => $overwriteable);
     if (self::checkOverwrite($new_link)) {
         self::$links[$new_link['url']] = $new_link;
     }
 }
コード例 #3
0
ファイル: user_webservice.php プロジェクト: ratbird/hope
 /**
  * This parses an old-style Stud.IP message string and strips off all markup
  *
  * @param string $long_msg Stud.IP messages, concatenated with $separator
  * @param string $separator
  */
 static function parse_msg_to_clean_text($long_msg, $separator = "§")
 {
     $msg = explode($separator, $long_msg);
     $ret = array();
     for ($i = 0; $i < count($msg); $i = $i + 2) {
         if ($msg[$i + 1]) {
             $ret[] = trim(decodeHTML(preg_replace("'<[\\/\\!]*?[^<>]*?>'si", "", $msg[$i + 1])));
         }
     }
     return join("\n", $ret);
 }
コード例 #4
0
ファイル: wikiplugin_code.php プロジェクト: noikiy/owaspbwa
function wikiplugin_code($data, $params)
{
    if (is_array($params)) {
        extract($params, EXTR_SKIP);
    }
    $code = $data;
    $out = '';
    if (isset($caption)) {
        $out .= '<div class="codecaption">' . $caption . '</div>';
    }
    if (isset($rtl) && $rtl == 1) {
        $out .= '<div dir="rtl">';
        // force writing the code right to left
    } else {
        $out .= '<div dir="ltr">';
        // default is left to right
    }
    if (isset($colors) and $colors == 'php') {
        $out .= "<div class='codelisting'>~np~" . highlight_string(decodeHTML(trim($code)), 1) . "~/np~</div>";
    } else {
        if (isset($ln) && $ln == 1) {
            $lines = explode("\n", trim($code));
            $code = '';
            $i = 1;
            foreach ($lines as $line) {
                $code .= sprintf("% 3d", $i) . ' . ' . $line . "\n";
                $i++;
            }
        }
        if (isset($wrap) && $wrap == 1) {
            if (isset($wiki) && $wiki == 1) {
                $out .= "<div class='codelisting'>" . $code . "</div>";
            } else {
                $code = preg_replace("/\n/", "<br />", $code);
                $out .= "<div class='codelisting'>~np~" . $code . "~/np~</div>";
            }
        } else {
            if (isset($wiki) && $wiki == 1) {
                $out .= "<pre class='codelisting'>" . $code . "</pre>";
            } else {
                $out .= "<pre class='codelisting'>~np~" . $code . "~/np~</pre>";
            }
        }
    }
    $out = str_replace("\\", "\\\\", $out);
    //prevents vanishing of backslash occurences
    $out = str_replace("\$", "\\\$", $out);
    //prevents vanishing of e.g. $1 strings from code listing
    $out .= '</div>';
    return $out;
}
コード例 #5
0
ファイル: pdf.php プロジェクト: jwest00724/mambo
function dofreePDF($database)
{
    global $mosConfig_live_site, $mosConfig_sitename, $mosConfig_offset, $mosConfig_hideCreateDate, $mosConfig_hideAuthor, $mosConfig_hideModifyDate;
    $id = intval(mosGetParam($_REQUEST, 'id', 1));
    // Access check
    global $gid;
    $now = date('Y-m-d H:i:s', time() + $mosConfig_offset * 60 * 60);
    $query = "SELECT COUNT(a.id)" . "\n FROM #__content AS a" . "\n LEFT JOIN #__categories AS cc ON cc.id = a.catid" . "\n LEFT JOIN #__sections AS s ON s.id = cc.section AND s.scope='content'" . "\n LEFT JOIN #__users AS u ON u.id = a.created_by" . "\n LEFT JOIN #__content_rating AS v ON a.id = v.content_id" . "\n LEFT JOIN #__groups AS g ON a.access = g.id" . "\n WHERE a.id='" . $id . "' " . "\n AND (a.state = '1' OR a.state = '-1')" . "\n AND (publish_up = '0000-00-00 00:00:00' OR publish_up <= '{$now}')" . "\n AND (publish_down = '0000-00-00 00:00:00' OR publish_down >= '{$now}')" . "\n AND a.access <= " . intval($gid);
    $database->setQuery($query);
    if (!$database->loadResult()) {
        exit(T_('You are not authorized to view this resource.'));
    }
    include 'includes/class.ezpdf.php';
    $row = new mosContent($database);
    $row->load($id);
    //Find Author Name
    $users_rows = new mosUser($database);
    $users_rows->load($row->created_by);
    $row->author = $users_rows->name;
    $row->usertype = $users_rows->usertype;
    // Ugly but needed to get rid of all the stuff the PDF class cant handle
    $row->fulltext = str_replace('<p>', "\n\n", $row->fulltext);
    $row->fulltext = str_replace('<P>', "\n\n", $row->fulltext);
    $row->fulltext = str_replace('<br />', "\n", $row->fulltext);
    $row->fulltext = str_replace('<br>', "\n", $row->fulltext);
    $row->fulltext = str_replace('<BR />', "\n", $row->fulltext);
    $row->fulltext = str_replace('<BR>', "\n", $row->fulltext);
    $row->fulltext = str_replace('<li>', "\n - ", $row->fulltext);
    $row->fulltext = str_replace('<LI>', "\n - ", $row->fulltext);
    $row->fulltext = strip_tags($row->fulltext);
    $row->fulltext = str_replace('{mosimage}', '', $row->fulltext);
    $row->fulltext = str_replace('{mospagebreak}', '', $row->fulltext);
    $row->fulltext = decodeHTML($row->fulltext);
    $row->introtext = str_replace('<p>', "\n\n", $row->introtext);
    $row->introtext = str_replace('<P>', "\n\n", $row->introtext);
    $row->introtext = str_replace('<li>', "\n - ", $row->introtext);
    $row->introtext = str_replace('<LI>', "\n - ", $row->introtext);
    $row->introtext = strip_tags($row->introtext);
    $row->introtext = str_replace('{mosimage}', '', $row->introtext);
    $row->introtext = str_replace('{mospagebreak}', '', $row->introtext);
    $row->introtext = decodeHTML($row->introtext);
    $pdf =& new Cezpdf('a4', 'P');
    //A4 Portrait
    $pdf->ezSetCmMargins(2, 1.5, 1, 1);
    $pdf->selectFont('./fonts/Helvetica.afm');
    //choose font
    $all = $pdf->openObject();
    $pdf->saveState();
    $pdf->setStrokeColor(0, 0, 0, 1);
    // footer
    $pdf->line(10, 40, 578, 40);
    $pdf->line(10, 822, 578, 822);
    $pdf->addText(30, 34, 6, $mosConfig_live_site . ' - ' . $mosConfig_sitename);
    $pdf->addText(250, 34, 6, T_('Powered by Mambo'));
    $pdf->addText(450, 34, 6, T_('Generated:') . date('j F, Y, H:i', time() + $mosConfig_offset * 60 * 60));
    $pdf->restoreState();
    $pdf->closeObject();
    $pdf->addObject($all, 'all');
    $pdf->ezSetDy(30);
    $txt1 = $row->title;
    $pdf->ezText($txt1, 14);
    $txt2 = NULL;
    $mod_date = NULL;
    $create_date = NULL;
    if (intval($row->modified) != 0) {
        $mod_date = mosFormatDate($row->modified);
    }
    if (intval($row->created) != 0) {
        $create_date = mosFormatDate($row->created);
    }
    if ($mosConfig_hideCreateDate == '0') {
        $txt2 .= '(' . $create_date . ') - ';
    }
    if ($mosConfig_hideAuthor == "0") {
        if ($row->author != '' && $mosConfig_hideAuthor == '0') {
            if ($row->usertype == 'administrator' || $row->usertype == 'superadministrator') {
                $txt2 .= T_('Written by') . ' ' . ($row->created_by_alias ? $row->created_by_alias : $row->author);
            } else {
                $txt2 .= T_('Contributed by') . ' ' . ($row->created_by_alias ? $row->created_by_alias : $row->author);
            }
        }
    }
    if ($mosConfig_hideModifyDate == "0") {
        $txt2 .= ' - ' . T_('Last Updated') . ' (' . $mod_date . ') ';
    }
    $txt2 .= "\n\n";
    $pdf->ezText($txt2, 8);
    $txt3 = $row->introtext . "\n" . $row->fulltext;
    $pdf->ezText($txt3, 10);
    $pdf->ezStream();
}
コード例 #6
0
ファイル: cite_ascii.php プロジェクト: Olari0/Finugriling
function citeRecords($result, $rowsFound, $query, $queryURL, $showQuery, $showLinks, $rowOffset, $showRows, $previousOffset, $nextOffset, $wrapResults, $citeStyle, $citeOrder, $citeType, $orderBy, $headerMsg, $userID, $viewType)
{
    global $officialDatabaseName;
    // these variables are defined in 'ini.inc.php'
    global $databaseBaseURL;
    global $contentTypeCharset;
    global $client;
    // The array '$transtab_refbase_ascii' contains search & replace patterns for conversion from refbase markup to plain text
    global $transtab_refbase_ascii;
    // defined in 'transtab_refbase_ascii.inc.php'
    $plainTextData = "";
    // make sure that our buffer variable is empty
    // Header:
    if (!empty($headerMsg)) {
        // Decode any HTML entities:
        // (these may occur in the header message e.g. if the user's preferred display language is not English but German or French, etc)
        $headerMsg = decodeHTML($contentTypeCharset, $headerMsg);
        // function 'decodeHTML()' is defined in 'include.inc.php', and '$contentTypeCharset' is defined in 'ini.inc.php'
        // Convert refbase markup in the header message into plain text:
        $headerMsg = searchReplaceText($transtab_refbase_ascii, $headerMsg, true);
        // function 'searchReplaceText()' is defined in 'include.inc.php'
        $plainTextData .= "{$headerMsg}\n\n";
        // prefix any passed header message
    }
    // Initialize array variables:
    $yearsArray = array();
    $typeTitlesArray = array();
    // Define inline text markup to be used by the 'citeRecord()' function:
    $markupPatternsArray = array("bold-prefix" => "", "bold-suffix" => "", "italic-prefix" => "", "italic-suffix" => "", "underline-prefix" => "", "underline-suffix" => "", "endash" => "-", "emdash" => "-", "ampersand" => "&", "double-quote" => '"', "double-quote-left" => '"', "double-quote-right" => '"', "single-quote" => "'", "single-quote-left" => "'", "single-quote-right" => "'", "less-than" => "<", "greater-than" => ">", "newline" => "\n");
    // Defines search & replace 'actions' that will be applied upon TEXT output to all those refbase fields that are listed
    // in the corresponding 'fields' element:
    $plainTextSearchReplaceActionsArray = array(array('fields' => array("title", "publication", "abbrev_journal", "address", "keywords", "abstract", "orig_title", "series_title", "abbrev_series_title", "notes"), 'actions' => $transtab_refbase_ascii));
    // For CLI queries, we'll allow paging thru the result set, i.e. we honour the values of the CLI options '-S|--start' ('$rowOffset')
    // and '-R|--rows' ('$showRows') ('$rowOffset' and '$showRows' are re-assigned in function 'seekInMySQLResultsToOffset()' in 'include.inc.php')
    if (preg_match("/^cli/i", $client)) {
        // if the query originated from a command line client such as the "refbase" CLI client ("cli-refbase-1.0")
        $showMaxRows = $showRows;
    } else {
        $showMaxRows = $rowsFound;
    }
    // otherwise show all rows
    // LOOP OVER EACH RECORD:
    // Fetch one page of results (or less if on the last page)
    // (i.e., upto the limit specified in $showMaxRows) fetch a row into the $row array and ...
    for ($rowCounter = 0; $rowCounter < $showMaxRows && ($row = @mysql_fetch_array($result)); $rowCounter++) {
        foreach ($row as $rowFieldName => $rowFieldValue) {
            // Apply search & replace 'actions' to all fields that are listed in the 'fields' element of the arrays contained in '$plainTextSearchReplaceActionsArray':
            foreach ($plainTextSearchReplaceActionsArray as $fieldActionsArray) {
                if (in_array($rowFieldName, $fieldActionsArray['fields'])) {
                    $row[$rowFieldName] = searchReplaceText($fieldActionsArray['actions'], $row[$rowFieldName], true);
                }
            }
        }
        // function 'searchReplaceText()' is defined in 'include.inc.php'
        // Order attributes according to the chosen output style & record type:
        $record = citeRecord($row, $citeStyle, $citeType, $markupPatternsArray, false);
        // function 'citeRecord()' is defined in the citation style file given in '$citeStyleFile' (which, in turn, must reside in the 'cite' directory of the refbase root directory), see function 'generateCitations()'
        // Print out the current record:
        if (!empty($record)) {
            // Print any section heading(s):
            if (preg_match("/year|type/i", $citeOrder)) {
                list($yearsArray, $typeTitlesArray, $sectionHeading) = generateSectionHeading($yearsArray, $typeTitlesArray, $row, $citeOrder, "", "", "", "\n\n", "", "\n\n");
                // function 'generateSectionHeading()' is defined in 'cite.inc.php'
                $plainTextData .= $sectionHeading;
            }
            // Write plain TEXT paragraph:
            if (preg_match("/^cli/i", $client)) {
                // This is a stupid hack that maps the names of the '$row' array keys to those used
                // by the '$formVars' array (which is required by function 'generateCiteKey()')
                // (eventually, the '$formVars' array should use the MySQL field names as names for its array keys)
                $formVars = buildFormVarsArray($row);
                // function 'buildFormVarsArray()' is defined in 'include.inc.php'
                // Generate or extract the cite key for this record:
                // NOTE: currently, the following placeholders are not available for citation output:
                //       <:keywords:>, <:issn:>, <:area:>, <:notes:>, <:userKeys:>
                //       if the cite key specification uses one of these placeholders, it will get ignored
                $citeKey = generateCiteKey($formVars);
                // function 'generateCiteKey()' is defined in 'include.inc.php'
                $plainTextData .= "[" . $row['serial'] . "] ";
                if (!empty($citeKey)) {
                    // Use the custom cite key that's been build according to the user's individual export options:
                    $plainTextData .= "{" . $citeKey . "} ";
                }
            }
            $plainTextData .= $record . "\n\n";
            // create paragraph with encoded record text
        }
    }
    if (preg_match("/^cli/i", $client)) {
        // Calculate the maximum result number on each page:
        if ($rowOffset + $showRows < $rowsFound) {
            $showMaxRow = $rowOffset + $showRows;
        } else {
            $showMaxRow = $rowsFound;
        }
        // for the last results page, correct the maximum result number if necessary
        if ($rowsFound == 1) {
            $footerInfoPart = " record found";
        } else {
            $footerInfoPart = " records found";
        }
        $rowsFoundInfo = $rowOffset + 1 . "-" . $showMaxRow . " of " . $rowsFound . $footerInfoPart;
        // prints e.g. "1-5 of 23 records found"
        $rowsFoundDelimiter = preg_replace("/./i", "-", $rowsFoundInfo);
        // generate a line of hyphens which has the same length as the string in '$rowsFoundInfo' (e.g. "-----------------------")
        $plainTextData .= $rowsFoundDelimiter . "\n" . $rowsFoundInfo . "\n\n";
        // append info about rows displayed/found
        $plainTextData .= $officialDatabaseName . "\n" . $databaseBaseURL . "\n\n";
        // append database name and URL (comment this line if you don't like that)
        if ($showQuery == "1") {
            // display SQL query:
            $plainTextData .= "Query: " . $query . "\n\n";
        }
    }
    return $plainTextData;
}
コード例 #7
0
ファイル: WysiwygDocument.php プロジェクト: ratbird/hope
 /**
  * Throw exception if upload of given file is forbidden.
  *
  * @param Array $file  PHP file info array of uploaded file.
  * @throws AccessDeniedException if file is forbidden by Stud.IP settings.
  */
 private static function verifyUpload($file)
 {
     $GLOBALS['msg'] = '';
     // validate_upload will store messages here
     if (!\validate_upload($file)) {
         // upload is forbidden
         // remove error pattern from message
         $message = \preg_replace('/error§(.+)§/', '$1', $GLOBALS['msg']);
         // clear global messages and throw exception
         $GLOBALS['msg'] = '';
         throw new \AccessDeniedException(\decodeHTML($message));
     }
 }
コード例 #8
0
ファイル: cite_pdf.php プロジェクト: Olari0/Finugriling
function citeRecords($result, $rowsFound, $query, $queryURL, $showQuery, $showLinks, $rowOffset, $showRows, $previousOffset, $nextOffset, $wrapResults, $citeStyle, $citeOrder, $citeType, $orderBy, $headerMsg, $userID, $viewType)
{
    global $officialDatabaseName;
    // these variables are defined in 'ini.inc.php'
    global $databaseBaseURL;
    global $contentTypeCharset;
    global $pdfPageSize;
    global $client;
    // The array '$transtab_refbase_pdf' contains search & replace patterns for conversion from refbase markup to PDf markup & entities
    global $transtab_refbase_pdf;
    // defined in 'transtab_refbase_pdf.inc.php'
    // Initialize array variables:
    $yearsArray = array();
    $typeTitlesArray = array();
    // Define inline text markup to be used by the 'citeRecord()' function:
    $markupPatternsArray = array("bold-prefix" => "<b>", "bold-suffix" => "</b>", "italic-prefix" => "<i>", "italic-suffix" => "</i>", "underline-prefix" => "<u>", "underline-suffix" => "</u>", "endash" => "¦", "emdash" => "©", "ampersand" => "&", "double-quote" => '"', "double-quote-left" => "ª", "double-quote-right" => "¬", "single-quote" => "'", "single-quote-left" => "®", "single-quote-right" => "¶", "less-than" => "<", "greater-than" => ">", "newline" => "\n");
    // Defines search & replace 'actions' that will be applied upon PDF output to all those refbase fields that are listed
    // in the corresponding 'fields' element:
    $pdfSearchReplaceActionsArray = array(array('fields' => array("title", "publication", "abbrev_journal", "address", "keywords", "abstract", "orig_title", "series_title", "abbrev_series_title", "notes"), 'actions' => $transtab_refbase_pdf));
    // For CLI queries, we'll allow paging thru the result set, i.e. we honour the values of the CLI options '-S|--start' ('$rowOffset')
    // and '-R|--rows' ('$showRows') ('$rowOffset' and '$showRows' are re-assigned in function 'seekInMySQLResultsToOffset()' in 'include.inc.php')
    if (preg_match("/^cli/i", $client)) {
        // if the query originated from a command line client such as the "refbase" CLI client ("cli-refbase-1.0")
        $showMaxRows = $showRows;
    } else {
        $showMaxRows = $rowsFound;
    }
    // otherwise show all rows
    // Setup the basic PDF document structure (PDF functions defined in 'class.ezpdf.php'):
    $pdf = new Cezpdf($pdfPageSize, 'portrait');
    // initialize PDF object
    if (!empty($headerMsg)) {
        // adjust upper page margin if a custom header message was given
        $pageMarginTop = "70";
    } else {
        $pageMarginTop = "50";
    }
    $pdf->ezSetMargins($pageMarginTop, 70, 50, 50);
    // set document margins (top, bottom, left, right)
    // Set fonts:
    $headingFont = 'includes/classes/org/pdf-php/fonts/Helvetica.afm';
    $textBodyFont = 'includes/classes/org/pdf-php/fonts/Times-Roman.afm';
    // Re-map character numbers from the 0->255 range to a named character, i.e. replace an (unused) character for any other PostScript char;
    // see the PDF reference for a list of supported PostScript/PDF character names: <http://www.adobe.com/devnet/pdf/pdf_reference.html>;
    // for the decimal code numbers of the ISO-8859-1 character set, see e.g.: <http://www.ramsch.org/martin/uni/fmi-hp/iso8859-1.html>
    $diff = array(166 => 'endash', 169 => 'emdash', 170 => 'quotedblleft', 172 => 'quotedblright', 174 => 'quoteleft', 182 => 'quoteright');
    // Select a font:
    $pdf->selectFont($textBodyFont, array('encoding' => 'WinAnsiEncoding', 'differences' => $diff));
    $pdf->openHere('Fit');
    // Put a footer (and optionally a header) on all the pages:
    $all = $pdf->openObject();
    // start an independent object; all further writes to a page will actually go into this object, until a 'closeObject()' call is made
    $pdf->saveState();
    $pdf->setStrokeColor(0, 0, 0, 1);
    // set line color
    $pdf->setLineStyle(0.5);
    // set line width
    // - print header line and header message at the specified x/y position:
    if (!empty($headerMsg)) {
        // Remove any colon (":") from end of header message:
        $headerMsg = trimTextPattern($headerMsg, ":", false, true);
        // function 'trimTextPattern()' is defined in 'include.inc.php'
        // Decode any HTML entities:
        // (these may occur in the header message e.g. if the user's preferred display language is not English but German or French, etc)
        $headerMsg = decodeHTML($contentTypeCharset, $headerMsg);
        // function 'decodeHTML()' is defined in 'include.inc.php', and '$contentTypeCharset' is defined in 'ini.inc.php'
        // Convert refbase markup in the header message into appropriate PDF markup & entities:
        $headerMsg = searchReplaceText($transtab_refbase_pdf, $headerMsg, true);
        // function 'searchReplaceText()' is defined in 'include.inc.php'
        if ($pdfPageSize == 'a4') {
            $pdf->line(20, 800, 575, 800);
            $pdf->addText(50, 805, 10, $headerMsg);
        } elseif ($pdfPageSize == 'letter') {
            $pdf->line(20, 750, 592, 750);
            $pdf->addText(50, 755, 10, $headerMsg);
        }
    }
    // - print footer line and footer text at the specified x/y position:
    if ($pdfPageSize == 'a4') {
        $pdf->line(20, 40, 575, 40);
        $pdf->addText(50, 28, 10, $officialDatabaseName . ' ¦ ' . $databaseBaseURL);
        // w.r.t. the endash, see notes at '$markupPatternsArray' and '$diff' above
    } elseif ($pdfPageSize == 'letter') {
        $pdf->line(20, 40, 592, 40);
        $pdf->addText(50, 28, 10, $officialDatabaseName . ' ¦ ' . $databaseBaseURL);
    }
    $pdf->restoreState();
    $pdf->closeObject();
    // close the currently open object; further writes will now go to the current page
    $pdf->addObject($all, 'all');
    // note that object can be told to appear on just odd or even pages by changing 'all' to 'odd' or 'even'
    // Start printing page numbers:
    if ($pdfPageSize == 'a4') {
        $pdf->ezStartPageNumbers(550, 28, 10, '', '', 1);
    } elseif ($pdfPageSize == 'letter') {
        $pdf->ezStartPageNumbers(567, 28, 10, '', '', 1);
    }
    // LOOP OVER EACH RECORD:
    // Fetch one page of results (or less if on the last page)
    // (i.e., upto the limit specified in $showMaxRows) fetch a row into the $row array and ...
    for ($rowCounter = 0; $rowCounter < $showMaxRows && ($row = @mysql_fetch_array($result)); $rowCounter++) {
        foreach ($row as $rowFieldName => $rowFieldValue) {
            // Apply search & replace 'actions' to all fields that are listed in the 'fields' element of the arrays contained in '$pdfSearchReplaceActionsArray':
            foreach ($pdfSearchReplaceActionsArray as $fieldActionsArray) {
                if (in_array($rowFieldName, $fieldActionsArray['fields'])) {
                    $row[$rowFieldName] = searchReplaceText($fieldActionsArray['actions'], $row[$rowFieldName], true);
                }
            }
        }
        // function 'searchReplaceText()' is defined in 'include.inc.php'
        // Order attributes according to the chosen output style & record type:
        $record = citeRecord($row, $citeStyle, $citeType, $markupPatternsArray, false);
        // function 'citeRecord()' is defined in the citation style file given in '$citeStyleFile' (which, in turn, must reside in the 'cite' directory of the refbase root directory), see function 'generateCitations()'
        // Print out the current record:
        if (!empty($record)) {
            // Print any section heading(s):
            if (preg_match("/year|type/i", $citeOrder)) {
                $headingPrefix = "";
                $headingSuffix = "";
                $sectionMarkupPrefix = "<b>";
                $sectionMarkupSuffix = "</b>\n";
                $subSectionMarkupPrefix = "";
                $subSectionMarkupSuffix = "\n";
                if ($citeOrder == "type-year") {
                    $sectionMarkupSuffix .= "\n";
                }
                list($yearsArray, $typeTitlesArray, $sectionHeading) = generateSectionHeading($yearsArray, $typeTitlesArray, $row, $citeOrder, $headingPrefix, $headingSuffix, $sectionMarkupPrefix, $sectionMarkupSuffix, $subSectionMarkupPrefix, $subSectionMarkupSuffix);
                // function 'generateSectionHeading()' is defined in 'cite.inc.php'
                if (!empty($sectionHeading)) {
                    $pdf->selectFont($headingFont, array('encoding' => 'WinAnsiEncoding', 'differences' => $diff));
                    // use Helvetica
                    $pdf->ezText($sectionHeading, '14', array('justification' => 'left'));
                    // create heading using a font size of 14pt
                }
            }
            // If character encoding is not UTF-8 already, convert record text to UTF-8:
            //				if ($contentTypeCharset != "UTF-8")
            //					$record = convertToCharacterEncoding("UTF-8", "IGNORE", $record); // function 'convertToCharacterEncoding()' is defined in 'include.inc.php'
            // NOTE: Export of cited references to PDF does currently only work with a latin1 database but not with UTF-8 (since I don't know how to write Unicode characters to PDF).
            //       As a workaround, we could convert UTF-8 characters to latin1 if possible (and omit any other higher ASCII chars)
            // TODO: While this workaround indeed fixes display issues with higher ASCII chars that have equivalents in the latin1 charset, this will currently swallow higher ASCII
            //       hyphens/dashes such as endashes (which display correctly without this workaround).
            //				if ($contentTypeCharset == "UTF-8")
            //					$record = convertToCharacterEncoding("ISO-8859-1", "TRANSLIT", $record, "UTF-8"); // function 'convertToCharacterEncoding()' is defined in 'include.inc.php'
            // Set paragraph text options:
            $textOptions = array('justification' => 'full');
            // possible array options:
            // 'left'=> number, gap to leave from the left margin
            // 'right'=> number, gap to leave from the right margin
            // 'aleft'=> number, absolute left position (overrides 'left')
            // 'aright'=> number, absolute right position (overrides 'right')
            // 'justification' => 'left','right','center','centre','full'
            //
            // only set one of the next two items (leading overrides spacing)
            // 'leading' => number, defines the total height taken by the line, independent of the font height.
            // 'spacing' => a real number, though usually set to one of 1, 1.5, 2 (line spacing as used in word processing)
            // Write PDF paragraph:
            $pdf->selectFont($textBodyFont, array('encoding' => 'WinAnsiEncoding'));
            // use Times-Roman
            $pdf->ezText($record . "\n", '12', $textOptions);
            // create text block with record text using "Times Roman" and a font size of 12pt
        }
    }
    return $pdf->ezStream();
}
コード例 #9
0
ファイル: wiki.inc.php プロジェクト: ratbird/hope
/**
* Refresh wiki_links table for backlinks from given page to
* other pages
*
* @param    string  keyword WikiPage-name for $str content
* @param    string  str Page content containing links
*
**/
function refreshBacklinks($keyword, $str) {
    global $SessSemName;
    // insert links from page to db
    // logic: all links are added, also links to nonexistant pages
    // (these will change when submitting other pages)

    // first delete all links
    $query = "DELETE FROM wiki_links WHERE range_id = ? AND from_keyword = ?";
    $statement = DBManager::get()->prepare($query);
    $statement->execute(array($SessSemName[1], $keyword));

    // then reinsert those (still) existing
    $wikiLinkList = getWikiLinks($str);
    if (!empty($wikiLinkList)) {
        $query = "INSERT INTO wiki_links (range_id, from_keyword, to_keyword)
                  VALUES (?, ?, ?)";
        $statement = DBManager::get()->prepare($query);

        foreach ($wikiLinkList as $key => $value) {
            $statement->execute(array($SessSemName[1], $keyword, decodeHTML($value)));
        }
    }
}
コード例 #10
0
ファイル: kunena.pdf.php プロジェクト: kaantunc/MYK-BOR
function filterHTML(&$string)
{
    // Ugly but needed to get rid of all the stuff the PDF class cant handle
    $string = str_replace('<p>', "\n\n", $string);
    $string = str_replace('<P>', "\n\n", $string);
    $string = str_replace('<br />', "\n", $string);
    $string = str_replace('<br>', "\n", $string);
    $string = str_replace('<BR />', "\n", $string);
    $string = str_replace('<BR>', "\n", $string);
    $string = str_replace('<li>', "\n - ", $string);
    $string = str_replace('<LI>', "\n - ", $string);
    $string = strip_tags($string);
    $string = str_replace('{mosimage}', '', $string);
    $string = str_replace('{mospagebreak}', '', $string);
    // bbcode
    $string = preg_replace("/\\[(.*?)\\]/si", "", $string);
    $string = decodeHTML($string);
}
コード例 #11
0
ファイル: pdf.php プロジェクト: patricmutwiri/joomlaclube
function pdfCleaner($text)
{
    // Ugly but needed to get rid of all the stuff the PDF class cant handle
    $text = str_replace('<p>', "\n\n", $text);
    $text = str_replace('<P>', "\n\n", $text);
    $text = str_replace('<br />', "\n", $text);
    $text = str_replace('<br>', "\n", $text);
    $text = str_replace('<BR />', "\n", $text);
    $text = str_replace('<BR>', "\n", $text);
    $text = str_replace('<li>', "\n - ", $text);
    $text = str_replace('<LI>', "\n - ", $text);
    $text = str_replace('{mosimage}', '', $text);
    $text = str_replace('{mospagebreak}', '', $text);
    $text = strip_tags($text);
    $text = decodeHTML($text);
    return $text;
}
コード例 #12
0
ファイル: import_modify.php プロジェクト: Olari0/Finugriling
    // function 'detectCharacterEncoding()' is defined in 'include.inc.php'
    $sourceText = convertToCharacterEncoding("ISO-8859-1", "TRANSLIT", $sourceText, "UTF-8");
}
// function 'convertToCharacterEncoding()' is defined in 'include.inc.php'
// Decode any HTML entities remaining in the source text:
// NOTE: - Web browsers send back form data in the same encoding as the page containing the form. So if a user imports UTF-8 data (via the 'sourceText' text entry form) into
//         a latin1-based database, non-latin1 characters will be encoded by the browser as HTML entities (e.g., the greek delta character would be represented as '&#948;'
//         in the source text). Therefore, we'll use function 'decodeHTML()' to convert any remaining HTML entities first to UTF-8, then convert Unicode entities to refbase
//         markup (if possible), and finally transform all Unicode characters that can't be successfully converted to their ASCII equivalents.
//       - Alternatively, it might be easier to always use UTF-8 as page encoding for 'import.php' so that we'll always receive UTF-8 encoded data, then use function
//         'detectCharacterEncoding()' to detect the actual character encoding of the given source text, and convert to refbase markup/latin1 if needed.
//
// TODO: - this conversion causes invalid XML when importing MODS XML that contains encoded angle brackets! (e.g. '<title>Harbours &lt;dt.&gt;</title>');
//         to work around this issue, the next line needs to be commented out; for a real fix, the decoding of characters needs to be adopted based on the '$sourceFormat'
//         (which, ATM, is only identified further down below)
$sourceText = decodeHTML($contentTypeCharset, $sourceText);
// function 'decodeHTML()' is defined in 'include.inc.php', and '$contentTypeCharset' is defined in 'ini.inc.php'
// Process record number input:
$importRecordNumbersArray = array();
// initialize array variable which will hold all the record numbers that shall be imported
if (!empty($importRecords)) {
    // split input string on all but digits or the hyphen ("-") character:
    // (the 'PREG_SPLIT_NO_EMPTY' flag causes only non-empty pieces to be returned)
    $importRecordsArray = preg_split("/[^0-9-]+/", $importRecords, -1, PREG_SPLIT_NO_EMPTY);
    // this keeps only elements such as '1', '3-5', '3-5-9' or '3-' (we'll deal with the last two cases below)
    foreach ($importRecordsArray as $importRecordsElement) {
        if (preg_match("/\\d+-\\d+/", $importRecordsElement)) {
            $importRecordsElementArray = preg_split("/-/", $importRecordsElement);
            // split input string on hyphen ("-") character
            // generate an array that includes all numbers from start number to end number:
            // (in case of incorrect input (such as '3-5-9') we'll only take the first two numbers and ignore anything else)
コード例 #13
0
ファイル: cite_latex.php プロジェクト: Olari0/Finugriling
function citeRecords($result, $rowsFound, $query, $queryURL, $showQuery, $showLinks, $rowOffset, $showRows, $previousOffset, $nextOffset, $wrapResults, $citeStyle, $citeOrder, $citeType, $orderBy, $headerMsg, $userID, $viewType)
{
    global $contentTypeCharset;
    // defined in 'ini.inc.php'
    global $client;
    // The array '$transtab_refbase_latex' contains search & replace patterns for conversion from refbase markup to LaTeX markup & entities.
    // Converts refbase fontshape markup (italic, bold) into LaTeX commands of the 'textcomp' package, super- and subscript as well as greek
    // symbols get converted into the respective commands in math mode. You may need to adopt the LaTeX markup to suit your individual needs.
    global $transtab_refbase_latex;
    // defined in 'transtab_refbase_latex.inc.php'
    // The arrays '$transtab_latin1_latex' and '$transtab_unicode_latex' provide translation tables for best-effort conversion of higher ASCII
    // characters from ISO-8859-1 (or Unicode, respectively) to LaTeX entities.
    global $transtab_latin1_latex;
    // defined in 'transtab_latin1_latex.inc.php'
    global $transtab_unicode_latex;
    // defined in 'transtab_unicode_latex.inc.php'
    // Initialize array variables:
    $yearsArray = array();
    $typeTitlesArray = array();
    // Define inline text markup to be used by the 'citeRecord()' function:
    $markupPatternsArray = array("bold-prefix" => "\\textbf{", "bold-suffix" => "}", "italic-prefix" => "\\textit{", "italic-suffix" => "}", "underline-prefix" => "\\ul{", "underline-suffix" => "}", "endash" => "--", "emdash" => "---", "ampersand" => "&", "double-quote" => '"', "double-quote-left" => "{\\textquotedblleft}", "double-quote-right" => "{\\textquotedblright}", "single-quote" => "'", "single-quote-left" => "{\\textquoteleft}", "single-quote-right" => "{\\textquoteright}", "less-than" => "<", "greater-than" => ">", "newline" => "\n\n");
    // Defines search & replace 'actions' that will be applied upon LaTeX output to all those refbase fields that are listed
    // in the corresponding 'fields' element:
    $latexSearchReplaceActionsArray = array(array('fields' => array("title", "publication", "abbrev_journal", "address", "keywords", "abstract", "orig_title", "series_title", "abbrev_series_title", "notes"), 'actions' => $transtab_refbase_latex));
    // For CLI queries, we'll allow paging thru the result set, i.e. we honour the values of the CLI options '-S|--start' ('$rowOffset')
    // and '-R|--rows' ('$showRows') ('$rowOffset' and '$showRows' are re-assigned in function 'seekInMySQLResultsToOffset()' in 'include.inc.php')
    if (preg_match("/^cli/i", $client)) {
        // if the query originated from a command line client such as the "refbase" CLI client ("cli-refbase-1.0")
        $showMaxRows = $showRows;
    } else {
        $showMaxRows = $rowsFound;
    }
    // otherwise show all rows
    // Setup the basic LaTeX document structure:
    $latexData = "%&LaTeX\n" . "\\documentclass{article}\n\n";
    // NOTE: the "Vancouver" & "Harvard 1" citation styles make use of the '\ul' command which requires '\usepackage{soul}'
    // TODO: figure out a better logic when to include the '\usepackage{soul}' statement (or should we simply always include it?)
    if (preg_match("/^(Vancouver|Harvard 1)\$/i", $citeStyle)) {
        $latexData .= "\\usepackage{soul}\n";
    }
    if ($contentTypeCharset == "UTF-8") {
        $latexData .= "\\usepackage[utf8]{inputenc}\n";
    } else {
        $latexData .= "\\usepackage[latin1]{inputenc}\n";
    }
    $latexData .= "\\usepackage[T1]{fontenc}\n" . "\\usepackage{textcomp}\n\n";
    $latexData .= "\\begin{document}\n\n";
    // Header:
    if (!empty($headerMsg)) {
        // Remove any colon (":") from end of header message:
        $headerMsg = trimTextPattern($headerMsg, ":", false, true);
        // function 'trimTextPattern()' is defined in 'include.inc.php'
        // Decode any HTML entities:
        // (these may occur in the header message e.g. if the user's preferred display language is not English but German or French, etc)
        $headerMsg = decodeHTML($contentTypeCharset, $headerMsg);
        // function 'decodeHTML()' is defined in 'include.inc.php', and '$contentTypeCharset' is defined in 'ini.inc.php'
        // Convert refbase markup in the header message into appropriate LaTeX markup & entities:
        $headerMsg = searchReplaceText($transtab_refbase_latex, $headerMsg, true);
        // function 'searchReplaceText()' is defined in 'include.inc.php'
        // Attempt to convert higher ASCII chars (i.e., characters with an ASCII value of >= 128) in the header message to their corresponding LaTeX entities:
        if ($contentTypeCharset == "UTF-8") {
            $headerMsg = searchReplaceText($transtab_unicode_latex, $headerMsg, false);
        } else {
            $headerMsg = searchReplaceText($transtab_latin1_latex, $headerMsg, false);
        }
        $latexData .= "\\title{" . $headerMsg . "}\n\n" . "\\maketitle\n\n";
    }
    if (!preg_match("/type|year/i", $citeOrder)) {
        $latexData .= "\\begin{thebibliography}{" . $showMaxRows . "}\n\n";
    }
    // LOOP OVER EACH RECORD:
    // Fetch one page of results (or less if on the last page)
    // (i.e., upto the limit specified in $showMaxRows) fetch a row into the $row array and ...
    for ($rowCounter = 0; $rowCounter < $showMaxRows && ($row = @mysql_fetch_array($result)); $rowCounter++) {
        foreach ($row as $rowFieldName => $rowFieldValue) {
            // Apply search & replace 'actions' to all fields that are listed in the 'fields' element of the arrays contained in '$latexSearchReplaceActionsArray':
            foreach ($latexSearchReplaceActionsArray as $fieldActionsArray) {
                if (in_array($rowFieldName, $fieldActionsArray['fields'])) {
                    $row[$rowFieldName] = searchReplaceText($fieldActionsArray['actions'], $row[$rowFieldName], true);
                }
            }
        }
        // function 'searchReplaceText()' is defined in 'include.inc.php'
        // Order attributes according to the chosen output style & record type:
        $record = citeRecord($row, $citeStyle, $citeType, $markupPatternsArray, false);
        // function 'citeRecord()' is defined in the citation style file given in '$citeStyleFile' (which, in turn, must reside in the 'cite' directory of the refbase root directory), see function 'generateCitations()'
        // Print out the current record:
        if (!empty($record)) {
            // Print any section heading(s):
            if (preg_match("/year|type/i", $citeOrder)) {
                list($yearsArray, $typeTitlesArray, $sectionHeading) = generateSectionHeading($yearsArray, $typeTitlesArray, $row, $citeOrder, "", "", "\\section*{", "}\n\n", "\\subsection*{", "}\n\n");
                // function 'generateSectionHeading()' is defined in 'cite.inc.php'
                $latexData .= $sectionHeading;
            }
            // Attempt to convert higher ASCII chars (i.e., characters with an ASCII value of >= 128) to their corresponding LaTeX entities:
            if ($contentTypeCharset == "UTF-8") {
                $recordEncoded = searchReplaceText($transtab_unicode_latex, $record, false);
            } else {
                $recordEncoded = searchReplaceText($transtab_latin1_latex, $record, false);
            }
            // Write LaTeX paragraph:
            if (!preg_match("/type|year/i", $citeOrder)) {
                // This is a stupid hack that maps the names of the '$row' array keys to those used
                // by the '$formVars' array (which is required by function 'generateCiteKey()')
                // (eventually, the '$formVars' array should use the MySQL field names as names for its array keys)
                $formVars = buildFormVarsArray($row);
                // function 'buildFormVarsArray()' is defined in 'include.inc.php'
                // Generate or extract the cite key for this record:
                // NOTE: currently, the following placeholders are not available for citation output:
                //       <:keywords:>, <:issn:>, <:area:>, <:notes:>, <:userKeys:>
                //       if the cite key specification uses one of these placeholders, it will get ignored
                $citeKey = generateCiteKey($formVars);
                // function 'generateCiteKey()' is defined in 'include.inc.php'
                if (!empty($citeKey)) {
                    // Use the custom cite key that's been build according to the user's individual export options:
                    $latexData .= "\\bibitem{" . $citeKey . "} ";
                } else {
                    // The '\bibitem' command requires a cite key, which is why we'll include the record's serial number
                    // even when the user's export options specify 'export_cite_keys=no' or 'autogenerate_cite_keys=no':
                    $latexData .= "\\bibitem{" . $row['serial'] . "} ";
                }
            }
            $latexData .= $recordEncoded . "\n\n";
            // create paragraph with encoded record text
        }
    }
    if (!preg_match("/type|year/i", $citeOrder)) {
        $latexData .= "\\end{thebibliography}\n\n";
    }
    $latexData .= "\\end{document}\n\n";
    return $latexData;
}
コード例 #14
0
ファイル: StudipFormat.php プロジェクト: ratbird/hope
 /**
  * Stud.IP markup for images, audio, video and flash-films
  */
 protected static function markupMedia($markup, $matches)
 {
     $tag = $matches[1];
     $params = explode(":", $matches[2]);
     $url = $matches[3];
     $whitespace = $matches[4];
     foreach ($params as $key => $param) {
         if ($param) {
             if (is_numeric($param)) {
                 $width = $param;
             } elseif (in_array($param, words("left center right"))) {
                 $position = $param;
             } elseif ($key === 0 && $param[0] === "=") {
                 $title = substr($param, 1);
             } elseif ($key < count($params) - 1) {
                 $virtual_url = $param . ":" . $params[$key + 1];
                 if (isURL($virtual_url)) {
                     $link = $virtual_url;
                 }
             }
         }
     }
     $format_strings = array('img' => '<img src="%s" style="%s" title="%s" alt="%s">', 'audio' => '<audio src="%s" style="%s" title="%s" alt="%s" controls></audio>', 'video' => '<video src="%s" style="%s" title="%s" alt="%s" controls></video>');
     $url = TransformInternalLinks($url);
     $pu = @parse_url($url);
     if (($pu['scheme'] == 'http' || $pu['scheme'] == 'https') && ($pu['host'] == $_SERVER['HTTP_HOST'] || $pu['host'] . ':' . $pu['port'] == $_SERVER['HTTP_HOST']) && strpos($pu['path'], $GLOBALS['CANONICAL_RELATIVE_PATH_STUDIP']) === 0) {
         $intern = true;
         $checkpath = urldecode(substr($pu['path'], strlen($GLOBALS['CANONICAL_RELATIVE_PATH_STUDIP'])));
         if (strpos($checkpath, '../') === false) {
             list($pu['first_target']) = explode('/', $checkpath);
         } else {
             $pu['first_target'] = false;
         }
     }
     $LOAD_EXTERNAL_MEDIA = Config::GetInstance()->getValue('LOAD_EXTERNAL_MEDIA');
     if ($intern && !in_array($pu['first_target'], array('sendfile.php', 'download', 'assets', 'pictures')) && !($pu['first_target'] === 'dispatch.php' && strpos($pu['path'], 'dispatch.php/document/download') !== false)) {
         return $matches[0];
     } elseif ((!$LOAD_EXTERNAL_MEDIA || $LOAD_EXTERNAL_MEDIA === 'deny') && !$intern) {
         return $matches[0];
     }
     //Mediaproxy?
     if (!$intern && $LOAD_EXTERNAL_MEDIA === "proxy" && Seminar_Session::is_current_session_authenticated()) {
         $media_url = $GLOBALS['ABSOLUTE_URI_STUDIP'] . 'dispatch.php/media_proxy?url=' . urlencode(decodeHTML(idna_link($url)));
     } else {
         $media_url = idna_link($url);
     }
     if ($tag === "flash") {
         $width = $width ? $width : 200;
         $height = round($width * 0.75);
         $flash_config = $width > 200 ? $GLOBALS['FLASHPLAYER_DEFAULT_CONFIG_MAX'] : $GLOBALS['FLASHPLAYER_DEFAULT_CONFIG_MIN'];
         $media = '<object type="application/x-shockwave-flash" id="FlashPlayer" data="' . Assets::url() . 'flash/player_flv.swf" width="' . $width . '" height="' . $height . '">
                     <param name="movie" value="' . Assets::url() . 'flash/player_flv.swf">
                     <param name="allowFullScreen" value="true">
                     <param name="FlashVars" value="flv=' . urlencode(decodeHTML($media_url)) . '&amp;startimage=' . $link . $flash_config . '">
                     <embed src="' . Assets::url() . 'flash/player_flv.swf" movie="$media_url" type="application/x-shockwave-flash" FlashVars="flv=' . urlencode(decodeHTML($media_url)) . '&amp;startimage=' . $link . $flash_config . '">
                     </object>';
     } else {
         $media = sprintf($format_strings[$tag], $media_url, isset($width) ? "width: " . $width . "px;" : "", $title, $title);
     }
     if ($tag === 'audio') {
         $random_id = 'audio-' . substr(md5(uniqid('audio', true)), -8);
         $media = str_replace('<audio ', '<audio id="' . $random_id . '" onerror="STUDIP.Audio.handle(this);" ', $media);
     }
     if ($link && $tag === "img") {
         $media = sprintf('<a href="%s"%s>%s</a>', $link, !isLinkIntern($link) ? ' target="_blank"' : "", $media);
     }
     if ($position) {
         $media = '<div style="text-align: ' . $position . '">' . $media . '</div>';
     }
     $media .= $whitespace;
     return $media;
 }
コード例 #15
0
ファイル: Files.php プロジェクト: ratbird/hope
 /**
  * Update einer Datei bzw. eines Ordners
  *
  * @put /file/:file_id
  */
 public function putFile($id)
 {
     $folder = $this->loadFolder($id);
     if (!$folder) {
         $document = $this->loadFile($id);
         $folder = $this->loadFolder($document['range_id']);
     }
     if (!$folder) {
         $this->error(404, 'folder does not exist');
     }
     if ($document) {
         foreach (words('name description protected') as $c) {
             if (isset($this->data[$c])) {
                 $document[$c] = $this->data[$c];
             }
         }
         if (is_array($this->data['_FILES']) && count($this->data['_FILES'])) {
             //fileupload
             $file = current($this->data['_FILES']);
             $GLOBALS['msg'] = '';
             validate_upload($file);
             if ($GLOBALS['msg']) {
                 $this->error(400, decodeHTML(trim(substr($GLOBALS['msg'], 6), '§')));
             }
             if ($file['size']) {
                 $document['filename'] = strtolower($file['name']);
                 $document['user_id'] = $GLOBALS['user']->id;
                 $document['author_name'] = get_fullname();
                 $document['filesize'] = $file['size'];
                 $document['autor_host'] = $_SERVER['REMOTE_ADDR'];
                 $ok = \StudipDocument::createWithFile($file['tmp_name'], $document);
                 @unlink($file['tmp_name']);
             }
             if (!$ok) {
                 $this->error(400, 'could not create file');
             }
         } else {
             $document->store();
         }
     } else {
         //update folder
         foreach (words('name description') as $c) {
             if (isset($this->data[$c])) {
                 $folder[$c] = $this->data[$c];
             }
         }
         $folder->store();
     }
     $this->status(204);
     $this->body(null);
     //no content means no content
 }
コード例 #16
0
ファイル: visual.inc.php プロジェクト: ratbird/hope
/**
* convert links with 'umlauten' to punycode
*
* @access   public
* @param    string  link to convert
* @param    boolean  for mailadr = true and for other link = false
* @return   string  link in punycode
*/
function idna_link($link, $mail = false)
{
    if (!$GLOBALS['CONVERT_IDNA_URL']) {
        return $link;
    }
    $pu = @parse_url($link);
    if (preg_match('/&\\w+;/i', $pu['host'])) {
        //umlaute?  (html-coded)
        $IDN = new idna_convert();
        $out = false;
        if ($mail) {
            if (preg_match('#^([^@]*)@(.*)$#i', $link, $matches)) {
                $out = $IDN->encode(utf8_encode(decodeHTML($matches[2], ENT_NOQUOTES)));
                // false by error
                $out = $out ? $matches[1] . '@' . $out : $link;
            }
        } elseif (preg_match('#^([^/]*)//([^/?]*)(((/|\\?).*$)|$)#i', $link, $matches)) {
            $out = $IDN->encode(utf8_encode(decodeHTML($matches[2], ENT_NOQUOTES)));
            // false by error
            $out = $out ? $matches[1] . '//' . $out . $matches[3] : $link;
        }
        return $out ? $out : $link;
    }
    return $link;
}
コード例 #17
0
ファイル: WikiFormat.php プロジェクト: ratbird/hope
 protected static function markupWikiLinks($markup, $matches)
 {
     $page = decodeHTML($matches[1]);
     $display_page = $matches[2] ? $markup->format($matches[2]) : htmlReady($page);
     if (keywordExists($page, $_SESSION['SessionSeminar'])) {
         return sprintf('<a href="%s">%s</a>', URLHelper::getLink("wiki.php", array('keyword' => $page)), $display_page);
     } else {
         return sprintf('<a href="%s">%s(?)</a>', URLHelper::getLink("wiki.php", array('keyword' => $page, 'view' => 'editnew')), $display_page);
     }
 }
コード例 #18
0
ファイル: cite_rtf.php プロジェクト: Olari0/Finugriling
function citeRecords($result, $rowsFound, $query, $queryURL, $showQuery, $showLinks, $rowOffset, $showRows, $previousOffset, $nextOffset, $wrapResults, $citeStyle, $citeOrder, $citeType, $orderBy, $headerMsg, $userID, $viewType)
{
    global $contentTypeCharset;
    // defined in 'ini.inc.php'
    global $client;
    // The array '$transtab_refbase_rtf' contains search & replace patterns for conversion from refbase markup to RTF markup & entities
    global $transtab_refbase_rtf;
    // defined in 'transtab_refbase_rtf.inc.php'
    // Initialize array variables:
    $yearsArray = array();
    $typeTitlesArray = array();
    // Define inline text markup to be used by the 'citeRecord()' function:
    $markupPatternsArray = array("bold-prefix" => "{\\b ", "bold-suffix" => "}", "italic-prefix" => "{\\i ", "italic-suffix" => "}", "underline-prefix" => "{\\ul ", "underline-suffix" => "}", "endash" => "\\endash ", "emdash" => "\\emdash ", "ampersand" => "&", "double-quote" => '"', "double-quote-left" => "\\ldblquote ", "double-quote-right" => "\\rdblquote ", "single-quote" => "'", "single-quote-left" => "\\lquote ", "single-quote-right" => "\\rquote ", "less-than" => "<", "greater-than" => ">", "newline" => "\n{\\f1\\fs24 \\par}\n");
    // Defines search & replace 'actions' that will be applied upon RTF output to all those refbase fields that are listed
    // in the corresponding 'fields' element:
    $rtfSearchReplaceActionsArray = array(array('fields' => array("title", "publication", "abbrev_journal", "address", "keywords", "abstract", "orig_title", "series_title", "abbrev_series_title", "notes"), 'actions' => $transtab_refbase_rtf));
    // For CLI queries, we'll allow paging thru the result set, i.e. we honour the values of the CLI options '-S|--start' ('$rowOffset')
    // and '-R|--rows' ('$showRows') ('$rowOffset' and '$showRows' are re-assigned in function 'seekInMySQLResultsToOffset()' in 'include.inc.php')
    if (preg_match("/^cli/i", $client)) {
        // if the query originated from a command line client such as the "refbase" CLI client ("cli-refbase-1.0")
        $showMaxRows = $showRows;
    } else {
        $showMaxRows = $rowsFound;
    }
    // otherwise show all rows
    // Setup the basic RTF document structure (RTF functions defined in 'MINIMALRTF.php'):
    $rtf = new MINIMALRTF();
    // initialize RTF object
    $rtfData = $rtf->openRtf();
    // create RTF opening tag
    $rtf->createFontBlock(0, "Arial");
    // create & set RTF font blocks
    $rtf->createFontBlock(1, "Times New Roman");
    $rtfData .= $rtf->setFontBlock();
    // Header:
    if (!empty($headerMsg)) {
        // Remove any colon (":") from end of header message:
        $headerMsg = trimTextPattern($headerMsg, ":", false, true);
        // function 'trimTextPattern()' is defined in 'include.inc.php'
        // Decode any HTML entities:
        // (these may occur in the header message e.g. if the user's preferred display language is not English but German or French, etc)
        $headerMsg = decodeHTML($contentTypeCharset, $headerMsg);
        // function 'decodeHTML()' is defined in 'include.inc.php', and '$contentTypeCharset' is defined in 'ini.inc.php'
        // Convert refbase markup in the header message into appropriate RTF markup & entities:
        $headerMsg = searchReplaceText($transtab_refbase_rtf, $headerMsg, true);
        // function 'searchReplaceText()' is defined in 'include.inc.php'
        $rtfData .= "{\\header\\pard\\qc {$headerMsg}\\par}\n";
    }
    $rtfData .= $rtf->justify("full", 0.5, 0, -0.5);
    // by default, we'll justify text and set a hanging indent (left indent: 0.5, right indent: 0, first-line indent: -0.5)
    // LOOP OVER EACH RECORD:
    // Fetch one page of results (or less if on the last page)
    // (i.e., upto the limit specified in $showMaxRows) fetch a row into the $row array and ...
    for ($rowCounter = 0; $rowCounter < $showMaxRows && ($row = @mysql_fetch_array($result)); $rowCounter++) {
        foreach ($row as $rowFieldName => $rowFieldValue) {
            // Apply search & replace 'actions' to all fields that are listed in the 'fields' element of the arrays contained in '$rtfSearchReplaceActionsArray':
            foreach ($rtfSearchReplaceActionsArray as $fieldActionsArray) {
                if (in_array($rowFieldName, $fieldActionsArray['fields'])) {
                    $row[$rowFieldName] = searchReplaceText($fieldActionsArray['actions'], $row[$rowFieldName], true);
                }
            }
        }
        // function 'searchReplaceText()' is defined in 'include.inc.php'
        // Order attributes according to the chosen output style & record type:
        $record = citeRecord($row, $citeStyle, $citeType, $markupPatternsArray, false);
        // function 'citeRecord()' is defined in the citation style file given in '$citeStyleFile' (which, in turn, must reside in the 'cite' directory of the refbase root directory), see function 'generateCitations()'
        // Print out the current record:
        if (!empty($record)) {
            // Print any section heading(s):
            if (preg_match("/year|type/i", $citeOrder)) {
                $headingPrefix = $rtf->justify("left", 0, 0, 0) . $rtf->paragraph(0, 12);
                // create empty paragraph in front of heading using "Arial" (font block 0) and a font size of 12pt
                $headingSuffix = $rtf->justify("full", 0.5, 0, -0.5);
                // justify any following text and set a hanging indent (left indent: 0.5, right indent: 0, first-line indent: -0.5)
                if ($citeOrder == "type") {
                    // for 'citeOrder=type' we'll always print an empty paragraph after the heading
                    $headingSuffix .= $rtf->paragraph(0, 12);
                }
                // create empty paragraph using "Arial" (font block 0) and a font size of 12pt
                list($yearsArray, $typeTitlesArray, $sectionHeading) = generateSectionHeading($yearsArray, $typeTitlesArray, $row, $citeOrder, $headingPrefix, $headingSuffix, "{\\f0\\fs28 {\\b ", "}\\par}\n", "{\\f0\\fs24 {\\b ", "}\\par}\n");
                // function 'generateSectionHeading()' is defined in 'cite.inc.php'
                // Note that we pass raw RTF commands to the above function instead of using the 'textBlock()' function from 'MINIMALRTF.php'. This is due to a current limitation of the 'generateSectionHeading()' function.
                // For 'citeOrder=year', the appropriate call to the 'textBlock()' function would look like this:
                // $rtfData .= $rtf->textBlock(0, 14, $rtf->bold($row['year'])); // create major heading with the current year using "Arial" (font block 0) and a font size of 14pt, printed in bold
                $rtfData .= $sectionHeading;
            }
            // If character encoding is not UTF-8 already, convert record text to UTF-8:
            if ($contentTypeCharset != "UTF-8") {
                $record = convertToCharacterEncoding("UTF-8", "IGNORE", $record);
            }
            // function 'convertToCharacterEncoding()' is defined in 'include.inc.php'
            // Encode characters with an ASCII value of >= 128 in RTF 1.16 unicode format:
            $recordUnicodeCharEncoded = $rtf->utf8_2_unicode($record);
            // converts UTF-8 chars to unicode character codes
            // Write RTF paragraph:
            $rtfData .= $rtf->textBlock(1, 12, $recordUnicodeCharEncoded);
            // create text block with encoded record text using "Times New Roman" (font block 1) and a font size of 12pt
        }
    }
    $rtfData .= $rtf->closeRtf();
    // create RTF closing tag
    return $rtfData;
}
コード例 #19
0
ファイル: pdf.php プロジェクト: cwcw/cms
function dofreePDF($database)
{
    global $mosConfig_live_site, $mosConfig_sitename, $mosConfig_offset, $mosConfig_hideCreateDate, $mosConfig_hideAuthor, $mosConfig_hideModifyDate;
    $id = intval(mosGetParam($_REQUEST, 'id', 1));
    include 'includes/class.ezpdf.php';
    $row = new mosContent($database);
    $row->load($id);
    //Find Author Name
    $users_rows = new mosUser($database);
    $users_rows->load($row->created_by);
    $row->author = $users_rows->name;
    $row->usertype = $users_rows->usertype;
    // Ugly but needed to get rid of all the stuff the PDF class cant handle
    $row->fulltext = str_replace('<p>', "\n\n", $row->fulltext);
    $row->fulltext = str_replace('<P>', "\n\n", $row->fulltext);
    $row->fulltext = str_replace('<br />', "\n", $row->fulltext);
    $row->fulltext = str_replace('<br>', "\n", $row->fulltext);
    $row->fulltext = str_replace('<BR />', "\n", $row->fulltext);
    $row->fulltext = str_replace('<BR>', "\n", $row->fulltext);
    $row->fulltext = str_replace('<li>', "\n - ", $row->fulltext);
    $row->fulltext = str_replace('<LI>', "\n - ", $row->fulltext);
    $row->fulltext = strip_tags($row->fulltext);
    $row->fulltext = str_replace('{mosimage}', '', $row->fulltext);
    $row->fulltext = str_replace('{mospagebreak}', '', $row->fulltext);
    $row->fulltext = decodeHTML($row->fulltext);
    $row->introtext = str_replace('<p>', "\n\n", $row->introtext);
    $row->introtext = str_replace('<P>', "\n\n", $row->introtext);
    $row->introtext = str_replace('<li>', "\n - ", $row->introtext);
    $row->introtext = str_replace('<LI>', "\n - ", $row->introtext);
    $row->introtext = strip_tags($row->introtext);
    $row->introtext = str_replace('{mosimage}', '', $row->introtext);
    $row->introtext = str_replace('{mospagebreak}', '', $row->introtext);
    $row->introtext = decodeHTML($row->introtext);
    $pdf =& new Cezpdf('a4', 'P');
    //A4 Portrait
    $pdf->ezSetCmMargins(2, 1.5, 1, 1);
    $pdf->selectFont('./fonts/Helvetica.afm');
    //choose font
    $all = $pdf->openObject();
    $pdf->saveState();
    $pdf->setStrokeColor(0, 0, 0, 1);
    // footer
    $pdf->line(10, 40, 578, 40);
    $pdf->line(10, 822, 578, 822);
    $pdf->addText(30, 34, 6, $mosConfig_live_site . ' - ' . $mosConfig_sitename);
    $pdf->addText(250, 34, 6, 'Powered by Mambo');
    $pdf->addText(450, 34, 6, 'Generated: ' . date('j F, Y, H:i', time() + $mosConfig_offset * 60 * 60));
    $pdf->restoreState();
    $pdf->closeObject();
    $pdf->addObject($all, 'all');
    $pdf->ezSetDy(30);
    $txt1 = $row->title;
    $pdf->ezText($txt1, 14);
    $txt2 = NULL;
    $mod_date = NULL;
    $create_date = NULL;
    if (intval($row->modified) != 0) {
        $mod_date = mosFormatDate($row->modified);
    }
    if (intval($row->created) != 0) {
        $create_date = mosFormatDate($row->created);
    }
    if ($mosConfig_hideCreateDate == '0') {
        $txt2 .= '(' . $create_date . ') - ';
    }
    if ($mosConfig_hideAuthor == "0") {
        if ($row->author != '' && $mosConfig_hideAuthor == '0') {
            if ($row->usertype == 'administrator' || $row->usertype == 'superadministrator') {
                $txt2 .= _WRITTEN_BY . ' ' . ($row->created_by_alias ? $row->created_by_alias : $row->author);
            } else {
                $txt2 .= _AUTHOR_BY . ' ' . ($row->created_by_alias ? $row->created_by_alias : $row->author);
            }
        }
    }
    if ($mosConfig_hideModifyDate == "0") {
        $txt2 .= ' - ' . _LAST_UPDATED . ' (' . $mod_date . ') ';
    }
    $txt2 .= "\n\n";
    $pdf->ezText($txt2, 8);
    $txt3 = $row->introtext . "\n" . $row->fulltext;
    $pdf->ezText($txt3, 10);
    $pdf->ezStream();
}
コード例 #20
0
ファイル: kunena.pdf.php プロジェクト: vuchannguyen/hoctap
function filterHTML(&$string)
{
    // Ugly but needed to get rid of all the stuff the PDF class cant handle
    $string = str_replace('<p>', "\n\n", $string);
    $string = str_replace('<P>', "\n\n", $string);
    $string = str_replace('<br />', "\n", $string);
    $string = str_replace('<br>', "\n", $string);
    $string = str_replace('<BR />', "\n", $string);
    $string = str_replace('<BR>', "\n", $string);
    $string = str_replace('<li>', "\n - ", $string);
    $string = str_replace('<LI>', "\n - ", $string);
    $string = strip_tags($string);
    $string = str_replace('{mosimage}', '', $string);
    $string = str_replace('{mospagebreak}', '', $string);
    // bbcode
    $string = preg_replace('/\\[confidential\\](.*?)\\[\\/confidential\\]/s', '', $string);
    $string = preg_replace('/\\[ebay\\](.*?)\\[\\/ebay\\]/s', '', $string);
    $string = preg_replace('/\\[map\\](.*?)\\[\\/map\\]/s', '', $string);
    $string = preg_replace('/\\[video(.*?)\\](.*?)\\[\\/video\\]/s', "", $string);
    $string = decodeHTML($string);
}
コード例 #21
0
ファイル: teams.php プロジェクト: antt1995/starkicktraders
   			echo "<INPUT TYPE=SUBMIT VALUE=$l_submit><INPUT TYPE=RESET VALUE=$l_reset>";
   			echo "</FORM>";
   			echo "<BR><BR>";
   		} else {
   		        $teamname = htmlspecialchars($teamname);
                        $teamdesc = htmlspecialchars($teamdesc);
   	                $res = $db->Execute("UPDATE $dbtables[teams] SET team_name='$teamname', description='$teamdesc' WHERE id=$whichteam") or die("<font color=red>error: " . $db->ErrorMSG() . "</font>");
   			echo "$l_team_alliance <B>$teamname</B> $l_team_hasbeenr<BR><BR>";
   			/*
   			   Adding a log entry to all members of the renamed alliance
   			*/
   		   $result_team_name = $db->Execute("SELECT player_id FROM $dbtables[players] WHERE team=$whichteam AND player_id<>$playerinfo[player_id]") or die("<font color=red>error: " . $db->ErrorMsg() . "</font>");
   			playerlog($playerinfo[player_id], LOG_TEAM_RENAME, decodeHTML($teamname));
   			while(!$result_team_name->EOF) {
          $teamname_array = $result_team_name->fields;
   			   playerlog($teamname_array[player_id], LOG_TEAM_M_RENAME, decodeHTML($teamname));
                           $result_team_name->MoveNext();
            }
     		}
   		LINK_BACK();
   		break;
	   }
	   else
	   {
   		echo $l_team_error;
   		LINK_BACK();
   		break;
	   }
	case 10: // Retract Invite
    if ($playerinfo[team] == $team[id])
    {
コード例 #22
0
ファイル: streams.php プロジェクト: ratbird/hope
 /**
  * Saves given files (dragged into the textarea) and returns the link to the
  * file to the user as json.
  * @throws AccessDeniedException
  */
 public function post_files_action()
 {
     $context = Request::option("context") ? Request::get("context") : $GLOBALS['user']->id;
     $context_type = Request::option("context_type");
     if (!Request::isPost() || $context_type === "course" && !$GLOBALS['perm']->have_studip_perm("autor", $context)) {
         throw new AccessDeniedException();
     }
     //check folders
     $db = DBManager::get();
     $folder_id = md5("Blubber_" . $context . "_" . $GLOBALS['user']->id);
     $parent_folder_id = md5("Blubber_" . $context);
     if ($context_type !== "course") {
         $folder_id = $parent_folder_id;
     }
     $folder = $db->query("SELECT * " . "FROM folder " . "WHERE folder_id = " . $db->quote($folder_id) . " " . "")->fetch(PDO::FETCH_COLUMN, 0);
     if (!$folder) {
         $folder = $db->query("SELECT * " . "FROM folder " . "WHERE folder_id = " . $db->quote($parent_folder_id) . " " . "")->fetch(PDO::FETCH_COLUMN, 0);
         if (!$folder) {
             $db->exec("INSERT IGNORE INTO folder " . "SET folder_id = " . $db->quote($parent_folder_id) . ", " . "range_id = " . $db->quote($context) . ", " . "seminar_id = " . $db->quote($context) . ", " . "user_id = " . $db->quote($GLOBALS['user']->id) . ", " . "name = " . $db->quote("BlubberDateien") . ", " . "permission = '7', " . "mkdate = " . $db->quote(time()) . ", " . "chdate = " . $db->quote(time()) . " " . "");
         }
         if ($context_type === "course") {
             $db->exec("INSERT IGNORE INTO folder " . "SET folder_id = " . $db->quote($folder_id) . ", " . "range_id = " . $db->quote($parent_folder_id) . ", " . "seminar_id = " . $db->quote($context) . ", " . "user_id = " . $db->quote($GLOBALS['user']->id) . ", " . "name = " . $db->quote(get_fullname()) . ", " . "permission = '7', " . "mkdate = " . $db->quote(time()) . ", " . "chdate = " . $db->quote(time()) . " " . "");
         }
     }
     $output = array();
     foreach ($_FILES as $file) {
         $GLOBALS['msg'] = '';
         validate_upload($file);
         if ($GLOBALS['msg']) {
             $output['errors'][] = $file['name'] . ': ' . decodeHTML(trim(substr($GLOBALS['msg'], 6), '§'));
             continue;
         }
         if ($file['size']) {
             $document['name'] = $document['filename'] = studip_utf8decode(strtolower($file['name']));
             $document['user_id'] = $GLOBALS['user']->id;
             $document['author_name'] = get_fullname();
             $document['seminar_id'] = $context;
             $document['range_id'] = $context_type === "course" ? $folder_id : $parent_folder_id;
             $document['filesize'] = $file['size'];
             if ($context === $GLOBALS['user']->id && Config::get()->PERSONALDOCUMENT_ENABLE) {
                 try {
                     $root_dir = RootDirectory::find($GLOBALS['user']->id);
                     $blubber_directory = $root_dir->listDirectories()->findOneBy('name', 'Blubber');
                     if (!$blubber_directory) {
                         $blubber_directory = $root_dir->mkdir('Blubber', _('Ihre Dateien aus Blubberstreams'));
                     }
                     $newfile = $blubber_directory->file->createFile($document['name']);
                     $newfile->name = $document['name'];
                     $newfile->store();
                     $handle = $newfile->file;
                     $handle->restricted = 0;
                     $handle->mime_type = $file['type'];
                     $handle->setContentFromFile($file['tmp_name']);
                     $handle->update();
                     $url = $newfile->getDownloadLink(true, true);
                     $success = true;
                 } catch (Exception $e) {
                     $output['error'][] = $e->getMessage();
                     $success = false;
                 }
             } else {
                 $newfile = StudipDocument::createWithFile($file['tmp_name'], $document);
                 $success = (bool) $newfile;
                 if ($success) {
                     $url = GetDownloadLink($newfile->getId(), $newfile['filename']);
                 }
             }
             if ($success) {
                 $type = null;
                 strpos($file['type'], 'image') === false || ($type = "img");
                 strpos($file['type'], 'video') === false || ($type = "video");
                 if (strpos($file['type'], 'audio') !== false || strpos($document['filename'], '.ogg') !== false) {
                     $type = "audio";
                 }
                 if ($type) {
                     $output['inserts'][] = "[" . $type . "]" . $url;
                 } else {
                     $output['inserts'][] = "[" . $document['filename'] . "]" . $url;
                 }
             }
         }
     }
     $this->render_json($output);
 }
コード例 #23
0
ファイル: cite_markdown.php プロジェクト: Olari0/Finugriling
function citeRecords($result, $rowsFound, $query, $queryURL, $showQuery, $showLinks, $rowOffset, $showRows, $previousOffset, $nextOffset, $wrapResults, $citeStyle, $citeOrder, $citeType, $orderBy, $headerMsg, $userID, $viewType)
{
    global $contentTypeCharset;
    // defined in 'ini.inc.php'
    global $client;
    // The array '$transtab_refbase_markdown' contains search & replace patterns for conversion from refbase markup to Markdown markup & entities
    global $transtab_refbase_markdown;
    // defined in 'transtab_refbase_markdown.inc.php'
    $markdownData = "";
    // make sure that our buffer variable is empty
    // Header:
    if (!empty($headerMsg)) {
        // Decode any HTML entities:
        // (these may occur in the header message e.g. if the user's preferred display language is not English but German or French, etc)
        $headerMsg = decodeHTML($contentTypeCharset, $headerMsg);
        // function 'decodeHTML()' is defined in 'include.inc.php', and '$contentTypeCharset' is defined in 'ini.inc.php'
        // Convert refbase markup in the header message into appropriate Markdown markup & entities:
        $headerMsg = searchReplaceText($transtab_refbase_markdown, $headerMsg, true);
        // function 'searchReplaceText()' is defined in 'include.inc.php'
        $markdownData .= "# {$headerMsg} #\n\n";
    }
    // Initialize array variables:
    $yearsArray = array();
    $typeTitlesArray = array();
    // Define inline text markup to be used by the 'citeRecord()' function:
    $markupPatternsArray = array("bold-prefix" => "**", "bold-suffix" => "**", "italic-prefix" => "_", "italic-suffix" => "_", "underline-prefix" => "<u>", "underline-suffix" => "</u>", "endash" => "&ndash;", "emdash" => "&mdash;", "ampersand" => "&", "double-quote" => '"', "double-quote-left" => "&ldquo;", "double-quote-right" => "&rdquo;", "single-quote" => "'", "single-quote-left" => "&lsquo;", "single-quote-right" => "&rsquo;", "less-than" => "<", "greater-than" => ">", "newline" => "  \n");
    // Defines search & replace 'actions' that will be applied upon Markdown output to all those refbase fields that are listed
    // in the corresponding 'fields' element:
    $markdownSearchReplaceActionsArray = array(array('fields' => array("title", "publication", "abbrev_journal", "address", "keywords", "abstract", "orig_title", "series_title", "abbrev_series_title", "notes"), 'actions' => $transtab_refbase_markdown));
    // For CLI queries, we'll allow paging thru the result set, i.e. we honour the values of the CLI options '-S|--start' ('$rowOffset')
    // and '-R|--rows' ('$showRows') ('$rowOffset' and '$showRows' are re-assigned in function 'seekInMySQLResultsToOffset()' in 'include.inc.php')
    if (preg_match("/^cli/i", $client)) {
        // if the query originated from a command line client such as the "refbase" CLI client ("cli-refbase-1.0")
        $showMaxRows = $showRows;
    } else {
        $showMaxRows = $rowsFound;
    }
    // otherwise show all rows
    // LOOP OVER EACH RECORD:
    // Fetch one page of results (or less if on the last page)
    // (i.e., upto the limit specified in $showMaxRows) fetch a row into the $row array and ...
    for ($rowCounter = 0; $rowCounter < $showMaxRows && ($row = @mysql_fetch_array($result)); $rowCounter++) {
        foreach ($row as $rowFieldName => $rowFieldValue) {
            // Apply search & replace 'actions' to all fields that are listed in the 'fields' element of the arrays contained in '$markdownSearchReplaceActionsArray':
            foreach ($markdownSearchReplaceActionsArray as $fieldActionsArray) {
                if (in_array($rowFieldName, $fieldActionsArray['fields'])) {
                    $row[$rowFieldName] = searchReplaceText($fieldActionsArray['actions'], $row[$rowFieldName], true);
                }
            }
        }
        // function 'searchReplaceText()' is defined in 'include.inc.php'
        // Order attributes according to the chosen output style & record type:
        $record = citeRecord($row, $citeStyle, $citeType, $markupPatternsArray, false);
        // function 'citeRecord()' is defined in the citation style file given in '$citeStyleFile' (which, in turn, must reside in the 'cite' directory of the refbase root directory), see function 'generateCitations()'
        // Print out the current record:
        if (!empty($record)) {
            // Print any section heading(s):
            if (preg_match("/year|type/i", $citeOrder)) {
                $headingPrefix = "";
                $headingSuffix = "";
                if (!empty($headerMsg)) {
                    $sectionMarkupPrefix = "## ";
                    $sectionMarkupSuffix = " ##\n\n";
                    $subSectionMarkupPrefix = "### ";
                    $subSectionMarkupSuffix = " ###\n\n";
                } else {
                    $sectionMarkupPrefix = "# ";
                    $sectionMarkupSuffix = " #\n\n";
                    $subSectionMarkupPrefix = "## ";
                    $subSectionMarkupSuffix = " ##\n\n";
                }
                list($yearsArray, $typeTitlesArray, $sectionHeading) = generateSectionHeading($yearsArray, $typeTitlesArray, $row, $citeOrder, $headingPrefix, $headingSuffix, $sectionMarkupPrefix, $sectionMarkupSuffix, $subSectionMarkupPrefix, $subSectionMarkupSuffix);
                // function 'generateSectionHeading()' is defined in 'cite.inc.php'
                $markdownData .= $sectionHeading;
            }
            // Write plain TEXT paragraph:
            $markdownData .= $record . "\n\n";
            // create paragraph with encoded record text
        }
    }
    return $markdownData;
}