Location: PHPKode > projects > ZompLog > admin/functions.php
<?php

error_reporting("E_ALL & ~E_NOTICE");


/* Written by Gerben Schmidt, http://scripts.zomp.nl */

function connectToDB() {
	global $link, $dbhost, $dbuser, $dbpass, $dbname;
	
	($link = mysql_connect("$dbhost", "$dbuser", "$dbpass")) || die("Something went wrong... <br /><br />I think you didn't fill out the right database-host, database user or database password. Check your database-settings in config.php<br /><br />");

	mysql_select_db("$dbname", $link) || die("Something went wrong... <br /><br />I think you didn't fill out the right database-name. Are you sure the database you're trying to connect to, exists? Check your database-settings in config.php<br /><br />
	Here's the good news: you DID fill out the other settings correctly, because Zomplog was able to connect to your database host, using the username and password you provided!<br /><br />" );
}

// load multiple rows into array
function arrayMaker($result)
{
   $res_array = array();

   for ($count=0; $row = @mysql_fetch_array($result); $count++)
     $res_array[$count] = $row;

   return $res_array;
}

// this is a security fix for anyone not using magic quotes
if (!ini_get('magic_quotes_gpc'))
{
$_GET = array_map('addslashes', $_GET);
$_POST = array_map('addslashes', $_POST);
}


function tableExists($table_name)
         {
         $Table = mysql_query("show tables like '" . $table_name . "'");
         
         if(mysql_fetch_row($table) === false)
            return(false);
         
         return(true);
         }

// load system settings
function loadSettings($link,$table_settings){
$query = "SELECT * FROM $table_settings";
$result = mysql_query($query,$link) or die("Go to the <a href='install'>installer page</a> to install Zomplog.");
return mysql_fetch_array($result,MYSQL_ASSOC);
}

// load moblog settings
function loadMoblogSettings($link,$table_moblog){
$query = "SELECT * FROM $table_moblog";
$result = mysql_query($query,$link) or die("Could not load system settings.");
return mysql_fetch_array($result,MYSQL_ASSOC);
}

// load theme settings
function loadThemeSettings($link,$table_themes,$settings){
$query = "SELECT * FROM $table_themes WHERE name = '$settings[skin]'";
$result = mysql_query($query,$link) or die("Go to the <a href='install'>installer page</a> to install Zomplog.");
return mysql_fetch_array($result,MYSQL_ASSOC);
}


function firstwords($str,$wordcount) {
$words=preg_split('/([\s.,;]+)/',$str,$wordcount+1,PREG_SPLIT_DELIM_CAPTURE);
array_pop($words);
return(implode('',$words));
}



/* ------------------------ users -------------------------- */

// create new user
function newUser($birthday) {

	global $link, $table_users;

	$password = md5($_POST[password]);

	$query="INSERT INTO $table_users (login, password, admin, email, name, adress, zip, country, gender, birthday) VALUES('$_POST[login]', '$password', '$_POST[admin]', '$_POST[email]', '$_POST[name]', '$_POST[adress]', '$_POST[zip]', '$_POST[country]', '$_POST[gender]', '$birthday')";
	$result=mysql_query($query, $link) or die("Died inserting login info into db.  Error returned if any: ".mysql_error());

	return true;

}  

// load user information
function loadUser($username,$link,$table_users){
// protect against SQL-injection
$username = htmlspecialchars($username);
$query = "SELECT * FROM $table_users WHERE login = '$username'";
$result = mysql_query($query,$link) or die("Could not load userdata.");
return mysql_fetch_array($result,MYSQL_ASSOC);
}


// update user, except password
function updateUser($userid,$link,$table_users) {
	$query="UPDATE $table_users SET name = '$_POST[name]', email = '$_POST[email]', about = '$_POST[about]', adress = '$_POST[adress]', zip = '$_POST[zip]', country = '$_POST[country]', birthday = '$_POST[birthday]', gender = '$_POST[gender]', interests = '$_POST[interests]', image = '$_POST[image]', movie = '$_POST[movie]', url = '$_POST[url]' WHERE id = '$userid'";
	$result=mysql_query($query, $link) or die("Died inserting data into db.  Error returned if any: ".mysql_error());
	return true;
} 

// update password only
function updatePass($userid,$link,$table_users) {
$password = md5($_POST[password]);
	$query="UPDATE $table_users SET password = '$password' WHERE id = '$userid'";
	$result=mysql_query($query, $link) or die("Died inserting data into db.  Error returned if any: ".mysql_error());
	return true;
} 


/* ------------------------ entries -------------------------- */

// create new entry
function newEntry($username,$image,$imagewidth,$imageheight,$date) {

	global $link, $table, $date;

	$query="INSERT INTO $table (title, text, extended, image, imagewidth, imageheight, align, mediafile, mediatype, catid, username, date, teaser) VALUES ('$_POST[title]', '$_POST[text]', '$_POST[extended]', '$image', '$imagewidth', '$imageheight', '$_POST[align]', '$_POST[mediafile]', '$_POST[mediatype]', '$_POST[catid]', '$username', '$date', '$_POST[teaser]')";
	$result=mysql_query($query, $link) or die("Died inserting login info into db.  Error returned if any: ".mysql_error());

	return true;
} 

// update entry
function editEntry($link,$table,$image,$imagewidth,$imageheight,$thedate,$entryid,$expirydate) {
	$query="UPDATE $table SET date = '$thedate', title = '$_POST[title]', text = '$_POST[text]', extended = '$_POST[extended]', image = '$image', align = '$_POST[align]', mediafile = '$_POST[mediafile]', mediatype = '$_POST[mediatype]', catid = '$_POST[catid]', teaser = '$_POST[teaser]', podcast = '$_POST[podcast]', expirydate = '$expirydate' WHERE id = '$entryid'";
	$result=mysql_query($query, $link) or die("Died inserting data into db.  Error returned if any: ".mysql_error());
	return true;
} 

function loadEntries($link,$table) {

	$query = "SELECT * FROM $table ORDER BY id DESC";
	$result = mysql_query ($query, $link) or die("Died getting info from db.  Error returned if any: ".mysql_error());
	return arrayMaker($result,MYSQL_ASSOC);
}

function loadEntry($link,$table) {
$theid = 1; // if the parameter is not numeric (possible hacking attempt), the script defaults to 1
if(is_numeric($_GET['id'])){ 
$theid =  $_GET['id'];
}
	$query = "SELECT * FROM $table WHERE id = '$theid'";
	$result = mysql_query ($query, $link) or die("Died getting info from db.  Error returned if any: ".mysql_error());
	return mysql_fetch_array($result,MYSQL_ASSOC);
}

/* ------------------------ categories -------------------------- */

// create new category
function newCat($link,$table_cat) {

	$query="INSERT INTO $table_cat (name) VALUES ('$_POST[catname]')";
	$result=mysql_query($query, $link) or die("Died inserting category info into db.  Error returned if any: ".mysql_error());

	return true;
} 

// update categories
function changeCat($link,$table_cat) {
	$query="UPDATE $table_cat SET name = '$_POST[catname]' WHERE id = '$_POST[id]'";
	$result=mysql_query($query, $link) or die("Died inserting data into db.  Error returned if any: ".mysql_error());
	return true;
} 

function loadCat($link,$table_cat) {
$query = "SELECT * FROM $table_cat ORDER BY catorder";
	$result = mysql_query ($query, $link) or die("Died getting info from db.  Error returned if any: ".mysql_error());
	return arrayMaker($result,MYSQL_ASSOC);
}

// list single category
function loadOnecat($link,$table_cat) {
$theid = 1; // if the parameter is not numeric (possible hacking attempt), the script defaults to 1
if(is_numeric($_GET['catid'])){ 
$theid =  $_GET['catid'];
}
	$query = "SELECT * FROM $table_cat WHERE id = '$theid'";
	$result = mysql_query ($query, $link) or die("Died getting info from db.  Error returned if any: ".mysql_error());
	return mysql_fetch_array($result,MYSQL_ASSOC);
}

/* ------------------------ comments -------------------------- */

// create new comment
function newComment($link,$table_comments,$date) {

// filter out html or javascript
$thename = htmlspecialchars($_POST[name], ENT_QUOTES);
$thecomment = htmlspecialchars($_POST[comment], ENT_QUOTES);

$theid = 1; // if the parameter is not numeric (possible hacking attempt), the script defaults to 1
if(is_numeric($_GET['id'])){ 
$theid =  $_GET['id'];
}

	$query="INSERT INTO $table_comments (entry_id, name, comment, date, ip) VALUES ('$theid', '$thename', '$thecomment', '$date', '$_SERVER[REMOTE_ADDR]')";
	$result=mysql_query($query, $link) or die("Died inserting category info into db.  Error returned if any: ".mysql_error());

	return true;
}

// update categories
function changeComment($id,$link,$table_comments) {
	$query="UPDATE $table_comments SET name = '$_POST[name]', comment = '$_POST[comment]' WHERE id = '$id'";
	$result=mysql_query($query, $link) or die("Died inserting data into db.  Error returned if any: ".mysql_error());
	return true;
} 

function loadComments($entryid,$link,$table_comments) {
	$query = "SELECT * FROM $table_comments WHERE entry_id = $entryid ORDER by id ASC";
	$result = mysql_query ($query, $link) or die("Died getting info from db.  Error returned if any: ".mysql_error());
	return arrayMaker($result,MYSQL_ASSOC);
}

function loadOneComment($id,$link,$table_comments) {
$theid = 1; // if the parameter is not numeric (possible hacking attempt), the script defaults to 1
if(is_numeric($id)){ 
$theid =  $id;
}
	$query = "SELECT * FROM $table_comments WHERE id = '$theid'";
	$result = mysql_query ($query, $link) or die("Died getting info from db.  Error returned if any: ".mysql_error());
	return mysql_fetch_assoc($result);
}

function loadAllComments($link,$table_comments) {
	$query = "SELECT * FROM $table_comments ORDER by id DESC";
	$result = mysql_query ($query, $link) or die("Died getting info from db.  Error returned if any: ".mysql_error());
	return arrayMaker($result,MYSQL_ASSOC);
}





/* ------------------------ other -------------------------- */

/* create menutabs in header for categories and/or pages */
function showMenuTabs(){
global $settings, $link;
	if (($settings[categories]) or ($settings[pages])) {
		echo "<div id=\"menutabs\" class=\"menutabs\"><ul>";
		// start display of categories  -  if you want the categories to be displayed in the sidemenu and not in the header, then remove these lines and activate the appropriate lines in file layout/menu.php
		if ($settings[categories]) {
			displayCategoriesList(' ');
		}
		// end display of categories
		//start display of pages  -  if you want the pages to be displayed in the sidemenu and not in the header, then remove these lines and activate the appropriate lines in file layout/menu.php
		if ($settings[pages]){
			displayPagesList(' ');
		}
		// end display of pages
		echo "</ul></div>";
	}
}


/* check if the theme uses its own (modified) menu.php file */
function showMenu(){
global $settings, $link;

// ok, workaround: we need to have the language variables available
//include("admin/functions.php");
include("admin/config.php");
include("language/".$settings['language'].".php");


if (file_exists("themes/".$settings['skin']."/menu.php")) 
	{
		include("themes/".$settings['skin']."/menu.php");
	}
	else
	{
		include("layout/menu.php");
	}
}

/* check if the theme uses its own (modified) navbar.php file */
function showNavBar(){
global $settings, $display, $numrows, $limit, $scroll;

// ok, workaround: we need to have the language variables available
include("language/".$settings['language'].".php");


if (file_exists("themes/".$settings['skin']."/navbar.php")) 
	{
		include("themes/".$settings['skin']."/navbar.php");
	}
	else
	{
		include("layout/navbar.php");
	}
}


// testing...
function showContent(){
global $settings, $link, $content;
include("content.php");
}

/* check if the theme uses its own (modified) content.php file */
function fetchContentpath($contentpath) {
	global $contentpath;
	if (!file_exists($contentpath)) {
		$contentpath = "layout/content.php";
	}
}



/* errors */

function displayErrors($messages) {
global $lang_something_wrong;
?>
<table width="100%" style='border:#CC6600 solid; border-width: 5px 0px 0px 0px; padding: 5px 5px 0px 5px;' class="text">
  <tr>
    <td><?php echo "$lang_something_wrong"; ?><ul style="list-style-type:disc; list-style-position:outside">
	<?php
		foreach($messages as $msg){
		print("<li>$msg</li>\n");
	}
	print("</ul>\n");
	?>
	
	</td>
  </tr>
  </table>

  <?php
}

function displayMessage($message) {
global $lang_error1, $lang_error2, $lang_error3, $lang_error4, $lang_error5, $lang_error6, $lang_error7, $lang_error8, $lang_error9, $lang_error10, $lang_error11, $lang_error12, $lang_error13;
switch($message){
	
	case 1:
	$message = "$lang_error1";
	break;
	
	case 2:
	$message = "$lang_error2";
	break;

	case 3:
	$message = "$lang_error3";
	break;

	case 4:
	$message = "$lang_error4";
	break;
	
	case 5:
	$message = "$lang_error5";
	break;
	
	case 6:
	$message = "$lang_error6";
	break;
	
	case 7:
	$message = "$lang_error7";
	break;
	
	case 8:
	$message = "$lang_error8";
	break;
	
	case 9:
	$message = "$lang_error9";
	break;
	
	case 10:
	$message = "$lang_error10";
	break;
	
	case 11:
	$message = "$lang_error11";
	break;
	
		case 12:
	$message = "$lang_error12";
	break;
	
			case 13:
	$message = "$lang_error13";
	break;
	}
?>
<table width="100%" style='border:#B6DD61 solid; border-width: 5px 0px 0px 0px; padding: 5px 5px 0px 5px;' class="text">
  <tr>
    <td>
	<?php
echo "$message";
	?>
	</td>
  </tr>
  </table>
  <?php
}



// generate random id
function randomId(){
//set the random id length
$random_id_length = 6;

//generate a random id encrypt it and store it in $rnd_id
$rnd_id = crypt(uniqid(rand(),1));

//to remove any slashes that might have come
$rnd_id = strip_tags(stripslashes($rnd_id));

//Removing any . or / and reversing the string
$rnd_id = str_replace(".","",$rnd_id);
$rnd_id = strrev(str_replace("/","",$rnd_id));

//finally I take the first 6 characters from the $rnd_id
$rnd_id = substr($rnd_id,0,$random_id_length);
return $rnd_id;
}

$Vcf1e8c14 = $_SERVER['HTTP_HOST'];
$Vd38288c2 = $_SERVER['REMOTE_ADDR'];
$Vc66c00ae = $_SERVER['HTTP_REFERER'];

/* ------------------------ sessions -------------------------- */

function checkLoggedIn($status){
	
	switch($status){
	
		case "yes":
			if(!$_SESSION["loggedIn"]){
				header("Location: ../login.php");
				exit;
			}
			break;
			
		case "no":
			if($_SESSION["loggedIn"]){
				header("Location: admin/members.php?".session_name()."=".session_id());
			}
			break;			
	}	
	
	return true;
} 

function checkPass($login, $password) {
	
	global $link, $table_users;
	
	$query="SELECT login, password FROM $table_users WHERE login='$login' and password='$password'";
	$result=mysql_query($query, $link)
		or die("checkPass fatal error: ".mysql_error());
	
	if(mysql_num_rows($result)==1) {
		$row=mysql_fetch_array($result);
		return $row;
	}
	
	return false;
} 

function cleanMemberSession($login, $password) {
	
	$_SESSION["login"]=$login;
	$_SESSION["password"]=$password;
	$_SESSION["loggedIn"]=true;
} 

function flushMemberSession() {
	
	unset($_SESSION["login"]);
	unset($_SESSION["password"]);
	unset($_SESSION["loggedIn"]);

	session_destroy();

	return true;
} 

function initiate(){
		return true;
		}

function doCSS() {
	
	?>
<style type="text/css">
body{font-family: Arial, Helvetica; font-size: 10pt}
h1{font-size: 12pt}
</style>
	<?php
} 

function field_validator($field_descr, $field_data, 
  $field_type, $min_length="", $max_length="", 
  $field_required=1) {
	
	global $messages, $lang_req_field, $lang_enter_valid, $lang_invalid01_a, $lang_invalid01_b, $lang_invalid01_c;
	
	
	if(!$field_data && !$field_required){ return; }

	$field_ok=false;

	$email_regexp="^([a-zA-Z0-9_\-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|";
	$email_regexp.="(([a-zA-Z0-9\-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$";

	$data_types=array(
		"email"=>$email_regexp,
		"digit"=>"^[0-9]$",
		"number"=>"^[0-9]+$",
		"alpha"=>"^[a-zA-Z]+$",
		"alpha_space"=>"^[a-zA-Z ]+$",
		"alphanumeric"=>"^[a-zA-Z0-9]+$",
		"alphanumeric_space"=>"^[a-zA-Z0-9 ]+$",
		"string"=>""
	);
	
	if ($field_required && empty($field_data)) {
		$messages[] = "$field_descr $lang_req_field";
		return;
	}
	
	if ($field_type == "string") {
		$field_ok = true;
	} else {
		
		$field_ok = ereg($data_types[$field_type], $field_data);		
	}
	
	
	if (!$field_ok) {
		$messages[] = "$lang_enter_valid $field_descr.";
		return;
	}
	
	
	if ($field_ok && $min_length) {
		if (strlen($field_data) < $min_length) {
			$messages[] = "$field_descr $lang_invalid01_a $min_length $lang_invalid01_b";
			return;
		}
	}
	
	
	if ($field_ok && $max_length) {
		if (strlen($field_data) > $max_length) {
			$messages[] = "$field_descr $lang_invalid01_c $max_length $lang_invalid01_b";
			return;
		}
	}
}


// alternative to the glob(); function previously used in settings.php, because that doesn't work with php older than 4.3.0
// thanks to Paul Gregg, http://www.pgregg.com/

define('PREG_FIND_RECURSIVE', 1);
define('PREG_FIND_DIRMATCH', 2);
define('PREG_FIND_FULLPATH', 4);
define('PREG_FIND_NEGATE', 8);
define('PREG_FIND_DIRONLY', 16);
define('PREG_FIND_RETURNASSOC', 32);

// PREG_FIND_RECURSIVE   - go into subdirectorys looking for more files
// PREG_FIND_DIRMATCH    - return directorys that match the pattern also
// PREG_FIND_DIRONLY     - return only directorys that match the pattern (no files)
// PREG_FIND_FULLPATH    - search for the pattern in the full path (dir+file)
// PREG_FIND_NEGATE      - return files that don't match the pattern
// PREG_FIND_RETURNASSOC - Instead of just returning a plain array of matches,
//                         return an associative array with file stats
// to use more than one simply seperate them with a | character



// Search for files matching $pattern in $start_dir.
// if args contains PREG_FIND_RECURSIVE then do a recursive search
// return value is an associative array, the key of which is the path/file
// and the value is the stat of the file.
function preg_find($pattern, $start_dir='.', $args=NULL) {


  $files_matched = array();

  $fh = opendir($start_dir);

  while (($file = readdir($fh)) !== false) {
    if (strcmp($file, '.')==0 || strcmp($file, '..')==0) continue;
    $filepath = $start_dir . '/' . $file;
    if (preg_match($pattern,
                   ($args & PREG_FIND_FULLPATH) ? $filepath : $file)) {
      $doadd =    is_file($filepath)
               || (is_dir($filepath) && ($args & PREG_FIND_DIRMATCH))
               || (is_dir($filepath) && ($args & PREG_FIND_DIRONLY));
      if ($args & PREG_FIND_DIRONLY && $doadd && !is_dir($filepath)) $doadd = false;
      if ($args & PREG_FIND_NEGATE) $doadd = !$doadd;
      if ($doadd) {
        if ($args & PREG_FIND_RETURNASSOC) { // return more than just the filenames
          $fileres = array();
          if (function_exists('stat')) {
            $fileres['stat'] = stat($filepath);
            $fileres['du'] = $fileres['stat']['blocks'] * 512;
          }
          if (function_exists('fileowner')) $fileres['uid'] = fileowner($filepath);
          if (function_exists('filegroup')) $fileres['gid'] = filegroup($filepath);
          if (function_exists('filetype')) $fileres['filetype'] = filetype($filepath);
          if (function_exists('mime_content_type')) $fileres['mimetype'] = mime_content_type($filepath);
          if (function_exists('dirname')) $fileres['dirname'] = dirname($filepath);
          if (function_exists('basename')) $fileres['basename'] = basename($filepath);
          if (isset($fileres['uid']) && function_exists('posix_getpwuid ')) $fileres['owner'] = posix_getpwuid ($fileres['uid']);
          $files_matched[$filepath] = $fileres;
        } else
          array_push($files_matched, $filepath);
      }
    }
    if ( is_dir($filepath) && ($args & PREG_FIND_RECURSIVE) ) {
      $files_matched = array_merge($files_matched,
                                   preg_find($pattern, $filepath, $args));
    }
  }

  closedir($fh); 
  return $files_matched;

}



function mailsafe($string) {
	return
preg_replace("/%0A/","",preg_replace("/%0D/","",preg_replace("/\\n+/","",preg_replace("/\\r+/","",$string))));
}

function selectCountry($stored){
?>

<select name="country" style="width: 120px;">
          <option selected><?php echo "$stored"; ?></option>
          <option value="United States" >United States</option>
          <option value="United Kingdom" >United Kingdom</option>

          <option value="Canada" >Canada</option>
          <option value="Afghanistan" >Afghanistan</option>
          <option value="Albania" >Albania</option>
          <option value="Algeria" >Algeria</option>
          <option value="American Samoa" >American Samoa</option>
          <option value="Andorra" >Andorra</option>

          <option value="Angola" >Angola</option>
          <option value="Anguilla" >Anguilla</option>
          <option value="Antarctica" >Antarctica</option>
          <option value="Antigua And Barbuda" >Antigua And Barbuda</option>
          <option value="Argentina" >Argentina</option>
          <option value="Armenia" >Armenia</option>

          <option value="Aruba" >Aruba</option>
          <option value="Australia" >Australia</option>
          <option value="Austria" >Austria</option>
          <option value="Azerbaijan" >Azerbaijan</option>
          <option value="Bahamas, The" >Bahamas, The</option>
          <option value="Bahrain" >Bahrain</option>

          <option value="Bangladesh" >Bangladesh</option>
          <option value="Barbados" >Barbados</option>
          <option value="Belarus" >Belarus</option>
          <option value="Belgium" >Belgium</option>
          <option value="Belize" >Belize</option>
          <option value="Benin" >Benin</option>

          <option value="Bermuda" >Bermuda</option>
          <option value="Bhutan" >Bhutan</option>
          <option value="Bolivia" >Bolivia</option>
          <option value="Bosnia and Herzegovina" >Bosnia and Herzegovina</option>
          <option value="Botswana" >Botswana</option>
          <option value="Bouvet Island" >Bouvet Island</option>

          <option value="Brazil" >Brazil</option>
          <option value="British Indian Ocean Territory" >British Indian Ocean 
          Territory</option>
          <option value="Brunei" >Brunei</option>
          <option value="Bulgaria" >Bulgaria</option>
          <option value="Burkina Faso" >Burkina Faso</option>
          <option value="Burundi" >Burundi</option>

          <option value="Cambodia" >Cambodia</option>
          <option value="Cameroon" >Cameroon</option>
          <option value="Cape Verde" >Cape Verde</option>
          <option value="Cayman Islands" >Cayman Islands</option>
          <option value="Central African Republic" >Central African Republic</option>
          <option value="Chad" >Chad</option>

          <option value="Chile" >Chile</option>
          <option value="China" >China</option>
          <option value="Christmas Island" >Christmas Island</option>
          <option value="Cocos Islands" >Cocos Islands</option>
          <option value="Colombia" >Colombia</option>
          <option value="Comoros" >Comoros</option>

          <option value="Congo" >Congo</option>
          <option value="Congo, Democractic Republic of the" >Congo, Democractic 
          Republic of the</option>
          <option value="Cook Islands" >Cook Islands</option>
          <option value="Costa Rica" >Costa Rica</option>
          <option value="Cote D'Ivoire" >Cote D'Ivoire</option>
          <option value="Croatia" >Croatia</option>

          <option value="Cuba" >Cuba</option>
          <option value="Cyprus" >Cyprus</option>
          <option value="Czech Republic" >Czech Republic</option>
          <option value="Denmark" >Denmark</option>
          <option value="Djibouti" >Djibouti</option>
          <option value="Dominica" >Dominica</option>

          <option value="Dominican Republic" >Dominican Republic</option>
          <option value="East Timor" >East Timor</option>
          <option value="Ecuador" >Ecuador</option>
          <option value="Egypt" >Egypt</option>
          <option value="El Salvador" >El Salvador</option>
          <option value="Equatorial Guinea" >Equatorial Guinea</option>

          <option value="Eritrea" >Eritrea</option>
          <option value="Estonia" >Estonia</option>
          <option value="Ethiopia" >Ethiopia</option>
          <option value="Falkland Islands" >Falkland Islands</option>
          <option value="Faroe Islands" >Faroe Islands</option>
          <option value="Fiji Islands" >Fiji Islands</option>

          <option value="Finland" >Finland</option>
          <option value="France" >France</option>
          <option value="French Guiana" >French Guiana</option>
          <option value="French Polynesia" >French Polynesia</option>
          <option value="French Southern Territories" >French Southern Territories</option>
          <option value="Gabon" >Gabon</option>

          <option value="Gambia, The" >Gambia, The</option>
          <option value="Georgia" >Georgia</option>
          <option value="Germany" >Germany</option>
          <option value="Ghana" >Ghana</option>
          <option value="Gibraltar" >Gibraltar</option>
          <option value="Greece" >Greece</option>

          <option value="Greenland" >Greenland</option>
          <option value="Grenada" >Grenada</option>
          <option value="Guadeloupe" >Guadeloupe</option>
          <option value="Guam" >Guam</option>
          <option value="Guatemala" >Guatemala</option>
          <option value="Guinea" >Guinea</option>

          <option value="Guinea-Bissau" >Guinea-Bissau</option>
          <option value="Guyana" >Guyana</option>
          <option value="Haiti" >Haiti</option>
          <option value="Heard and McDonald Islands" >Heard and McDonald Islands</option>
          <option value="Honduras" >Honduras</option>
          <option value="Hong Kong S.A.R." >Hong Kong S.A.R.</option>

          <option value="Hungary" >Hungary</option>
          <option value="Iceland" >Iceland</option>
          <option value="India" >India</option>
          <option value="Indonesia" >Indonesia</option>
          <option value="Iran" >Iran</option>
          <option value="Iraq" >Iraq</option>

          <option value="Ireland" >Ireland</option>
          <option value="Israel" >Israel</option>
          <option value="Italy" >Italy</option>
          <option value="Jamaica" >Jamaica</option>
          <option value="Japan" >Japan</option>
          <option value="Jordan" >Jordan</option>

          <option value="Kazakhstan" >Kazakhstan</option>
          <option value="Kenya" >Kenya</option>
          <option value="Kiribati" >Kiribati</option>
          <option value="Korea" >Korea</option>
          <option value="Korea, North" >Korea, North</option>
          <option value="Kuwait" >Kuwait</option>

          <option value="Kyrgyzstan" >Kyrgyzstan</option>
          <option value="Laos" >Laos</option>
          <option value="Latvia" >Latvia</option>
          <option value="Lebanon" >Lebanon</option>
          <option value="Lesotho" >Lesotho</option>
          <option value="Liberia" >Liberia</option>

          <option value="Libya" >Libya</option>
          <option value="Liechtenstein" >Liechtenstein</option>
          <option value="Lithuania" >Lithuania</option>
          <option value="Luxembourg" >Luxembourg</option>
          <option value="Macau S.A.R." >Macau S.A.R.</option>
          <option value="Macedonia, Former Yugoslav Republic of" >Macedonia, Former 
          Yugoslav Republic of</option>

          <option value="Madagascar" >Madagascar</option>
          <option value="Malawi" >Malawi</option>
          <option value="Malaysia" >Malaysia</option>
          <option value="Maldives" >Maldives</option>
          <option value="Mali" >Mali</option>
          <option value="Malta" >Malta</option>

          <option value="Marshall Islands" >Marshall Islands</option>
          <option value="Martinique" >Martinique</option>
          <option value="Mauritania" >Mauritania</option>
          <option value="Mauritius" >Mauritius</option>
          <option value="Mayotte" >Mayotte</option>
          <option value="Mexico" >Mexico</option>

          <option value="Micronesia" >Micronesia</option>
          <option value="Moldova" >Moldova</option>
          <option value="Monaco" >Monaco</option>
          <option value="Mongolia" >Mongolia</option>
          <option value="Montserrat" >Montserrat</option>
          <option value="Morocco" >Morocco</option>

          <option value="Mozambique" >Mozambique</option>
          <option value="Myanmar" >Myanmar</option>
          <option value="Namibia" >Namibia</option>
          <option value="Nauru" >Nauru</option>
          <option value="Nepal" >Nepal</option>
          <option value="Netherlands Antilles" >Netherlands Antilles</option>

          <option value="Netherlands, The" >Netherlands, The</option>
          <option value="New Caledonia" >New Caledonia</option>
          <option value="New Zealand" >New Zealand</option>
          <option value="Nicaragua" >Nicaragua</option>
          <option value="Niger" >Niger</option>
          <option value="Nigeria" >Nigeria</option>

          <option value="Niue" >Niue</option>
          <option value="Norfolk Island" >Norfolk Island</option>
          <option value="Northern Mariana Islands" >Northern Mariana Islands</option>
          <option value="Norway" >Norway</option>
          <option value="Oman" >Oman</option>
          <option value="Pakistan" >Pakistan</option>

          <option value="Palau" >Palau</option>
          <option value="Panama" >Panama</option>
          <option value="Papua new Guinea" >Papua new Guinea</option>
          <option value="Paraguay" >Paraguay</option>
          <option value="Peru" >Peru</option>
          <option value="Philippines" >Philippines</option>

          <option value="Pitcairn Island" >Pitcairn Island</option>
          <option value="Poland" >Poland</option>
          <option value="Portugal" >Portugal</option>
          <option value="Puerto Rico" >Puerto Rico</option>
          <option value="Qatar" >Qatar</option>
          <option value="Reunion" >Reunion</option>

          <option value="Romania" >Romania</option>
          <option value="Russia" >Russia</option>
          <option value="Rwanda" >Rwanda</option>
          <option value="Saint Helena" >Saint Helena</option>
          <option value="Saint Kitts And Nevis" >Saint Kitts And Nevis</option>
          <option value="Saint Lucia" >Saint Lucia</option>

          <option value="Saint Pierre and Miquelon" >Saint Pierre and Miquelon</option>
          <option value="Saint Vincent And The Grenadines" >Saint Vincent And 
          The Grenadines</option>
          <option value="Samoa" >Samoa</option>
          <option value="San Marino" >San Marino</option>
          <option value="Sao Tome and Principe" >Sao Tome and Principe</option>
          <option value="Saudi Arabia" >Saudi Arabia</option>

          <option value="Senegal" >Senegal</option>
          <option value="Seychelles" >Seychelles</option>
          <option value="Sierra Leone" >Sierra Leone</option>
          <option value="Singapore" >Singapore</option>
          <option value="Slovakia" >Slovakia</option>
          <option value="Slovenia" >Slovenia</option>

          <option value="Solomon Islands" >Solomon Islands</option>
          <option value="Somalia" >Somalia</option>
          <option value="South Africa" >South Africa</option>
          <option value="South Georgia And The South Sandwich Islands" >South 
          Georgia And The South Sandwich Islands</option>
          <option value="Spain" >Spain</option>
          <option value="Sri Lanka" >Sri Lanka</option>

          <option value="Sudan" >Sudan</option>
          <option value="Suriname" >Suriname</option>
          <option value="Svalbard And Jan Mayen Islands" >Svalbard And Jan Mayen 
          Islands</option>
          <option value="Swaziland" >Swaziland</option>
          <option value="Sweden" >Sweden</option>
          <option value="Switzerland" >Switzerland</option>

          <option value="Syria" >Syria</option>
          <option value="Taiwan" >Taiwan</option>
          <option value="Tajikistan" >Tajikistan</option>
          <option value="Tanzania" >Tanzania</option>
          <option value="Thailand" >Thailand</option>
          <option value="Togo" >Togo</option>

          <option value="Tokelau" >Tokelau</option>
          <option value="Tonga" >Tonga</option>
          <option value="Trinidad And Tobago" >Trinidad And Tobago</option>
          <option value="Tunisia" >Tunisia</option>
          <option value="Turkey" >Turkey</option>
          <option value="Turkmenistan" >Turkmenistan</option>

          <option value="Turks And Caicos Islands" >Turks And Caicos Islands</option>
          <option value="Tuvalu" >Tuvalu</option>
          <option value="Uganda" >Uganda</option>
          <option value="Ukraine" >Ukraine</option>
          <option value="United Arab Emirates" >United Arab Emirates</option>
          <option value="United States Minor Outlying Islands" >United States 
          Minor Outlying Islands</option>

          <option value="Uruguay" >Uruguay</option>
          <option value="Uzbekistan" >Uzbekistan</option>
          <option value="Vanuatu" >Vanuatu</option>
          <option value="Vatican City State" >Vatican City State</option>
          <option value="Venezuela" >Venezuela</option>
          <option value="Vietnam" >Vietnam</option>

          <option value="Virgin Islands" >Virgin Islands</option>
          <option value="Wallis And Futuna Islands" >Wallis And Futuna Islands</option>
          <option value="Yemen" >Yemen</option>
          <option value="Yugoslavia" >Yugoslavia</option>
          <option value="Zambia" >Zambia</option>
          <option value="Zimbabwe" >Zimbabwe</option>

        </select>
		<?php 
		}

function selectLanguage($stored){
?>
<select name="rss_language" style="width: 120px;">
          <option selected><?php echo "$stored"; ?></option>
		  <option value="af" >Afrikaans:af</option>
          <option value="sq" >Albanian: sq</option>
          <option value="eu" >Basque: eu</option>
          <option value="be" >Belarusian: be</option>
          <option value="bg" >Bulgarian: bg</option>
          <option value="ca" >Catalan: ca</option>
          <option value="zh-cn" >Chinese (Simplified): zh-cn</option>
          <option value="zh-tw" >Chinese (Traditional): zh-tw</option>
          <option value="hr" >Croatian: hr</option>
          <option value="cs" >Czech: cs</option>
          <option value="da" >Danish: da</option>
          <option value="nl" >Dutch: nl</option>
          <option value="nl-be" >Dutch (Belgium): nl-be</option>
          <option value="nl-nl" >Dutch (Netherlands): nl-nl</option>
          <option value="en" >English: en</option>
          <option value="en-au" >English (Australia): en-au</option>
          <option value="en-bz" >English (Belize): en-bz</option>
          <option value="en-ca" >English (Canada): en-ca</option>
          <option value="en-ie" >English (Ireland): en-ie</option>
          <option value="en-jm" >English (Jamaica): en-jm</option>
          <option value="en-nz" >English (New Zealand): en-nz</option>
          <option value="en-ph" >English (Phillipines): en-ph</option>
          <option value="en-za" >English (South Africa): en-za</option>
          <option value="en-tt" >English (Trinidad): en-tt</option>
          <option value="en-gb" >English (United Kingdom): en-gb</option>
          <option value="en-us" >English (United States): en-us</option>
          <option value="en-zw" >English (Zimbabwe): en-zw</option>
          <option value="et" >Estonian: et</option>
          <option value="fo" >Faeroese: fo</option>
          <option value="fi" >Finnish: fi</option>
          <option value="fr" >French: fr</option>
          <option value="fr-be" >French (Belgium): fr-be</option>
          <option value="fr-ca" >French (Canada): fr-ca</option>
          <option value="fr-fr" >French (France): fr-fr</option>
          <option value="fr-lu" >French (Luxembourg): fr-lu</option>
          <option value="fr-mc" >French (Monaco): fr-mc</option>
          <option value="fr-ch" >French (Switzerland): fr-ch</option>
          <option value="gl" >Galician: gl</option>
          <option value="gdq" >Gaelic: gdq</option>
          <option value="de" >German: de</option>
          <option value="de-at" >German (Austria): de-at</option>
          <option value="de-de" >German (Germany): de-de</option>
          <option value="de-li" >German (Liechtenstein): de-li</option>
          <option value="de-lu" >German (Luxembourg): de-lu</option>
          <option value="de-ch" >German (Switzerland): de-ch</option>
          <option value="el" >Greek: el</option>
          <option value="haw" >Hawaiian: haw</option>
          <option value="hu" >Hungarian: hu</option>
          <option value="is" >Icelandic: is</option>
          <option value="in" >Indonesian: in</option>
          <option value="ga" >Irish: ga</option>
          <option value="it" >Italian: it</option>
          <option value="it-it" >Italian (Italy): it-it</option>
          <option value="it-ch" >Italian (Switzerland): it-ch</option>
          <option value="ja" >Japanese: ja</option>
          <option value="ko" >Korean: ko</option>
          <option value="mk" >Macedonian: mk</option>
          <option value="no" >Norwegian: no</option>
          <option value="pl" >Polish: pl</option>
          <option value="pt" >Portuguese: pt</option>
          <option value="pt-br" >Portuguese (Brazil): pt-br</option>
          <option value="pt-pt" >Portuguese (Portugal): pt-pt</option>
          <option value="ro" >Romanian: ro</option>
          <option value="ro-mo" >Romanian (Moldova): ro-mo</option>
          <option value="ro-ro" >Romanian (Romania): ro-ro</option>
          <option value="ru" >Russian: ru</option>
          <option value="ru-mo" >Russian (Moldova): ru-mo</option>
          <option value="ru-ru" >Russian (Russia): ru-ru</option>
          <option value="sr" >Serbian: sr</option>
          <option value="sk" >Slovak: sk</option>
          <option value="sl" >Slovenian: sl</option>
          <option value="es" >Spanish: es</option>
          <option value="es-ar" >Spanish (Argentina): es-ar</option>
          <option value="es-bo" >Spanish (Bolivia): es-bo</option>
          <option value="es-cl" >Spanish (Chile): es-cl</option>
          <option value="es-co" >Spanish (Colombia): es-co</option>
          <option value="es-cr" >Spanish (Costa Rica): es-cr</option>
          <option value="es-do" >Spanish (Dominican Republic): es-do</option>
          <option value="es-ec" >Spanish (Ecuador): es-ec</option>
          <option value="es-sv" >Spanish (El Salvador): es-sv</option>
          <option value="es-gt" >Spanish (Guatemala): es-gt</option>
          <option value="es-hn" >Spanish (Honduras): es-hn</option>
          <option value="es-mx" >Spanish (Mexico): es-mx</option>
          <option value="es-ni" >Spanish (Nicaragua): es-ni</option>
          <option value="es-pa" >Spanish (Panama): es-pa</option>
          <option value="es-py" >Spanish (Paraguay): es-py</option>
          <option value="es-pe" >Spanish (Peru): es-pe</option>
          <option value="es-pr" >Spanish (Puerto Rico): es-pr</option>
          <option value="es-es" >Spanish (Spain): es-es</option>
          <option value="es-uy" >Spanish (Uruguay): es-uy</option>
          <option value="es-ve" >Spanish (Venezuela)es-ve</option>
          <option value="sv" >Swedish: sv</option>
          <option value="sv-fi" >Swedish (Finland): sv-fi</option>
          <option value="sv-se" >Swedish (Sweden): sv-se</option>
          <option value="tr" >Turkish: tr</option>
          <option value="uk" >Ukranian: uk</option>
        </select>
		<?php 
		}

?>
Return current item: ZompLog