예제 #1
0
     // get the contents of the 'head' element
     $head .= ContentUtility::getHtmlHeadByTag($content, $html_head_tags);
     // Specifically handle eXe package
     // NOTE: THIS NEEDS WORK! TO FIND A WAY APPLY EXE .CSS FILES ONLY ON COURSE CONTENT PART.
     // NOW USE OUR OWN .CSS CREATED SOLELY FOR EXE
     $isExeContent = false;
     // check xml file in eXe package
     if (preg_match("/<organization[ ]*identifier=\"eXe*>*/", $ims_manifest_xml)) {
         $isExeContent = true;
     }
     // use ATutor's eXe style sheet as the ones from eXe conflicts with ATutor's style sheets
     if ($isExeContent) {
         $head = preg_replace('/(<style.*>)(.*)(<\\/style>)/ms', '\\1@import url(/docs/exestyles.css);\\3', $head);
     }
     // end of specifically handle eXe package
     $content = ContentUtility::getHtmlBody($content);
     if ($contains_glossary_terms) {
         // replace glossary content package links to real glossary mark-up using [?] [/?]
         // refer to bug 3641, edited by Harris
         $content = preg_replace('/<a href="([.\\w\\d\\s]+[^"]+)" target="body" class="at-term">([.\\w\\d\\s&;"]+|.*)<\\/a>/i', '[?]\\2[/?]', $content);
     }
     /* potential security risk? */
     if (strpos($content_info['href'], '..') === false && !preg_match('/((.*)\\/)*tests\\_[0-9]+\\.xml$/', $content_info['href'])) {
         //				@unlink($import_path.$content_info['href']);
     }
 } else {
     if ($ext) {
         /* non text file, and can't embed (example: PDF files) */
         $content = '<a href="' . $content_info['href'] . '">' . $content_info['title'] . '</a>';
     }
 }
function paste_from_file()
{
    global $msg;
    include_once TR_INCLUDE_PATH . '../home/classes/ContentUtility.class.php';
    if ($_FILES['uploadedfile_paste']['name'] == '') {
        $msg->addError('FILE_NOT_SELECTED');
        return;
    }
    if ($_FILES['uploadedfile_paste']['name'] && ($_FILES['uploadedfile_paste']['type'] == 'text/plain' || $_FILES['uploadedfile_paste']['type'] == 'text/html')) {
        $path_parts = pathinfo($_FILES['uploadedfile_paste']['name']);
        $ext = strtolower($path_parts['extension']);
        if (in_array($ext, array('html', 'htm'))) {
            $_POST['body_text'] = file_get_contents($_FILES['uploadedfile_paste']['tmp_name']);
            /* get the <title></title> of this page				*/
            $start_pos = strpos(strtolower($_POST['body_text']), '<title>');
            $end_pos = strpos(strtolower($_POST['body_text']), '</title>');
            if ($start_pos !== false && $end_pos !== false) {
                $start_pos += strlen('<title>');
                $_POST['title'] = trim(substr($_POST['body_text'], $start_pos, $end_pos - $start_pos));
            }
            unset($start_pos);
            unset($end_pos);
            $_POST['head'] = ContentUtility::getHtmlHeadByTag($_POST['body_text'], array("link", "style", "script"));
            if (strlen(trim($_POST['head'])) > 0) {
                $_POST['use_customized_head'] = 1;
            } else {
                $_POST['use_customized_head'] = 0;
            }
            $_POST['body_text'] = ContentUtility::getHtmlBody($_POST['body_text']);
            $msg->addFeedback('FILE_PASTED');
        } else {
            if ($ext == 'txt') {
                $_POST['body_text'] = file_get_contents($_FILES['uploadedfile_paste']['tmp_name']);
                //LAW
                //			debug($_POST);
                $msg->addFeedback('FILE_PASTED');
            }
        }
    } else {
        $msg->addError('BAD_FILE_TYPE');
    }
    return;
}