コード例 #1
0
function media_filename($string)
{
    require_once LEPTON_PATH . '/framework/summary.utf8.php';
    $string = entities_to_7bit($string);
    // Now remove all bad characters
    $bad = array('\'', '"', '`', '!', '@', '#', '$', '%', '^', '&', '*', '=', '+', '|', '/', '\\', ';', ':', ',', '?');
    $string = str_replace($bad, '', $string);
    // replace multiple dots in filename to single dot and (multiple) dots at the end of the filename to nothing
    $string = preg_replace(array('/\\.+/', '/\\.+$/', '/\\s/'), array('.', '', '_'), $string);
    // Clean any page spacers at the end of string
    $string = trim($string);
    // Finally, return the cleaned string
    return $string;
}
コード例 #2
0
/**
 *	Function to convert a page title to a page filename.
 *	
 */
function page_filename($string)
{
    require_once LEPTON_PATH . '/framework/functions/function.entities_to_7bit.php';
    $string = entities_to_7bit($string);
    // $string = page_filename_2($string);
    // Now remove all bad characters
    $bad = array('\'', '"', '`', '!', '@', '#', '$', '%', '^', '&', '*', '=', '+', '|', '/', '\\', ';', ':', ',', '?');
    $string = str_replace($bad, '', $string);
    // replace multiple dots in filename to single dot and (multiple) dots at the end of the filename to nothing
    $string = preg_replace(array('/\\.+/', '/\\.+$/'), array('.', ''), $string);
    // Now replace spaces with page spcacer
    $string = trim($string);
    $string = preg_replace('/(\\s)+/', PAGE_SPACER, $string);
    // Now convert to lower-case
    $string = strtolower($string);
    // If there are any weird language characters, this will protect us against possible problems they could cause
    $string = str_replace(array('%2F', '%'), array('/', ''), urlencode($string));
    // Finally, return the cleaned string
    return $string;
}
コード例 #3
0
ファイル: Directory.php プロジェクト: ircoco/BlackCatCMS
 /**
  * convert string to a valid filename
  *
  * @access public
  * @param  string  $string - filename
  * @return string
  **/
 public static function sanitizeFilename($string)
 {
     require_once CAT_PATH . '/framework/functions-utf8.php';
     $string = entities_to_7bit($string);
     // remove all bad characters
     $bad = array('\'', '"', '`', '!', '@', '#', '$', '%', '^', '&', '*', '=', '+', '|', '/', '\\', ';', ':', ',', '?', '(', ')');
     $string = str_replace($bad, '', $string);
     // replace multiple dots in filename to single dot and (multiple) dots at the end of the filename to nothing
     $string = preg_replace(array('/\\.+/', '/\\.+$/'), array('.', ''), $string);
     // replace spaces
     $string = trim($string);
     $string = preg_replace('/(\\s)+/', '_', $string);
     // replace any weird language characters
     $string = str_replace(array('%2F', '%'), array('/', ''), urlencode($string));
     // remove path
     $string = pathinfo($string, PATHINFO_FILENAME);
     // Finally, return the cleaned string
     return $string;
 }
コード例 #4
0
ファイル: functions.php プロジェクト: ircoco/BlackCatCMS
/**
 *
 **/
function getLanguages()
{
    $langs = CAT_Helper_Addons::get_addons(0, 'language');
    $data = array();
    foreach ($langs as $addon) {
        $l_codes[$addon['NAME']] = $addon['VALUE'];
        $l_names[$addon['NAME']] = entities_to_7bit($addon['NAME']);
        // sorting-problem workaround
    }
    asort($l_names);
    $counter = 0;
    foreach ($l_names as $l_name => $v) {
        $data[$counter]['CODE'] = $l_codes[$l_name];
        $data[$counter]['NAME'] = $l_name;
        $data[$counter]['SELECTED'] = DEFAULT_LANGUAGE == $l_codes[$l_name] ? true : false;
        $counter++;
    }
    return $data;
}
コード例 #5
0
function opf_clean_filename($filename, $ascii = FALSE)
{
    $filename = preg_replace('~[][ /\\\\%#&:;`|*?!=\\~<>^(){}$,\'\\x00-\\x1f\\x7f"]~', '_', $filename);
    if ($ascii) {
        require_once WB_PATH . '/framework/functions-utf8.php';
        $filename = entities_to_7bit($filename);
    }
    return trim($filename);
}
コード例 #6
0
    $template->set_var('NAME', $name);
    $template->set_var('VALUE', $number);
    if ($results_array['menu'] == $number) {
        $template->set_var('SELECTED', ' selected="selected"');
    } else {
        $template->set_var('SELECTED', '');
    }
    $template->parse('menu_list', 'menu_list_block', true);
}
// Insert language values
$template->set_block('main_block', 'language_list_block', 'language_list');
$sql = 'SELECT * FROM `' . TABLE_PREFIX . 'addons` WHERE `type` = "language" ORDER BY `name`';
if ($res_languages = $database->query($sql)) {
    while ($rec_language = $res_languages->fetchRow(MYSQLI_ASSOC)) {
        $l_codes[$rec_language['name']] = $rec_language['directory'];
        $l_names[$rec_language['name']] = entities_to_7bit($rec_language['name']);
        // sorting-problem workaround
    }
    asort($l_names);
    foreach ($l_names as $l_name => $v) {
        $langIcons = empty($l_codes[$l_name]) ? 'none' : strtolower($l_codes[$l_name]);
        // Insert code and name
        $template->set_var(array('VALUE' => $l_codes[$l_name], 'NAME' => $l_name, 'FLAG_LANG_ICONS' => 'url(' . THEME_URL . '/images/flags/' . $langIcons . '.png)'));
        // Check if it is selected
        if ($results_array['language'] == $l_codes[$l_name]) {
            $template->set_var('SELECTED', ' selected="selected"');
        } else {
            $template->set_var('SELECTED', '');
        }
        $template->parse('language_list', 'language_list_block', true);
    }