function categories_header()
{
    /*
    echo "<pre>";
    var_dump(process_categories($_GET['categories']));
    echo "</pre>";
    */
    global $cfgrow, $pixelpost_db_prefix;
    if ($_GET['x'] == "save" and isset($_POST['categories'])) {
        if (isset($_POST['categories'])) {
            $tags = process_categories($_POST['categories']);
            #echo "Pass #3 of 3<BR>\n";
            #	echo "EXECUTE MYSQL TAGS!!!";
            unset($_POST['category']);
            $categories = categories_array(false);
            $i = 0;
            while ($i < count($tags)) {
                $cat_id = array_search(strtolower($tags[$i]), $categories);
                if ($cat_id) {
                    $category[] = $cat_id;
                } elseif (CREATECAT == true) {
                    $query = "INSERT INTO " . $pixelpost_db_prefix . "categories(id,name) VALUES(NULL,'" . $tags[$i] . "')";
                    $result = mysql_query($query) || die("Error: " . mysql_error());
                    $cat_id = mysql_insert_id();
                    $category[] = $cat_id;
                }
                $i++;
            }
            // subsetude tags for categories
            $_POST['category'] = $category;
        }
    }
}
Example #2
0
//=============================================================================================
// Generate and Write KML and KMZ files to uploads directory
//=============================================================================================
// TOD: Add something to check if new incidents have come in and re-create files only if needed?
// If file was modified in last X=$cache_time seconds (and debug mode off), don't bother re-generating
if (file_exists($kmzFileName) && time() - filemtime($kmzFileName) < $cache_secs && $cache_on) {
    //if (file_exists($kmzFileName) && (time() - filemtime($kmzFileName) < $cache_secs) && $debug_cache_off = false) {
    kohana::log('info', "returning cached kmz");
} else {
    // older, so generate a new one
    kohana::log('info', "generating new kml and kmz files");
    $kmlFile = fopen($kmlFileName, "w");
    if (flock($kmlFile, LOCK_EX)) {
        // do an exclusive lock
        kohana::log('info', "Got lock on {$kmlFileName}");
        process_categories($kmlFile, $categories, $catID_icons, $kml_styles, $catID_data, $cat_to_subcats, $options);
        write_kml_head($kmlFile, $kml_name, $kml_tagline, $options);
        fwrite($kmlFile, $kml_styles);
        write_kml_data($kmlFile, $items, $catID_to_incidents, $cat_to_subcats, $catID_data, $catID_icons, $logo, $options);
        write_kml_foot($kmlFile);
        flock($kmlFile, LOCK_UN);
        // release the lock
        fclose($kmlFile);
        kohana::log('info', " ...locked and closed {$kmlFileName}");
        $kmz = create_kmz($kmlFileName, $kmzFileName);
    } else {
        kohana::log('error', "Couldn't lock {$kmlFileName}");
    }
}
//=== Read file out to user ==
//readfile($kmlFileName);
Example #3
0
function child_categories($category_id)
{
    return process_categories("SELECT * FROM `cms_categories` WHERE `parent` = '{$category_id}' ORDER BY `name`");
}