当前位置: 首页>>代码示例>>PHP>>正文


PHP replace_dangerous_char函数代码示例

本文整理汇总了PHP中replace_dangerous_char函数的典型用法代码示例。如果您正苦于以下问题:PHP replace_dangerous_char函数的具体用法?PHP replace_dangerous_char怎么用?PHP replace_dangerous_char使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了replace_dangerous_char函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: export

 public function export()
 {
     $postsList = $this->loadTopic($this->getTopicId());
     $topicInfo = get_topic_settings($this->getTopicId());
     $this->createPDF($topicInfo['topic_title']);
     $this->pdf->AddPage();
     $htmlContent = '<p>' . "\n" . '<table cellspacing="0" cellpadding="2" border="1">' . "\n" . '<tbody>' . "\n" . '<tr>' . "\n" . '<th colspan="2" style="font-weight: bold; background-color: #EDF1E3; color: #669933; border-bottom: 1px solid #96BB7A;">' . claro_utf8_encode($topicInfo['topic_title']) . '</th>' . '</tr>' . "\n";
     foreach ($postsList as $post) {
         $htmlContent .= '<tr>' . "\n" . '<td style="width: 150px; background-color: #EEEEEE;">' . "\n" . '<div style="font-weight: bold;">' . claro_utf8_encode($post['firstname'] . ' ' . $post['lastname'], get_conf('charset')) . '</div>' . "\n" . '<small>' . claro_html_localised_date(get_locale('dateTimeFormatLong'), datetime_to_timestamp($post['post_time'])) . '</small>' . "\n" . '</td>' . "\n" . '<td style="width: 354px;">' . claro_utf8_encode(claro_parse_user_text(strip_tags($post['post_text'])), get_conf('charset')) . '</td>' . "\n" . '</tr>' . "\n";
     }
     $htmlContent .= '</tbody>' . "\n" . '</table>' . "\n" . '</p>';
     //exit( claro_utf8_decode($htmlContent) );
     $this->pdf->writeHTML($htmlContent, true, 0, true, 0);
     switch ($this->output) {
         case 'screen':
             $this->pdf->Output(claro_utf8_encode($topicInfo['topic_id'] . '_' . $topicInfo['topic_title'] . '.pdf'), 'D');
             break;
         default:
             $path = get_conf('rootSys') . get_conf('tmpPathSys') . '/forum_export/';
             claro_mkdir($path);
             $this->pdf->Output($path . claro_utf8_encode(replace_dangerous_char($topicInfo['topic_id'] . '_' . $topicInfo['topic_title']) . '.pdf'), 'F');
             break;
     }
     return true;
 }
开发者ID:rhertzog,项目名称:lcs,代码行数:25,代码来源:export.pdf.class.php

示例2: export

 public function export()
 {
     $postsList = $this->loadTopic($this->getTopicId());
     $topicInfo = get_topic_settings($this->getTopicId());
     $css = $this->importCss();
     $form = new PhpTemplate(get_module_path('CLFRM') . '/templates/forum_export.tpl.php');
     $form->assign('forum_id', $topicInfo['forum_id']);
     $form->assign('topic_id', $topicInfo['topic_id']);
     $form->assign('notification_bloc', false);
     $form->assign('topic_subject', $topicInfo['topic_title']);
     $form->assign('postList', $postsList);
     $form->assign('claro_notifier', false);
     $form->assign('is_allowedToEdit', false);
     $form->assign('date', null);
     $out = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">' . "\n" . '<html>' . "\n" . '<head>' . "\n" . '<meta http-equiv="Content-Type" content="text/HTML; charset=' . get_conf('charset') . '"  />' . "\n" . '<style type="text/css">' . $css . '</style>' . "\n" . '<title>' . $topicInfo['topic_title'] . '</title>' . "\n" . '</head>' . "\n" . '<body><div id="forumExport">' . "\n";
     $out .= $form->render();
     $out .= '</div></body>' . "\n" . '</html>';
     $path = get_conf('rootSys') . get_conf('tmpPathSys') . '/forum_export/';
     $filename = $path . replace_dangerous_char(str_replace(' ', '_', $topicInfo['topic_title']) . '_' . $topicInfo['topic_id']) . '.html';
     claro_mkdir($path);
     file_put_contents($filename, $out);
     switch ($this->output) {
         case 'screen':
             header('Content-Description: File Transfer');
             header('Content-Type: application/force-download');
             header('Content-Length: ' . filesize($filename));
             header('Content-Disposition: attachment; filename=' . basename($filename));
             readfile($filename);
             claro_delete_file($filename);
             break;
         case 'file':
             break;
     }
     return true;
 }
开发者ID:rhertzog,项目名称:lcs,代码行数:35,代码来源:export.html.class.php

示例3: generateDefaultCertificate

 /**
  * Generate a default certificate for a courses
  *
  * @global string $css CSS directory
  * @global string $img_dir image directory
  * @global string $default_course_dir Course directory
  * @global string $js JS directory
  * @param array $courseData The course info
  */
 public static function generateDefaultCertificate($courseData)
 {
     global $css, $img_dir, $default_course_dir, $js;
     $codePath = api_get_path(REL_CODE_PATH);
     $dir = '/certificates';
     $title = get_lang('DefaultCertificate');
     $comment = null;
     $fileName = replace_dangerous_char($title);
     $filePath = api_get_path(SYS_COURSE_PATH) . "{$courseData['path']}/document{$dir}";
     $fileFullPath = "{$filePath}/{$fileName}.html";
     $fileSize = 0;
     $fileType = 'file';
     $templateContent = file_get_contents(api_get_path(SYS_CODE_PATH) . 'gradebook/certificate_template/template.html');
     $search = array('{CSS}', '{IMG_DIR}', '{REL_CODE_PATH}', '{COURSE_DIR}');
     $replace = array($css . $js, $img_dir, $codePath, $default_course_dir);
     $fileContent = str_replace($search, $replace, $templateContent);
     $saveFilePath = "{$dir}/{$fileName}.html";
     if (!is_dir($filePath)) {
         mkdir($filePath, api_get_permissions_for_new_directories());
     }
     $defaultCertificateFile = $fp = @fopen($fileFullPath, 'w');
     if ($defaultCertificateFile != false) {
         @fputs($defaultCertificateFile, $fileContent);
         fclose($defaultCertificateFile);
         chmod($fileFullPath, api_get_permissions_for_new_files());
         $fileSize = filesize($fileFullPath);
     }
     $documentId = add_document($courseData, $saveFilePath, $fileType, $fileSize, $title, $comment);
     $defaultCertificateId = self::get_default_certificate_id($courseData['code']);
     if (!isset($defaultCertificateId)) {
         self::attach_gradebook_certificate($courseData['code'], $documentId);
     }
 }
开发者ID:annickvdp,项目名称:Chamilo1.9.10,代码行数:42,代码来源:document.lib.php

示例4: move_uploaded_file_collection_into_directory

		//put the uploaded files in the new directory and get the paths
		$paths_to_replace_in_file = move_uploaded_file_collection_into_directory($_course, $_FILES['img_file'],$base_work_dir,$missing_files_dir,$_user['user_id'],$to_group_id,$to_user_id,$max_filled_space);
		//open the html file and replace the paths
        replace_img_path_in_html_file(
            $_POST['img_file_path'],
            $paths_to_replace_in_file,
            $base_work_dir . $_POST['related_file']
        );
		//update parent folders
		item_property_update_on_folder($_course,$_POST['curdirpath'],$_user['user_id']);
	}
}
//they want to create a directory
if (isset($_POST['create_dir']) && $_POST['dirname']!='') {
	$added_slash = ($path=='/')?'':'/';
	$dir_name = $path.$added_slash.replace_dangerous_char($_POST['dirname']);
	$created_dir = create_unexisting_directory($_course,$_user['user_id'],api_get_session_id(), $to_group_id,$to_user_id,$base_work_dir,$dir_name,$_POST['dirname']);
    if ($created_dir) {
        Display::display_normal_message(get_lang('DirCr'));
        $path = $created_dir;
    } else {
        display_error(get_lang('CannotCreateDir'));
    }
}

if (isset($_GET['createdir'])) {
	//create the form that asks for the directory name
	$new_folder_text = '<form action="'.api_get_self().'" method="POST">';
	$new_folder_text .= '<input type="hidden" name="curdirpath" value="'.$path.'"/>';
	$new_folder_text .= get_lang('NewDir') .' ';
	$new_folder_text .= '<input type="text" name="dirname"/>';
开发者ID:annickvdp,项目名称:Chamilo1.9.10,代码行数:31,代码来源:upload.document.php

示例5: fetch

        /**
         * Fetch info from the database
         *
         * @return False on error, true otherwise.
         * @author Thanos Kyritsis <atkyritsis@upnet.gr>
         * @author Amand Tihon <amand@alrj.org>
         */
        function fetch() {
            global $webDir, $course_code, $course_id, $langLearningPathNotFound, $langLearningPathEmpty;

            /* Get general infos about the learning path */
            $lp = Database::get()->querySingle("SELECT `name`, `comment` FROM `lp_learnPath`
                WHERE `learnPath_id` = ?d AND `course_id` = ?d", $this->id, $course_id);
            if (!$lp) {
                $this->error[] = $langLearningPathNotFound;
                return false;
            }

            $this->name = $lp->name;
            $this->comment = $lp->comment;

            /* Build various directories' names */

            // Replace ',' too, because pclzip doesn't support it.
            $this->destDir = $webDir . "/courses/" . $course_code . '/temp/'
                    . str_replace(',', '_', replace_dangerous_char($this->name));
            $this->srcDirDocument = $webDir . "/courses/" . $course_code . "/document";
            $this->srcDirExercise = $webDir . "/courses/" . $course_code . "/exercise";
            $this->srcDirScorm = $webDir . "/courses/" . $course_code . "/scormPackages/path_" . $this->id;
            $this->srcDirVideo = $webDir . "/video/" . $course_code;

            /* Now, get the complete list of modules, etc... */
            $sql = 'SELECT  LPM.`learnPath_module_id` ID, LPM.`lock`, LPM.`visible`, LPM.`rank`,
                        LPM.`parent`, LPM.`raw_to_pass`, LPM.`specificComment` itemComment,
                        M.`name`, M.`contentType`, M.`comment` resourceComment, A.`path`
                FROM `lp_rel_learnPath_module` AS LPM
                LEFT JOIN `lp_module` AS M
                       ON LPM.`module_id` = M.`module_id`
                LEFT JOIN `lp_asset` AS A
                       ON M.`startAsset_id` = A.`asset_id`
                WHERE LPM.`learnPath_id` = ?d
                AND M.`course_id` = ?d
                ORDER BY LPM.`parent`, LPM.`rank`';

            $result = Database::get()->queryArray($sql, $this->id, $course_id);
            if (!$result) {
                $this->error[] = $langLearningPathEmpty;
                return false;
            }
            
            $module = array();
            foreach ($result as $modobj) {
                $module['ID'] = $modobj->ID;
                $module['lock'] = $modobj->lock;
                $module['visible'] = $modobj->visible;
                $module['rank'] = $modobj->rank;
                $module['parent'] = $modobj->parent;
                $module['raw_to_pass'] = $modobj->raw_to_pass;
                $module['itemComment'] = $modobj->itemComment;
                $module['name'] = $modobj->name;
                $module['contentType'] = $modobj->contentType;
                $module['resourceComment'] = $modobj->resourceComment;
                $module['path'] = $modobj->path;
            
                // Check for SCORM content. If at least one module is SCORM, we need to export the existing SCORM package
                if ($module['contentType'] == 'SCORM' || $module['contentType'] == 'SCORM_ASSET') {
                    $this->fromScorm = true;
                }

                // If it is an exercise, create a filename for it.
                if ($module['contentType'] == 'EXERCISE') {
                    $module['fileName'] = 'quiz_' . $module['path'] . '.html';
                }

                // Only for clarity :
                $id = $module['ID'];
                $parent = $module['parent'];

                // Add to the flat resource map
                $this->resourceMap[$id] = $module;

                // Build Item tree, only keeping visible modules
                if ($module['visible'] == 1) {
                    if (!$parent) {
                        // parent is 0, item is at root
                        $this->itemTree[$id] = &$this->resourceMap[$id];
                    } else {
                        /* item has a parent. Add it to the list of its children.
                          Note that references are used, not copies. */
                        $this->resourceMap[$parent]['children'][] = &$this->resourceMap[$id];
                    }
                }
            }


            return true;
        }
开发者ID:nikosv,项目名称:openeclass,代码行数:97,代码来源:scormExport.inc.php

示例6: document_exists

/**
 * Check if a document width the chosen filename already exists
 */
function document_exists($filename)
{
    global $dir;
    // Clean up the name, only ASCII characters should stay. (and strict)
    $cleanName = replace_dangerous_char($filename, 'strict');
    // No "dangerous" files
    $cleanName = disable_dangerous_file($cleanName);
    return !DocumentManager::documentExists($dir . $cleanName . '.html', api_get_course_info(), api_get_session_id(), api_get_group_id());
    /*$filename = addslashes(trim($filename));
    	$filename = Security::remove_XSS($filename);
    	$filename = replace_dangerous_char($filename);
    	$filename = disable_dangerous_file($filename);
    	return !file_exists($filepath.$filename.'.html');*/
}
开发者ID:annickvdp,项目名称:Chamilo1.9.10,代码行数:17,代码来源:create_document.php

示例7: claro_mkdir

    claro_mkdir($pathSys);
}
/*
 * Init request vars
 */
if (!empty($_REQUEST['relativePath']) && $_REQUEST['relativePath'] != '/' && $_REQUEST['relativePath'] != '.') {
    $relativePath = str_replace('..', '', $_REQUEST['relativePath']) . '/';
} else {
    $relativePath = '/';
}
/*
 * Handle upload
 */
if ($is_allowedToEdit && isset($_FILES['sentFile']['tmp_name']) && is_uploaded_file($_FILES['sentFile']['tmp_name'])) {
    $imgFile = $_FILES['sentFile'];
    $imgFile['name'] = replace_dangerous_char($imgFile['name'], 'strict');
    $imgFile['name'] = get_secure_file_name($imgFile['name']);
    if (claro_is_in_a_course()) {
        $enoughSize = enough_size($_FILES['sentFile']['size'], $pathSys, $maxFilledSpace);
    } else {
        $enoughSize = true;
    }
    if (is_image($imgFile['name']) && $enoughSize) {
        // rename if file already exists
        if (file_exists($pathSys . $relativePath . $imgFile['name'])) {
            $pieceList = explode('.', $imgFile['name']);
            $base = $pieceList[0];
            $ext = $pieceList[1];
            $i = 1;
            while (file_exists($pathSys . $relativePath . $base . '_' . $i . '.' . $ext)) {
                $i++;
开发者ID:rhertzog,项目名称:lcs,代码行数:31,代码来源:image.php

示例8: saveOptions

 /**
  * @param array $params
  *
  * @return int
  */
 public function saveOptions($params, $show_query = false)
 {
     $optionInfo = self::get_field_option_by_field_and_option($params['field_id'], $params['option_value']);
     // Use URLify only for new items
     //$optionValue = URLify::filter($params['option_value']);
     $optionValue = replace_dangerous_char($params['option_value']);
     $option = $params['option_value'];
     if ($optionInfo == false) {
         $order = self::get_max_order($params['field_id']);
         $new_params = array('field_id' => $params['field_id'], 'option_value' => trim($optionValue), 'option_display_text' => trim($option), 'option_order' => $order, 'tms' => api_get_utc_datetime());
         return parent::save($new_params, $show_query);
     }
     return false;
 }
开发者ID:annickvdp,项目名称:Chamilo1.9.10,代码行数:19,代码来源:extra_field_option.lib.php

示例9: claro_rename_file

/**
 * Rename a file or a directory
 *
 * @param  - $filePath (string) - complete path of the file or the directory
 * @param  - $newFileName (string) - new name for the file or the directory
 * @return - string  - new file path if it succeeds
 *         - boolean - false otherwise
 * @see    - rename() uses the check_name_exist() and php2phps() functions
 */
function claro_rename_file($oldFilePath, $newFilePath)
{
    if (realpath($oldFilePath) == realpath($newFilePath)) {
        return true;
    }
    /* CHECK IF THE NEW NAME HAS AN EXTENSION */
    if (!is_dir($oldFilePath)) {
        $ext_new = get_file_extension($newFilePath);
        $ext_old = get_file_extension($oldFilePath);
        if (empty($ext_new) && !empty($ext_old)) {
            $newFilePath .= '.' . $ext_old;
        }
    }
    /* PREVENT FILE NAME WITH PHP EXTENSION */
    $newFilePath = get_secure_file_name($newFilePath);
    /* REPLACE CHARACTER POTENTIALY DANGEROUS FOR THE SYSTEM */
    $newFilePath = dirname($newFilePath) . '/' . replace_dangerous_char(basename($newFilePath));
    if (check_name_exist($newFilePath) && $newFilePath != $oldFilePath) {
        return false;
    } else {
        if (check_name_exist($oldFilePath)) {
            if (rename($oldFilePath, $newFilePath)) {
                return $newFilePath;
            } else {
                return false;
            }
        } else {
            return false;
        }
    }
}
开发者ID:rhertzog,项目名称:lcs,代码行数:40,代码来源:fileManage.lib.php

示例10: return_menu

function return_menu()
{
    $navigation = return_navigation_array();
    $navigation = $navigation['navigation'];
    // Displaying the tabs
    $lang = '';
    //el for "Edit Language"
    if (!empty($_SESSION['user_language_choice'])) {
        $lang = $_SESSION['user_language_choice'];
    } elseif (!empty($_SESSION['_user']['language'])) {
        $lang = $_SESSION['_user']['language'];
    } else {
        $lang = get_setting('platformLanguage');
    }
    //Preparing home folder for multiple urls
    if (api_get_multiple_access_url()) {
        $access_url_id = api_get_current_access_url_id();
        if ($access_url_id != -1) {
            $url_info = api_get_access_url($access_url_id);
            $url = api_remove_trailing_slash(preg_replace('/https?:\\/\\//i', '', $url_info['url']));
            $clean_url = replace_dangerous_char($url);
            $clean_url = str_replace('/', '-', $clean_url);
            $clean_url .= '/';
            $homep = api_get_path(SYS_PATH) . 'home/' . $clean_url;
            //homep for Home Path
            //we create the new dir for the new sites
            if (!is_dir($homep)) {
                mkdir($homep, api_get_permissions_for_new_directories());
            }
        }
    } else {
        $homep = api_get_path(SYS_PATH) . 'home/';
    }
    $ext = '.html';
    $menutabs = 'home_tabs';
    $mtloggedin = 'home_tabs_logged_in';
    $home_top = '';
    if (is_file($homep . $menutabs . '_' . $lang . $ext) && is_readable($homep . $menutabs . '_' . $lang . $ext)) {
        $home_top = @(string) file_get_contents($homep . $menutabs . '_' . $lang . $ext);
    } elseif (is_file($homep . $menutabs . $lang . $ext) && is_readable($homep . $menutabs . $lang . $ext)) {
        $home_top = @(string) file_get_contents($homep . $menutabs . $lang . $ext);
    } else {
        //$errorMsg = get_lang('HomePageFilesNotReadable');
    }
    $home_top = api_to_system_encoding($home_top, api_detect_encoding(strip_tags($home_top)));
    $open = str_replace('{rel_path}', api_get_path(REL_PATH), $home_top);
    $open = api_to_system_encoding($open, api_detect_encoding(strip_tags($open)));
    $open_mtloggedin = '';
    if (api_get_user_id() && !api_is_anonymous()) {
        if (is_file($homep . $mtloggedin . '_' . $lang . $ext) && is_readable($homep . $mtloggedin . '_' . $lang . $ext)) {
            $home_top = @(string) file_get_contents($homep . $mtloggedin . '_' . $lang . $ext);
            $home_top = str_replace('::private', '', $home_top);
        } elseif (is_file($homep . $mtloggedin . $lang . $ext) && is_readable($homep . $mtloggedin . $lang . $ext)) {
            $home_top = @(string) file_get_contents($homep . $mtloggedin . $lang . $ext);
            $home_top = str_replace('::private', '', $home_top);
        } else {
            //$errorMsg = get_lang('HomePageFilesNotReadable');
        }
        $home_top = api_to_system_encoding($home_top, api_detect_encoding(strip_tags($home_top)));
        $open_mtloggedin = str_replace('{rel_path}', api_get_path(REL_PATH), $home_top);
        $open_mtloggedin = api_to_system_encoding($open_mtloggedin, api_detect_encoding(strip_tags($open_mtloggedin)));
    }
    $lis = '';
    if (!empty($open) or !empty($open_mtloggedin)) {
        if (strpos($open . $open_mtloggedin, 'show_menu') === false) {
            if (api_is_anonymous()) {
                $navigation[SECTION_CAMPUS] = null;
            }
        } else {
            //$lis .= Display::tag('li', $open);
            if (api_get_user_id() && !api_is_anonymous()) {
                $lis .= $open_mtloggedin;
            } else {
                $lis .= $open;
            }
        }
    }
    if (count($navigation) > 0 || !empty($lis)) {
        $pre_lis = '';
        foreach ($navigation as $section => $navigation_info) {
            $key = !empty($navigation_info['key']) ? 'tab-' . $navigation_info['key'] : '';
            if (isset($GLOBALS['this_section'])) {
                $current = $section == $GLOBALS['this_section'] ? ' id="current" class="active ' . $key . '" ' : ' class="' . $key . '"';
            } else {
                $current = '';
            }
            if (!empty($navigation_info['title'])) {
                $pre_lis .= '<li' . $current . '><a  href="' . $navigation_info['url'] . '" target="_top">' . $navigation_info['title'] . '</a></li>';
            }
        }
        $lis = $pre_lis . $lis;
    }
    $menu = null;
    if (!empty($lis)) {
        $menu .= $lis;
    }
    return $menu;
}
开发者ID:annickvdp,项目名称:Chamilo1.9.10,代码行数:98,代码来源:banner.lib.php

示例11: convert_document

    /**
     * @param string $file
     * @param string $action_after_conversion
     * @return bool|int
     */
    public function convert_document($file, $action_after_conversion = 'make_lp')
    {
        global $_course;
        $this->file_name = pathinfo($file['name'], PATHINFO_FILENAME);
        // Create the directory
        $result = $this->generate_lp_folder($_course, $this->file_name);

         // Create the directory
        $this->base_work_dir = api_get_path(SYS_COURSE_PATH).$_course['path'].'/document';
        ///learning_path/ppt_dirname directory
        $this->created_dir = substr($result['dir'], 0, strlen($result['dir']) -1);
        $this->file_path = $this->created_dir.'/'.replace_dangerous_char($file['name'], 'strict');

        //var_dump($this->file_name, $this->file_path, $this->base_work_dir, $this->created_dir);

        /*
         * Original code
        global $_course, $_user, $_configuration;

        $this->file_name = (strrpos($file['name'], '.') > 0 ? substr($file['name'], 0, strrpos($file['name'], '.')) : $file['name']);
        $this->file_name = replace_dangerous_char($this->file_name, 'strict');
        $this->file_name = strtolower($this->file_name);

        $visio_dir = ($action_after_conversion == 'add_docs_to_visio') ? VIDEOCONF_UPLOAD_PATH : '';

        $this->file_path = $visio_dir.'/'.$this->file_name.'.'.pathinfo($file['name'], PATHINFO_EXTENSION);

        $dir_name = $visio_dir.'/'.$this->file_name;


        // Create the directory.
        $this->base_work_dir = api_get_path(SYS_COURSE_PATH).$_course['path'].'/document';

        $this->created_dir = create_unexisting_directory($_course, $_user['user_id'], api_get_session_id(), 0, 0, $this->base_work_dir, $dir_name);

            var_dump($this->file_name, $this->file_path, $this->base_work_dir, $this->created_dir);

        */

        $ppt2lp_host = api_get_setting('service_ppt2lp', 'host');

        if ($ppt2lp_host == 'localhost') {
            move_uploaded_file($file['tmp_name'], $this->base_work_dir.'/'.$this->file_path);
            //var_dump( $this->base_work_dir.$this->created_dir.$this->file_path);
            $perm = api_get_setting('permissions_for_new_files');

            if (IS_WINDOWS_OS) { // IS_WINDOWS_OS has been defined in main_api.lib.php
                $converter_path = str_replace('/', '\\', api_get_path(SYS_PATH) . 'main/inc/lib/ppt2png');
                $class_path = $converter_path . ';' . $converter_path . '/jodconverter-2.2.2.jar;' . $converter_path . '/jodconverter-cli-2.2.2.jar';
                //$cmd = 'java -cp "'.$class_path.'" DokeosConverter';
                $cmd = 'java -Dfile.encoding=UTF-8 -cp "' . $class_path . '" DokeosConverter';
            } else {
                $converter_path = api_get_path(SYS_PATH) . 'main/inc/lib/ppt2png';
                //$class_path = '-cp .:jodconverter-2.2.1.jar:jodconverter-cli-2.2.1.jar';
                $class_path = ' -Dfile.encoding=UTF-8 -cp .:jodconverter-2.2.2.jar:jodconverter-cli-2.2.2.jar';
                $cmd = 'cd ' . $converter_path . ' && java ' . $class_path . ' DokeosConverter';
            }

            $cmd .= ' -p ' . api_get_setting('service_ppt2lp', 'port');
            // Call to the function implemented by child.
            $cmd .= $this->add_command_parameters();
            // To allow openoffice to manipulate docs.
            @chmod($this->base_work_dir, 0777);
            @chmod($this->base_work_dir.$this->created_dir, 0777);
            @chmod($this->base_work_dir.$this->file_path, 0777);

            $locale = $this->original_locale; // TODO: Improve it because we're not sure this locale is present everywhere.
            putenv('LC_ALL=' . $locale);

            $files = array();
            $return = 0;
            $shell = exec($cmd, $files, $return);

            if ($return != 0) { // If the java application returns an error code.
                switch ($return) {
                    // Can't connect to openoffice.
                    case 1: $this->error = get_lang('CannotConnectToOpenOffice');
                        break;
                    // Conversion failed in openoffice.
                    case 2: $this->error = get_lang('OogieConversionFailed');
                        break;
                    // Conversion can't be launch because command failed.
                    case 255: $this->error = get_lang('OogieUnknownError');
                        break;
                }
                DocumentManager::delete_document($_course, $this->created_dir, $this->base_work_dir);
                return false;
            }
        } else {
            // get result from webservices
            $result = $this->_get_remote_ppt2lp_files($file);
            $result = unserialize($result);
            // Save remote images to server
            chmod($this->base_work_dir.$this->created_dir, api_get_permissions_for_new_directories());
            if (!empty($result['images'])) {
//.........这里部分代码省略.........
开发者ID:annickvdp,项目名称:Chamilo1.9.10,代码行数:101,代码来源:openoffice_document.class.php

示例12: get_lang

             Display::display_footer();
             exit;
         }
     }
 }
 $tool_name = get_lang('Registration', null, !empty($_POST['language']) ? $_POST['language'] : $_user['language']);
 if (api_get_setting('allow_terms_conditions') == 'true' && $user_already_registered_show_terms) {
     $tool_name = get_lang('TermsAndConditions');
 }
 $home = api_get_path(SYS_PATH) . 'home/';
 if (api_is_multiple_url_enabled()) {
     $access_url_id = api_get_current_access_url_id();
     if ($access_url_id != -1) {
         $url_info = api_get_access_url($access_url_id);
         $url = api_remove_trailing_slash(preg_replace('/https?:\\/\\//i', '', $url_info['url']));
         $clean_url = replace_dangerous_char($url);
         $clean_url = str_replace('/', '-', $clean_url);
         $clean_url .= '/';
         $home_old = api_get_path(SYS_PATH) . 'home/';
         $home = api_get_path(SYS_PATH) . 'home/' . $clean_url;
     }
 }
 if (file_exists($home . 'register_top_' . $user_selected_language . '.html')) {
     $home_top_temp = @(string) file_get_contents($home . 'register_top_' . $user_selected_language . '.html');
     $open = str_replace('{rel_path}', api_get_path(REL_PATH), $home_top_temp);
     $open = api_to_system_encoding($open, api_detect_encoding(strip_tags($open)));
     if (!empty($open)) {
         $content = '<div class="well_border">' . $open . '</div>';
     }
 }
 // Forbidden to self-register
开发者ID:annickvdp,项目名称:Chamilo1.9.10,代码行数:31,代码来源:inscription.php

示例13: downloadAllFilesPerUser

/**
 * Downloads all user files per user
 * @param int $userId
 * @param array $courseInfo
 * @return bool
 */
function downloadAllFilesPerUser($userId, $courseInfo)
{
    $userInfo = api_get_user_info($userId);

    if (empty($userInfo) || empty($courseInfo)) {
        return false;
    }

    require_once api_get_path(LIBRARY_PATH).'pclzip/pclzip.lib.php';
    $tempZipFile = api_get_path(SYS_ARCHIVE_PATH).api_get_unique_id().".zip";
    $coursePath = api_get_path(SYS_COURSE_PATH).$courseInfo['path'].'/work/';

    $zip  = new PclZip($tempZipFile);

    $workPerUser = getWorkPerUser($userId);

    if (!empty($workPerUser)) {
        $files = array();
        foreach ($workPerUser as $work) {
            $work = $work['work'];
            foreach ($work->user_results as $userResult) {
                if (empty($userResult['url']) || empty($userResult['contains_file'])) {
                    continue;
                }
                $data = getFileContents($userResult['id'], $courseInfo);
                if (!empty($data) && isset($data['path'])) {
                    $files[basename($data['path'])] = array(
                        'title' => $data['title'],
                        'path' => $data['path']
                    );
                }
            }
        }

        if (!empty($files)) {
            Session::write('files', $files);
            foreach ($files as $data) {
                $zip->add(
                    $data['path'],
                    PCLZIP_OPT_REMOVE_PATH,
                    $coursePath,
                    PCLZIP_CB_PRE_ADD,
                    'preAddAllWorkStudentCallback'
                );
            }
        }

        // Start download of created file
        $name = basename(replace_dangerous_char($userInfo['complete_name'])).'.zip';
        event_download($name.'.zip (folder)');
        if (Security::check_abs_path($tempZipFile, api_get_path(SYS_ARCHIVE_PATH))) {
            DocumentManager::file_send_for_download($tempZipFile, true, $name);
            @unlink($tempZipFile);
            exit;
        }
    }
    exit;
}
开发者ID:annickvdp,项目名称:Chamilo1.9.10,代码行数:64,代码来源:work.lib.php

示例14: api_get_path

        $work_temp = api_get_path(SYS_ARCHIVE_PATH).api_get_unique_id().'_'.$filename;
        file_put_contents($work_temp, $not_deleted_file['description']);
        $files[basename($work_temp)] = $filename;
        $addStatus = $zip_folder->add(
            $work_temp,
            PCLZIP_OPT_REMOVE_PATH,
            api_get_path(SYS_ARCHIVE_PATH),
            PCLZIP_CB_PRE_ADD,
            'my_pre_add_callback'
        );
        @unlink($work_temp);
    }
}

if (!empty($files)) {
    $fileName = replace_dangerous_char($work_data['title']);
    // Logging
    event_download($fileName .'.zip (folder)');

    //start download of created file
    $name = $fileName .'.zip';
    if (Security::check_abs_path($temp_zip_file, api_get_path(SYS_ARCHIVE_PATH))) {
        DocumentManager::file_send_for_download($temp_zip_file, true, $name);
        @unlink($temp_zip_file);
        exit;
    }
} else {
    exit;
}

/*	Extra function (only used here) */
开发者ID:annickvdp,项目名称:Chamilo1.9.10,代码行数:31,代码来源:downloadfolder.inc.php

示例15: store_add_dropbox

/**
 * @return array|null|string
 */
function store_add_dropbox()
{
    $_course = api_get_course_info();
    $_user = api_get_user_info();
    $dropbox_cnf = getDropboxConf();
    // Validating the form data
    // there are no recipients selected
    if (!isset($_POST['recipients']) || count($_POST['recipients']) <= 0) {
        return get_lang('YouMustSelectAtLeastOneDestinee');
    } else {
        // Check if all the recipients are valid
        $thisIsAMailing = false;
        $thisIsJustUpload = false;
        foreach ($_POST['recipients'] as $rec) {
            if ($rec == 'mailing') {
                $thisIsAMailing = true;
            } elseif ($rec == 'upload') {
                $thisIsJustUpload = true;
            } elseif (strpos($rec, 'user_') === 0 && !isCourseMember(substr($rec, strlen('user_')))) {
                return get_lang('InvalideUserDetected');
            } elseif (strpos($rec, 'group_') !== 0 && strpos($rec, 'user_') !== 0) {
                return get_lang('InvalideGroupDetected');
            }
        }
    }
    // we are doing a mailing but an additional recipient is selected
    if ($thisIsAMailing && count($_POST['recipients']) != 1) {
        return get_lang('MailingSelectNoOther');
    }
    // we are doing a just upload but an additional recipient is selected.
    // note: why can't this be valid? It is like sending a document to yourself AND to a different person (I do this quite often with my e-mails)
    if ($thisIsJustUpload && count($_POST['recipients']) != 1) {
        return get_lang('MailingJustUploadSelectNoOther');
    }
    if (empty($_FILES['file']['name'])) {
        $error = true;
        return get_lang('NoFileSpecified');
    }
    // are we overwriting a previous file or sending a new one
    $dropbox_overwrite = false;
    if (isset($_POST['cb_overwrite']) && $_POST['cb_overwrite']) {
        $dropbox_overwrite = true;
    }
    // doing the upload
    $dropbox_filename = $_FILES['file']['name'];
    $dropbox_filesize = $_FILES['file']['size'];
    $dropbox_filetype = $_FILES['file']['type'];
    $dropbox_filetmpname = $_FILES['file']['tmp_name'];
    // check if the filesize does not exceed the allowed size.
    if ($dropbox_filesize <= 0 || $dropbox_filesize > $dropbox_cnf['maxFilesize']) {
        return get_lang('DropboxFileTooBig');
        // TODO: The "too big" message does not fit in the case of uploading zero-sized file.
    }
    // check if the file is actually uploaded
    if (!is_uploaded_file($dropbox_filetmpname)) {
        // check user fraud : no clean error msg.
        return get_lang('TheFileIsNotUploaded');
    }
    $upload_ok = process_uploaded_file($_FILES['file'], true);
    if (!$upload_ok) {
        return null;
    }
    // Try to add an extension to the file if it hasn't got one
    $dropbox_filename = add_ext_on_mime($dropbox_filename, $dropbox_filetype);
    // Replace dangerous characters
    $dropbox_filename = replace_dangerous_char($dropbox_filename);
    // Transform any .php file in .phps fo security
    $dropbox_filename = php2phps($dropbox_filename);
    //filter extension
    if (!filter_extension($dropbox_filename)) {
        return get_lang('UplUnableToSaveFileFilteredExtension');
    }
    // set title
    $dropbox_title = $dropbox_filename;
    // set author
    if (!isset($_POST['authors'])) {
        $_POST['authors'] = getUserNameFromId($_user['user_id']);
    }
    // note: I think we could better migrate everything from here on to separate functions: store_new_dropbox, store_new_mailing, store_just_upload
    if ($dropbox_overwrite) {
        $dropbox_person = new Dropbox_Person($_user['user_id'], api_is_course_admin(), api_is_course_tutor());
        foreach ($dropbox_person->sentWork as $w) {
            if ($w->title == $dropbox_filename) {
                if ($w->recipients[0]['id'] > dropbox_cnf('mailingIdBase') xor $thisIsAMailing) {
                    return get_lang('MailingNonMailingError');
                }
                if ($w->recipients[0]['id'] == $_user['user_id'] xor $thisIsJustUpload) {
                    return get_lang('MailingJustUploadSelectNoOther');
                }
                $dropbox_filename = $w->filename;
                $found = true;
                // note: do we still need this?
                break;
            }
        }
    } else {
        // rename file to login_filename_uniqueId format
//.........这里部分代码省略.........
开发者ID:annickvdp,项目名称:Chamilo1.9.10,代码行数:101,代码来源:dropbox_functions.inc.php


注:本文中的replace_dangerous_char函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。