unknowns = 'remove_nonjs'; $tpl->set_root(TPL_PATH); $tpl->set_file('main', $tpl_file, 1); return $tpl; } // // finish parsing template and print it // function tpl_end($tpl, // template $title='') // page title { $tpl->set_var('PAGE_TITLE', $title); print $tpl->process('', 'main', 1); } // // Save uploaded file to specified dir // function save_file($path, $file, $filename){ $error = ""; // get name and extension of the file ereg("(.*)(\..+)$", $filename, $regs); $filename_base = $regs[1]; $filename_ext = $regs[2]; // create unique filename $version = 0; $new_filename = ROOT_PATH . $path . $filename_base . $filename_ext; //echo $new_filename; while(file_exists($new_filename)){ $version++; $new_filename = ROOT_PATH . $path . $filename_base . $version . $filename_ext; } @copy($file, $new_filename); if ($version > 0) { $new_filename = $filename_base. $version. $filename_ext; } else { $new_filename = $filename_base. $filename_ext; } return array($error, $new_filename); } // // get category data from db // function get_supercat_title($s_id){ global $db_tables, $lang; // get category $query = "SELECT title_$lang as title FROM $db_tables[supercat] WHERE s_id='$s_id'"; $result = mysql_query($query) //or die("db error: can't retrieve supercategory data"); or die(mysql_error()); $row = mysql_fetch_array($result); // or die("db error: get supercat title"); return $row['title']; } // // check if variable is set and not empty // function valid($a){ if (isset($a)) if (!empty($a)) return true; return false; } function set_language () { // select language if (isset($_GET['lang'])) { switch (strtolower($_GET['lang'])) { case 'lt': $lang = 'lt'; $charset = 'UTF-8'; break; case 'en': $lang = 'en'; $charset = 'UTF-8'; break; case 'ru': $lang = 'ru'; $charset = 'UTF-8'; break; /* case 'de': $lang = 'de'; $charset = 'windows-1250'; break; */ default: $lang = DEFAULT_LANGUAGE; $charset = DEFAULT_CHARSET; } } else { $lang = DEFAULT_LANGUAGE; $charset = DEFAULT_CHARSET; } return array($lang, $charset); } // clean data from slashes and escape htmls spec chars // function slash_clean($data){ if (is_array($data)) { foreach (array_keys($data) as $key){ $data[$key] = htmlspecialchars(stripslashes($data[$key])); } } else { $data = htmlspecialchars(stripslashes($data)); } return $data; } // print language select // function select_lang(){ global $data, $tpl, $lang; $tpl->set_file('lang_select_file', '/admin/select_lang.tpl.html'); $tpl->set_var("select_$lang", 'selected'); $tpl->process("select_lang", 'lang_select_file'); } ?>