<?php
$program_prefix = 'wlrb_';
$folder = 'wlrb_files';
function magic_quote_alter($value,$quote='') {
if ($quote = '"') {
$value = str_replace('"','\"',$value);
} elseif ($quote= "'") {
$value = str_replace("'","\'",$value);
}
if (!get_magic_quotes_gpc()) {
return addslashes($value);
} else {
return $value;
}
}
function ternary($current,$item1,$item2) {
if ($current == $item1) {
return $item2;
} else {
return $item1;
}
}
function getResultDiv($value,$type='error') {
// Formats successful or error results whether they are in an array or a snippet.
if ($type == 'success') {
$class = 'success-div';
} elseif ($type == 'test') {
$class = 'test-div';
} else {
$class = 'error-div';
}
if (is_array($value)) {
for ($i = 0; $value[$i] != ''; $i++) {
$result_div .= '<li>' . $value[$i] . '</li>';
}
if ($result_div != '') {
$result_div = '<div class="' . $class . '"><ul>' . $result_div . '</ul></div>';
}
} else {
if ($value != '') {
$result_div = '<div class="' . $class . '">' . $value . '</div>';
}
}
return $result_div;
}
function showSelected($value,$to_match) {
if ($value == $to_match) {
return ' selected ';
} else {
return '';
}
}
function listArray($array) {
while ($var = each($array)) {
printf ("Key <b>%s</b> has the value of: <b>%s</b><br>", $var['key'], $var['value']);
}
}
if(!function_exists('str_split')){
function str_split($str,$length=1){
$cnt = strlen($str);
for ($i=0; $i<$cnt; $i+=$length) {
$array[]= substr($str,$i,$length);
}
return $array;
}
}
function checkValidChars($string,$valid_chars) {
$string_array = str_split($string);
$valid_chars_array = str_split($valid_chars);
$i = 0;
while ($string_array[$i] != '') {
if (!in_array($string_array[$i],$valid_chars_array)) {
return false;
}
$i++;
}
return true;
}
function checkAdminLogin($username,$password) {
global $program_prefix;
$result = mysql_query('
SELECT *
FROM ' .$program_prefix . 'administrators
WHERE administrators_username = "' . $username . '" and
administrators_pass = "' . $password . '"');
if (mysql_num_rows($result) > 0) {
return true;
} else {
return false;
}
}
function startOptionDiv($unique_id,$title) {
global $app_template_absolute_url;
global $folder;
return '<div class="option-main-div">
<a onclick="switchImage (\'' . $app_template_absolute_url . '/' . $folder . '/images/white-arrow-over.gif\',\'' . $app_template_absolute_url . '/' . $folder . '/images/white-arrow-down.gif\',\'' . $unique_id . '_image\')" href="javascript:toggleLayer(\'manage_' . $unique_id . '\');"><img src="' . $app_template_absolute_url . '/' . $folder . '/images/white-arrow-over.gif" id="' . $unique_id . '_image" name="' . $unique_id . '_image" alt="Click to expand" title="Click to expand"><p> ' . $title . '</p></a>
</div>
<div class="option-block-div" id="manage_' . $unique_id . '">
<div class="highlighted-border">';
}
function endOptionDiv() {
return '</div>
</div>';
}
function updateCustomSetting($setting,$value,$is_required=0) {
global $result_div;
global $program_prefix;
if ($is_required == 1) {
if (strlen($value) < 1) {
return false;
}
}
if ($update = mysql_query('
UPDATE ' .$program_prefix . 'custom_configuration
SET custom_configuration_value = "' . magic_quote_alter($value) . '"
WHERE custom_configuration_variable = "' . $setting . '"')) {
return true;
} else {
$result_div .= getResultDiv(mysql_error());
}
}
function getCustomVars() {
global $program_prefix;
$result = mysql_query('
SELECT *
FROM ' .$program_prefix . 'custom_configuration');
while ($row = mysql_fetch_array($result)) {
$custom[$row['custom_configuration_variable']] = $row['custom_configuration_value'];
}
return $custom;
}
function quickStrip($string) {
$string = strip_tags($string);
$string = str_replace(' ','',$string);
$string = str_replace('*','',$string);
$string = trim($string);
return $string;
}
function strip_word_chars($contents) {
$contents = str_replace('',"'",$contents);
$contents = str_replace('','"',$contents);
$contents = str_replace('','"',$contents);
$contents = str_replace('','"',$contents);
$contents = str_replace('','–',$contents);
$contents = str_replace("È",'E',$contents);
$contents = str_replace("É",'E',$contents);
$contents = str_replace("é",'e',$contents);
$contents = str_replace("È",'E',$contents);
$contents = str_replace("Ö",'O',$contents);
$contents = str_replace("ö",'o',$contents);
$contents = str_replace("Ä",'a',$contents);
$contents = str_replace("É",'o',$contents);
$contents = str_replace("á",'a',$contents);
return $contents;
}
function full_input_clean($contents) {
$contents = trim($contents);
$contents = str_replace(' ',' ',$contents);
$contents = str_replace('"',"'",$contents);
$contents = strip_word_chars($contents);
$contents = strip_tags($contents);
return $contents;
}
?>