Esempio n. 1
0
/**
*	This is an XML HTML template library.
*	Include/require it in your code to use its functionality.
*
*   This library defines function xht_htmlwchars & class xhtdoc with methods:
*   - xht_fill_template($template_name)
*   - xht_substitute($subtext)
*
*   Check htt_error after defining a new xhtdoc(htt_file_contents).
*
*   Assign xht_xmldoc (, xht_get_lang, xht_resource, xht_dbgn)
*   before calling the class methods.
*
*	@package chamilo.library
*/
function xht_htmlwchars($s)
{
    //return ereg_replace('\[((/?(b|big|i|small|sub|sup|u))|br/)\]', '<\\1>',
    //    str_replace('@�@', '&',
    //    htmlspecialchars(ereg_replace('&#([0-9]+);', '@�@#\\1;', $s))));
    global $charset;
    return api_ereg_replace('\\[((/?(b|big|i|small|sub|sup|u))|br/)\\]', '<\\1>', str_replace('@�@', '&', htmlspecialchars(api_ereg_replace('&#([0-9]+);', '@�@#\\1;', $s), ENT_QUOTES, $charset)));
    // replaces htmlspecialchars for double-escaped xml chars like '&amp;#nnn;'
    // and                       when html tags <...> are represented as [...]
}
/**
 * creates the folder (if needed) and uploads the stylesheet in it
 *
 * @param array $values the values of the form
 * @param array $picture the values of the uploaded file
 * 
 * @author Patrick Cool <*****@*****.**>, Ghent University, Belgium
 * @version May 2008
 * @since Dokeos 1.8.5
 */
function upload_stylesheet($values, $picture)
{
    // valid name for the stylesheet folder
    $style_name = api_ereg_replace("[^A-Za-z0-9]", "", $values['name_stylesheet']);
    // create the folder if needed
    if (!is_dir(api_get_path(SYS_CODE_PATH) . 'css/' . $style_name . '/')) {
        if (mkdir(api_get_path(SYS_CODE_PATH) . 'css/' . $style_name . '/')) {
            $perm = api_get_setting('permissions_for_new_directories');
            $perm = octdec(!empty($perm) ? $perm : '0770');
            chmod(api_get_path(SYS_CODE_PATH) . 'css/' . $style_name . '/', $perm);
        }
    }
    // move the file in the folder
    move_uploaded_file($picture['tmp_name'], api_get_path(SYS_CODE_PATH) . 'css/' . $style_name . '/' . $picture['name']);
}