Example #1
0
function rebuild_cat_file()
{
    global $system, $main_path, $DBPrefix;
    $query = "SELECT cat_id, cat_name, parent_id FROM " . $DBPrefix . "categories ORDER BY cat_name";
    $result = mysql_query($query);
    $cats = array();
    while ($catarr = mysql_fetch_array($result)) {
        $cats[$catarr['cat_id']] = $catarr['cat_name'];
        $allcats[] = $catarr;
    }
    $output = "<?php\n";
    $output .= "\$" . "category_names = array(\n";
    $num_rows = count($cats);
    $i = 0;
    foreach ($cats as $k => $v) {
        $output .= "{$k} => '{$v}'";
        $i++;
        if ($i < $num_rows) {
            $output .= ",\n";
        } else {
            $output .= "\n";
        }
    }
    $output .= ");\n\n";
    $output .= "\$" . "category_plain = array(\n0 => ''";
    $output .= search_cats(0, 0);
    $output .= ");\n?>";
    $handle = fopen($main_path . 'language/' . $system->SETTINGS['defaultlanguage'] . '/categories.inc.php', 'w');
    fputs($handle, $output);
}
function rebuild_cat_file($cats)
{
    global $language, $main_path;
    $output = "<?php\n";
    $output .= "\$" . "category_names = array(\n";
    $num_rows = count($cats);
    $i = 0;
    foreach ($cats as $k => $v) {
        $v = str_replace("'", "\\'", $v);
        $output .= "{$k} => '{$v}'";
        $i++;
        if ($i < $num_rows) {
            $output .= ",\n";
        } else {
            $output .= "\n";
        }
    }
    $output .= ");\n\n";
    $output .= "\$" . "category_plain = array(\n0 => ''";
    $output .= search_cats(0, 0);
    $output .= ");\n?>";
    $handle = fopen($main_path . 'language/' . $language . '/categories.inc.php', 'w');
    fputs($handle, $output);
    fclose($handle);
}
Example #3
0
function rebuild_cat_file()
{
    global $system, $DBPrefix, $db;
    $query = "SELECT cat_id, cat_name, parent_id FROM " . $DBPrefix . "categories ORDER BY cat_name";
    $db->direct_query($query);
    $cats = array();
    while ($catarr = $db->fetch()) {
        $cats[$catarr['cat_id']] = $catarr['cat_name'];
        $allcats[] = $catarr;
    }
    $output = "<?php\n";
    $output .= "\$" . "category_names = " . var_export($cats, true) . ";\n\n";
    $output .= "\$" . "category_plain = " . var_export(search_cats(0, 0), true) . ";\n";
    $handle = fopen(MAIN_PATH . 'language/' . $system->SETTINGS['defaultlanguage'] . '/categories.inc.php', 'w');
    fputs($handle, $output);
}