Пример #1
0
function showAllCat($child, $cols)
{
    global $connection;
    global $catName;
    global $form_id;
    # initialise the global subcat flag
    # query to get all the nodes that are the
    # children of child id
    $sql = "SELECT categories.*, categories.category_id as CID, cat_name_translations.category_name AS NAME FROM categories LEFT JOIN cat_name_translations ON categories.category_id=cat_name_translations.category_id WHERE parent_category_id='" . jb_escape_sql($child) . "' AND form_id=1 AND (lang='" . jb_escape_sql($_SESSION['LANG']) . "') ORDER BY list_order, category_name ";
    $x = 0;
    # do the query
    $result = jb_mysql_query($sql) or die($query . mysql_error());
    while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
        $cats[] = $row;
        $x++;
        if ($x == $cols) {
            showRow($cats);
            unset($cats);
            # clear array
            $x = 0;
        }
    }
    # show the remaining cats
    showRow($cats);
}
Пример #2
0
function does_field_exist($table, $field)
{
    global $jb_mysql_link;
    $result = jb_mysql_query("show columns from `" . jb_escape_sql($table) . "`");
    while ($row = @mysql_fetch_row($result)) {
        //echo $row[0]." ";
        if ($row[0] == $field) {
            return true;
        }
    }
    return false;
}
Пример #3
0
function correct_default_lang()
{
    $sql = "SELECT * FROM `lang` WHERE is_active='Y' AND is_default='Y' ";
    $result = jb_mysql_query($sql);
    if (mysql_num_rows($result) == 0) {
        // nothing active and default?
        // reset default
        $sql = "UPDATE lang SET is_default='N' ";
        JB_mysql_query($sql);
        $sql = "SELECT * FROM `lang` WHERE is_active='Y' LIMIT 1 ";
        $result = jb_mysql_query($sql);
        $row = mysql_fetch_array($result, MYSQL_ASSOC);
        $sql = "UPDATE lang set is_default='Y' where lang_code='" . jb_escape_sql($row['lang_code']) . "' ";
        JB_mysql_query($sql);
    }
}
Пример #4
0
function JB_load_motd($type)
{
    if ($type != 'E' && $type != 'U') {
        return false;
    }
    $data = array();
    $sql = "SELECT * FROM `motd` where `motd_type` = '" . jb_escape_sql($type) . "' AND `motd_lang`='" . jb_escape_sql($_SESSION['LANG']) . "' ";
    $result = @JB_mysql_query($sql) or $DB_ERROR = mysql_error();
    $row = @mysql_fetch_array($result, MYSQL_ASSOC);
    $data['title'] = $row['motd_title'];
    $data['message'] = $row['motd_message'];
    $data['updated'] = $row['motd_date_updated'];
    $sql = "SELECT * FROM `jb_variables` where `key` = 'MOTD_" . jb_escape_sql($type) . "_DISPLAY' ";
    $result = @JB_mysql_query($sql) or $DB_ERROR = mysql_error();
    $row = @mysql_fetch_array($result, MYSQL_ASSOC);
    $data['display'] = $row['val'];
    return $data;
}
Пример #5
0
function &JB_schema_get_fields($form_id, $result_type = JB_FIELD_LIST)
{
    $form_id = (int) $form_id;
    $fields = JB_schema_get_static_fields($form_id, $result_type);
    if ($result_type == JB_DB_MAP) {
        $sql_exclude = " AND field_type != 'BLANK' AND field_type !='SEPERATOR' AND field_type !='NOTE' ";
    }
    $sql = "SELECT t1.*, t2.field_label AS NAME FROM `form_fields` as t1, form_field_translations as t2 where t1.field_id = t2.field_id AND t2.lang='" . jb_escape_sql($_SESSION['LANG']) . "' AND form_id='" . jb_escape_sql($form_id) . "' {$sql_exclude} ORDER BY field_sort ";
    $result = JB_mysql_query($sql);
    while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
        $fields[$row['field_id']]['field_id'] = $row['field_id'];
        $fields[$row['field_id']]['field_type'] = $row['field_type'];
        $fields[$row['field_id']]['field_label'] = $row['NAME'];
        $fields[$row['field_id']]['template_tag'] = $row['template_tag'];
        $fields[$row['field_id']]['is_hidden'] = $row['is_hidden'];
        // Is hidden from website. Only visibile on the editing form.
        // sometimes, template tag can be blank
        if ($fields[$row['field_id']]['template_tag'] == '') {
            $fields[$row['field_id']]['template_tag'] = $form_id . '_' . $row['field_id'];
        }
        switch ($form_id) {
            case 1:
                $fields[$row['field_id']]['is_member'] = $row['is_member'];
                break;
            case 2:
                $fields[$row['field_id']]['is_anon'] = $row['is_anon'];
                // resumes can have anonymous fiields
                $fields[$row['field_id']]['is_blocked'] = $row['is_blocked'];
                $fields[$row['field_id']]['is_member'] = $row['is_member'];
                break;
            case 3:
                $fields[$row['field_id']]['is_member'] = $row['is_member'];
                break;
            case 4:
                break;
            case 5:
                break;
            default:
                break;
        }
    }
    JBPLUG_do_callback('schema_get_fields', $fields, $form_id, $result_type);
    return $fields;
}
Пример #6
0
function JB_seed_mod_rewrite_for_categories()
{
    $sql = "SELECT * FROM `categories` WHERE  `categories`.`form_id`=1 ";
    $result = jb_mysql_query($sql);
    while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
        if (!trim($row['seo_fname'])) {
            $fname = JB_utf8_to_html(urldecode(jb_format_url_string($row['category_name'])));
            $i = 0;
            $postfix = '';
            $sql = "SELECT category_id FROM `categories` WHERE `seo_fname` = '" . jb_escape_sql($fname . $postfix . '.html') . "' ";
            $result2 = jb_mysql_query($sql);
            while (mysql_num_rows($result2) > 0) {
                $i++;
                $postfix = '-' . $i;
                $sql = "SELECT category_id FROM `categories` WHERE `seo_fname` = '" . jb_escape_sql($fname . $postfix . '.html') . "' ";
                $result2 = jb_mysql_query($sql);
            }
            $fname .= $postfix . '.html';
            $sql = "update `categories` set `seo_fname`='" . jb_escape_sql($fname) . "' where category_id='" . $row['category_id'] . "' ";
            jb_mysql_query($sql);
        }
    }
}
Пример #7
0
function JB_load_help($type)
{
    if ($type != 'E' && $type != 'U') {
        return false;
    }
    $data = array();
    $sql = "SELECT * FROM `help_pages` where `help_type` = '{$type}' AND `help_lang`='" . jb_escape_sql($_SESSION['LANG']) . "' ";
    $result = @JB_mysql_query($sql) or $DB_ERROR = mysql_error();
    $row = @mysql_fetch_array($result, MYSQL_ASSOC);
    $data['title'] = $row['help_title'];
    $data['message'] = $row['help_message'];
    $data['updated'] = $row['help_date_updated'];
    /*$sql = "SELECT * FROM `jb_variables` where `key` = 'HELP_$type"."_DISPLAY' ";
    	$result = @JB_mysql_query($sql) or $DB_ERROR = mysql_error();
    	$row = @mysql_fetch_array($result, MYSQL_ASSOC);
    	$data['display']=$row['val'];
    	*/
    if ($data['message'] == '') {
        $data['message'] = jb_extract_old_help_file($type);
        global $label;
        $data['title'] = $label['c_help_heading'];
    }
    return $data;
}
Пример #8
0
        $JBMarkup->error_msg("Cannot save the feed due to the following errors:");
        echo $error;
        JBXM_display_xml_feed_form();
    } else {
        JBXM_save_xml_feed_input();
        $JBMarkup->ok_msg('Changes Saved.');
    }
}
if ($_REQUEST['clear'] != '') {
    $cache_dir = JB_get_cache_dir();
    $filename = $cache_dir . 'feed_' . md5($_REQUEST['clear'] . $_REQUEST['feed_key']) . ".xml";
    @unlink($filename);
    $JBMarkup->ok_msg('Cache Cleared.');
}
if ($_REQUEST['delfeed'] != '') {
    $sql = "DELETE FROM xml_export_feeds WHERE feed_id='" . jb_escape_sql($_REQUEST['feed_id']) . "' ";
    JB_mysql_query($sql) or die(mysql_error());
    $JBMarkup->ok_msg('Feed Deleted.');
}
if ($_REQUEST['new'] == 'yes') {
    if ($_REQUEST['schema_id'] == '') {
        echo '<p>';
        echo 'Please select what type of feed you would like to create (Schema):<br>';
        ?>
		<form method='post' action="<?php 
        echo htmlentities($_SERVER['PHP_SELF']);
        ?>
">
		<input type="hidden" name='new' value='yes'>
		<select name='schema_id'>
			<option value=''>[Select]</option>
Пример #9
0
    $error = JB_validate_field_form();
    if ($error == '') {
        $id = JB_save_field($error, $NEW_FIELD);
        JB_format_field_translation_table(4);
        JB_cache_del_keys_for_form(4);
        $JBMarkup->ok_msg('Changes Saved.');
        $NEW_FIELD = "NO";
        $_REQUEST['field_id'] = $id;
    } else {
        $JBMarkup->error_msg('<b>ERROR!</b>');
        echo $error;
    }
}
if ($_REQUEST['delete'] != '') {
    echo "Deleting...";
    $sql = "SELECT * FROM form_fields WHERE form_id=4 and field_id='" . jb_escape_sql($_REQUEST['field_id']) . "'";
    $result = JB_mysql_query($sql);
    $row = mysql_fetch_array($result, MYSQL_ASSOC) or die(mysql_error());
    if (JB_is_reserved_template_tag($row['template_tag'])) {
        $JBMarkup->error_msg("<b>Cannot Delete:</b>  This field contains a reserved 'Template Tag' and is needed by the system. Click on the 'R' icon next to the field for more information. Instead of deleting, please rename this field / change the type / move up or down. ");
    } else {
        echo "Deleting...";
        JB_cache_del_keys_for_form(4);
        JB_delete_field($_REQUEST['field_id']);
        echo "OK!";
        $_REQUEST['field_id'] = "";
    }
}
if (JB_is_table_unsaved("employers")) {
    require dirname(__FILE__) . '/build_employers_table.php';
    JB_cache_del_keys_for_form(4);
Пример #10
0
		<input type="button" value="Send Emails" onClick="window.location='<?php 
    echo htmlentities($_SERVER['PHP_SELF']);
    ?>
?action=send&letter_id=<?php 
    echo $row['letter_id'];
    ?>
'">
		<?php 
}
// end if action
if ($action == "edit" || $action == "new" && $unsent_newsletters == 0) {
    if ($action == 'edit') {
        echo "Note: Editing a mailing list will not reset the recipient list.";
    }
    if ($_REQUEST['letter_id'] != '') {
        $sql = "SELECT * from `newsletters` WHERE `letter_id`='" . jb_escape_sql($_REQUEST['letter_id']) . "' ";
        $result = JB_mysql_query($sql) or die($sql . mysql_error());
        $row = mysql_fetch_array($result, MYSQL_ASSOC);
        $to = $row['to'];
        $message = $row['message'];
        $subject = $row['subject'];
    } else {
        $subject = stripslashes($subject);
        $message = stripslashes($message);
    }
    ?>

<h2>Newsletter Editor</h2>
<form method="post" action="<?php 
    echo htmlentities($_SERVER['PHP_SELF']);
    ?>
Пример #11
0
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this file,
# You can obtain one at http://mozilla.org/MPL/2.0/.
###########################################################################
require '../config.php';
require_once '../include/skill_matrix_functions.php';
require_once dirname(__FILE__) . "/admin_common.php";
JB_admin_header('Admin -> Build Matrix');
?>
<form method="post">
<?php 
if ($_REQUEST['submit'] != '') {
    $sql = "REPLACE INTO skill_matrix (matrix_id, field_id, row_count) VALUES ('" . jb_escape_sql($_REQUEST['field_id']) . "', '" . jb_escape_sql($_REQUEST['field_id']) . "', '" . jb_escape_sql($_REQUEST['row_count']) . "') ";
    JB_mysql_query($sql) or die(mysql_error());
}
$sql = "Select * from skill_matrix WHERE field_id='" . jb_escape_sql($_REQUEST['field_id']) . "' ";
$result = JB_mysql_query($sql) or die(mysql_error());
$row = mysql_fetch_array($result, MYSQL_ASSOC);
?>

	<b>Number of rows:</b> <input type="text" size="3" name="row_count" value="<?php 
echo $row['row_count'];
?>
">
	<input type="hidden" name="matrix_id" value="<?php 
echo jb_escape_html($row['matrix_id']);
?>
">
	<input type="hidden" name="field_id" value="<?php 
echo jb_escape_html($_REQUEST['field_id']);
?>
Пример #12
0
###########################################################################
# Copyright Jamit Software 2012, http://www.jamit.com
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this file,
# You can obtain one at http://mozilla.org/MPL/2.0/.
###########################################################################
require "../config.php";
include 'login_functions.php';
JB_process_login();
JBPLUG_do_callback('emp_logout', $A = false);
$now = gmdate("Y-m-d H:i:s");
$sql = "UPDATE `employers` SET `logout_date`='{$now}' WHERE `Username`='" . jb_escape_sql($_SESSION['JB_Username']) . "'";
//echo $sql;
JB_mysql_query($sql);
// clear the session table
$sql = "DELETE FROM `jb_sessions` WHERE session_id='" . jb_escape_sql(session_id()) . "' ";
JB_mysql_query($sql) or die($sql . mysql_error());
unset($_SESSION['JB_ID']);
unset($_SESSION['JB_Domain']);
unset($_SESSION['JB_FirstName']);
unset($_SESSION['JB_LastName']);
unset($_SESSION['JB_Username']);
unset($_SESSION['Rank']);
unset($_SESSION['JB_Base']);
$page_title = JB_SITE_NAME;
JB_template_employers_outside_header($page_title);
?>
<h3 style="text-align: center;"><?php 
echo $label['employer_logout_ok'];
?>
</h3> 
Пример #13
0
function JB_is_privileged_user($employer_id, $type)
{
    $row = false;
    if (JB_SUBSCRIPTION_FEE_ENABLED == 'YES') {
        // check subscription quotas
        $row = jb_get_active_subscription_invoice($employer_id);
        // This user is subscribed
        // Therefore cannot be privileged... return false
        if ($row) {
            return false;
        }
    }
    $sql = "SELECT * FROM `employers` WHERE ID='" . jb_escape_sql($employer_id) . "'";
    $result = JB_mysql_query($sql) or die(mysql_error());
    $row = mysql_fetch_array($result, MYSQL_ASSOC);
    if ($type == 'resume') {
        if ($row['subscription_can_view_resume'] == 'Y') {
            // subscribed to view resumes posts
            $PRIVILEGED = true;
        }
    } elseif ($type == 'premium') {
        // premium
        if ($row['subscription_can_premium_post'] == 'Y') {
            // subscribed to view resumes posts
            $PRIVILEGED = true;
        }
    } elseif (JB_POSTING_FEE_ENABLED == 'YES') {
        // standard posts
        if ($row['subscription_can_post'] == 'Y') {
            // subscribed to view resumes posts
            $PRIVILEGED = true;
        }
    }
    return $PRIVILEGED;
}
Пример #14
0
function JB_do_upgrade($flag)
{
    $upgrade_needed = false;
    global $jb_mysql_link;
    global $JBMarkup;
    if (defined('JB_VERSION')) {
        $version = jb_get_variable('JB_VERSION');
        if ($version == JB_VERSION) {
            // current version database
            return false;
            // upgrade not needed
        }
    }
    $sql = "DELETE FROM `form_fields` WHERE `field_id` = 999193 LIMIT 1";
    if ($flag) {
        JB_mysql_query($sql);
    }
    $sql = "DELETE FROM `form_fields` WHERE `field_id` = 999194 LIMIT 1";
    if ($flag) {
        JB_mysql_query($sql);
    }
    $sql = "UPDATE `form_fields` SET `template_tag`='RESUME_EMAIL' WHERE form_id=2 and field_label='Email' AND field_id=40 ";
    if ($flag) {
        JB_mysql_query($sql) or die(mysql_error());
    }
    if (!does_field_exist("xml_export_elements", "is_mandatory")) {
        $sql = "DROP TABLE IF EXISTS `xml_export_elements`";
        if ($flag) {
            JB_mysql_query($sql) or die($sql . mysql_error());
        }
        $sql = "CREATE TABLE `xml_export_elements` (\n\t\t  `element_id` int(11) NOT NULL auto_increment,\n\t\t  `element_name` varchar(255) NOT NULL default '',\n\t\t  `is_cdata` set('Y','N') NOT NULL default '',\n\t\t  `parent_element_id` int(11) default '0',\n\t\t  `form_id` int(11) NOT NULL default '0',\n\t\t  `field_id` varchar(128) NOT NULL default '0',\n\t\t  `schema_id` int(11) NOT NULL default '0',\n\t\t  `attributes` varchar(255) NOT NULL default '',\n\t\t  `static_data` varchar(255) NOT NULL default '',\n\t\t  `is_pivot` set('Y','N') NOT NULL default '',\n\t\t  `description` varchar(255) NOT NULL default '',\n\t\t  `fieldcondition` varchar(255) NOT NULL default '',\n\t\t  `is_boolean` set('Y','N') NOT NULL default 'N',\n\t\t  `qualify_codes` set('Y','N') NOT NULL default 'N',\n\t\t  `qualify_cats` set('Y','N') NOT NULL default 'N',\n\t\t  `truncate` int(11) NOT NULL default '0',\n\t\t  `strip_tags` set('Y','N') NOT NULL default 'N',\n\t\t  `is_mandatory` set('Y','N') NOT NULL default '',\n\t\t  PRIMARY KEY  (`element_id`) )";
        if ($flag) {
            JB_mysql_query($sql) or die($sql . mysql_error());
        }
        $sql = "INSERT INTO `xml_export_elements` VALUES (1, 'rss', 'N', 0, 1, '0', 1, 'version =\"2.0\" xmlns:g=\"http://base.google.com/ns/1.0\"', '', '', '', '', 'N', 'N', 'N', 0, 'N', '')";
        if ($flag) {
            JB_mysql_query($sql) or die($sql . mysql_error());
        }
        $sql = "INSERT INTO `xml_export_elements` VALUES (2, 'channel', 'N', 1, 1, '0', 1, '', '', '', '', '', 'N', 'N', 'N', 0, 'N', '')";
        if ($flag) {
            JB_mysql_query($sql) or die($sql . mysql_error());
        }
        $sql = "INSERT INTO `xml_export_elements` VALUES (4, 'description', 'N', 2, 1, '0', 1, '', '%SITE_DESCRIPTION%', '', '', '', 'N', 'N', 'N', 0, 'N', '')";
        if ($flag) {
            JB_mysql_query($sql) or die($sql . mysql_error());
        }
        $sql = "INSERT INTO `xml_export_elements` VALUES (5, 'link', 'N', 2, 1, '0', 1, '', '%BASE_HTTP_PATH%', '', '', '', 'N', 'N', 'N', 0, 'N', '')";
        if ($flag) {
            JB_mysql_query($sql) or die($sql . mysql_error());
        }
        $sql = "INSERT INTO `xml_export_elements` VALUES (6, 'item', 'N', 2, 1, '0', 1, '', '', 'Y', '', '', 'N', 'N', 'N', 0, 'N', '')";
        if ($flag) {
            JB_mysql_query($sql) or die($sql . mysql_error());
        }
        $sql = "INSERT INTO `xml_export_elements` VALUES (11, 'g:expiration_date', 'N', 6, 1, '', 1, '', '%EXPIRE_DATE%', 'N', '', '', 'N', 'N', 'N', 0, 'N', 'Y')";
        if ($flag) {
            JB_mysql_query($sql) or die($sql . mysql_error());
        }
        $sql = "INSERT INTO `xml_export_elements` VALUES (14, 'g:immigration_status', 'N', 6, 1, '', 1, '', '', 'N', '', '', 'N', 'N', 'N', 0, 'N', 'Y')";
        if ($flag) {
            JB_mysql_query($sql) or die($sql . mysql_error());
        }
        $sql = "INSERT INTO `xml_export_elements` VALUES (19, 'g:location', 'N', 6, 1, '', 1, '', '', 'N', '', '', 'N', 'N', 'N', 0, 'N', 'Y')";
        if ($flag) {
            JB_mysql_query($sql) or die($sql . mysql_error());
        }
        $sql = "INSERT INTO `xml_export_elements` VALUES (20, 'g:salary', 'N', 6, 1, '', 1, '', '', 'N', '', '', 'N', 'N', 'N', 0, 'N', 'Y')";
        if ($flag) {
            JB_mysql_query($sql) or die($sql . mysql_error());
        }
        $sql = "INSERT INTO `xml_export_elements` VALUES (21, 'g:salary_type', 'N', 6, 1, '', 1, '', '', 'N', '', '', 'N', 'N', 'N', 0, 'N', 'Y')";
        if ($flag) {
            JB_mysql_query($sql) or die($sql . mysql_error());
        }
        $sql = "INSERT INTO `xml_export_elements` VALUES (23, 'publisher', 'N', 22, 1, '', 2, '', '', 'N', '', '', 'N', 'N', 'N', 0, 'N', '')";
        if ($flag) {
            JB_mysql_query($sql) or die($sql . mysql_error());
        }
        $sql = "INSERT INTO `xml_export_elements` VALUES (24, 'publisherurl', 'N', 22, 1, '', 2, '', '', 'N', '', '', 'N', 'N', 'N', 0, 'N', '')";
        if ($flag) {
            JB_mysql_query($sql) or die($sql . mysql_error());
        }
        $sql = "INSERT INTO `xml_export_elements` VALUES (25, 'lastBuildDate', 'N', 22, 1, '', 2, '', '', 'N', '', '', 'N', 'N', 'N', 0, 'N', '')";
        if ($flag) {
            JB_mysql_query($sql) or die($sql . mysql_error());
        }
        $sql = "INSERT INTO `xml_export_elements` VALUES (26, 'job', 'N', 22, 1, '', 2, '', '', 'Y', '', '', 'N', 'N', 'N', 0, 'N', '')";
        if ($flag) {
            JB_mysql_query($sql) or die($sql . mysql_error());
        }
        $sql = "INSERT INTO `xml_export_elements` VALUES (27, 'title', 'Y', 26, 1, '2', 2, '', '', 'N', '', '', 'N', 'N', 'N', 0, 'N', '')";
        if ($flag) {
            JB_mysql_query($sql) or die($sql . mysql_error());
        }
        $sql = "INSERT INTO `xml_export_elements` VALUES (28, 'date', 'Y', 26, 1, 'post_date', 2, '', '', 'N', '', '', 'N', 'N', 'N', 0, 'N', '')";
        if ($flag) {
            JB_mysql_query($sql) or die($sql . mysql_error());
        }
        $sql = "INSERT INTO `xml_export_elements` VALUES (29, 'referencenumber', 'Y', 26, 1, 'post_id', 2, '', '', 'N', '', '', 'N', 'N', 'N', 0, 'N', '')";
        if ($flag) {
            JB_mysql_query($sql) or die($sql . mysql_error());
        }
        $sql = "INSERT INTO `xml_export_elements` VALUES (31, 'company', 'Y', 26, 1, '8', 2, '', '', 'N', '', '', 'N', 'N', 'N', 0, 'N', '')";
        if ($flag) {
            JB_mysql_query($sql) or die($sql . mysql_error());
        }
        $sql = "INSERT INTO `xml_export_elements` VALUES (32, 'city', 'Y', 26, 1, '', 2, '', '', 'N', '', '', 'N', 'N', 'N', 0, 'N', '')";
        if ($flag) {
            JB_mysql_query($sql) or die($sql . mysql_error());
        }
        $sql = "INSERT INTO `xml_export_elements` VALUES (34, 'country', 'Y', 26, 1, '', 2, '', 'USA', 'N', '', '', 'N', 'N', 'N', 0, 'N', '')";
        if ($flag) {
            JB_mysql_query($sql) or die($sql . mysql_error());
        }
        $sql = "INSERT INTO `xml_export_elements` VALUES (35, 'postalcode', 'Y', 26, 1, '', 2, '', '', 'N', '', '', 'N', 'N', 'N', 0, 'N', '')";
        if ($flag) {
            JB_mysql_query($sql) or die($sql . mysql_error());
        }
        $sql = "INSERT INTO `xml_export_elements` VALUES (36, 'description', 'Y', 26, 1, 'summary', 2, '', '', 'N', '', '', 'N', 'N', 'N', 0, 'N', '')";
        if ($flag) {
            JB_mysql_query($sql) or die($sql . mysql_error());
        }
        $sql = "INSERT INTO `xml_export_elements` VALUES (37, 'salary', 'Y', 26, 1, '10', 2, '', '', 'N', '', '', 'N', 'N', 'N', 0, 'N', '')";
        if ($flag) {
            JB_mysql_query($sql) or die($sql . mysql_error());
        }
        $sql = "INSERT INTO `xml_export_elements` VALUES (38, 'experience', 'Y', 26, 1, '', 2, '', '', 'N', '', '', 'N', 'N', 'N', 0, 'N', '')";
        if ($flag) {
            JB_mysql_query($sql) or die($sql . mysql_error());
        }
        $sql = "INSERT INTO `xml_export_elements` VALUES (40, 'jobtype', 'Y', 26, 1, '', 2, '', '', 'N', '', '', 'N', 'N', 'N', 0, 'N', '')";
        if ($flag) {
            JB_mysql_query($sql) or die($sql . mysql_error());
        }
        $sql = "INSERT INTO `xml_export_elements` VALUES (42, 'jobs', 'N', 0, 1, '', 4, '', '', 'N', '', '', 'N', 'N', 'N', 0, 'N', '')";
        if ($flag) {
            JB_mysql_query($sql) or die($sql . mysql_error());
        }
        $sql = "INSERT INTO `xml_export_elements` VALUES (43, 'job', 'N', 42, 1, '', 4, '', '', 'Y', '', '', 'N', 'N', 'N', 0, 'N', '')";
        if ($flag) {
            JB_mysql_query($sql) or die($sql . mysql_error());
        }
        $sql = "INSERT INTO `xml_export_elements` VALUES (44, 'title', 'N', 43, 1, '', 4, '', '', 'N', '', '', 'N', 'N', 'N', 0, 'N', 'Y')";
        if ($flag) {
            JB_mysql_query($sql) or die($sql . mysql_error());
        }
        $sql = "INSERT INTO `xml_export_elements` VALUES (45, 'job-code', 'N', 43, 1, '', 4, '', '', 'N', '', '', 'N', 'N', 'N', 0, 'N', 'Y')";
        if ($flag) {
            JB_mysql_query($sql) or die($sql . mysql_error());
        }
        $sql = "INSERT INTO `xml_export_elements` VALUES (46, 'action', 'N', 43, 1, '', 4, '', '', 'N', '', '', 'N', 'N', 'N', 0, 'N', '')";
        if ($flag) {
            JB_mysql_query($sql) or die($sql . mysql_error());
        }
        $sql = "INSERT INTO `xml_export_elements` VALUES (47, 'job-board-name', 'N', 43, 1, '', 4, '', '%SITE_NAME%', 'N', '', '', 'N', 'N', 'N', 0, 'N', '')";
        if ($flag) {
            JB_mysql_query($sql) or die($sql . mysql_error());
        }
        $sql = "INSERT INTO `xml_export_elements` VALUES (48, 'job-board-url', 'N', 43, 1, '', 4, '', '%BASE_HTTP_PATH%', 'N', '', '', 'N', 'N', 'N', 0, 'N', '')";
        if ($flag) {
            JB_mysql_query($sql) or die($sql . mysql_error());
        }
        $sql = "INSERT INTO `xml_export_elements` VALUES (49, 'detail-url', 'N', 43, 1, '', 4, '', '%LINK%', 'N', '', '', 'N', 'N', 'N', 0, 'N', 'Y')";
        if ($flag) {
            JB_mysql_query($sql) or die($sql . mysql_error());
        }
        $sql = "INSERT INTO `xml_export_elements` VALUES (50, 'apply-url', 'N', 43, 1, '', 4, '', '%LINK%', 'N', '', '', 'N', 'N', 'N', 0, 'N', '')";
        if ($flag) {
            JB_mysql_query($sql) or die($sql . mysql_error());
        }
        $sql = "INSERT INTO `xml_export_elements` VALUES (51, 'description', 'N', 43, 1, '', 4, '', '', 'N', '', '', 'N', 'N', 'N', 0, 'N', '')";
        if ($flag) {
            JB_mysql_query($sql) or die($sql . mysql_error());
        }
        $sql = "INSERT INTO `xml_export_elements` VALUES (52, 'summary', 'N', 51, 1, '', 4, '', '', 'N', '', '', 'N', 'N', 'N', 0, 'Y', 'Y')";
        if ($flag) {
            JB_mysql_query($sql) or die($sql . mysql_error());
        }
        $sql = "INSERT INTO `xml_export_elements` VALUES (53, 'required-skills', 'N', 51, 1, '', 4, '', '', 'N', '', '', 'N', 'N', 'N', 0, 'N', '')";
        if ($flag) {
            JB_mysql_query($sql) or die($sql . mysql_error());
        }
        $sql = "INSERT INTO `xml_export_elements` VALUES (54, 'required-education', 'N', 51, 1, '', 4, '', '', 'N', '', '', 'N', 'N', 'N', 0, 'N', '')";
        if ($flag) {
            JB_mysql_query($sql) or die($sql . mysql_error());
        }
        $sql = "INSERT INTO `xml_export_elements` VALUES (55, 'required-experience', 'N', 51, 1, '', 4, '', '', 'N', '', '', 'N', 'N', 'N', 0, 'N', '')";
        if ($flag) {
            JB_mysql_query($sql) or die($sql . mysql_error());
        }
        $sql = "INSERT INTO `xml_export_elements` VALUES (56, 'full-time', 'N', 51, 1, '', 4, '', '', 'N', '', '', 'Y', 'N', 'N', 0, 'N', '')";
        if ($flag) {
            JB_mysql_query($sql) or die($sql . mysql_error());
        }
        $sql = "INSERT INTO `xml_export_elements` VALUES (57, 'part-time', 'N', 51, 1, '', 4, '', '', 'N', '', '', 'Y', 'N', 'N', 0, 'N', '')";
        if ($flag) {
            JB_mysql_query($sql) or die($sql . mysql_error());
        }
        $sql = "INSERT INTO `xml_export_elements` VALUES (59, 'flex-time', 'N', 51, 1, '', 4, '', '', 'N', '', '', 'Y', 'N', 'N', 0, 'N', '')";
        if ($flag) {
            JB_mysql_query($sql) or die($sql . mysql_error());
        }
        $sql = "INSERT INTO `xml_export_elements` VALUES (60, 'internship', 'N', 51, 1, '', 4, '', '', 'N', '', '', 'Y', 'N', 'N', 0, 'N', '')";
        if ($flag) {
            JB_mysql_query($sql) or die($sql . mysql_error());
        }
        $sql = "INSERT INTO `xml_export_elements` VALUES (61, 'volunteer', 'N', 51, 1, '', 4, '', '', 'N', '', '', 'Y', 'N', 'N', 0, 'N', '')";
        if ($flag) {
            JB_mysql_query($sql) or die($sql . mysql_error());
        }
        $sql = "INSERT INTO `xml_export_elements` VALUES (62, 'exempt', 'N', 51, 1, '', 4, '', '', 'N', '', '', 'Y', 'N', 'N', 0, 'N', '')";
        if ($flag) {
            JB_mysql_query($sql) or die($sql . mysql_error());
        }
        $sql = "INSERT INTO `xml_export_elements` VALUES (63, 'contract', 'N', 51, 1, '', 4, '', '', 'N', '', '', 'Y', 'N', 'N', 0, 'N', '')";
        if ($flag) {
            JB_mysql_query($sql) or die($sql . mysql_error());
        }
        $sql = "INSERT INTO `xml_export_elements` VALUES (64, 'permanent', 'N', 51, 1, '', 4, '', '', 'N', '', '', 'Y', 'N', 'N', 0, 'N', '')";
        if ($flag) {
            JB_mysql_query($sql) or die($sql . mysql_error());
        }
        $sql = "INSERT INTO `xml_export_elements` VALUES (65, 'temporary', 'N', 51, 1, '', 4, '', '', 'N', '', '', 'Y', 'N', 'N', 0, 'N', '')";
        if ($flag) {
            JB_mysql_query($sql) or die($sql . mysql_error());
        }
        $sql = "INSERT INTO `xml_export_elements` VALUES (66, 'telecommute', 'N', 51, 1, '', 4, '', '', 'N', '', '', 'Y', 'N', 'N', 0, 'N', '')";
        if ($flag) {
            JB_mysql_query($sql) or die($sql . mysql_error());
        }
        $sql = "INSERT INTO `xml_export_elements` VALUES (67, 'compensation', 'N', 43, 1, '', 4, '', '', 'N', '', '', 'N', 'N', 'N', 0, 'N', '')";
        if ($flag) {
            JB_mysql_query($sql) or die($sql . mysql_error());
        }
        $sql = "INSERT INTO `xml_export_elements` VALUES (68, 'salary-range', 'N', 67, 1, '', 4, '', '', 'N', '', '', 'N', 'N', 'N', 0, 'N', '')";
        if ($flag) {
            JB_mysql_query($sql) or die($sql . mysql_error());
        }
        $sql = "INSERT INTO `xml_export_elements` VALUES (69, 'salary-amount', 'N', 67, 1, '', 4, '', '', 'N', '', '', 'N', 'N', 'N', 0, 'N', '')";
        if ($flag) {
            JB_mysql_query($sql) or die($sql . mysql_error());
        }
        $sql = "INSERT INTO `xml_export_elements` VALUES (70, 'salary-currency', 'N', 67, 1, '', 4, '', '', 'N', '', '', 'N', 'N', 'N', 0, 'N', '')";
        if ($flag) {
            JB_mysql_query($sql) or die($sql . mysql_error());
        }
        $sql = "INSERT INTO `xml_export_elements` VALUES (71, 'benefits', 'N', 67, 1, '', 4, '', '', 'N', '', '', 'N', 'N', 'N', 0, 'N', '')";
        if ($flag) {
            JB_mysql_query($sql) or die($sql . mysql_error());
        }
        $sql = "INSERT INTO `xml_export_elements` VALUES (72, 'posted-date', 'N', 43, 1, '', 4, '', '%DATE%', 'N', '', '', 'N', 'N', 'N', 0, 'N', '')";
        if ($flag) {
            JB_mysql_query($sql) or die($sql . mysql_error());
        }
        $sql = "INSERT INTO `xml_export_elements` VALUES (73, 'close-date', 'N', 43, 1, '', 4, '', '', 'N', '', '', 'N', 'N', 'N', 0, 'N', '')";
        if ($flag) {
            JB_mysql_query($sql) or die($sql . mysql_error());
        }
        $sql = "INSERT INTO `xml_export_elements` VALUES (74, 'location', 'N', 43, 1, '', 4, '', '', 'N', '', '', 'N', 'N', 'N', 0, 'N', '')";
        if ($flag) {
            JB_mysql_query($sql) or die($sql . mysql_error());
        }
        $sql = "INSERT INTO `xml_export_elements` VALUES (75, 'address', 'N', 74, 1, '', 4, '', '', 'N', '', '', 'N', 'N', 'N', 0, 'N', '')";
        $sql = "INSERT INTO `xml_export_elements` VALUES (76, 'city', 'N', 74, 1, '', 4, '', '', 'N', '', '', 'N', 'N', 'N', 0, 'N', '')";
        if ($flag) {
            JB_mysql_query($sql) or die($sql . mysql_error());
        }
        $sql = "INSERT INTO `xml_export_elements` VALUES (77, 'state', 'N', 74, 1, '', 4, '', '', 'N', '', '', 'N', 'N', 'N', 0, 'N', 'Y')";
        if ($flag) {
            JB_mysql_query($sql) or die($sql . mysql_error());
        }
        $sql = "INSERT INTO `xml_export_elements` VALUES (78, 'zip', 'N', 74, 1, '', 4, '', '', 'N', '', '', 'N', 'N', 'N', 0, 'N', '')";
        if ($flag) {
            JB_mysql_query($sql) or die($sql . mysql_error());
        }
        $sql = "INSERT INTO `xml_export_elements` VALUES (79, 'country', 'N', 74, 1, '', 4, '', '', 'N', '', '', 'N', 'N', 'N', 0, 'N', '')";
        if ($flag) {
            JB_mysql_query($sql) or die($sql . mysql_error());
        }
        $sql = "INSERT INTO `xml_export_elements` VALUES (80, 'area-code', 'N', 74, 1, '', 4, '', '', 'N', '', '', 'N', 'N', 'N', 0, 'N', '')";
        if ($flag) {
            JB_mysql_query($sql) or die($sql . mysql_error());
        }
        $sql = "INSERT INTO `xml_export_elements` VALUES (81, 'contact', 'N', 43, 1, '', 4, '', '', 'N', '', '', 'N', 'N', 'N', 0, 'N', '')";
        if ($flag) {
            JB_mysql_query($sql) or die($sql . mysql_error());
        }
        $sql = "INSERT INTO `xml_export_elements` VALUES (82, 'name', 'N', 81, 1, '', 4, '', '', 'N', '', '', 'N', 'N', 'N', 0, 'N', '')";
        if ($flag) {
            JB_mysql_query($sql) or die($sql . mysql_error());
        }
        $sql = "INSERT INTO `xml_export_elements` VALUES (84, 'email', 'N', 81, 1, '', 4, '', '', 'N', '', '', 'N', 'N', 'N', 0, 'N', '')";
        if ($flag) {
            JB_mysql_query($sql) or die($sql . mysql_error());
        }
        $sql = "INSERT INTO `xml_export_elements` VALUES (85, 'hiring-manager-name', 'N', 81, 1, '', 4, '', '', 'N', '', '', 'N', 'N', 'N', 0, 'N', '')";
        if ($flag) {
            JB_mysql_query($sql) or die($sql . mysql_error());
        }
        $sql = "INSERT INTO `xml_export_elements` VALUES (86, 'hiring-manager-email', 'N', 81, 1, '', 4, '', '', 'N', '', '', 'N', 'N', 'N', 0, 'N', '')";
        if ($flag) {
            JB_mysql_query($sql) or die($sql . mysql_error());
        }
        $sql = "INSERT INTO `xml_export_elements` VALUES (87, 'phone', 'N', 81, 1, '', 4, '', '', 'N', '', '', 'N', 'N', 'N', 0, 'N', '')";
        if ($flag) {
            JB_mysql_query($sql) or die($sql . mysql_error());
        }
        $sql = "INSERT INTO `xml_export_elements` VALUES (88, 'fax', 'N', 81, 1, '', 4, '', '', 'N', '', '', 'N', 'N', 'N', 0, 'N', '')";
        if ($flag) {
            JB_mysql_query($sql) or die($sql . mysql_error());
        }
        $sql = "INSERT INTO `xml_export_elements` VALUES (89, 'company', 'N', 43, 1, '', 4, '', '', 'N', '', '', 'N', 'N', 'N', 0, 'N', '')";
        if ($flag) {
            JB_mysql_query($sql) or die($sql . mysql_error());
        }
        $sql = "INSERT INTO `xml_export_elements` VALUES (90, 'name', 'N', 89, 1, '', 4, '', '', 'N', '', '', 'N', 'N', 'N', 0, 'N', '')";
        if ($flag) {
            JB_mysql_query($sql) or die($sql . mysql_error());
        }
        $sql = "INSERT INTO `xml_export_elements` VALUES (91, 'description', 'N', 89, 1, '', 4, '', '', 'N', '', '', 'N', 'N', 'N', 0, 'N', '')";
        if ($flag) {
            JB_mysql_query($sql) or die($sql . mysql_error());
        }
        $sql = "INSERT INTO `xml_export_elements` VALUES (92, 'industry', 'N', 89, 1, '', 4, '', '', 'N', '', '', 'N', 'N', 'N', 0, 'N', '')";
        if ($flag) {
            JB_mysql_query($sql) or die($sql . mysql_error());
        }
        $sql = "INSERT INTO `xml_export_elements` VALUES (93, 'url', 'N', 89, 1, '', 4, '', '', 'N', '', '', 'N', 'N', 'N', 0, 'N', '')";
        if ($flag) {
            JB_mysql_query($sql) or die($sql . mysql_error());
        }
        $sql = "INSERT INTO `xml_export_elements` VALUES (94, 'title', 'N', 2, 1, '', 1, '', '%SITE_NAME%', 'N', '', '', 'N', 'N', 'N', 0, 'N', '')";
        if ($flag) {
            JB_mysql_query($sql) or die($sql . mysql_error());
        }
        $sql = "INSERT INTO `xml_export_elements` VALUES (96, 'title', 'N', 6, 1, '', 1, '', '', 'N', '', '', 'N', 'N', 'N', 0, 'N', 'Y')";
        if ($flag) {
            JB_mysql_query($sql) or die($sql . mysql_error());
        }
        $sql = "INSERT INTO `xml_export_elements` VALUES (97, 'description', 'N', 6, 1, '', 1, '', '', 'N', '', '', 'N', 'N', 'N', 0, 'Y', 'Y')";
        if ($flag) {
            JB_mysql_query($sql) or die($sql . mysql_error());
        }
        $sql = "INSERT INTO `xml_export_elements` VALUES (98, 'g:job_function', 'N', 6, 1, '', 1, '', '', 'N', '', '', 'N', 'N', 'N', 0, 'N', 'Y')";
        if ($flag) {
            JB_mysql_query($sql) or die($sql . mysql_error());
        }
        $sql = "INSERT INTO `xml_export_elements` VALUES (99, 'g:job_industry', 'N', 6, 1, '', 1, '', '', 'N', '', '', 'N', 'N', 'N', 0, 'N', 'Y')";
        if ($flag) {
            JB_mysql_query($sql) or die($sql . mysql_error());
        }
        $sql = "INSERT INTO `xml_export_elements` VALUES (100, 'g:job_type', 'N', 6, 1, '', 1, '', '', 'N', '', '', 'N', 'N', 'N', 0, 'N', 'Y')";
        if ($flag) {
            JB_mysql_query($sql) or die($sql . mysql_error());
        }
        $sql = "INSERT INTO `xml_export_elements` VALUES (101, 'link', 'N', 6, 1, '', 1, '', '%LINK%', 'N', '', '', 'N', 'N', 'N', 0, 'N', 'Y')";
        if ($flag) {
            JB_mysql_query($sql) or die($sql . mysql_error());
        }
        $sql = "INSERT INTO `xml_export_elements` VALUES (102, 'g:publish_date', 'N', 6, 1, '', 1, '', '%DATE%', 'N', '', '', 'N', 'N', 'N', 0, 'N', 'Y')";
        if ($flag) {
            JB_mysql_query($sql) or die($sql . mysql_error());
        }
        $sql = "INSERT INTO `xml_export_elements` VALUES (103, 'g:education', 'N', 6, 1, '', 1, '', '', 'N', '', '', 'N', 'N', 'N', 0, 'N', 'Y')";
        if ($flag) {
            JB_mysql_query($sql) or die($sql . mysql_error());
        }
        $sql = "INSERT INTO `xml_export_elements` VALUES (104, 'g:employer', 'N', 6, 1, '', 1, '', '', 'N', '', '', 'N', 'N', 'N', 0, 'N', 'Y')";
        if ($flag) {
            JB_mysql_query($sql) or die($sql . mysql_error());
        }
        $sql = "INSERT INTO `xml_export_elements` VALUES (105, 'guid', 'N', 6, 1, '', 1, '', '%LINK%', 'N', '', '', 'N', 'N', 'N', 0, 'N', 'Y')";
        if ($flag) {
            JB_mysql_query($sql) or die($sql . mysql_error());
        }
        $sql = "INSERT INTO `xml_export_elements` VALUES (106, 'image_link', 'N', 6, 1, '', 1, '', '', 'N', '', '', 'N', 'N', 'N', 0, 'N', 'Y')";
        if ($flag) {
            JB_mysql_query($sql) or die($sql . mysql_error());
        }
        $sql = "INSERT INTO `xml_export_elements` VALUES (107, 'source', 'N', 0, 1, '', 2, '', '', 'N', '', '', 'N', 'N', 'N', 0, 'N', '')";
        if ($flag) {
            JB_mysql_query($sql) or die($sql . mysql_error());
        }
        $sql = "INSERT INTO `xml_export_elements` VALUES (108, 'publisher', 'N', 107, 1, '', 2, '', '%SITE_NAME%', 'N', '', '', 'N', 'N', 'N', 0, 'N', '')";
        if ($flag) {
            JB_mysql_query($sql) or die($sql . mysql_error());
        }
        $sql = "INSERT INTO `xml_export_elements` VALUES (109, 'publisherurl', 'N', 107, 1, '', 2, '', '%BASE_HTTP_PATH%', 'N', '', '', 'N', 'N', 'N', 0, 'N', '')";
        if ($flag) {
            JB_mysql_query($sql) or die($sql . mysql_error());
        }
        $sql = "INSERT INTO `xml_export_elements` VALUES (110, 'lastBuildDate', 'N', 107, 1, '', 2, '', '%FEED_DATE%', 'N', '', '', 'N', 'N', 'N', 0, 'N', '')";
        if ($flag) {
            JB_mysql_query($sql) or die($sql . mysql_error());
        }
        $sql = "INSERT INTO `xml_export_elements` VALUES (111, 'job', 'N', 107, 1, '', 2, '', '', 'Y', '', '', 'N', 'N', 'N', 0, 'N', '')";
        if ($flag) {
            JB_mysql_query($sql) or die($sql . mysql_error());
        }
        $sql = "INSERT INTO `xml_export_elements` VALUES (112, 'title', 'N', 111, 1, '', 2, '', '', 'N', '', '', 'N', 'N', 'N', 0, 'N', 'Y')";
        if ($flag) {
            JB_mysql_query($sql) or die($sql . mysql_error());
        }
        $sql = "INSERT INTO `xml_export_elements` VALUES (113, 'date', 'N', 111, 1, '', 2, '', '', 'N', '', '', 'N', 'N', 'N', 0, 'N', 'Y')";
        if ($flag) {
            JB_mysql_query($sql) or die($sql . mysql_error());
        }
        $sql = "INSERT INTO `xml_export_elements` VALUES (114, 'referencenumber', 'N', 111, 1, '', 2, '', '', 'N', '', '', 'N', 'N', 'N', 0, 'N', 'Y')";
        if ($flag) {
            JB_mysql_query($sql) or die($sql . mysql_error());
        }
        $sql = "INSERT INTO `xml_export_elements` VALUES (115, 'url', 'N', 111, 1, '', 2, '', '%LINK%', 'N', '', '', 'N', 'N', 'N', 0, 'N', 'Y')";
        if ($flag) {
            JB_mysql_query($sql) or die($sql . mysql_error());
        }
        $sql = "INSERT INTO `xml_export_elements` VALUES (116, 'company', 'N', 111, 1, '', 2, '', '', 'N', '', '', 'N', 'N', 'N', 0, 'N', '')";
        if ($flag) {
            JB_mysql_query($sql) or die($sql . mysql_error());
        }
        $sql = "INSERT INTO `xml_export_elements` VALUES (117, 'city', 'N', 111, 1, '', 2, '', '', 'N', '', '', 'N', 'N', 'N', 0, 'N', '')";
        if ($flag) {
            JB_mysql_query($sql) or die($sql . mysql_error());
        }
        $sql = "INSERT INTO `xml_export_elements` VALUES (118, 'state', 'N', 111, 1, '', 2, '', '', 'N', '', '', 'N', 'N', 'N', 0, 'N', '')";
        if ($flag) {
            JB_mysql_query($sql) or die($sql . mysql_error());
        }
        $sql = "INSERT INTO `xml_export_elements` VALUES (119, 'country', 'N', 111, 1, '', 2, '', '', 'N', '', '', 'N', 'N', 'N', 0, 'N', 'Y')";
        if ($flag) {
            JB_mysql_query($sql) or die($sql . mysql_error());
        }
        $sql = "INSERT INTO `xml_export_elements` VALUES (120, 'postalcode', 'N', 111, 1, '', 2, '', '', 'N', '', '', 'N', 'N', 'N', 0, 'N', '')";
        if ($flag) {
            JB_mysql_query($sql) or die($sql . mysql_error());
        }
        $sql = "INSERT INTO `xml_export_elements` VALUES (121, 'description', 'N', 111, 1, '', 2, '', '', 'N', '', '', 'N', 'N', 'N', 0, 'Y', 'Y')";
        if ($flag) {
            JB_mysql_query($sql) or die($sql . mysql_error());
        }
        $sql = "INSERT INTO `xml_export_elements` VALUES (122, 'salary', 'Y', 111, 1, '', 2, '', '', 'N', '', '', 'N', 'N', 'N', 0, 'N', '')";
        if ($flag) {
            JB_mysql_query($sql) or die($sql . mysql_error());
        }
        $sql = "INSERT INTO `xml_export_elements` VALUES (123, 'education', 'Y', 111, 1, '', 2, '', '', 'N', '', '', 'N', 'N', 'N', 0, 'N', '')";
        if ($flag) {
            JB_mysql_query($sql) or die($sql . mysql_error());
        }
        $sql = "INSERT INTO `xml_export_elements` VALUES (124, 'jobtype', 'Y', 111, 1, '', 2, '', '', 'N', '', '', 'N', 'Y', 'Y', 0, 'N', '')";
        if ($flag) {
            JB_mysql_query($sql) or die($sql . mysql_error());
        }
        $sql = "INSERT INTO `xml_export_elements` VALUES (125, 'category', 'Y', 111, 1, '', 2, '', '', 'N', '', '', 'N', 'Y', 'Y', 0, 'N', '')";
        if ($flag) {
            JB_mysql_query($sql) or die($sql . mysql_error());
        }
        $sql = "INSERT INTO `xml_export_elements` VALUES (126, 'experience', 'Y', 111, 1, '', 2, '', '', 'N', '', '', 'N', 'N', 'N', 0, 'N', '')";
        if ($flag) {
            JB_mysql_query($sql) or die($sql . mysql_error());
        }
        $sql = "INSERT INTO `xml_export_elements` VALUES (127, 'job-category', 'N', 43, 1, '', 4, '', '', 'N', '', '', 'N', 'N', 'Y', 0, 'N', 'N')";
        if ($flag) {
            JB_mysql_query($sql) or die($sql . mysql_error());
        }
        $sql = "INSERT INTO `xml_export_elements` VALUES (128, 'rss', 'N', 0, 1, '', 3, 'version=\"2.0\"', '', 'N', '', '', 'N', 'N', 'N', 0, 'N', '')";
        if ($flag) {
            JB_mysql_query($sql) or die($sql . mysql_error());
        }
        $sql = "INSERT INTO `xml_export_elements` VALUES (129, 'channel', 'N', 128, 1, '', 3, '', '', 'N', '', '', 'N', 'N', 'N', 0, 'N', '')";
        if ($flag) {
            JB_mysql_query($sql) or die($sql . mysql_error());
        }
        $sql = "INSERT INTO `xml_export_elements` VALUES (130, 'title', 'N', 129, 1, '', 3, '', '%SITE_NAME%', 'N', '', '', 'N', 'N', 'N', 0, 'N', '')";
        if ($flag) {
            JB_mysql_query($sql) or die($sql . mysql_error());
        }
        $sql = "INSERT INTO `xml_export_elements` VALUES (131, 'link', 'N', 129, 1, '', 3, '', '%BASE_HTTP_PATH%', 'N', '', '', 'N', 'N', 'N', 0, 'N', '')";
        if ($flag) {
            JB_mysql_query($sql) or die($sql . mysql_error());
        }
        $sql = "INSERT INTO `xml_export_elements` VALUES (132, 'description', 'N', 129, 1, '', 3, '', '%SITE_DESCRIPTION%', 'N', '', '', 'N', 'N', 'N', 0, 'N', '')";
        if ($flag) {
            JB_mysql_query($sql) or die($sql . mysql_error());
        }
        $sql = "INSERT INTO `xml_export_elements` VALUES (133, 'language', 'N', 129, 1, '', 3, '', '%DEFAULT_LANG%', 'N', '', '', 'N', 'N', 'N', 0, 'N', '')";
        if ($flag) {
            JB_mysql_query($sql) or die($sql . mysql_error());
        }
        $sql = "INSERT INTO `xml_export_elements` VALUES (134, 'pubDate', 'N', 129, 1, '', 3, '', '%FEED_DATE%', 'N', '', '', 'N', 'N', 'N', 0, 'N', '')";
        if ($flag) {
            JB_mysql_query($sql) or die($sql . mysql_error());
        }
        $sql = "INSERT INTO `xml_export_elements` VALUES (135, 'lastBuildDate', 'N', 129, 1, '', 3, '', '%FEED_DATE%', 'N', '', '', 'N', 'N', 'N', 0, 'N', '')";
        if ($flag) {
            JB_mysql_query($sql) or die($sql . mysql_error());
        }
        $sql = "INSERT INTO `xml_export_elements` VALUES (136, 'docs', 'N', 129, 1, '', 3, '', 'http://blogs.law.harvard.edu/tech/rss', 'N', '', '', 'N', 'N', 'N', 0, 'N', '')";
        if ($flag) {
            JB_mysql_query($sql) or die($sql . mysql_error());
        }
        $sql = "INSERT INTO `xml_export_elements` VALUES (137, 'generator', 'N', 129, 1, '', 3, '', 'Jamit Job Board XML export tool', 'N', '', '', 'N', 'N', 'N', 0, 'N', '')";
        if ($flag) {
            JB_mysql_query($sql) or die($sql . mysql_error());
        }
        $sql = "INSERT INTO `xml_export_elements` VALUES (138, 'managingEditor', 'N', 129, 1, '', 3, '', '%SITE_CONTACT_EMAIL%', 'N', '', '', 'N', 'N', 'N', 0, 'N', '')";
        if ($flag) {
            JB_mysql_query($sql) or die($sql . mysql_error());
        }
        $sql = "INSERT INTO `xml_export_elements` VALUES (139, 'webMaster', 'N', 129, 1, '', 3, '', '%SITE_CONTACT_EMAIL%', 'N', '', '', 'N', 'N', 'N', 0, 'N', '')";
        if ($flag) {
            JB_mysql_query($sql) or die($sql . mysql_error());
        }
        $sql = "INSERT INTO `xml_export_elements` VALUES (140, 'image', 'N', 129, 1, '', 3, '', '', 'N', '', '', 'N', 'N', 'N', 0, 'N', '')";
        if ($flag) {
            JB_mysql_query($sql) or die($sql . mysql_error());
        }
        $sql = "INSERT INTO `xml_export_elements` VALUES (141, 'link', 'N', 140, 1, '', 3, '', '%BASE_HTTP_PATH%', 'N', '', '', 'N', 'N', 'N', 0, 'N', '')";
        if ($flag) {
            JB_mysql_query($sql) or die($sql . mysql_error());
        }
        $sql = "INSERT INTO `xml_export_elements` VALUES (142, 'title', 'N', 140, 1, '', 3, '', '%SITE_NAME%', 'N', '', '', 'N', 'N', 'N', 0, 'N', '')";
        if ($flag) {
            JB_mysql_query($sql) or die($sql . mysql_error());
        }
        $sql = "INSERT INTO `xml_export_elements` VALUES (143, 'url', 'N', 140, 1, '', 3, '', '%RSS_FEED_LOGO%', 'N', '', '', 'N', 'N', 'N', 0, 'N', '')";
        if ($flag) {
            JB_mysql_query($sql) or die($sql . mysql_error());
        }
        $sql = "INSERT INTO `xml_export_elements` VALUES (144, 'height', 'N', 140, 1, '', 3, '', '%RSS_LOGO_HEIGHT%', 'N', '', '', 'N', 'N', 'N', 0, 'N', '')";
        if ($flag) {
            JB_mysql_query($sql) or die($sql . mysql_error());
        }
        $sql = "INSERT INTO `xml_export_elements` VALUES (145, 'width', 'N', 140, 1, '', 3, '', '%RSS_LOGO_WIDTH%', 'N', '', '', 'N', 'N', 'N', 0, 'N', '')";
        if ($flag) {
            JB_mysql_query($sql) or die($sql . mysql_error());
        }
        $sql = "INSERT INTO `xml_export_elements` VALUES (146, 'item', 'N', 129, 1, '', 3, '', '', 'Y', '', '', 'N', 'N', 'N', 0, 'N', '')";
        if ($flag) {
            JB_mysql_query($sql) or die($sql . mysql_error());
        }
        $sql = "INSERT INTO `xml_export_elements` VALUES (147, 'title', 'N', 146, 1, '', 3, '', '', 'N', '', '', 'N', 'N', 'N', 0, 'N', 'Y')";
        if ($flag) {
            JB_mysql_query($sql) or die($sql . mysql_error());
        }
        $sql = "INSERT INTO `xml_export_elements` VALUES (148, 'link', 'N', 146, 1, '', 3, '', '%LINK%', 'N', '', '', 'N', 'N', 'N', 0, 'N', 'Y')";
        if ($flag) {
            JB_mysql_query($sql) or die($sql . mysql_error());
        }
        $sql = "INSERT INTO `xml_export_elements` VALUES (149, 'description', 'N', 146, 1, '', 3, '', '', 'N', '', '', 'N', 'N', 'N', 300, 'Y', 'Y')";
        if ($flag) {
            JB_mysql_query($sql) or die($sql . mysql_error());
        }
        $sql = "INSERT INTO `xml_export_elements` VALUES (151, 'pubDate', 'N', 146, 1, '', 3, '', '', 'N', '', '', 'N', 'N', 'N', 0, 'N', 'Y')";
        if ($flag) {
            JB_mysql_query($sql) or die($sql . mysql_error());
        }
        $sql = "INSERT INTO `xml_export_elements` VALUES (152, 'guid', 'N', 146, 1, '', 3, '', '%LINK%', 'N', '', '', 'N', 'N', 'N', 0, 'N', 'Y')";
        if ($flag) {
            JB_mysql_query($sql) or die($sql . mysql_error());
        }
        $upgrade_needed = true;
    }
    if (!does_field_exist("categories", "seo_fname")) {
        $sql = "ALTER TABLE categories ADD `seo_fname` VARCHAR(100) NULL default NULL";
        if ($flag) {
            JB_mysql_query($sql) or die($sql . mysql_error());
        }
        $upgrade_needed = true;
    }
    if (!does_field_exist("categories", "seo_title")) {
        $sql = "ALTER TABLE categories ADD `seo_title` VARCHAR(255) NULL default NULL";
        if ($flag) {
            JB_mysql_query($sql) or die($sql . mysql_error());
        }
        $upgrade_needed = true;
    }
    if (!does_field_exist("categories", "seo_desc")) {
        $sql = "ALTER TABLE categories ADD `seo_desc` VARCHAR(255) NULL default NULL";
        if ($flag) {
            JB_mysql_query($sql) or die($sql . mysql_error());
        }
        $upgrade_needed = true;
    }
    if (!does_field_exist("categories", "seo_keys")) {
        $sql = "ALTER TABLE categories ADD `seo_keys` VARCHAR(255) NULL default NULL";
        if ($flag) {
            JB_mysql_query($sql) or die($sql . mysql_error());
        }
        $upgrade_needed = true;
        // update the Indexes
        $sql = "ALTER TABLE `categories` DROP PRIMARY KEY ";
        if ($flag) {
            JB_mysql_query($sql);
        }
        $sql = "ALTER TABLE `categories` DROP INDEX `category_id` ";
        if ($flag) {
            JB_mysql_query($sql);
        }
        $sql = "ALTER TABLE `categories` ADD INDEX ( `seo_fname` ) ";
        if ($flag) {
            JB_mysql_query($sql);
        }
        $sql = "ALTER TABLE `categories` ADD PRIMARY KEY ( `category_id` ) ";
        if ($flag) {
            JB_mysql_query($sql);
        }
    }
    if (!does_field_exist('categories', 'allow_records')) {
        $sql = "ALTER TABLE `categories` ADD `allow_records` SET( 'Y', 'N' ) DEFAULT 'Y' NOT NULL";
        if ($flag) {
            JB_mysql_query($sql) or die(mysql_error());
        }
        $upgrade_needed = true;
    }
    if (!does_field_exist("categories", "has_child")) {
        $sql = "ALTER TABLE `categories` ADD `has_child` SET( 'Y', 'N' ) DEFAULT NULL ;";
        if ($flag) {
            JB_mysql_query($sql) or die($sql . mysql_error());
        }
        if ($flag) {
            JB_compute_cat_has_child();
        }
        if ($flag) {
            JB_cache_flush();
        }
        $upgrade_needed = true;
    }
    if (!does_field_exist('lang', 'is_default')) {
        $sql = "ALTER TABLE `lang` ADD `is_default` SET( 'Y', 'N' ) DEFAULT 'N' NOT NULL";
        if ($flag) {
            JB_mysql_query($sql) or die(mysql_error());
        }
        $upgrade_needed = true;
    }
    if (!does_field_exist('lang', 'charset')) {
        $sql = "ALTER TABLE `lang` ADD `charset` VARCHAR( 32 ) NOT NULL ";
        if ($flag) {
            JB_mysql_query($sql) or die(mysql_error());
        }
        $upgrade_needed = true;
    }
    if (!does_field_exist('employers', 'newsletter_last_run')) {
        $sql = "ALTER TABLE `employers` ADD `newsletter_last_run` DATETIME NOT NULL ";
        if ($flag) {
            JB_mysql_query($sql) or die(mysql_error());
        }
        $upgrade_needed = true;
    }
    if (!does_field_exist('users', 'newsletter_last_run')) {
        $sql = "ALTER TABLE `users` ADD `newsletter_last_run` DATETIME NOT NULL ";
        if ($flag) {
            JB_mysql_query($sql) or die(mysql_error());
        }
        $upgrade_needed = true;
    }
    if (!does_field_exist('package_invoices', 'payment_method')) {
        $sql = "ALTER TABLE `package_invoices` ADD `payment_method` VARCHAR( 64 ) NOT NULL  ";
        if ($flag) {
            JB_mysql_query($sql) or die(mysql_error());
        }
        $upgrade_needed = true;
    }
    if (!does_field_exist('subscription_invoices', 'payment_method')) {
        $sql = "ALTER TABLE `subscription_invoices` ADD `payment_method` VARCHAR( 64 ) NOT NULL ";
        if ($flag) {
            JB_mysql_query($sql) or die(mysql_error());
        }
        $upgrade_needed = true;
    }
    if (!does_field_exist('users', 'lang')) {
        $sql = "ALTER TABLE `users` ADD `lang` VARCHAR( 3 ) NOT NULL ";
        if ($flag) {
            JB_mysql_query($sql) or die(mysql_error());
        }
        $upgrade_needed = true;
    }
    if (!does_field_exist('skill_matrix', 'matrix_id')) {
        $sql = "CREATE TABLE `skill_matrix` ( " . "`matrix_id` INT NOT NULL AUTO_INCREMENT , " . "`field_id` INT NOT NULL , " . "`row_count` VARCHAR( 255 ) NOT NULL , " . "PRIMARY KEY ( `matrix_id` ) " . ")  ;";
        if ($flag) {
            JB_mysql_query($sql) or die(mysql_error());
        }
        $upgrade_needed = true;
    }
    if (!does_field_exist('skill_matrix_data', 'field_id')) {
        $sql = "CREATE TABLE `skill_matrix_data` ( " . "`field_id` INT NOT NULL , " . "`row` INT NOT NULL , " . "`object_id` INT NOT NULL , " . " `user_id` INT NOT NULL , " . "`name` VARCHAR( 255 ) NOT NULL , " . "`years` VARCHAR( 2 ) NOT NULL , " . "`rating` VARCHAR( 2 ) NOT NULL , " . "PRIMARY KEY ( `field_id` , `row` ) " . ")  ";
        if ($flag) {
            JB_mysql_query($sql) or die(mysql_error() . "f53cjku");
        }
        $upgrade_needed = true;
    }
    if (!does_field_exist('skill_matrix_data', 'user_id')) {
        $sql = "ALTER TABLE skill_matrix_data ADD `user_id` int ( 11 ) NOT NULL  ";
        if ($flag) {
            JB_mysql_query($sql) or die(mysql_error() . "jhjkh");
        }
        $upgrade_needed = true;
    }
    $sql = "ALTER TABLE `applications` CHANGE `app_id` `app_id` INT( 11 ) NOT NULL AUTO_INCREMENT ";
    if ($flag) {
        JB_mysql_query($sql) or die(mysql_error() . "hgfhdde4");
    }
    if (!does_field_exist('currencies', 'code')) {
        $sql = "CREATE TABLE `currencies` ( " . "`code` VARCHAR( 3 ) NOT NULL , " . "`name` VARCHAR( 50 ) NOT NULL , " . "`rate` DECIMAL (10,4) NOT NULL , " . "`is_default` SET( 'Y', 'N' ) NOT NULL, " . "`sign` VARCHAR (8) NOT NULL , " . "`decimal_places` SMALLINT NOT NULL, " . "`decimal_point` VARCHAR( 3 ) NOT NULL , " . "`thousands_sep` VARCHAR( 3 ) NOT NULL , " . "PRIMARY KEY (`code`))";
        if ($flag) {
            JB_mysql_query($sql) or die(mysql_error() . "hjhj");
        }
        if ($flag) {
            mysql_query("INSERT INTO `currencies` VALUES ('AUD', 'Australian Dollar', 1.3228, 'N', '\$', 2, '.', ',')") or die(mysql_error() . "hjhj1");
        }
        if ($flag) {
            mysql_query("INSERT INTO `currencies` VALUES ('CAD', 'Canadian Dollar', 1.1998, 'N', '\$', 2, '.', ',')") or die(mysql_error() . "hjhj2");
        }
        if ($flag) {
            mysql_query("INSERT INTO `currencies` VALUES ('EUR', 'Euro', 0.8138, 'N', '€', 2, '.', ',')") or die(mysql_error() . "hjhj3");
        }
        if ($flag) {
            mysql_query("INSERT INTO `currencies` VALUES ('GBP', 'British Pound', 0.5555, 'N', '£', 2, '.', ',')") or die(mysql_error() . "hjhj4");
        }
        if ($flag) {
            mysql_query("INSERT INTO `currencies` VALUES ('JPY', 'Japanese Yen', 110.1950, 'N', '¥', 0, '.', ',')") or die(mysql_error() . "hjhj5");
        }
        if ($flag) {
            mysql_query("INSERT INTO `currencies` VALUES ('KRW', 'Korean Won', 1028.8000, 'N', '&#8361;', 0, '.', ',')") or die(mysql_error() . "hjhj6");
        }
        if ($flag) {
            mysql_query("INSERT INTO `currencies` VALUES ('USD', 'U.S. Dollar', 1, 'Y', '\$', 2, '.', ',')") or die(mysql_error() . "hjhj7");
        }
        $upgrade_needed = true;
    }
    if (!does_field_exist('currencies', 'sign')) {
        $sql = "ALTER TABLE currencies ADD `sign` VARCHAR( 8 ) NOT NULL  ";
        if ($flag) {
            JB_mysql_query($sql) or die(mysql_error() . "ghgg7fcd");
        }
        $upgrade_needed = true;
    }
    if (!does_field_exist('currencies', 'decimal_places')) {
        $sql = "ALTER TABLE currencies ADD `decimal_places` SMALLINT NOT NULL  ";
        if ($flag) {
            JB_mysql_query($sql) or die(mysql_error() . "gdd3hgg7fcd");
        }
        $upgrade_needed = true;
    }
    if (!does_field_exist('currencies', 'decimal_point')) {
        $sql = "ALTER TABLE currencies ADD `decimal_point` VARCHAR( 1 ) NOT NULL  ";
        if ($flag) {
            JB_mysql_query($sql) or die(mysql_error() . "ghgg7fcd");
        }
        $upgrade_needed = true;
    }
    if (!does_field_exist('currencies', 'thousands_sep')) {
        $sql = "ALTER TABLE currencies ADD `thousands_sep` VARCHAR( 3 ) NOT NULL  ";
        if ($flag) {
            JB_mysql_query($sql) or die(mysql_error() . "ghgg7fcd");
        }
        $upgrade_needed = true;
    }
    if (!does_field_exist('packages', 'currency_code')) {
        $sql = "ALTER TABLE packages ADD `currency_code` VARCHAR( 3 ) NOT NULL  ";
        if ($flag) {
            JB_mysql_query($sql) or die(mysql_error() . "gh7fcd");
        }
        $upgrade_needed = true;
    }
    if (!does_field_exist('subscriptions', 'currency_code')) {
        $sql = "ALTER TABLE subscriptions ADD `currency_code` VARCHAR( 3 ) NOT NULL  ";
        if ($flag) {
            JB_mysql_query($sql) or die(mysql_error() . 'hjkh');
        }
        $upgrade_needed = true;
    }
    if (!does_field_exist('subscription_invoices', 'currency_code')) {
        $sql = "ALTER TABLE subscription_invoices ADD `currency_code` VARCHAR( 3 ) NOT NULL  ";
        if ($flag) {
            JB_mysql_query($sql) or die(mysql_error() . 'hjddkh');
        }
        $upgrade_needed = true;
    }
    if (!does_field_exist('subscription_invoices', 'currency_rate')) {
        $sql = "ALTER TABLE subscription_invoices ADD `currency_rate` DECIMAL( 10, 4) NOT NULL  ";
        if ($flag) {
            JB_mysql_query($sql) or die(mysql_error() . 'hjw3dkh');
        }
        $upgrade_needed = true;
    }
    if (!does_field_exist('package_invoices', 'currency_code')) {
        $sql = "ALTER TABLE package_invoices ADD `currency_code` VARCHAR( 3 ) NOT NULL  ";
        if ($flag) {
            JB_mysql_query($sql) or die(mysql_error() . 'hjddkh');
        }
        $upgrade_needed = true;
    }
    if (!does_field_exist('package_invoices', 'currency_rate')) {
        $sql = "ALTER TABLE package_invoices ADD `currency_rate` DECIMAL( 10, 4) NOT NULL  ";
        if ($flag) {
            JB_mysql_query($sql) or die(mysql_error() . 'hjw3dkh');
        }
        $upgrade_needed = true;
    }
    if (!does_field_exist('form_fields', 'is_cat_multiple')) {
        $sql = "ALTER TABLE form_fields ADD `is_cat_multiple` SET ('Y', 'N') NOT NULL DEFAULT 'N' ";
        if ($flag) {
            JB_mysql_query($sql) or die(mysql_error() . 'hjw3sdh');
        }
        $upgrade_needed = true;
    }
    if (!does_field_exist('form_fields', 'multiple_sel_all')) {
        $sql = "ALTER TABLE form_fields ADD `multiple_sel_all` char(1) NOT NULL default 'N' ";
        if ($flag) {
            JB_mysql_query($sql) or die(mysql_error() . 'hwrwgkh');
        }
        $upgrade_needed = true;
    }
    if (!does_field_exist('form_fields', 'cat_multiple_rows')) {
        $sql = "ALTER TABLE form_fields ADD `cat_multiple_rows` INT(11) NOT NULL DEFAULT 1 ";
        if ($flag) {
            JB_mysql_query($sql) or die(mysql_error() . 'hw33rdkh');
        }
        $upgrade_needed = true;
    }
    if (!does_field_exist('form_fields', 'is_blocked')) {
        $sql = "ALTER TABLE form_fields ADD `is_blocked` char(1) NOT NULL default 'N' ";
        if ($flag) {
            JB_mysql_query($sql) or die(mysql_error() . 'hwrwgkh');
        }
        $upgrade_needed = true;
    }
    if (!does_field_exist('form_fields', 'is_prefill')) {
        $sql = "ALTER TABLE form_fields ADD `is_prefill` char(1) NOT NULL default 'N' ";
        if ($flag) {
            JB_mysql_query($sql) or die(mysql_error() . 'hwrwgkh');
        }
        $upgrade_needed = true;
    }
    if (!does_field_exist('form_fields', 'is_member')) {
        $sql = "ALTER TABLE form_fields ADD `is_member` char(1) NOT NULL default 'N' ";
        if ($flag) {
            JB_mysql_query($sql) or die(mysql_error() . 'hwrkjwgkh');
        }
        $upgrade_needed = true;
    }
    if (!does_field_exist('subscriptions', 'can_view_blocked')) {
        $sql = "ALTER TABLE subscriptions ADD `can_view_blocked` set('Y', 'N') NOT NULL default 'Y' ";
        if ($flag) {
            JB_mysql_query($sql) or die(mysql_error() . 'hwrwgkh');
        }
        $sql = "UPDATE subscriptions SET `can_view_blocked` = 'Y' ";
        if ($flag) {
            JB_mysql_query($sql) or die(mysql_error() . 'hwrwgkh');
        }
        $upgrade_needed = true;
    }
    if (!does_field_exist('subscription_invoices', 'can_view_blocked')) {
        $sql = "ALTER TABLE subscription_invoices ADD `can_view_blocked` set('Y', 'N') NOT NULL default 'Y' ";
        if ($flag) {
            JB_mysql_query($sql) or die(mysql_error() . 'hwrwgkh');
        }
        $upgrade_needed = true;
    }
    if (!does_field_exist('categories', 'list_order')) {
        $sql = "ALTER TABLE categories ADD `list_order` smallint(6) NOT NULL default '1' ";
        if ($flag) {
            JB_mysql_query($sql) or die(mysql_error() . 'hwrwgkh');
        }
        $upgrade_needed = true;
    }
    if (!does_field_exist('categories', 'search_set')) {
        $sql = "ALTER TABLE categories ADD `search_set` text NOT NULL  ";
        if ($flag) {
            JB_mysql_query($sql) or die(mysql_error() . 'hwrhjhwgkh');
        }
        $upgrade_needed = true;
    }
    if (!does_field_exist('mail_queue', 'mail_id')) {
        $sql = "CREATE TABLE `mail_queue` (\n  `mail_id` int(11) NOT NULL auto_increment,\n  `mail_date` datetime NOT NULL default '0000-00-00 00:00:00',\n  `to_address` varchar(128) NOT NULL default '',\n  `to_name` varchar(128) NOT NULL default '',\n  `from_address` varchar(128) NOT NULL default '',\n  `from_name` varchar(128) NOT NULL default '',\n  `subject` varchar(255) NOT NULL default '',\n  `message` text NOT NULL,\n  `html_message` text NOT NULL,\n  `attachments` set('Y','N') NOT NULL default '',\n  `status` set('queued','sent','error') NOT NULL default '',\n  `error_msg` varchar(255) NOT NULL default '',\n  `retry_count` smallint(6) NOT NULL default '0',\n  `template_id` int(11) NOT NULL default '0',\n  `att1_name` varchar(128) NOT NULL default '',\n  `att2_name` varchar(128) NOT NULL default '',\n  `att3_name` varchar(128) NOT NULL default '',\n  `date_stamp` datetime NOT NULL default '0000-00-00 00:00:00',\n  PRIMARY KEY  (`mail_id`)) ";
        if ($flag) {
            JB_mysql_query($sql) or die(mysql_error() . 'hwrjhhjhwgkh');
        }
        $upgrade_needed = true;
        $sql = "INSERT INTO `email_templates` (`EmailID`,  `EmailText`, `EmailFromAddress`, `EmailSubject`, `EmailFromName`) VALUES (60,  'Dear  %LNAME%, %FNAME%\r\n\r\nYour order on %SITE_NAME% was confirmed, thank you.\r\n\r\n========================\r\nORDER DETAILS\r\n=========================\r\nOrder ID: #%INVOICE_CODE%\r\nPosts: %QUANTITY% \r\nPrice: %INVOICE_AMOUNT%\r\nStatus: Confirmed\r\nPayment Method: Bank Deposit\r\n--------------------------.\r\n\r\nPlease deposit %INVOICE_AMOUNT% to the following account:\r\n\tBank: %BANK_NAME%\r\n        Bank Address: %BANK_ADDRESS%\r\n        SWIFT CODE: %BANK_AC_SWIFT%\r\n\tA/C Name: %AC_NAME%\r\n\tA/C Number: %AC_NUMBER%\r\n\r\nAfter making the deposit, please send an email to \r\ntest@example.com with the following \r\nOrder Number: %INVOICE_CODE% to help us speed up the process. \r\n\r\nFeel free to contact %SITE_CONTACT_EMAIL% if you have \r\nany questions / problems. \r\n\r\nThank you!\r\n\r\n\r\n%SITE_NAME% team.\r\n%SITE_URL%\r\n\r\nNote: This is an automated email.', '*****@*****.**', 'Order confirmed', 'Jamit Demo')";
        if ($flag) {
            JB_mysql_query($sql) or die(mysql_error() . 'hwrjhhjhwgkh');
        }
        $sql = "INSERT INTO `email_templates` (`EmailID`,  `EmailText`, `EmailFromAddress`, `EmailSubject`, `EmailFromName`) VALUES (61,  'Dear  %LNAME%, %FNAME%\r\n\r\nYour order on %SITE_NAME% was confirmed, thank you.\r\n\r\n========================\r\nORDER DETAILS\r\n=========================\r\nOrder ID: #%INVOICE_CODE%\r\nPosts: %QUANTITY% \r\nPrice: %INVOICE_AMOUNT%\r\nStatus: Confirmed\r\nPayment Method: Check / Money Order\r\n--------------------------.\r\n\r\nPlease send Check / Money Order to:\r\n\tName: %PAYEE_NAME%\r\n        Address: %PAYEE_ADDRESS%\r\n        Amount: %INVOICE_AMOUNT%\r\n        Currency: %CHECK_CURRENCY%\r\n\r\n\r\nFeel free to contact %SITE_CONTACT_EMAIL% if you have \r\nany questions / problems. \r\n\r\nThank you!\r\n\r\n\r\n%SITE_NAME% team.\r\n%SITE_URL%\r\n\r\nNote: This is an automated email.', '*****@*****.**', 'Confirmed Order', 'Jamit Demo')";
        if ($flag) {
            JB_mysql_query($sql) or die(mysql_error() . 'hwrjhhjhwgkh');
        }
        $sql = "INSERT INTO `email_templates` (`EmailID`,  `EmailText`, `EmailFromAddress`, `EmailSubject`, `EmailFromName`) VALUES (62,  'Dear  %LNAME%, %FNAME%\r\n\r\nYour order on %SITE_NAME% was confirmed, thank you.\r\n\r\n========================\r\nORDER DETAILS\r\n=========================\r\nOrder ID: #%INVOICE_CODE%\r\nPosts: %QUANTITY% \r\nPrice: %INVOICE_AMOUNT%\r\nStatus: Confirmed\r\nPayment Method: Instant (%PAYMENT_METHOD%)\r\n\r\n--------------------------\r\n\r\nFeel free to contact %SITE_CONTACT_EMAIL% if you have \r\nany questions / problems. \r\n\r\nThank you!\r\n\r\n\r\n%SITE_NAME% team.\r\n%SITE_URL%\r\n\r\nNote: This is an automated email.', '*****@*****.**', 'Order Confirmed', 'Jamit Demo')";
        if ($flag) {
            JB_mysql_query($sql) or die(mysql_error() . 'hwrjhhjhwgkh');
        }
        $sql = "INSERT INTO `email_templates` (`EmailID`,  `EmailText`, `EmailFromAddress`, `EmailSubject`, `EmailFromName`) VALUES (63,  'Dear  %LNAME%, %FNAME%\r\n\r\nYour order on %SITE_NAME% was confirmed, thank you.\r\n\r\n========================\r\nORDER DETAILS\r\n=========================\r\nOrder ID: #%INVOICE_CODE%\r\nPosts: %QUANTITY% \r\nPrice: %INVOICE_AMOUNT%\r\nStatus: Confirmed\r\nPayment Method: Instant (%PAYMENT_METHOD%)\r\n\r\n--------------------------\r\n\r\nFeel free to contact %SITE_CONTACT_EMAIL% if you have \r\nany questions / problems. \r\n\r\nThank you!', '*****@*****.**', 'Order Completed', 'Jamit Demo')";
        if ($flag) {
            JB_mysql_query($sql) or die(mysql_error() . 'hwrjhhjhwgkh');
        }
        $sql = "INSERT INTO `email_template_translations` (`EmailID`, `lang`, `EmailText`, `EmailFromAddress`, `EmailSubject`, `EmailFromName`) VALUES (60, 'EN', 'Dear  %LNAME%, %FNAME%\r\n\r\nYour order on %SITE_NAME% was confirmed, thank you.\r\n\r\n========================\r\nORDER DETAILS\r\n=========================\r\nOrder ID: #%INVOICE_CODE%\r\nPosts: %QUANTITY% \r\nPrice: %INVOICE_AMOUNT%\r\nStatus: Confirmed\r\nPayment Method: Bank Deposit\r\n--------------------------.\r\n\r\nPlease deposit %INVOICE_AMOUNT% to the following account:\r\n\tBank: %BANK_NAME%\r\n        Bank Address: %BANK_ADDRESS%\r\n        SWIFT CODE: %BANK_AC_SWIFT%\r\n\tA/C Name: %AC_NAME%\r\n\tA/C Number: %AC_NUMBER%\r\n\r\nAfter making the deposit, please send an email to \r\ntest@example.com with the following \r\nOrder Number: %INVOICE_CODE% to help us speed up the process. \r\n\r\nFeel free to contact %SITE_CONTACT_EMAIL% if you have \r\nany questions / problems. \r\n\r\nThank you!\r\n\r\n\r\n%SITE_NAME% team.\r\n%SITE_URL%\r\n\r\nNote: This is an automated email.', '*****@*****.**', 'Order confirmed', 'Jamit Demo')";
        if ($flag) {
            JB_mysql_query($sql) or die(mysql_error() . 'hwrjhhjhwgkh');
        }
        $sql = "INSERT INTO `email_template_translations` (`EmailID`, `lang`, `EmailText`, `EmailFromAddress`, `EmailSubject`, `EmailFromName`) VALUES (61, 'EN', 'Dear  %LNAME%, %FNAME%\r\n\r\nYour order on %SITE_NAME% was confirmed, thank you.\r\n\r\n========================\r\nORDER DETAILS\r\n=========================\r\nOrder ID: #%INVOICE_CODE%\r\nPosts: %QUANTITY% \r\nPrice: %INVOICE_AMOUNT%\r\nStatus: Confirmed\r\nPayment Method: Check / Money Order\r\n--------------------------.\r\n\r\nPlease send Check / Money Order to:\r\n\tName: %PAYEE_NAME%\r\n        Address: %PAYEE_ADDRESS%\r\n        Amount: %INVOICE_AMOUNT%\r\n        Currency: %CHECK_CURRENCY%\r\n\r\n\r\nFeel free to contact %SITE_CONTACT_EMAIL% if you have \r\nany questions / problems. \r\n\r\nThank you!\r\n\r\n\r\n%SITE_NAME% team.\r\n%SITE_URL%\r\n\r\nNote: This is an automated email.', '*****@*****.**', 'Confirmed Order', 'Jamit Demo')";
        if ($flag) {
            JB_mysql_query($sql) or die(mysql_error() . 'hwrjhhjhwgkh');
        }
        $sql = "INSERT INTO `email_template_translations` (`EmailID`, `lang`, `EmailText`, `EmailFromAddress`, `EmailSubject`, `EmailFromName`) VALUES (62, 'EN', 'Dear  %LNAME%, %FNAME%\r\n\r\nYour order on %SITE_NAME% was confirmed, thank you.\r\n\r\n========================\r\nORDER DETAILS\r\n=========================\r\nOrder ID: #%INVOICE_CODE%\r\nPosts: %QUANTITY% \r\nPrice: %INVOICE_AMOUNT%\r\nStatus: Confirmed\r\nPayment Method: Instant (%PAYMENT_METHOD%)\r\n\r\n--------------------------\r\n\r\nFeel free to contact %SITE_CONTACT_EMAIL% if you have \r\nany questions / problems. \r\n\r\nThank you!\r\n\r\n\r\n%SITE_NAME% team.\r\n%SITE_URL%\r\n\r\nNote: This is an automated email.', '*****@*****.**', 'Order Confirmed', 'Jamit Demo')";
        if ($flag) {
            JB_mysql_query($sql) or die(mysql_error() . 'hwrjhhjhwgkh');
        }
        $sql = "INSERT INTO `email_template_translations` (`EmailID`, `lang`, `EmailText`, `EmailFromAddress`, `EmailSubject`, `EmailFromName`) VALUES (63, 'EN', 'Dear  %LNAME%, %FNAME%\r\n\r\nYour order on %SITE_NAME% was confirmed, thank you.\r\n\r\n========================\r\nORDER DETAILS\r\n=========================\r\nOrder ID: #%INVOICE_CODE%\r\nPosts: %QUANTITY% \r\nPrice: %INVOICE_AMOUNT%\r\nStatus: Confirmed\r\nPayment Method: Instant (%PAYMENT_METHOD%)\r\n\r\n--------------------------\r\n\r\nFeel free to contact %SITE_CONTACT_EMAIL% if you have \r\nany questions / problems. \r\n\r\nThank you!', '*****@*****.**', 'Order Completed', 'Jamit Demo')";
        if ($flag) {
            JB_mysql_query($sql) or die(mysql_error() . 'hwrjhhjhwgkh');
        }
    }
    if (!does_field_exist('users', 'alert_query')) {
        $sql = "ALTER TABLE users ADD  `alert_query` TEXT NOT NULL  ";
        if ($flag) {
            JB_mysql_query($sql) or die(mysql_error() . 'hwrhjhwgkh');
        }
        $upgrade_needed = true;
    }
    if (!does_field_exist('employers', 'alert_query')) {
        $sql = "ALTER TABLE employers ADD `alert_query` TEXT NOT NULL ";
        if ($flag) {
            JB_mysql_query($sql) or die(mysql_error() . 'rr4456f');
        }
        $upgrade_needed = true;
    }
    //
    if (!does_field_exist('jb_variables', 'key')) {
        $sql = "CREATE TABLE `jb_variables` (\n\t\t`key` VARCHAR( 255 ) NOT NULL ,\n\t\t`val` VARCHAR( 255 ) NOT NULL ,\n\t\tPRIMARY KEY ( `key` ) \n\t\t)";
        if ($flag) {
            JB_mysql_query($sql) or die(mysql_error() . 'grrvvvg');
        }
        $upgrade_needed = true;
    }
    if ($flag) {
        $sql = "SELECT * FROM `jb_variables` WHERE `key`='HOUSEKEEP_RUNNING' ";
        $res = JB_mysql_query($sql);
        $row = mysql_fetch_array($res);
        if ($row['val'] == '') {
            $sql = "REPLACE INTO `jb_variables` (`key`, `val`) VALUES ('HOUSEKEEP_RUNNING', 'NO') ";
            if ($flag) {
                JB_mysql_query($sql);
            }
        }
    }
    if ($flag) {
        $sql = "SELECT * FROM `jb_variables` WHERE `key`='MAIL_QUEUE_RUNNING' ";
        $res = JB_mysql_query($sql);
        $row = mysql_fetch_array($res);
        if ($row['val'] == '') {
            $sql = "REPLACE INTO `jb_variables` (`key`, `val`) VALUES ('MAIL_QUEUE_RUNNING', 'NO') ";
            if ($flag) {
                JB_mysql_query($sql);
            }
        }
    }
    //
    if (!does_field_exist('jb_sessions', 'session_id')) {
        $sql = "CREATE TABLE `jb_sessions` (\n\t\t`session_id` VARCHAR( 255 ) NOT NULL ,\n\t\t`last_request_time` datetime NOT NULL default '0000-00-00 00:00:00',\n\t\t`domain` SET( 'EMPLOYER', 'CANDIDATE' ) NOT NULL ,\n        `id` INT NOT NULL,\n\t\t`remote_addr` VARCHAR( 255 ) NOT NULL ,\n\t\tPRIMARY KEY ( `session_id` ) \n\t\t)";
        if ($flag) {
            JB_mysql_query($sql) or die(mysql_error() . 'hwrhjhwgkh');
        }
        $upgrade_needed = true;
    }
    if (!does_field_exist('jb_sessions', 'user_agent')) {
        $sql = "ALTER TABLE `jb_sessions` ADD `user_agent` varchar(255) NOT NULL ";
        if ($flag) {
            JB_mysql_query($sql) or die(mysql_error() . 'hd4olfhma');
        }
        $upgrade_needed = true;
    }
    // http_referer
    if (!does_field_exist('jb_sessions', 'http_referer')) {
        $sql = "ALTER TABLE `jb_sessions` ADD `http_referer` varchar(255) NOT NULL ";
        if ($flag) {
            JB_mysql_query($sql) or die(mysql_error() . 'hdslfhfda');
        }
        $upgrade_needed = true;
    }
    if (!does_field_exist('form_lists', 'column_id')) {
        $sql = "CREATE TABLE `form_lists` (\n\t\t  `form_id` int(11) NOT NULL default '0',\n\t\t  `field_type` varchar(255) NOT NULL default '',\n\t\t  `sort_order` int(11) NOT NULL default 0,\n\t\t  `field_id` varchar(255) NOT NULL default '0',\n\t\t  `template_tag` varchar(255) NOT NULL default '',\n\t\t  `column_id` int(11) NOT NULL auto_increment,\n\t\t  `linked` set('Y','N') NOT NULL default 'N',\n\t\t  `admin` set('Y','N') NOT NULL default 'N',\n\t\t  `truncate_length` SMALLINT( 4 ) NOT NULL default '0',\n\t\t  `clean_format` set('Y','N') NOT NULL default '',\n\t\t  `is_bold` set('Y','N') NOT NULL default 'N',\n\t\t  `no_wrap` set('Y','N') NOT NULL default 'N',\n\t\t  PRIMARY KEY  (`column_id`)\n\t\t)";
        if ($flag) {
            JB_mysql_query($sql) or die(mysql_error() . 'hd4olfhma');
        }
        $sql = "INSERT INTO `form_lists` VALUES (1, 'TIME', '1', 'post_date', 'DATE', 13, 'N', 0, 'N', 'N', 'N', 'Y')";
        if ($flag) {
            JB_mysql_query($sql) or die(mysql_error() . 'hd4olfhma');
        }
        $sql = "INSERT INTO `form_lists` VALUES (1, 'TEXT', '2', 'summary', 'POST_SUMMARY', 14, 'N', 0, 'N', 'N', 'N', '')";
        if ($flag) {
            JB_mysql_query($sql) or die(mysql_error() . 'hd4olfhma');
        }
        $sql = "INSERT INTO `form_lists` VALUES (1, 'TEXT', '3', '15', 'LOCATION', 15, 'N', 0, 'N', 'Y', 'Y', 'N')";
        if ($flag) {
            JB_mysql_query($sql) or die(mysql_error() . 'hd4olfhma');
        }
        $sql = "INSERT INTO `form_lists` VALUES (1, 'TEXT', '4', 'hits', 'HITS', 16, 'Y', 0, 'N', 'N', '', '')";
        if ($flag) {
            JB_mysql_query($sql) or die(mysql_error() . 'hd4olfhma');
        }
        $sql = "INSERT INTO `form_lists` VALUES (2, 'TEXT', '2', '36', 'RESUME_NAME', 5, 'Y', 0, 'N', '', '', '')";
        if ($flag) {
            JB_mysql_query($sql) or die(mysql_error() . 'hd4olfhma');
        }
        $sql = "INSERT INTO `form_lists` VALUES (2, 'TIME', '1', 'resume_date', 'DATE', 6, '', 0, 'N', '', '', '')";
        if ($flag) {
            JB_mysql_query($sql) or die(mysql_error() . 'hd4olfhma');
        }
        $sql = "INSERT INTO `form_lists` VALUES (2, 'DATE', '3', '54', 'RESUME_COL3', 7, 'N', 0, 'Y', '', '', '')";
        if ($flag) {
            JB_mysql_query($sql) or die(mysql_error() . 'hd4olfhma');
        }
        $sql = "INSERT INTO `form_lists` VALUES (2, 'TEXT', '4', '39', 'RESUME_COL4', 8, 'N', 0, 'N', 'N', 'N', 'N')";
        if ($flag) {
            JB_mysql_query($sql) or die(mysql_error() . 'hd4olfhma');
        }
        $upgrade_needed = true;
    } else {
        // fix column type bug...
        $sql = "SHOW columns from `form_lists`";
        $result = JB_mysql_query($sql);
        while ($row = mysql_fetch_row($result)) {
            if ($row[0] == 'sort_order' && $row[1] == 'varchar(255)') {
                $sql = "ALTER TABLE `form_lists` CHANGE `sort_order` `sort_order` INT( 11 ) NOT NULL";
                JB_mysql_query($sql);
            }
        }
    }
    if (!does_field_exist('form_lists', 'is_sortable')) {
        $sql = "ALTER TABLE `form_lists` ADD `is_sortable` set('Y','N') NOT NULL default 'N' ";
        if ($flag) {
            JB_mysql_query($sql) or die(mysql_error() . 'hd4olfhma');
        }
        $upgrade_needed = true;
    }
    if (!does_field_exist('email_templates', 'sub_template')) {
        $sql = "ALTER TABLE `email_templates` ADD `sub_template` TEXT NOT NULL ";
        if ($flag) {
            JB_mysql_query($sql) or die(mysql_error() . 'hd4olfhma');
        }
        $upgrade_needed = true;
    }
    if (!does_field_exist('saved_jobs', 'post_id')) {
        $sql = "CREATE TABLE `saved_jobs` (\n\t\t  `post_id` int(11) NOT NULL default '0',\n\t\t  `user_id` int(11) NOT NULL default '0',\n\t\t  `save_date` datetime NOT NULL default '0000-00-00 00:00:00',\n\t\t  PRIMARY KEY  (`post_id`,`user_id`))";
        if ($flag) {
            JB_mysql_query($sql) or die(mysql_error() . 'hd4sjwfhma');
        }
        $upgrade_needed = true;
    }
    if (!does_field_exist('email_template_translations', 'sub_template')) {
        $sql = "ALTER TABLE `email_template_translations` ADD `sub_template` TEXT NOT NULL ";
        if ($flag) {
            JB_mysql_query($sql) or die(mysql_error() . 'fdsf');
        }
        ### populate sub_template ##
        $sql = "UPDATE `email_templates` SET `sub_template`='%DATE% : %RESUME_NAME% (%NATIONALITY%)' WHERE EmailID=5 ";
        if ($flag) {
            JB_mysql_query($sql) or die(mysql_error() . 'hd4olfhma');
        }
        $sql = "UPDATE `email_template_translations` SET `sub_template`='%DATE% : %RESUME_NAME% (%NATIONALITY%)' WHERE EmailID=5 ";
        if ($flag) {
            JB_mysql_query($sql) or die(mysql_error() . 'hd4olfhma');
        }
        $sql = "UPDATE `email_templates` SET `sub_template`='<font face=''arial'' size=''2''>%DATE% - %RESUME_NAME% </font>' WHERE EmailID=6 ";
        if ($flag) {
            JB_mysql_query($sql) or die(mysql_error() . 'hd4olfhma');
        }
        $sql = "UPDATE `email_template_translations` SET `sub_template`='<font face=''arial'' size=''2''>%DATE% - %RESUME_NAME% </font>' WHERE EmailID=6 ";
        if ($flag) {
            JB_mysql_query($sql) or die(mysql_error() . 'hd4olfhma');
        }
        $sql = "UPDATE `email_templates` SET `sub_template`='%FORMATTED_DATE% : %TITLE% (%LOCATION%)\nLink: %BASE_HTTP_PATH%index.php?post_id=%POST_ID%' WHERE EmailID=7 ";
        if ($flag) {
            JB_mysql_query($sql) or die(mysql_error() . 'hd4oglfghma');
        }
        $sql = "UPDATE `email_template_translations` SET `sub_template`='%FORMATTED_DATE% : %TITLE% (%LOCATION%)\nLink: %BASE_HTTP_PATH%index.php?post_id=%POST_ID%' WHERE EmailID=7 ";
        if ($flag) {
            JB_mysql_query($sql) or die(mysql_error() . 'hd4oglfghma');
        }
        $sql = "UPDATE `email_templates` SET `sub_template`='<font face=''arial'' size=''2''>%FORMATTED_DATE% - <a href=''%BASE_HTTP_PATH%index.php?post_id=%POST_ID%''>%TITLE%</a></font> (%LOCATION%) <font face=''arial'' size=''1'' color=''#808080''>%DESCRIPTION%</font>' WHERE EmailID=8 ";
        if ($flag) {
            JB_mysql_query($sql) or die(mysql_error() . 'hd4wwolfhma');
        }
        $sql = "UPDATE `email_template_translations` SET `sub_template`='<font face=''arial'' size=''2''>%FORMATTED_DATE% - <a href=''%BASE_HTTP_PATH%index.php?post_id=%POST_ID%''>%TITLE%</a></font> (%LOCATION%) <font face=''arial'' size=''1'' color=''#808080''>%DESCRIPTION%</font>' WHERE EmailID=8 ";
        if ($flag) {
            JB_mysql_query($sql) or die(mysql_error() . 'hd4wwolfhma');
        }
        $upgrade_needed = true;
    }
    if (!does_field_exist('package_invoices', 'reason')) {
        $sql = "ALTER TABLE `package_invoices` ADD `reason` VARCHAR( 128 ) NOT NULL";
        if ($flag) {
            JB_mysql_query($sql) or die(mysql_error() . 'ggguufdds');
        }
        $upgrade_needed = true;
    }
    if (!does_field_exist('subscription_invoices', 'reason')) {
        $sql = "ALTER TABLE `subscription_invoices` ADD `reason` VARCHAR( 128 ) NOT NULL ";
        if ($flag) {
            JB_mysql_query($sql) or die(mysql_error() . 'nhhg');
        }
        $upgrade_needed = true;
    }
    if (does_field_exist('employers', 'alert_modify_date')) {
        $sql = "ALTER TABLE `employers` DROP `alert_modify_date` ";
        if ($flag) {
            JB_mysql_query($sql) or die(mysql_error() . 'jhjhg5s');
        }
        $upgrade_needed = true;
    }
    if (does_field_exist('employers', 'alert_modify_date')) {
        $sql = "ALTER TABLE `employers` DROP `alert_modify_date` ";
        if ($flag) {
            JB_mysql_query($sql) or die(mysql_error() . 'jhjhg5s');
        }
        $upgrade_needed = true;
    }
    if (does_field_exist('users', 'alert_modify_date')) {
        $sql = "ALTER TABLE `users` DROP `alert_modify_date` ";
        if ($flag) {
            JB_mysql_query($sql) or die(mysql_error() . 'dffdcvvv');
        }
        $upgrade_needed = true;
        // amd why not modify form_lists while we are at it...
        $sql = "INSERT INTO `form_lists` (`form_id`, `field_type`, `sort_order`, `field_id`, `template_tag`, `column_id`, `admin`, `truncate_length`, `linked`, `clean_format`, `is_bold`, `is_sortable`, `no_wrap`) VALUES (4, 'TEXT', 1, 'login_count', 'LCOUNT', 17, 'N', 0, '', 'N', 'N', 'N', 'Y');";
        if ($flag) {
            JB_mysql_query($sql) or mysql_error() . 'dffdc1';
        }
        $sql = "INSERT INTO `form_lists` (`form_id`, `field_type`, `sort_order`, `field_id`, `template_tag`, `column_id`, `admin`, `truncate_length`, `linked`, `clean_format`, `is_bold`, `is_sortable`, `no_wrap`) VALUES (4, 'TEXT', 2, 'Name', 'NAME', 18, 'N', 0, '', 'N', 'N', 'N', 'Y');";
        if ($flag) {
            JB_mysql_query($sql) or mysql_error() . 'dffdc2';
        }
        $sql = "INSERT INTO `form_lists` (`form_id`, `field_type`, `sort_order`, `field_id`, `template_tag`, `column_id`, `admin`, `truncate_length`, `linked`, `clean_format`, `is_bold`, `is_sortable`, `no_wrap`) VALUES (4, 'TEXT', 3, 'Username', 'USERNAME', 19, 'N', 0, '', 'N', 'N', 'N', 'Y');";
        if ($flag) {
            JB_mysql_query($sql) or mysql_error() . 'dffdc3';
        }
        $sql = "INSERT INTO `form_lists` (`form_id`, `field_type`, `sort_order`, `field_id`, `template_tag`, `column_id`, `admin`, `truncate_length`, `linked`, `clean_format`, `is_bold`, `is_sortable`, `no_wrap`) VALUES (4, 'TEXT', 4, 'Email', 'EMAIL', 20, 'N', 0, '', 'N', 'N', 'N', 'Y');";
        if ($flag) {
            JB_mysql_query($sql) or mysql_error() . 'dffdc4';
        }
        $sql = "INSERT INTO `form_lists` (`form_id`, `field_type`, `sort_order`, `field_id`, `template_tag`, `column_id`, `admin`, `truncate_length`, `linked`, `clean_format`, `is_bold`, `is_sortable`, `no_wrap`) VALUES (4, 'TEXT', 5, 'CompName', 'CNAME', 21, 'N', 0, 'Y,N', 'N', 'N', 'N', 'Y');";
        if ($flag) {
            JB_mysql_query($sql) or mysql_error() . 'dffdc5';
        }
        $sql = "INSERT INTO `form_lists` (`form_id`, `field_type`, `sort_order`, `field_id`, `template_tag`, `column_id`, `admin`, `truncate_length`, `linked`, `clean_format`, `is_bold`, `is_sortable`, `no_wrap`) VALUES (4, 'TEXT', 6, 'posts', 'POSTS', 22, 'N', 0, '', 'N', 'N', 'N', 'N');";
        if ($flag) {
            JB_mysql_query($sql) or mysql_error() . 'dffdc6';
        }
        $sql = "INSERT INTO `form_lists` (`form_id`, `field_type`, `sort_order`, `field_id`, `template_tag`, `column_id`, `admin`, `truncate_length`, `linked`, `clean_format`, `is_bold`, `is_sortable`, `no_wrap`) VALUES (4, 'TEXT', 7, 'Newsletter', 'NEWS', 23, 'N', 0, '', 'N', 'N', 'N', 'N');";
        if ($flag) {
            JB_mysql_query($sql) or mysql_error() . 'dffdc7';
        }
        $sql = "INSERT INTO `form_lists` (`form_id`, `field_type`, `sort_order`, `field_id`, `template_tag`, `column_id`, `admin`, `truncate_length`, `linked`, `clean_format`, `is_bold`, `is_sortable`, `no_wrap`) VALUES (4, 'TEXT', 8, 'Notification1', 'ALERTS', 24, 'N', 0, '', 'N', 'N', 'N', 'N');";
        if ($flag) {
            JB_mysql_query($sql) or mysql_error() . 'dffdc8';
        }
        $sql = "INSERT INTO `form_lists` (`form_id`, `field_type`, `sort_order`, `field_id`, `template_tag`, `column_id`, `admin`, `truncate_length`, `linked`, `clean_format`, `is_bold`, `is_sortable`, `no_wrap`) VALUES (4, 'TIME', 9, 'SignupDate', 'DATE', 25, 'N', 0, '', 'N', 'N', 'N', 'Y');";
        if ($flag) {
            JB_mysql_query($sql) or mysql_error() . 'dffdc9';
        }
        $sql = "INSERT INTO `form_lists` (`form_id`, `field_type`, `sort_order`, `field_id`, `template_tag`, `column_id`, `admin`, `truncate_length`, `linked`, `clean_format`, `is_bold`, `is_sortable`, `no_wrap`) VALUES (4, 'TEXT', 10, 'IP', 'IP', 26, 'N', 0, '', 'N', 'N', 'N', 'Y');";
        if ($flag) {
            JB_mysql_query($sql) or mysql_error() . 'dffdcnn';
        }
        $sql = "INSERT INTO `form_lists` (`form_id`, `field_type`, `sort_order`, `field_id`, `template_tag`, `column_id`, `admin`, `truncate_length`, `linked`, `clean_format`, `is_bold`, `is_sortable`, `no_wrap`) VALUES (5, 'TEXT', 1, 'login_count', 'LCOUNT', 27, 'N', 0, '', 'N', 'N', 'N', 'Y');";
        if ($flag) {
            JB_mysql_query($sql) or mysql_error() . 'dffdc99';
        }
        $sql = "INSERT INTO `form_lists` (`form_id`, `field_type`, `sort_order`, `field_id`, `template_tag`, `column_id`, `admin`, `truncate_length`, `linked`, `clean_format`, `is_bold`, `is_sortable`, `no_wrap`) VALUES (5, 'TEXT', 2, 'Name', 'NAME', 28, 'N', 0, '', 'N', 'N', 'N', 'Y');";
        if ($flag) {
            JB_mysql_query($sql) or mysql_error() . 'dffdc88';
        }
        $sql = "INSERT INTO `form_lists` (`form_id`, `field_type`, `sort_order`, `field_id`, `template_tag`, `column_id`, `admin`, `truncate_length`, `linked`, `clean_format`, `is_bold`, `is_sortable`, `no_wrap`) VALUES (5, 'TEXT', 3, 'Username', 'USERNAME', 29, 'N', 0, '', 'N', 'N', 'N', 'Y');";
        if ($flag) {
            JB_mysql_query($sql) or mysql_error() . 'dffdc66';
        }
        $sql = "INSERT INTO `form_lists` (`form_id`, `field_type`, `sort_order`, `field_id`, `template_tag`, `column_id`, `admin`, `truncate_length`, `linked`, `clean_format`, `is_bold`, `is_sortable`, `no_wrap`) VALUES (5, 'TEXT', 4, 'Email', 'EMAIL', 30, 'N', 0, '', 'N', 'N', 'N', 'Y');";
        if ($flag) {
            JB_mysql_query($sql) or mysql_error() . 'dffdc77';
        }
        $sql = "INSERT INTO `form_lists` (`form_id`, `field_type`, `sort_order`, `field_id`, `template_tag`, `column_id`, `admin`, `truncate_length`, `linked`, `clean_format`, `is_bold`, `is_sortable`, `no_wrap`) VALUES (5, 'TEXT', 5, 'Newsletter', 'NEWS', 31, 'N', 0, '', 'N', 'N', 'N', 'N');";
        if ($flag) {
            JB_mysql_query($sql) or mysql_error() . 'dffdc44';
        }
        $sql = "INSERT INTO `form_lists` (`form_id`, `field_type`, `sort_order`, `field_id`, `template_tag`, `column_id`, `admin`, `truncate_length`, `linked`, `clean_format`, `is_bold`, `is_sortable`, `no_wrap`) VALUES (5, 'TEXT', 6, 'Notification1', 'ALERTS', 32, 'N', 0, '', 'N', 'N', 'N', 'N');";
        if ($flag) {
            JB_mysql_query($sql) or mysql_error() . 'dffdc55';
        }
        $sql = "INSERT INTO `form_lists` (`form_id`, `field_type`, `sort_order`, `field_id`, `template_tag`, `column_id`, `admin`, `truncate_length`, `linked`, `clean_format`, `is_bold`, `is_sortable`, `no_wrap`) VALUES (5, 'TEXT', 7, 'resume_id', 'RESUME_ID', 33, 'N', 0, '', 'N', 'N', 'N', 'N');";
        if ($flag) {
            JB_mysql_query($sql) or mysql_error() . 'dffdc44';
        }
        $sql = "INSERT INTO `form_lists` (`form_id`, `field_type`, `sort_order`, `field_id`, `template_tag`, `column_id`, `admin`, `truncate_length`, `linked`, `clean_format`, `is_bold`, `is_sortable`, `no_wrap`) VALUES (5, 'TIME', 8, 'SignupDate', 'DATE', 34, 'N', 0, '', 'N', 'N', 'N', 'Y');";
        if ($flag) {
            JB_mysql_query($sql) or mysql_error() . 'dffdc22';
        }
        $sql = "INSERT INTO `form_lists` (`form_id`, `field_type`, `sort_order`, `field_id`, `template_tag`, `column_id`, `admin`, `truncate_length`, `linked`, `clean_format`, `is_bold`, `is_sortable`, `no_wrap`) VALUES (5, 'TEXT', 9, 'IP', 'IP', 35, 'N', 0, '', 'N', 'N', 'N', 'Y');";
        if ($flag) {
            JB_mysql_query($sql) or mysql_error() . 'dffdc33';
        }
        $sql = "INSERT INTO `form_lists` (`form_id`, `field_type`, `sort_order`, `field_id`, `template_tag`, `column_id`, `admin`, `truncate_length`, `linked`, `clean_format`, `is_bold`, `is_sortable`, `no_wrap`) VALUES (3, 'TEXT', 1, '65', 'PROFILE_BNAME', 37, 'Y', 0, '', 'N', 'N', 'N', 'Y');";
        if ($flag) {
            JB_mysql_query($sql) or mysql_error() . 'dffdc22';
        }
        $sql = "INSERT INTO `form_lists` (`form_id`, `field_type`, `sort_order`, `field_id`, `template_tag`, `column_id`, `admin`, `truncate_length`, `linked`, `clean_format`, `is_bold`, `is_sortable`, `no_wrap`) VALUES (3, 'RADIO', 2, '67', 'PROFILE_BTYPE', 38, 'N', 0, '', 'N', 'N', 'N', 'Y');";
        if ($flag) {
            JB_mysql_query($sql) or mysql_error() . 'dffdc11';
        }
        $sql = "INSERT INTO `form_lists` (`form_id`, `field_type`, `sort_order`, `field_id`, `template_tag`, `column_id`, `admin`, `truncate_length`, `linked`, `clean_format`, `is_bold`, `is_sortable`, `no_wrap`) VALUES (3, 'TEXT', 3, '72', 'PROFILE_CNAME', 39, 'N', 0, '', 'N', 'N', 'N', 'Y');";
        if ($flag) {
            JB_mysql_query($sql) or mysql_error() . 'dffdcff';
        }
        $sql = "INSERT INTO `form_lists` (`form_id`, `field_type`, `sort_order`, `field_id`, `template_tag`, `column_id`, `admin`, `truncate_length`, `linked`, `clean_format`, `is_bold`, `is_sortable`, `no_wrap`) VALUES (3, 'TEXT', 4, '83', 'PROFILE_COUNTRY', 40, 'N', 0, '', 'N', 'N', 'N', 'Y');";
        if ($flag) {
            JB_mysql_query($sql) or mysql_error() . 'dffffdc';
        }
        $sql = "INSERT INTO `form_lists` (`form_id`, `field_type`, `sort_order`, `field_id`, `template_tag`, `column_id`, `admin`, `truncate_length`, `linked`, `clean_format`, `is_bold`, `is_sortable`, `no_wrap`) VALUES (3, 'TEXT', 5, '75', 'PROFILE_EMAIL', 41, 'N', 0, '', 'N', 'N', 'N', 'Y');";
        if ($flag) {
            JB_mysql_query($sql) or mysql_error() . 'dffggdc';
        }
        $sql = "INSERT INTO `form_lists` (`form_id`, `field_type`, `sort_order`, `field_id`, `template_tag`, `column_id`, `admin`, `truncate_length`, `linked`, `clean_format`, `is_bold`, `is_sortable`, `no_wrap`) VALUES (3, 'TEXT', 6, '74', 'PROFILE_WEBURL', 42, 'N', 0, '', 'N', 'N', 'N', 'Y');";
        if ($flag) {
            JB_mysql_query($sql) or mysql_error() . 'dfhffdc';
        }
        /// fix template tags with the colums (only needed when upgrading)
        // simply copy over the template tags from form_fields to form_lists.
        if ($flag) {
            $result1 = jb_mysql_query("SELECT * FROM form_lists");
            while ($row = mysql_fetch_array($result1)) {
                $result2 = jb_mysql_query("SELECT template_tag FROM form_fields WHERE field_id='" . $row['field_id'] . "'");
                $row2 = mysql_fetch_array($result2);
                if ($row2['template_tag'] != '') {
                    // copy from form_fields to form_lists
                    jb_mysql_query("UPDATE form_lists SET template_tag='" . $row2['template_tag'] . "' WHERE field_id='" . $row['field_id'] . "' ");
                } else {
                    // copy from form_lists to form_fields
                    jb_mysql_query("UPDATE form_fields SET template_tag='" . $row['template_tag'] . "'  WHERE field_id='" . $row['field_id'] . "'");
                }
            }
        }
    }
    if (!does_field_exist("jb_config", "key")) {
        $sql = "CREATE TABLE `jb_config` (\n\t\t`key` VARCHAR( 255 ) NOT NULL ,\n\t\t`val` VARCHAR( 255 ) NOT NULL ,\n\t\tPRIMARY KEY ( `key` ) \n\t\t)";
        //$sql = "ALTER TABLE `blocks` ADD `published` SET( 'Y', 'N') NOT NULL ";
        if ($flag) {
            JB_mysql_query($sql) or die("<p><b>CANNOT UPGRADE YOUR DATABASE!<br>Please run the follwoing query manually from PhpMyAdmin:</b><br><pre>{$sql}</pre><br>");
        }
        $upgrade_needed = true;
        if ($flag) {
            if (MULTI_PAY_PAYPAL_ON == 'YES') {
                $sql = "REPLACE INTO jb_config (`key`, val) VALUES ('PAYPAL_ENABLED', 'Y')";
                JB_mysql_query($sql);
                $sql = "REPLACE INTO jb_config (`key`, val) VALUES ('PAYPAL_EMAIL', '" . PAYPAL_EMAIL . "')";
                JB_mysql_query($sql);
                $sql = "REPLACE INTO jb_config (`key`, val) VALUES ('PAYPAL_CURRENCY', '" . PAYPAL_CURRENCY . "')";
                JB_mysql_query($sql);
                $sql = "REPLACE INTO jb_config (`key`, val) VALUES ('PAYPAL_BUTTON_URL', '" . PAYPAL_BUTTON_URL . "')";
                $sql = "REPLACE INTO jb_config (`key`, val) VALUES ('PAYPAL_SUBSCR_BUTTON_URL', 'https://www.paypal.com/en_US/i/btn/x-click-butcc-subscribe.gif')";
                JB_mysql_query($sql);
                $sql = "REPLACE INTO jb_config (`key`, val) VALUES ('PAYPAL_RETURN_URL', '')";
                JB_mysql_query($sql);
                $sql = "REPLACE INTO jb_config (`key`, val) VALUES ('PAYPAL_IPN_URL', '')";
                JB_mysql_query($sql);
                $sql = "REPLACE INTO jb_config (`key`, val) VALUES ('PAYPAL_CANCEL_RETURN_URL', '')";
                JB_mysql_query($sql);
                $sql = "REPLACE INTO jb_config (`key`, val) VALUES ('PAYPAL_PAGE_STYLE', '" . PAYPAL_PAGE_STYLE . "')";
                JB_mysql_query($sql);
                $sql = "REPLACE INTO jb_config (`key`, val) VALUES ('PAYPAL_SERVER', '" . PAYPAL_SERVER . "')";
            }
            if (MULTI_PAY_BANK_ON == 'YES') {
                $sql = "REPLACE INTO jb_config (`key`, val) VALUES ('BANK_ENABLED', 'Y')";
                JB_mysql_query($sql);
                $sql = "REPLACE INTO jb_config (`key`, val) VALUES ('BANK_CURRENCY', '" . BANK_CURRENCY . "')";
                JB_mysql_query($sql);
                $sql = "REPLACE INTO jb_config (`key`, val) VALUES ('BANK_NAME', '" . BANK_NAME . "')";
                JB_mysql_query($sql);
                $sql = "REPLACE INTO jb_config (`key`, val) VALUES ('BANK_ADDRESS', '" . BANK_ADDRESS . "')";
                JB_mysql_query($sql);
                $sql = "REPLACE INTO jb_config (`key`, val) VALUES ('BANK_ACCOUNT_NAME', '" . BANK_ACCOUNT_NAME . "')";
                JB_mysql_query($sql);
                $sql = "REPLACE INTO jb_config (`key`, val) VALUES ('BANK_ACCOUNT_NUMBER', '" . BANK_ACCOUNT_NUMBER . "')";
                JB_mysql_query($sql);
                $sql = "REPLACE INTO jb_config (`key`, val) VALUES ('BANK_BRANCH_NUMBER', '" . BANK_BRANCH_NUMBER . "')";
                JB_mysql_query($sql);
                $sql = "REPLACE INTO jb_config (`key`, val) VALUES ('BANK_SWIFT', '" . BANK_SWIFT . "')";
                JB_mysql_query($sql);
                $sql = "REPLACE INTO jb_config (`key`, val) VALUES ('BANK_EMAIL_CONFIRM', '" . BANK_EMAIL_CONFIRM . "')";
                JB_mysql_query($sql);
            }
            if (MULTI_PAY_CHECK_ON == 'YES') {
                $sql = "REPLACE INTO jb_config (`key`, val) VALUES ('CHECK_ENABLED', 'Y')";
                JB_mysql_query($sql);
                $sql = "REPLACE INTO jb_config (`key`, val) VALUES ('CHECK_CURRENCY', '" . CHECK_CURRENCY . "')";
                JB_mysql_query($sql);
                $sql = "REPLACE INTO jb_config (`key`, val) VALUES ('CHECK_PAYABLE', '" . CHECK_PAYABLE . "')";
                JB_mysql_query($sql);
                $sql = "REPLACE INTO jb_config (`key`, val) VALUES ('CHECK_ADDRESS', '" . CHECK_ADDRESS . "')";
                JB_mysql_query($sql);
                $sql = "REPLACE INTO jb_config (`key`, val) VALUES ('CHECK_EMAIL_CONFIRM', '" . CHECK_EMAIL_CONFIRM . "')";
                JB_mysql_query($sql);
            }
            if (MULTI_PAY_NOCHEX_ON == 'YES') {
                $sql = "REPLACE INTO jb_config (`key`, val) VALUES ('NOCHEX_EMAIL', '" . NOCHEX_EMAIL . "')";
                JB_mysql_query($sql);
                $sql = "REPLACE INTO jb_config (`key`, val) VALUES ('NOCHEX_ENABLED', 'Y')";
                JB_mysql_query($sql);
                $sql = "REPLACE INTO jb_config (`key`, val) VALUES ('NOCHEX_LOGO_URL', '" . NOCHEX_LOGO_URL . "')";
                JB_mysql_query($sql);
                $sql = "REPLACE INTO jb_config (`key`, val) VALUES ('NOCHEX_CANCEL_RETURN_URL', '" . NOCHEX_CANCEL_RETURN_URL . "')";
                JB_mysql_query($sql);
                $sql = "REPLACE INTO jb_config (`key`, val) VALUES ('NOCHEX_RETURN_URL', '')";
                JB_mysql_query($sql);
                $sql = "REPLACE INTO jb_config (`key`, val) VALUES ('NOCHEX_APC_URL', '')";
                JB_mysql_query($sql);
                $sql = "REPLACE INTO jb_config (`key`, val) VALUES ('NOCHEX_BUTTON_URL', '" . NOCHEX_BUTTON_URL . "')";
                JB_mysql_query($sql);
                $sql = "REPLACE INTO jb_config (`key`, val) VALUES ('NOCHEX_CURRENCY', '" . NOCHEX_CURRENCY . "')";
                JB_mysql_query($sql);
            }
            if (MULTI_PAY_2CO_ON == 'YES') {
                $sql = "REPLACE INTO jb_config (`key`, val) VALUES ('_2CO_ENABLED', 'Y')";
                JB_mysql_query($sql);
                $sql = "REPLACE INTO jb_config (`key`, val) VALUES ('_2CO_SID', '" . _2CO_SID . "')";
                JB_mysql_query($sql);
                //$sql = "REPLACE INTO jb_config (`key`, val, descr) VALUES ('_2CO_PRODUCT_ID', '1', '# Your 2CO seller ID number.')";
                //JB_mysql_query($sql);
                $sql = "REPLACE INTO jb_config (`key`, val) VALUES ('_2CO_DEMO', '" . _2CO_DEMO . "')";
                JB_mysql_query($sql);
                $sql = "REPLACE INTO jb_config (`key`, val) VALUES ('_2CO_SECRET_WORD', '" . _2CO_SECRET_WORD . "')";
                JB_mysql_query($sql);
                $sql = "REPLACE INTO jb_config (`key`, val) VALUES ('_2CO_PAYMENT_ROUTINE', '" . _2CO_PAYMENT_ROUTINE . "')";
                JB_mysql_query($sql);
            }
        }
    }
    if (!does_field_exist("jb_txn", "transaction_id")) {
        $sql = "CREATE TABLE `jb_txn` (\n\t\t`transaction_id` int(11) NOT NULL auto_increment,\n\t\t`date` datetime NOT NULL default '0000-00-00 00:00:00',\n\t\t`invoice_id` int(11) NOT NULL default '0',\n\t\t`type` varchar(32) NOT NULL default '',\n\t\t`amount` float NOT NULL default '0',\n\t\t`currency` char(3) NOT NULL default '',\n\t\t`txn_id` varchar(128) NOT NULL default '',\n\t\t`reason` varchar(64) NOT NULL default '',\n\t\t`origin` varchar(32) NOT NULL default '',\n\t\t`product_type` char(1) NOT NULL default 'P',\n\t\tPRIMARY KEY  (`transaction_id`))";
        if ($flag) {
            JB_mysql_query($sql) or die("<p><b>CANNOT UPGRADE YOUR DATABASE!<br>Please run the follwoing query manually from PhpMyAdmin:</b><br><pre>{$sql}</pre><br>");
        }
        $upgrade_needed = true;
    }
    if (!does_field_exist("jb_txn", "reference")) {
        $sql = "ALTER TABLE jb_txn ADD `reference` VARCHAR( 128 ) NOT NULL  default ''";
        if ($flag) {
            JB_mysql_query($sql) or die($sql . mysql_error());
        }
        $upgrade_needed = true;
    }
    if (!does_field_exist("employers", "can_view_blocked")) {
        $sql = "ALTER TABLE employers ADD `can_view_blocked` SET( 'Y', 'N' ) NOT NULL default 'N'";
        if ($flag) {
            JB_mysql_query($sql) or die($sql . mysql_error());
        }
        $upgrade_needed = true;
    }
    if (!does_field_exist("posts_table", "guid")) {
        $sql = "ALTER TABLE posts_table ADD `guid` VARCHAR(255) NOT NULL default ''";
        if ($flag) {
            JB_mysql_query($sql) or die($sql . mysql_error());
        }
        $upgrade_needed = true;
    }
    if (!does_field_exist("posts_table", "cached_summary")) {
        $sql = "ALTER TABLE posts_table ADD `cached_summary` TEXT NOT NULL ";
        if ($flag) {
            JB_mysql_query($sql) or die($sql . mysql_error());
        }
        $upgrade_needed = true;
    }
    if (!does_field_exist("posts_table", "source")) {
        $sql = "ALTER TABLE posts_table ADD `source` VARCHAR(255) NOT NULL default ''";
        if ($flag) {
            JB_mysql_query($sql) or die($sql . mysql_error());
        }
        $upgrade_needed = true;
    }
    if (!does_field_exist("lang", "fckeditor_lang")) {
        $sql = "ALTER TABLE lang ADD `fckeditor_lang` VARCHAR(10) NOT NULL default 'en.js'";
        if ($flag) {
            JB_mysql_query($sql) or die($sql . mysql_error());
        }
        $upgrade_needed = true;
    }
    /*
    	if (!does_field_exist("lang", "direction")) {
    		$sql ="ALTER TABLE lang ADD `direction` CHAR(2) NOT NULL default 'LR'";
    		if ($flag) JB_mysql_query($sql) or die ($sql.mysql_error());
    		$upgrade_needed = true;
    	}
    */
    //
    if (!does_field_exist("motd", "motd_type")) {
        $sql = "CREATE TABLE `motd` (\n\t\t`motd_type` CHAR( 2 ) NOT NULL ,\n\t\t`motd_lang` CHAR( 2 ) NOT NULL ,\n\t\t`motd_message` TEXT NOT NULL,\n\t\t`motd_title` TEXT NOT NULL,\n\t\t`motd_date_updated` datetime NOT NULL,\n\t\tPRIMARY KEY ( `motd_type` , `motd_lang` ) )";
        if ($flag) {
            JB_mysql_query($sql) or die($sql . mysql_error());
        }
        $upgrade_needed = true;
    }
    if (!does_field_exist("help_pages", "help_type")) {
        $sql = "CREATE TABLE `help_pages` (\n\t\t`help_type` CHAR( 2 ) NOT NULL ,\n\t\t`help_lang` CHAR( 2 ) NOT NULL ,\n\t\t`help_message` TEXT NOT NULL,\n\t\t`help_title` TEXT NOT NULL,\n\t\t`help_date_updated` datetime NOT NULL,\n\t\tPRIMARY KEY ( `help_type` , `help_lang` ) )";
        if ($flag) {
            JB_mysql_query($sql) or die($sql . mysql_error());
        }
        $upgrade_needed = true;
    }
    if (!does_field_exist("payment_log", "date")) {
        $sql = "\n\t\tCREATE TABLE `payment_log` (\n\t\t  `seq_no` int(11) NOT NULL auto_increment,\n\t\t  `date` datetime NOT NULL default '0000-00-00 00:00:00',\n\t\t  `module` varchar(128) NOT NULL default '',\n\t\t  `log_entry` text NOT NULL,\n\t\t  PRIMARY KEY  (`seq_no`)\n\t\t) ";
        if ($flag) {
            JB_mysql_query($sql) or die($sql . mysql_error());
        }
        $upgrade_needed = true;
    }
    if (!does_field_exist("memberships", "membership_id")) {
        $sql = "\n\t\tCREATE TABLE `memberships` (\n\t\t`membership_id` INT NOT NULL AUTO_INCREMENT ,\n\t\t`name` VARCHAR( 255 ) NOT NULL ,\n\t\t`price` FLOAT NOT NULL ,\n\t\t`currency_code` VARCHAR( 3 ) NOT NULL ,\n\t\t`months` MEDIUMINT NOT NULL ,\n\t\tPRIMARY KEY ( `membership_id` ),\n\t\t`type` SET( 'E', 'C' ) NOT NULL\n\t\t) ";
        if ($flag) {
            JB_mysql_query($sql) or die($sql . mysql_error());
        }
        $upgrade_needed = true;
    }
    if (!does_field_exist("membership_invoices", "membership_id")) {
        $sql = "CREATE TABLE `membership_invoices` (\n\t\t`invoice_id` INT NOT NULL AUTO_INCREMENT ,\n\t\t`invoice_date` DATETIME NOT NULL ,\n\t\t`processed_date` DATETIME NULL ,\n\t\t`status` VARCHAR( 127 ) NOT NULL ,\n\t\t`user_type` SET( 'E', 'C' ) NOT NULL ,\n\t\t`user_id` INT NOT NULL ,\n\t\t`membership_id` INT NOT NULL ,\n\t\t`months_duration` MEDIUMINT NOT NULL ,\n\t\t`amount` FLOAT NOT NULL ,\n\t\t`currency_code` VARCHAR( 3 ) NOT NULL ,\n\t\t`currency_rate` DECIMAL( 10, 4 ) NOT NULL ,\n\t\t`item_name` VARCHAR( 255 ) NOT NULL ,\n\t\t`member_date` DATETIME NOT NULL ,\n\t\t`member_end` DATETIME NOT NULL ,\n\t\t`payment_method` VARCHAR( 64 ) NOT NULL ,\n\t\t`reason` VARCHAR( 127 ) NOT NULL ,\n\t\tPRIMARY KEY ( `invoice_id` ) \n\t\t); ";
        if ($flag) {
            JB_mysql_query($sql) or die($sql . mysql_error());
        }
        $upgrade_needed = true;
        $sql = "ALTER TABLE `posts_table` CHANGE `post_id` `post_id` INT( 11 ) NOT NULL AUTO_INCREMENT";
        if ($flag) {
            JB_mysql_query($sql) or die($sql . mysql_error());
        }
    }
    if (!does_field_exist("users", "membership_active")) {
        $sql = "ALTER TABLE users ADD `membership_active` CHAR(1) NOT NULL default 'N'";
        if ($flag) {
            JB_mysql_query($sql) or die($sql . mysql_error());
        }
        $upgrade_needed = true;
    }
    if (!does_field_exist("employers", "membership_active")) {
        $sql = "ALTER TABLE employers ADD `membership_active` CHAR(1) NOT NULL default 'N'";
        if ($flag) {
            JB_mysql_query($sql) or die($sql . mysql_error());
        }
        $upgrade_needed = true;
        // while at it, update the primary key on the skill matrix
        $sql = "ALTER TABLE `skill_matrix_data` DROP PRIMARY KEY , ADD PRIMARY KEY ( `field_id` , `row` , `user_id` ) ";
        if ($flag) {
            JB_mysql_query($sql) or die($sql . mysql_error());
        }
        // update some thing with field_init
    }
    if (!does_field_exist("posts_table", "expired")) {
        $sql = "ALTER TABLE `posts_table` ADD `expired` SET ('Y','N') NOT NULL default 'N' ;";
        if ($flag) {
            JB_mysql_query($sql) or die($sql . mysql_error());
        }
        $upgrade_needed = true;
    }
    if (!does_field_exist("resumes_table", "expired")) {
        $sql = "ALTER TABLE `resumes_table` ADD `expired` SET ('Y','N') NOT NULL default 'N' ;";
        if ($flag) {
            JB_mysql_query($sql) or die($sql . mysql_error());
        }
        $upgrade_needed = true;
    }
    if (!does_field_exist("profiles_table", "expired")) {
        $sql = "ALTER TABLE `profiles_table` ADD `expired` SET ('Y','N') NOT NULL default 'N' ;";
        if ($flag) {
            JB_mysql_query($sql) or die($sql . mysql_error());
        }
        $upgrade_needed = true;
    }
    if (!does_field_exist("employers", "expired")) {
        $sql = "ALTER TABLE `employers` ADD `expired` SET ('Y','N') NOT NULL default 'N' ;";
        if ($flag) {
            JB_mysql_query($sql) or die($sql . mysql_error());
        }
        $upgrade_needed = true;
    }
    if (!does_field_exist("users", "expired")) {
        $sql = "ALTER TABLE `users` ADD `expired` SET ('Y','N') NOT NULL default 'N' ;";
        if ($flag) {
            JB_mysql_query($sql) or die($sql . mysql_error());
        }
        $upgrade_needed = true;
    }
    if (!does_field_exist("mail_monitor_log", "log_id")) {
        $sql = "CREATE TABLE `mail_monitor_log` (\n\t\t`log_id` INT NOT NULL AUTO_INCREMENT ,\n\t\t`date` DATETIME NOT NULL ,\n\t\t`email` VARCHAR(255) NOT NULL ,\n\t\t`user_type` SET( 'E', 'C' ) NOT NULL ,\n\t\tPRIMARY KEY ( `log_id` ))";
        if ($flag) {
            JB_mysql_query($sql) or die($sql . mysql_error());
        }
        $upgrade_needed = true;
    }
    if (!does_field_exist("xml_export_elements", "has_child")) {
        $sql = "ALTER TABLE `xml_export_elements` ADD `has_child` SET( 'Y', 'N' ) DEFAULT NULL ;";
        if ($flag) {
            JB_mysql_query($sql) or die($sql . mysql_error());
        }
        if ($flag) {
            include_once '../include/xml_feed_functions.php';
            JB_compute_export_elements_has_child();
        }
        $upgrade_needed = true;
    }
    if (!does_field_exist("xml_export_feeds", "form_id")) {
        $sql = "DROP TABLE IF EXISTS `xml_export_feeds`";
        if ($flag) {
            JB_mysql_query($sql) or die($sql . mysql_error());
        }
        $sql = "\n\t\tCREATE TABLE `xml_export_feeds` (\n\t\t`feed_id` int(11) NOT NULL auto_increment,\n\t\t`feed_name` varchar(255) NOT NULL default '',\n\t\t`description` text NOT NULL,\n\t\t`field_settings` text NOT NULL,\n\t\t`search_settings` text NOT NULL,\n\t\t`max_records` int(11) NOT NULL default '0',\n\t\t`publish_mode` set('PUB','PRI') NOT NULL default '',\n\t\t`schema_id` int(11) NOT NULL default '0',\n\t\t`feed_key` varchar(255) NOT NULL default '',\n\t\t`hosts_allow` text NOT NULL,\n\t\t`is_locked` set('Y','N') NOT NULL default 'N',\n\t\t`form_id` int(11) NOT NULL default '0',\n\t\tPRIMARY KEY  (`feed_id`)\n\t\t)";
        if ($flag) {
            JB_mysql_query($sql) or die($sql . mysql_error());
        }
        $sql = "INSERT INTO `xml_export_feeds` VALUES (6, 'RSS Feed (Example)', 'this is a description', 'a:5:{i:147;s:1:\"2\";s:6:\"ft_147\";s:4:\"TEXT\";i:149;s:1:\"5\";s:6:\"ft_149\";s:6:\"EDITOR\";i:151;s:9:\"post_date\";}', 'a:4:{i:6;N;i:13;N;i:5;s:0:\"\";i:14;s:0:\"\";}', 50, 'PUB', 3, '', 'localhost', 'N', 1)";
        if ($flag) {
            JB_mysql_query($sql) or die($sql . mysql_error());
        }
        $sql = "INSERT INTO `xml_export_feeds` VALUES (9, 'Simply Hired Feed (Example)', 'Simply Hired - Jobs', 'a:49:{i:44;s:1:\"2\";s:5:\"ft_44\";s:4:\"TEXT\";i:45;s:7:\"post_id\";i:46;s:0:\"\";i:52;s:7:\"summary\";i:53;s:0:\"\";i:54;s:0:\"\";i:55;s:0:\"\";i:56;s:2:\"14\";s:12:\"boolean_p_56\";s:9:\"full-time\";s:5:\"ft_56\";s:8:\"CATEGORY\";i:57;s:1:\"2\";s:12:\"boolean_p_57\";s:9:\"part-time\";s:5:\"ft_57\";s:4:\"TEXT\";i:59;s:0:\"\";i:60;s:0:\"\";i:61;s:0:\"\";i:62;s:0:\"\";i:63;s:0:\"\";i:64;s:0:\"\";i:65;s:0:\"\";i:66;s:0:\"\";i:68;s:0:\"\";i:69;s:0:\"\";i:70;s:0:\"\";i:71;s:0:\"\";i:73;s:0:\"\";i:75;s:2:\"13\";s:5:\"ft_75\";s:8:\"CATEGORY\";i:76;s:0:\"\";i:77;s:0:\"\";i:78;s:0:\"\";i:79;s:0:\"\";i:80;s:0:\"\";i:82;s:1:\"8\";s:5:\"ft_82\";s:4:\"TEXT\";i:84;s:2:\"12\";s:5:\"ft_84\";s:4:\"TEXT\";i:85;s:0:\"\";i:86;s:0:\"\";i:87;s:0:\"\";i:88;s:0:\"\";i:90;s:1:\"8\";s:5:\"ft_90\";s:4:\"TEXT\";i:91;s:0:\"\";i:92;s:0:\"\";i:93;s:0:\"\";i:127;s:1:\"6\";s:6:\"ft_127\";s:8:\"CATEGORY\";}', 'a:4:{i:6;N;i:13;N;i:5;s:0:\"\";i:14;s:0:\"\";}', 50, 'PUB', 4, '', 'localhost', 'N', 1)";
        if ($flag) {
            JB_mysql_query($sql) or die($sql . mysql_error());
        }
        $sql = "INSERT INTO `xml_export_feeds` VALUES (10, 'Indeed Jobs Feed (Example)', 'My jobs feed to indeed!', 'a:20:{i:112;s:1:\"2\";s:6:\"ft_112\";s:4:\"TEXT\";i:113;s:9:\"post_date\";i:114;s:7:\"post_id\";i:116;s:1:\"8\";s:6:\"ft_116\";s:4:\"TEXT\";i:117;s:2:\"15\";s:6:\"ft_117\";s:4:\"TEXT\";i:118;s:0:\"\";i:119;s:0:\"\";i:120;s:0:\"\";i:121;s:1:\"5\";s:6:\"ft_121\";s:6:\"EDITOR\";i:122;s:0:\"\";i:123;s:0:\"\";i:124;s:2:\"14\";s:6:\"ft_124\";s:8:\"CATEGORY\";i:125;s:1:\"6\";s:6:\"ft_125\";s:8:\"CATEGORY\";i:126;s:0:\"\";}', 'a:4:{i:6;N;i:13;N;i:5;s:0:\"\";i:14;s:0:\"\";}', 50, 'PUB', 2, '', 'localhost', 'N', 1)";
        if ($flag) {
            JB_mysql_query($sql) or die($sql . mysql_error());
        }
        $sql = "INSERT INTO `xml_export_feeds` VALUES (11, 'Google Base Feed (Example)', 'Google Base Feed', 'a:17:{i:14;s:0:\"\";i:19;s:2:\"13\";s:5:\"ft_19\";s:8:\"CATEGORY\";i:20;s:0:\"\";i:21;s:0:\"\";i:96;s:1:\"2\";s:5:\"ft_96\";s:4:\"TEXT\";i:97;s:1:\"5\";s:5:\"ft_97\";s:6:\"EDITOR\";i:98;s:1:\"6\";s:5:\"ft_98\";s:8:\"CATEGORY\";i:99;s:0:\"\";i:100;s:0:\"\";i:103;s:0:\"\";i:104;s:1:\"8\";s:6:\"ft_104\";s:4:\"TEXT\";i:106;s:0:\"\";}', 'a:4:{i:6;N;i:13;N;i:5;s:0:\"\";i:14;s:0:\"\";}', 50, 'PUB', 1, '', 'ALL', 'N', 1)";
        if ($flag) {
            JB_mysql_query($sql) or die($sql . mysql_error());
        }
        $upgrade_needed = true;
    }
    if (!does_field_exist("xml_export_schemas", "is_locked")) {
        $sql = "CREATE TABLE `xml_export_schemas` (\n\t\t  `schema_id` int(11) NOT NULL auto_increment,\n\t\t  `schema_name` varchar(255) NOT NULL default '',\n\t\t  `description` text NOT NULL,\n\t\t  `form_id` int(11) NOT NULL default '0',\n\t\t  `is_locked` set('Y','N') NOT NULL default 'N',\n\t\t  PRIMARY KEY  (`schema_id`)\n\t\t)";
        if ($flag) {
            JB_mysql_query($sql) or die($sql . mysql_error());
        }
        $upgrade_needed = true;
        $sql = "INSERT INTO `xml_export_schemas` VALUES (1, 'Google Base  - Jobs', 'For a full description of the attributes (elements) see: http://www.google.com/base/jobs.html', 1, 'Y')";
        if ($flag) {
            JB_mysql_query($sql) or die($sql . mysql_error());
        }
        $sql = "INSERT INTO `xml_export_schemas` VALUES (2, 'Indeed.com', 'http://www.indeed.com/jsp/xmlinfo.jsp', 1, 'Y')";
        if ($flag) {
            JB_mysql_query($sql) or die($sql . mysql_error());
        }
        $sql = "INSERT INTO `xml_export_schemas` VALUES (3, 'RSS', 'http://blogs.law.harvard.edu/tech/rss', 1, 'Y')";
        if ($flag) {
            JB_mysql_query($sql) or die($sql . mysql_error());
        }
        $sql = "INSERT INTO `xml_export_schemas` VALUES (4, 'SimplyHired.com', 'Simply Hired can accept incoming job feeds in either xml or delimited formats\r\nhttp://www.simplyhired.com/feed.php#feed_spec', 1, 'Y')";
        if ($flag) {
            JB_mysql_query($sql) or die($sql . mysql_error());
        }
    }
    if (!does_field_exist("xml_export_feeds", "is_locked")) {
        $upgrade_needed = true;
        $sql = "ALTER TABLE `xml_export_feeds` ADD `is_locked` SET ('Y','N') NOT NULL default 'N' ;";
        if ($flag) {
            JB_mysql_query($sql) or die($sql . mysql_error());
        }
        $sql = "ALTER TABLE `xml_export_feeds` ADD `description` text NOT NULL";
        if ($flag) {
            JB_mysql_query($sql) or die($sql . mysql_error());
        }
        $sql = "ALTER TABLE `xml_export_feeds` ADD `field_settings` text NOT NULL";
        if ($flag) {
            JB_mysql_query($sql) or die($sql . mysql_error());
        }
        $sql = "ALTER TABLE `xml_export_feeds` ADD `search_settings` text NOT NULL";
        if ($flag) {
            JB_mysql_query($sql) or die($sql . mysql_error());
        }
        $sql = "ALTER TABLE `xml_export_feeds` ADD `max_records` int(11) NOT NULL default '0'";
        if ($flag) {
            JB_mysql_query($sql) or die($sql . mysql_error());
        }
        $sql = "ALTER TABLE `xml_export_feeds` ADD `publish_mode` set('PUB','PRI') NOT NULL default ''";
        if ($flag) {
            JB_mysql_query($sql) or die($sql . mysql_error());
        }
        $sql = "ALTER TABLE `xml_export_feeds` ADD `schema_id` int(11) NOT NULL default '0'";
        if ($flag) {
            JB_mysql_query($sql) or die($sql . mysql_error());
        }
        $sql = "ALTER TABLE `xml_export_feeds` ADD `feed_key` varchar(255) NOT NULL default ''";
        if ($flag) {
            JB_mysql_query($sql) or die($sql . mysql_error());
        }
        $sql = "ALTER TABLE `xml_export_feeds` ADD `hosts_allow` text NOT NULL";
        if ($flag) {
            JB_mysql_query($sql) or die($sql . mysql_error());
        }
    }
    // fix up MSELECT
    $sql = "SELECT * FROM jb_variables WHERE `key`='MSELECT_FIXED2'  ";
    $result = @JB_mysql_query($sql);
    if ($row = mysql_num_rows($result) == 0) {
        // fix MSELECT
        $sql = "SELECT * from form_fields WHERE field_type='RADIO' or field_type='MSELECT' ";
        $result = JB_mysql_query($sql);
        while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
            /*
            			// Uncomment if you are getting the following error:
            			// BLOB/TEXT column '22' used in key specification without a key length
            			// or similar error
            			// remove old indexes on the fields
            			/*
            			$sql = "SHOW index FROM posts_table";
            			$result = mysql_query($sql);
            			while ($row=mysql_fetch_array($result, MYSQL_ASSOC)) {
            	
            				if (strpos(strtolower($row['Key_name']), 'composite')!==false) {
            					$sql ="ALTER TABLE posts_table DROP INDEX `".$row['Key_name']."`";
            					mysql_query($sql) or die(mysql_error());
            	}
            				
            			}
            */
            $t_name = JB_get_table_name_by_id($row['form_id']);
            $sql = ' ALTER TABLE `' . $t_name . '` CHANGE `' . $row['field_id'] . '` `' . $row['field_id'] . '` TEXT NOT NULL  ';
            JB_mysql_query($sql) or die(mysql_error());
            //echo $sql."<br>";
        }
        // NOW FIX All the MSELECT records
        $sql = "SELECT * from form_fields WHERE field_type='MSELECT' ";
        $result = JB_mysql_query($sql);
        while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
            $table_name = JB_get_table_name_by_id($row['form_id']);
            $id_name = JB_get_table_id_column($row['form_id']);
            $sql = "SELECT `" . $row['field_id'] . "`, {$id_name} FROM {$table_name} ";
            //echo $sql." (idname: $id_name)<br>";
            $res2 = JB_mysql_query($sql) or die(mysql_error());
            while ($row2 = mysql_fetch_array($res2)) {
                $new_val = str_replace(' ', '', $row2[$row['field_id']]);
                // remove spaces
                $new_val = preg_replace('#^,#', '', $new_val);
                $new_val = preg_replace('#,$#', '', $new_val);
                $new_arr = explode(',', $new_val);
                $sql = "UPDATE {$table_name} SET `" . $row['field_id'] . "`='" . $new_val . "' WHERE {$id_name}='" . addslashes($row2[$id_name]) . "' ";
                JB_mysql_query($sql) or die(mysql_error());
            }
        }
        //Fixed MSELECT fields
        $sql = "REPLACE INTO jb_variables (`key`, `val`) VALUES ('MSELECT_FIXED2', 'YES') ";
        JB_mysql_query($sql) or die(mysql_error());
    }
    // rename %RESUME_ALERT% to %RESUME_ALERTS%
    $sql = "SELECT * FROM jb_variables WHERE `key`='RESUME_ALERT_RENAME_FIXED'  ";
    $result = JB_mysql_query($sql);
    if ($row = mysql_num_rows($result) == 0) {
        $sql = "SELECT * from email_templates WHERE EmailText LIKE  '%RESUME_ALERT%' ";
        $result = JB_mysql_query($sql) or die(mysql_error());
        while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
            $row['EmailText'] = str_replace('%RESUME_ALERT%', '%RESUME_ALERTS%', $row['EmailText']);
            $sql = "UPDATE email_templates SET EmailText = '" . addslashes($row['EmailText']) . "' WHERE EmailID='" . $row['EmailID'] . "' ";
            JB_mysql_query($sql);
        }
        $sql = "SELECT * from email_template_translations WHERE EmailText LIKE  '\\%RESUME_ALERT\\%' ";
        $result = JB_mysql_query($sql) or die(mysql_error());
        while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
            $row['EmailText'] = str_replace('%RESUME_ALERT%', '%RESUME_ALERTS%', $row['EmailText']);
            $sql = "UPDATE email_templates SET EmailText = '" . addslashes($row['EmailText']) . "' WHERE EmailID='" . $row['EmailID'] . "' ";
            JB_mysql_query($sql);
        }
        $sql = "SELECT * from email_template_translations WHERE EmailText LIKE  '\\%KEYWORDS_LINE\\%' ";
        $result = JB_mysql_query($sql) or die(mysql_error());
        while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
            if ($row['EmailID'] == 5 || $row['EmailID'] == 6) {
                $row['EmailText'] = str_replace('%KEYWORDS_LINE%', '%RESUME_ALERTS%', $row['EmailText']);
                $sql = "UPDATE email_templates SET EmailText = '" . addslashes($row['EmailText']) . "' WHERE EmailID='" . $row['EmailID'] . "' ";
                JB_mysql_query($sql);
            }
            if ($row['EmailID'] == 7 || $row['EmailID'] == 8) {
                $row['EmailText'] = str_replace('%KEYWORDS_LINE%', '%JOB_ALERTS%', $row['EmailText']);
                $sql = "UPDATE email_templates SET EmailText = '" . addslashes($row['EmailText']) . "' WHERE EmailID='" . $row['EmailID'] . "' ";
                JB_mysql_query($sql);
            }
        }
        //echo 'Updated email templates<br>';
        $sql = "REPLACE INTO jb_variables (`key`, `val`) VALUES ('RESUME_ALERT_RENAME_FIXED', 'YES') ";
        JB_mysql_query($sql) or die(mysql_error());
    }
    // update CATOPTION_CACHE_UPDATE
    $sql = "SELECT * FROM jb_variables WHERE `key`='CATOPTION_CACHE_UPDATE'  ";
    $result = @JB_mysql_query($sql);
    if ($row = mysql_num_rows($result) == 0) {
        if ($flag == true && does_field_exist("categories", "seo_fname")) {
            JB_cache_del_keys_for_form(1);
            JB_cache_del_keys_for_form(2);
            JB_cache_del_keys_for_form(3);
            JB_cache_del_keys_for_form(4);
            JB_cache_del_keys_for_form(5);
            JB_cache_del_keys_for_all_cats(1);
            JB_cache_del_keys_for_all_cats(2);
            JB_cache_del_keys_for_all_cats(3);
            JB_cache_del_keys_for_all_cats(4);
            JB_cache_del_keys_for_all_cats(5);
            JB_cache_del_keys_for_cat_options();
            echo "* Updated your category cache<br>";
            $sql = "REPLACE INTO jb_variables (`key`, `val`) VALUES ('CATOPTION_CACHE_UPDATE', 'YES') ";
            JB_mysql_query($sql) or die(mysql_error());
        }
    }
    // update CODESFIELD_CACHE_UPDATE
    $sql = "SELECT * FROM jb_variables WHERE `key`='CODESFIELD_CACHE_UPDATE'  ";
    $result = @JB_mysql_query($sql);
    if ($row = mysql_num_rows($result) == 0) {
        if (does_field_exist("categories", "seo_fname")) {
            // here
            $sql = "select field_id from codes group by field_id ";
            $result2 = JB_mysql_query($sql) or die(mysql_error());
            while ($row2 = mysql_fetch_array($result2, MYSQL_ASSOC)) {
                JB_cache_del_keys_for_codes($row2['field_id']);
            }
            echo "* Updated your codes cache<br>";
            $sql = "REPLACE INTO jb_variables (`key`, `val`) VALUES ('CODESFIELD_CACHE_UPDATE', 'YES') ";
            JB_mysql_query($sql) or die(mysql_error());
        }
    }
    if (!does_field_exist("xml_export_elements", "static_mod")) {
        $sql = "ALTER TABLE `xml_export_elements` ADD `static_mod` SET( 'A', 'P', 'F' ) DEFAULT 'F' NOT NULL ,\n\t\tADD `multi_fields` SMALLINT DEFAULT '1' NOT NULL ";
        if ($flag) {
            JB_mysql_query($sql) or die($sql . mysql_error());
        }
        $upgrade_needed = true;
    }
    if (!does_field_exist("xml_export_elements", "comment")) {
        $sql = "ALTER TABLE `xml_export_elements` ADD `comment` VARCHAR( 255 ) DEFAULT '' NOT NULL  ";
        if ($flag) {
            JB_mysql_query($sql) or die($sql . mysql_error());
        }
        $upgrade_needed = true;
    }
    if (!does_field_exist("posts_table", "app_type")) {
        $sql = "ALTER TABLE `posts_table` ADD `app_type` CHAR( 1 ) NOT NULL DEFAULT 'O', ADD `app_url` VARCHAR( 255 ) NOT NULL ; ";
        if ($flag) {
            JB_mysql_query($sql) or die($sql . mysql_error());
        }
        $upgrade_needed = true;
    }
    if (!does_field_exist("subscriptions", "views_quota")) {
        $sql = "ALTER TABLE `subscriptions` ADD  `views_quota` INT NOT NULL DEFAULT '-1', ADD `p_posts_quota` INT NOT NULL DEFAULT '-1', ADD `posts_quota` INT NOT NULL DEFAULT '-1' ; ";
        if ($flag) {
            JB_mysql_query($sql) or die($sql . mysql_error());
        }
        $upgrade_needed = true;
    }
    if (!does_field_exist("subscription_invoices", "views_quota")) {
        $sql = "ALTER TABLE `subscription_invoices` ADD  `views_quota` INT NOT NULL DEFAULT '-1', ADD `p_posts_quota` INT NOT NULL DEFAULT '-1', ADD `posts_quota` INT NOT NULL DEFAULT '-1' ; ";
        if ($flag) {
            JB_mysql_query($sql) or die($sql . mysql_error());
        }
        $upgrade_needed = true;
    }
    if (!does_field_exist("employers", "views_quota")) {
        $sql = "ALTER TABLE `employers` ADD  `views_quota` INT NOT NULL DEFAULT '-1', ADD `p_posts_quota` INT NOT NULL DEFAULT '-1', ADD `posts_quota` INT NOT NULL DEFAULT '-1', ADD  `views_quota_tally` INT NOT NULL DEFAULT '0', ADD `p_posts_quota_tally` INT NOT NULL DEFAULT '0', ADD `posts_quota_tally` INT NOT NULL DEFAULT '0', ADD `quota_timestamp` INT NOT NULL DEFAULT '0' ; ";
        if ($flag) {
            JB_mysql_query($sql) or die($sql . mysql_error());
        }
        $upgrade_needed = true;
    }
    if (does_field_exist("subscriptions", "subscr_date")) {
        $sql = "ALTER TABLE `subscriptions` DROP `subscr_date`, DROP `subscr_effective`, DROP `recurring`, DROP `subscr_id`;";
        if ($flag) {
            JB_mysql_query($sql) or die($sql . mysql_error());
        }
        $upgrade_needed = true;
    }
    if (!does_field_exist("short_urls", "url")) {
        $sql = "CREATE TABLE `short_urls` (\n\t\t  `url` varchar(255) NOT NULL,\n\t\t  `date` timestamp NOT NULL,\n\t\t  `hash` varchar(255) NOT NULL,\n\t\t  `expires` set('Y','N') NOT NULL,\n\t\t  `hits` bigint(20) NOT NULL,\n\t\t  PRIMARY KEY (`url`)\n\t\t)";
        if ($flag) {
            JB_mysql_query($sql) or die($sql . mysql_error());
        }
        $upgrade_needed = true;
    }
    if (!does_field_exist("mail_queue", "user_id")) {
        $sql = "ALTER TABLE `mail_queue` ADD `user_id` INT NULL DEFAULT NULL, ADD `user_type` VARCHAR( 10 ) NULL DEFAULT NULL;";
        if ($flag) {
            JB_mysql_query($sql) or die($sql . mysql_error());
        }
        $upgrade_needed = true;
    }
    if (!does_field_exist("sitemaps_urls", "url")) {
        $sql = "CREATE TABLE `sitemaps_urls` (\n\t\t\t\t`url` TEXT NOT NULL ,\n\t\t\t\t`priority` FLOAT NOT NULL ,\n\t\t\t\t`changefreq` VARCHAR( 15 ) NOT NULL\n\t\t\t\t) ";
        if ($flag) {
            JB_mysql_query($sql) or die($sql . mysql_error());
        }
        $upgrade_needed = true;
    }
    if (!does_field_exist("xml_export_feeds", "include_emp_accounts")) {
        $sql = "ALTER TABLE `xml_export_feeds` ADD `include_emp_accounts` SET( 'Y', 'N' ) NOT NULL DEFAULT 'N' ;";
        if ($flag) {
            JB_mysql_query($sql) or die($sql . mysql_error());
        }
        $upgrade_needed = true;
    }
    if (!does_field_exist("xml_export_feeds", "export_with_url")) {
        $sql = "ALTER TABLE `xml_export_feeds` ADD `export_with_url` SET( 'Y', 'N' ) NOT NULL DEFAULT 'Y' ;";
        if ($flag) {
            JB_mysql_query($sql) or die($sql . mysql_error());
        }
        $upgrade_needed = true;
    }
    $sql = "SELECT * FROM jb_variables WHERE `key`='CODESFIELD_CACHE_UPDATE'  ";
    $result = @JB_mysql_query($sql);
    if ($row = mysql_num_rows($result) == 0) {
    }
    $sql = "UPDATE form_fields SET field_init='' WHERE field_id=2 AND field_init=5 ";
    JB_mysql_query($sql) or die($sql . mysql_error());
    $sql = "UPDATE form_fields SET field_init='' WHERE field_id=5 AND field_init=5";
    JB_mysql_query($sql) or die($sql . mysql_error());
    if ($flag) {
        JB_fix_form_field_translations();
    }
    $sql = "ALTER TABLE `applications` CHANGE `app_id` `app_id` INT( 11 ) NOT NULL AUTO_INCREMENT ";
    if ($flag) {
        JB_mysql_query($sql) or die(mysql_error() . 'jsgd73cd');
    }
    if (1 == 1) {
        $sql = "INSERT INTO `email_templates` (`EmailID`, `EmailText`, `EmailFromAddress`, `EmailSubject`, `EmailFromName`, `sub_template`) VALUES (330, 'A new order was placed on %SITE_NAME% by %USER%!\r\n\r\nTo manage, see here:\r\n%ADMIN_LINK%\r\n\r\n==================================\r\n\r\nOrder by: %LNAME%, %FNAME%\r\nUsername: %USER%\r\n\r\n========================\r\nORDER DETAILS\r\n=========================\r\nItem: %ITEM_NAME%\r\nOrder ID: #%INVOICE_CODE%\r\nPrice: %INVOICE_AMOUNT%\r\n', '*****@*****.**', 'A New order was placed on %SITE_NAME%', 'Jamit Demo', '');";
        if (!JB_template_exists(330)) {
            JB_mysql_query($sql);
        }
        $sql = "INSERT INTO `email_templates` (`EmailID`,  `EmailText`, `EmailFromAddress`, `EmailSubject`, `EmailFromName`, `sub_template`) VALUES (320,  'A Resume resume was posted to / updated on %SITE_NAME%\r\n\r\nAdmin Link: \r\n%ADMIN_LINK%\r\n\r\n%RESUME_SUMMARY%\r\n\r\n\r\n', '*****@*****.**', 'A Resume was saved on %SITE_NAME%', 'Jamit Demo', '');";
        if (!JB_template_exists(320)) {
            JB_mysql_query($sql);
        }
        $sql = "INSERT INTO `email_templates` (`EmailID`, `EmailText`, `EmailFromAddress`, `EmailSubject`, `EmailFromName`, `sub_template`) VALUES (310, 'A new Post was posted to %SITE_NAME%\r\n\r\nAdmin Link: %ADMIN_LINK%\r\n\r\nTitle:\r\n%POST_TITLE%\r\nBy:\r\n%POSTED_BY%\r\nDate:\r\n%DATE%\r\nDescription:\r\n%POST_DESCRIPTION%\r\n', '*****@*****.**', 'A new Post was posted to %SITE_NAME%', 'Jamit Job Board', '');";
        if (!JB_template_exists(310)) {
            JB_mysql_query($sql);
        }
        $sql = "INSERT INTO `email_templates` (`EmailID`, `EmailText`, `EmailFromAddress`, `EmailSubject`, `EmailFromName`, `sub_template`) VALUES (210, 'Dear %FNAME% %LNAME%,\r\n\r\nWe would like to notify you that the following post had expired on %SITE_NAME%:\r\n\r\n%POST_DATE% - \"%POST_TITLE%\"\r\n\r\nStatistics:\r\n%VIEWS% views\r\n%APPS% Applications\r\n\r\nThis job post will no longer be visible in the job listings. You may log in to your employer''s account to view or re-post this job, or post a new job at any time.\r\n\r\nKind Regards,\r\n\r\n%SITE_NAME% team\r\n%SITE_URL%\r\n%SITE_CONTACT_EMAIL%', '*****@*****.**', 'Job post expired', 'Jamit Demo', '');";
        if (!JB_template_exists(210)) {
            JB_mysql_query($sql);
        }
        $sql = "INSERT INTO `email_templates` (`EmailID`, `EmailText`, `EmailFromAddress`, `EmailSubject`, `EmailFromName`, `sub_template`) VALUES (220, 'Dear %FNAME% %LNAME%,\r\n\r\nThank you for posting your job to %SITE_NAME%!\r\n\r\nWe have just approved the following job to be listed on our site:\r\n\r\n%POST_DATE% - \"%POST_TITLE%\"\r\n%POST_URL%\r\n\r\n\r\nThis job post will now become visible on the job listings. You may log in to your employer''s account to view or edit this job at any time.\r\n\r\nKind Regards,\r\n\r\n%SITE_NAME% team\r\n%SITE_URL%\r\n%SITE_CONTACT_EMAIL%', '*****@*****.**', 'Your job posting was Approved!', 'Jamit Demo', '');";
        if (!JB_template_exists(220)) {
            JB_mysql_query($sql);
        }
        $sql = "INSERT INTO `email_templates` (`EmailID`, `EmailText`, `EmailFromAddress`, `EmailSubject`, `EmailFromName`, `sub_template`) VALUES (230, 'Dear %FNAME% %LNAME%,\r\n\r\nThank you for posting your job to %SITE_NAME%.\r\n\r\nHowever, after reviewing your job post, we have decided to disapprove it.\r\n\r\nThe following job post was disapproved:\r\n\r\n%POST_DATE% - \"%POST_TITLE%\"\r\n\r\nReason for disapproval: %REASON%\r\n\r\nYou may log in to your employer''s account to edit this job so that we may review it again.\r\n\r\nKind Regards,\r\n\r\n%SITE_NAME% team\r\n%SITE_URL%\r\n%SITE_CONTACT_EMAIL%', '*****@*****.**', 'Your job posting was disapproved', 'Jamit Job Board', '');";
        if (!JB_template_exists(230)) {
            JB_mysql_query($sql);
        }
        $sql = "INSERT INTO `email_templates` (`EmailID`, `EmailText`, `EmailFromAddress`, `EmailSubject`, `EmailFromName`, `sub_template`) VALUES (60, 'Dear  %LNAME%, %FNAME%\r\n\r\nYour order on %SITE_NAME% was confirmed, thank you.\r\n\r\n========================\r\nORDER DETAILS\r\n=========================\r\nOrder ID: #%INVOICE_CODE%\r\nItem Name: %ITEM_NAME%\r\nPosts: %QUANTITY% \r\nPrice: %INVOICE_AMOUNT%\r\nStatus: Confirmed\r\nPayment Method: Bank Deposit\r\n--------------------------\r\n\r\nPlease deposit %INVOICE_AMOUNT% to the following account:\r\n\tBank: %BANK_NAME%\r\n\tA/C Name: %AC_NAME%\r\n\tA/C Number: %AC_NUMBER%\r\n\r\nAfter making the deposit, please send an email to \r\n%SITE_CONTACT_EMAIL% with the following \r\nOrder Number: %INVOICE_CODE% to help us process the transaction. \r\n\r\nFeel free to contact %SITE_CONTACT_EMAIL% if you have \r\nany questions / problems. \r\n\r\nThank you!\r\n\r\n\r\n%SITE_NAME% team.\r\n%SITE_URL%\r\n\r\nNote: This is an automated email.', '*****@*****.**', 'Order Confirmed', 'Hi Teacher', '');";
        if (!JB_template_exists(60)) {
            JB_mysql_query($sql);
        }
        // P. Confirmed - Bank
        $sql = "INSERT INTO `email_templates` (`EmailID`, `EmailText`, `EmailFromAddress`, `EmailSubject`, `EmailFromName`, `sub_template`) VALUES (61, 'Dear  %LNAME%, %FNAME%\r\n\r\nYour order on %SITE_NAME% was confirmed, thank you.\r\n\r\n========================\r\nORDER DETAILS\r\n=========================\r\nOrder ID: #%INVOICE_CODE%\r\nItem Name: %ITEM_NAME%\r\nPosts: %QUANTITY% \r\nPrice: %INVOICE_AMOUNT%\r\nStatus: Confirmed\r\nPayment Method: Check / Money Order\r\n--------------------------\r\n\r\nPlease send %INVOICE_AMOUNT% (%CHECK_CURRENCY%) to the following address:\r\n\tPayee Name: %PAYEE_NAME%\r\n\tAddress: \r\n        %PAYEE_ADDRESS%\r\n\t\r\n\r\nAfter mailing the check, please send an email to \r\n%SITE_CONTACT_EMAIL% with the following \r\nOrder Number: %INVOICE_CODE% to help us process the transaction. \r\n\r\nFeel free to contact %SITE_CONTACT_EMAIL% if you have \r\nany questions / problems. \r\n\r\nThank you!\r\n\r\n\r\n%SITE_NAME% team.\r\n%SITE_URL%\r\n\r\nNote: This is an automated email.', '*****@*****.**', 'Order Confirmed', 'Jamit Demo', '');";
        if (!JB_template_exists(61)) {
            JB_mysql_query($sql);
        }
        // P. Confirmed - Check
        $sql = "INSERT INTO `email_templates` (`EmailID`, `EmailText`, `EmailFromAddress`, `EmailSubject`, `EmailFromName`, `sub_template`) VALUES (70, 'Dear  %LNAME%, %FNAME%\r\n\r\nYour order on %SITE_NAME% was successfully completed, thank you!\r\n\r\nWe have credited your order to your account, and you may now use your available balance to post your job advertisement(s) to %SITE_NAME%.\r\n\r\n========================\r\nORDER DETAILS\r\n=========================\r\nOrder ID: #%INVOICE_CODE%\r\nItem Name: %ITEM_NAME%\r\nPosts: %QUANTITY% \r\nPrice: %INVOICE_AMOUNT%\r\nStatus: Completed\r\nPayment Method: %PAYMENT_METHOD%\r\n\r\n--------------------------\r\n\r\nThank you for using %SITE_NAME%! \r\n\r\nYou may view your balance and order history at any time.\r\nJust log in to your %SITE_NAME%, and go to ''Posts'' -> ''Posting Credits''.\r\n\r\n\r\n%SITE_NAME% team.\r\n%SITE_URL%\r\n\r\nNote: This is an automated email.', '*****@*****.**', 'Order completed!', 'Jamit Demo', '')";
        if (!JB_template_exists(70)) {
            JB_mysql_query($sql);
        }
        // posting credits order completed
        $sql = "INSERT INTO `email_templates` (`EmailID`, `EmailText`, `EmailFromAddress`, `EmailSubject`, `EmailFromName`, `sub_template`) VALUES (90, 'Dear  %LNAME%, %FNAME%\r\n\r\nYour subscription payment on %SITE_NAME% was successfully completed, thank you!\r\n\r\nWe have activated your subscription, and you may now log in to your account\r\nto access the resume database.\r\n\r\n========================\r\nORDER DETAILS\r\n=========================\r\nOrder ID: #%INVOICE_CODE%\r\nSubscription Name: %ITEM_NAME%\r\nSubscription Months: %SUB_DURATION%\r\nStart Date: %SUB_START%\r\nEnd Date: %SUB_END%\r\nPrice: %INVOICE_AMOUNT%\r\nStatus: Active\r\nPayment Method: %PAYMENT_METHOD%\r\n\r\n--------------------------\r\n\r\nThank you for using %SITE_NAME%! \r\n\r\nYou may view your subscription order history at any time.\r\nJust log in to your %SITE_NAME%, and go to ''Resumes'' -> ''Subscriptions''.\r\n\r\n\r\n%SITE_NAME% team.\r\n%SITE_URL%\r\n\r\nNote: This is an automated email.', '*****@*****.**', 'Subscription now active!', 'Jamit Demo', '')";
        if (!JB_template_exists(90)) {
            JB_mysql_query($sql);
        }
        // sub completed
        $sql = "INSERT INTO `email_templates` (`EmailID`, `EmailText`, `EmailFromAddress`, `EmailSubject`, `EmailFromName`, `sub_template`) VALUES (80, 'Dear  %LNAME%, %FNAME%\r\n\r\nYour subscription on %SITE_NAME% was confirmed, thank you.\r\n\r\n========================\r\nORDER DETAILS\r\n=========================\r\nOrder ID: #%INVOICE_CODE%\r\nSubscription Name: %ITEM_NAME%\r\nSubscription Months: %SUB_DURATION%\r\nPrice: %INVOICE_AMOUNT%\r\nStatus: Active\r\nPayment Method: Bank\r\n--------------------------\r\n\r\nPlease deposit %INVOICE_AMOUNT% to the following account:\r\n\tBank: %BANK_NAME%\r\n\tA/C Name: %AC_NAME%\r\n\tA/C Number: %AC_NUMBER%\r\n\r\nAfter making the deposit, please send an email to \r\n%SITE_CONTACT_EMAIL% with the following \r\nOrder Number: %INVOICE_CODE% to help us process the transaction. \r\n\r\nFeel free to contact %SITE_CONTACT_EMAIL% if you have \r\nany questions / problems. \r\n\r\nThank you!\r\n\r\n\r\n%SITE_NAME% team.\r\n%SITE_URL%\r\n', '*****@*****.**', 'Subscription order confirmed', 'Jamit Demo', '')";
        if (!JB_template_exists(80)) {
            JB_mysql_query($sql);
        }
        // sub confirmed (bank)
        $sql = "INSERT INTO `email_templates` (`EmailID`, `EmailText`, `EmailFromAddress`, `EmailSubject`, `EmailFromName`, `sub_template`) VALUES (81, 'Dear %LNAME%, %FNAME%\r\n\r\nYour order on %SITE_NAME% was confirmed, thank you.\r\n\r\n========================\r\nORDER DETAILS\r\n=========================\r\nOrder ID: #%INVOICE_CODE%\r\nSubscription Name: %ITEM_NAME%\r\nSubscription Months: %SUB_DURATION%\r\nPrice: %INVOICE_AMOUNT%\r\nStatus: Confirmed\r\nPayment Method: Check / Money Order\r\n--------------------------\r\n\r\nPlease send %INVOICE_AMOUNT% (%CHECK_CURRENCY%) to the following address:\r\n\tPayee Name: %PAYEE_NAME%\r\n\tAddress: \r\n        %PAYEE_ADDRESS%\r\n\t\r\n\r\nAfter mailing the check, please send an email to \r\n%SITE_CONTACT_EMAIL% with the following \r\nOrder Number: %INVOICE_CODE% to help us process the transaction. \r\n\r\nFeel free to contact %SITE_CONTACT_EMAIL% if you have \r\nany questions / problems. \r\n\r\nThank you!\r\n\r\n\r\n%SITE_NAME% team.\r\n%SITE_URL%\r\n\r\nNote: This is an automated email', '*****@*****.**', 'Subscription order confirmed', 'Jamit Demo', '')";
        if (!JB_template_exists(81)) {
            JB_mysql_query($sql);
        }
        // sub confirmed (check)
        $sql = "INSERT INTO `email_templates` (`EmailID`, `EmailText`, `EmailFromAddress`, `EmailSubject`, `EmailFromName`, `sub_template`) VALUES (120, 'Dear  %LNAME%, %FNAME%\r\n\r\nThis email is sent to notify you that your membership to %SITE_NAME% has expired.\r\n\r\nWe thank you for your patronage during your membership time, and we hope\r\nthat we can continue to serve you as our member in the future.\r\n\r\n\r\n========================\r\nORDER DETAILS\r\n=========================\r\nOrder ID: #%INVOICE_CODE%\r\nMembership Name: %ITEM_NAME%\r\nMembership Months: %MEM_DURATION%\r\nStart Date: %MEM_START%\r\nEnd Date: %MEM_END%\r\nPrice: %INVOICE_AMOUNT%\r\nStatus: Expired\r\nPayment Method: %PAYMENT_METHOD%\r\n\r\n--------------------------\r\n\r\nThank you for using %SITE_NAME%! \r\n\r\nYou may view your membership order history at any time.\r\nJust log in to your %SITE_NAME%, and go to ''Account'' -> ''Membership Details''.\r\n\r\n\r\n\r\n%SITE_NAME% team.\r\n%SITE_URL%\r\n\r\nNote: This is an automated email.', '*****@*****.**', 'Membership Expired', 'Jamit Demo', '')";
        if (!JB_template_exists(120)) {
            JB_mysql_query($sql);
        }
        // mem expired
        $sql = "INSERT INTO `email_templates` (`EmailID`, `EmailText`, `EmailFromAddress`, `EmailSubject`, `EmailFromName`, `sub_template`) VALUES (100, 'Dear  %LNAME%, %FNAME%\r\n\r\nYour membership on %SITE_NAME% was confirmed, thank you.\r\n\r\n========================\r\nORDER DETAILS\r\n=========================\r\nOrder ID: #%INVOICE_CODE%\r\nMembership Item: %ITEM_NAME%\r\nMembership Months: %MEM_DURATION%\r\nPrice: %INVOICE_AMOUNT%\r\nStatus: Confirmed\r\nPayment Method: Bank\r\n--------------------------\r\n\r\nPlease deposit %INVOICE_AMOUNT% to the following account:\r\n\tBank: %BANK_NAME%\r\n\tA/C Name: %AC_NAME%\r\n\tA/C Number: %AC_NUMBER%\r\n\r\nAfter making the deposit, please send an email to \r\n%SITE_CONTACT_EMAIL% with the following \r\nOrder Number: %INVOICE_CODE% to help us process the transaction. \r\n\r\nFeel free to contact %SITE_CONTACT_EMAIL% if you have \r\nany questions / problems. \r\n\r\nThank you!\r\n\r\n\r\n%SITE_NAME% team.\r\n%SITE_URL%\r\n', '*****@*****.**', 'Membership Order Confirmed', 'Jamit Demo', '')";
        if (!JB_template_exists(100)) {
            JB_mysql_query($sql);
        }
        // mem confirmed (BANK)
        $sql = "INSERT INTO `email_templates` (`EmailID`, `EmailText`, `EmailFromAddress`, `EmailSubject`, `EmailFromName`, `sub_template`) VALUES (101, 'Dear %LNAME%, %FNAME%\r\n\r\nYour order on %SITE_NAME% was confirmed, thank you.\r\n\r\n========================\r\nORDER DETAILS\r\n=========================\r\nOrder ID: #%INVOICE_CODE%\r\nMembership Name: %ITEM_NAME%\r\nMembership Months: %MEM_DURATION%\r\nPrice: %INVOICE_AMOUNT%\r\nStatus: Confirmed\r\nPayment Method: Check / Money Order\r\n--------------------------\r\n\r\nPlease send %INVOICE_AMOUNT% (%CHECK_CURRENCY%) to the following address:\r\n\tPayee Name: %PAYEE_NAME%\r\n\tAddress: \r\n        %PAYEE_ADDRESS%\r\n\t\r\n\r\nAfter mailing the check, please send an email to \r\n%SITE_CONTACT_EMAIL% with the following \r\nOrder Number: %INVOICE_CODE% to help us process the transaction. \r\n\r\nFeel free to contact %SITE_CONTACT_EMAIL% if you have \r\nany questions / problems. \r\n\r\nThank you!\r\n\r\n\r\n%SITE_NAME% team.\r\n%SITE_URL%\r\n\r\nNote: This is an automated email', '*****@*****.**', 'Membership Order Confirmed', 'Jamit Demo', '')";
        if (!JB_template_exists(101)) {
            JB_mysql_query($sql);
        }
        // member confirmed (check)
        $sql = "INSERT INTO `email_templates` (`EmailID`, `EmailText`, `EmailFromAddress`, `EmailSubject`, `EmailFromName`, `sub_template`) VALUES (110, 'Dear  %LNAME%, %FNAME%\r\n\r\nYour membership payment on %SITE_NAME% was successfully completed, thank you!\r\n\r\nWe have activated your membership, and we welcome you as our new member. \r\nHere are your membership payment details:\r\n\r\n========================\r\nORDER DETAILS\r\n=========================\r\nOrder ID: #%INVOICE_CODE%\r\nMembership Name: %ITEM_NAME%\r\nMembership Months: %MEM_DURATION%\r\nStart Date: %MEM_START%\r\nEnd Date: %MEM_END%\r\nPrice: %INVOICE_AMOUNT%\r\nStatus: Active\r\nPayment Method: %PAYMENT_METHOD%\r\n\r\n--------------------------\r\n\r\nThank you for using %SITE_NAME%! \r\n\r\nYou may view your membership order history at any time.\r\nJust log in to your %SITE_NAME%, and go to ''Account'' -> ''Membership Details''.\r\n\r\n\r\n%SITE_NAME% team.\r\n%SITE_URL%\r\n\r\nNote: This is an automated email.', '*****@*****.**', 'Membership Activated', 'Jamit Demo', '')";
        if (!JB_template_exists(110)) {
            JB_mysql_query($sql);
        }
        // member completed
        $sql = "INSERT INTO `email_templates` (`EmailID`, `EmailText`, `EmailFromAddress`, `EmailSubject`, `EmailFromName`, `sub_template`) VALUES (130, 'Dear  %LNAME%, %FNAME%\r\n\r\nThis email is sent to notify you that your subscription to %SITE_NAME% has expired.\r\n\r\nWe thank you for your patronage during your subscription time, and we hope\r\nthat we can continue to serve you as our subscriber in the future.\r\n\r\n\r\n========================\r\nORDER DETAILS\r\n=========================\r\nOrder ID: #%INVOICE_CODE%\r\nSubscription Name: %ITEM_NAME%\r\nSubscription Months: %SUB_DURATION%\r\nStart Date: %SUB_START%\r\nEnd Date: %SUB_END%\r\nPrice: %INVOICE_AMOUNT%\r\nStatus: Expired\r\nPayment Method: %PAYMENT_METHOD%\r\n\r\n--------------------------\r\n\r\nThank you for using %SITE_NAME%! \r\n\r\nYou may view your subscription order history at any time.\r\nJust log in to your %SITE_NAME%, and go to ''Account'' -> ''Subscription''.\r\n\r\n\r\n\r\n%SITE_NAME% team.\r\n%SITE_URL%\r\n\r\nNote: This is an automated email.', '*****@*****.**', 'Subscription Expired', 'Jamit Demo', '')";
        if (!JB_template_exists(130)) {
            JB_mysql_query($sql);
        }
        // sub expired
        $sql = "INSERT INTO `email_templates` ( `EmailText` , `EmailFromAddress` , `EmailFromName` , `EmailSubject` , `EmailID` , `sub_template` )VALUES ('%APP_LETTER% \r\n\r\n----------------------------------- \r\nThis email was sent from %SITE_NAME% %BASE_HTTP_PATH%\r\nOnline Resume Link: \r\n%RESUME_DB_LINK%\r\n', '', '', '', '12', '');";
        if (!JB_template_exists(12)) {
            JB_mysql_query($sql);
        }
        // application
        $sql = "INSERT INTO `email_templates` (`EmailID`, `EmailText`, `EmailFromAddress`, `EmailSubject`, `EmailFromName`, `sub_template`) VALUES (11, '%MESSAGE%\r\n\r\n\r\n\r\n\r\n------------------------\r\n%SITE_URL%\r\n\r\nThis message was sent by somebody using the \r\nweb-email service provided by %SITE_NAME%.\r\n\r\nName: %EMPLOYER_NAME%\r\nSender\\'s User ID: %USER_ID%\r\nSender IP: %SENDER_IP%\r\n', '*****@*****.**', '', 'Jamit Demo', '');";
        if (!JB_template_exists(11)) {
            JB_mysql_query($sql);
        }
        // employer to candidate
        $sql = "INSERT INTO `email_templates` (`EmailID`, `EmailText`, `EmailFromAddress`, `EmailSubject`, `EmailFromName`, `sub_template`) VALUES (44, 'Hello %EMP_NAME%\r\n\r\n%CAN_NAME% has granted you access to their online resume on %SITE_NAME%!\r\n\r\nTo view this resume, please see this link:\r\n\r\nResume link: %RESUME_DB_LINK%\r\n\r\nThanks,\r\n\r\n%SITE_NAME%\r\n%SITE_URL%\r\n-------------\r\n\r\n', '" . JB_SITE_CONTACT_EMAIL . "', '%CAN_NAME% granted you access to their resume on %SITE_NAME% ', '" . JB_SITE_NAME . "', '');";
        if (!JB_template_exists(44)) {
            JB_mysql_query($sql);
        }
        // employer to candidate
        if ($sql != '') {
            JB_format_email_translation_table();
        }
        // fix the profile tag
        $sql = "UPDATE form_fields SET template_tag = 'PROFILE_BNAME' WHERE template_tag='PROFILE_COL2' ";
        JB_mysql_query($sql);
        $sql = "UPDATE form_lists SET template_tag = 'PROFILE_BNAME' WHERE template_tag='PROFILE_COL2' ";
        JB_mysql_query($sql);
        // replace config.php
        if (mysql_affected_rows($jb_mysql_link) > 0) {
            $filename = JB_basedirpath() . 'config.php';
            $handle = fopen($filename, "r");
            $contents = fread($handle, filesize($filename));
            fclose($handle);
            $contents = str_replace('s:12:"PROFILE_COL2', 's:13:"PROFILE_BNAME', $contents);
            $handle = fopen($filename, 'w');
            fwrite($handle, $contents, strlen($contents));
            fclose($handle);
        }
        if (!does_field_exist("lang", "theme")) {
            $sql = "ALTER TABLE `lang` ADD `theme` VARCHAR(30) NULL default '" . JB_THEME . "'";
            //echo $sql." flag $flag";
            if ($flag) {
                JB_mysql_query($sql) or die($sql . mysql_error());
            }
            $upgrade_needed = true;
        }
        if (!does_field_exist("requests", "deleted")) {
            $sql = "ALTER TABLE `requests`  ADD `deleted` SET( 'Y', 'N' ) NOT NULL DEFAULT 'N' ";
            //echo $sql." flag $flag";
            if ($flag) {
                JB_mysql_query($sql) or die($sql . mysql_error());
            }
            $upgrade_needed = true;
        }
        if (!does_field_exist("xml_import_feeds", "feed_id")) {
            $sql = "CREATE TABLE `xml_import_feeds` (\n\t\t\t\t  `feed_id` int(11) NOT NULL auto_increment,\n\t\t\t\t  `feed_metadata` text NOT NULL,\n\t\t\t\t  `feed_name` varchar(255) NOT NULL,\n\t\t\t\t  `description` varchar(255) NOT NULL,\n\t\t\t\t  `date` date NOT NULL,\n\t\t\t\t  `xml_sample` text NOT NULL,\n\t\t\t\t  `feed_key` varchar(255) NOT NULL,\n\t\t\t\t  `ip_allow` text NOT NULL,\n\t\t\t\t  `feed_url` varchar(255) NOT NULL,\n\t\t\t\t  `feed_filename` varchar(255) NOT NULL,\n\t\t\t\t  `ftp_user` varchar(255) NOT NULL,\n\t\t\t\t  `ftp_pass` varchar(255) NOT NULL,\n\t\t\t\t  `ftp_filename` varchar(255) NOT NULL,\n\t\t\t\t  `ftp_host` varchar(255) NOT NULL,\n\t\t\t\t  `status` varchar(10) NOT NULL,\n\t\t\t\t  `pickup_method` varchar(5) NOT NULL,\n\t\t\t\t  `cron` set('Y','N') NOT NULL,\n\t\t\t\t  PRIMARY KEY  (`feed_id`)\n\t\t\t\t) ENGINE=MyISAM";
            if ($flag) {
                JB_mysql_query($sql) or die($sql . mysql_error());
            }
            $upgrade_needed = true;
            // change post_id to be auto-increment
            $sql = " ALTER TABLE `posts_table` CHANGE `post_id` `post_id` INT( 11 ) NOT NULL AUTO_INCREMENT  ";
            if ($flag) {
                JB_mysql_query($sql) or die($sql . mysql_error());
            }
        }
        if (!does_field_exist("package_invoices", "invoice_tax")) {
            $sql = "ALTER TABLE `package_invoices` ADD `invoice_tax` FLOAT NOT NULL DEFAULT '0';";
            if ($flag) {
                JB_mysql_query($sql) or die($sql . mysql_error());
            }
            $sql = "ALTER TABLE `subscription_invoices` ADD `invoice_tax` FLOAT NOT NULL DEFAULT '0';";
            if ($flag) {
                JB_mysql_query($sql) or die($sql . mysql_error());
            }
            $sql = "ALTER TABLE `membership_invoices` ADD `invoice_tax` FLOAT NOT NULL DEFAULT '0';";
            if ($flag) {
                JB_mysql_query($sql) or die($sql . mysql_error());
            }
            // change post_id to be auto-increment
            $sql = " ALTER TABLE `profiles_table` CHANGE `profile_id` `profile_id` INT( 11 ) NOT NULL AUTO_INCREMENT  ";
            if ($flag) {
                JB_mysql_query($sql) or die($sql . mysql_error());
            }
            // fix template tag for the logo field in profiles_table
            $sql = "UPDATE form_fields SET template_tag='IMAGE' WHERE field_id=66 AND template_tag = '' ";
            if ($flag) {
                JB_mysql_query($sql) or die($sql . mysql_error());
            }
            $upgrade_needed = true;
        }
        if (!does_field_exist('xml_export_feeds', 'include_imported')) {
            $sql = "ALTER TABLE `xml_export_feeds` ADD `include_imported` SET( 'Y', 'N' ) NOT NULL default 'N'";
            if ($flag) {
                JB_mysql_query($sql) or die($sql . mysql_error());
            }
            $upgrade_needed = true;
        }
        if (!does_field_exist("saved_resumes", "resume_id")) {
            $sql = "CREATE TABLE `saved_resumes` (\n\t\t\t\t  `resume_id` int(11) NOT NULL default '0',\n\t\t\t\t  `user_id` int(11) NOT NULL default '0',\n\t\t\t\t  `save_date` datetime NOT NULL default '0000-00-00 00:00:00',\n\t\t\t\t  PRIMARY KEY  (`resume_id`,`user_id`),\n\t\t\t\t  KEY `composite` (`user_id`,`save_date`)\n\t\t\t\t) ENGINE=InnoDB DEFAULT CHARSET=latin1;";
            if ($flag) {
                JB_mysql_query($sql) or die($sql . mysql_error());
            }
            $upgrade_needed = true;
        }
        if (1 == 1) {
            // check to make sure that all form fields have a template_tag, if not generate one
            $sql = "SELECT * FROM `form_fields` ";
            $result = mysql_query($sql);
            while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
                if ($row['field_type'] == 'BLANK' || $row['field_type'] == 'SEPERATOR' || $row['field_type'] == 'NOTE') {
                    continue;
                }
                if (trim($row['template_tag'] == '')) {
                    // create a new name for it
                    $template_tag = strtoupper(preg_replace('/[^a-z^0-9]+/i', '_', $row['field_label']));
                    $template_tag = preg_replace('/_$/', '', $template_tag);
                    $template_tag = preg_replace('/$_/', '', $template_tag);
                    $base_template_tag = $template_tag;
                    // check to see if it exists?
                    $i = 1;
                    do {
                        $sql = "SELECT * FROM `form_fields` WHERE `form_id`='" . jb_escape_sql($row['form_id']) . "' AND `template_tag`='" . jb_escape_sql($template_tag) . "' ";
                        $result2 = mysql_query($sql);
                        if (mysql_num_rows($result2) == 0) {
                            $sql = "UPDATE `form_fields` SET `template_tag`='" . jb_escape_sql($template_tag) . "' WHERE `field_id`='" . jb_escape_sql($row['field_id']) . "' ";
                            jb_mysql_query($sql);
                            //echo "$sql<br>";
                            break;
                        } else {
                            $i++;
                            $template_tag = $base_template_tag . $i;
                            if ($i > 10) {
                                break;
                            }
                        }
                    } while (0);
                }
            }
        }
        /*
        MySQL 5 only.
        // convert categories to UTF-8
        $sql = "ALTER TABLE `categories` CHANGE `category_name` `category_name` VARCHAR( 255 ) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL";
        JB_mysql_query($sql);
        // now convert data:
        $sql = "SELECT category_name, category_id FROM categories ";
        		$result = JB_mysql_query($sql);
        		while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
        			
        			$sql = "UPDATE categories SET category_name = '".jb_escape_sql(addslashes(JB_html_ent_to_utf8($row['category_name'])))."' WHERE category_id='".$row['category_id']."' ";
        			JB_mysql_query($sql);
        }
        $sql = "ALTER TABLE `cat_name_translations` CHANGE `category_name` `category_name` TEXT CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL ";
        JB_mysql_query($sql);
        // now convert data:
        $sql = "SELECT category_name, category_id FROM cat_name_translations ";
        		$result = JB_mysql_query($sql);
        		while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
        			
        			$sql = "UPDATE categories SET category_name = '".jb_escape_sql(addslashes(JB_html_ent_to_utf8($row['category_name'])))."' WHERE category_id='".$row['category_id']."' ";
        			JB_mysql_query($sql);
        }
        */
        // THIS CODE BLOCK SHOULD ALWAYS BE AT THE END
        // Update the cache
        if ($flag && does_field_exist("categories", "seo_fname")) {
            JB_cache_flush();
        }
        if ($upgrade_needed == false && defined('JB_VERSION')) {
            $sql = "REPLACE  INTO `jb_variables` VALUES ('JB_VERSION', '" . JB_VERSION . "')";
            JB_mysql_query($sql);
            $JBMarkup->ok_msg('- Job Board version changed to ' . JB_VERSION . '. Please log out form Admin and log in again for the version number to change.');
        }
    }
    return $upgrade_needed;
}
Пример #15
0
    	$from_date = "CONVERT_TZ('".$_REQUEST['from_year']."-".$_REQUEST['from_month']."-".$_REQUEST['from_day']." 00:00:00', '".$plus.JB_GMT_DIF.":00', '+00:00')" ;
    	$to_date = "CONVERT_TZ('".$_REQUEST['to_year']."-".$_REQUEST['to_month']."-".$_REQUEST['to_day']." 23:59:59', '".$plus.JB_GMT_DIF.":00', '+00:00')" ;
    */
    $where_date = "WHERE (invoice_date >= {$from_date} AND invoice_date <= {$to_date} ) ";
    if ($_REQUEST['status'] != '' && $_REQUEST['status'] != 'all') {
        $where_status = " AND status='" . $_REQUEST['status'] . "' ";
    }
    if ($_REQUEST['search_it'] != '') {
        $sql = "select ID from employers WHERE Username ='******'search_str']) . "' ";
        $result = JB_mysql_query($sql);
        if (mysql_num_rows($result) > 0) {
            $row = mysql_fetch_array($result, MYSQL_ASSOC);
            $sql = "select * FROM package_invoices WHERE employer_id='" . jb_escape_sql($row['ID']) . "' ORDER BY invoice_date DESC";
        } else {
            $_REQUEST['search_str'] = preg_replace('/[^0-9]/', '', $_REQUEST['search_str']);
            $sql = "select * FROM package_invoices WHERE invoice_id='" . jb_escape_sql($_REQUEST['search_str']) . "' ORDER BY invoice_date DESC";
        }
    } else {
        $sql = "select * FROM package_invoices {$where_date} {$where_status} ORDER BY invoice_date DESC";
    }
    $result = JB_mysql_query($sql) or die(mysql_error());
    if (mysql_num_rows($result) > 0) {
        ?>

<table  cellSpacing="1" cellPadding="3" style="margin: 0 auto; background-color: #d9d9d9; width:100%; border:0px" >

  <tr bgColor="#eaeaea">
    <td><b><font face="Arial" size="2">Order Date</font></b></td>
	<td><b><font face="Arial" size="2">Order ID</font></b></td>
	<td><b><font face="Arial" size="2">Client Name</font></b></td>
    <td><b><font face="Arial" size="2">Item Name</font></b></td>
Пример #16
0
// Assume quotes is always On, we need to strip slashes.
$subject = JB_clean_str(stripslashes($_REQUEST['subject']));
$message = JB_clean_str(stripslashes($_REQUEST['message']));
$your_name = JB_clean_str(stripslashes($_REQUEST['your_name']));
$your_email = JB_clean_str(stripslashes($_REQUEST['your_email']));
$to_email = JB_clean_str(stripslashes($_REQUEST['to_email']));
$to_name = JB_clean_str(stripslashes($_REQUEST['to_name']));
if (strlen(trim($to_name)) == 0) {
    $to_name = $to_email;
}
if (strlen(trim($your_name)) == 0) {
    $your_name = JB_get_formatted_name($_SESSION['JB_FirstName'], $_SESSION['JB_LastName']);
}
if (strlen(trim($your_email)) == 0) {
    //$your_email =
    $sql = "SELECT Email from users WHERE ID='" . jb_escape_sql($_SESSION['JB_ID']) . "'";
    $result = jb_mysql_query($sql);
    if (mysql_num_rows($result)) {
        $your_email = array_pop(mysql_fetch_row($result));
    }
}
if ($submit != '') {
    if ($your_email == '') {
        $error .= $label['taf_email_blank'] . " <br>";
    } elseif (!JB_validate_mail($your_email)) {
        $error .= $label['taf_email_invalid'] . "<br>";
    }
    if ($your_name == '') {
        $error .= $label['taf_name_blank'] . "<br>";
    }
    if ($to_email == '') {
Пример #17
0
###########################################################################
# Copyright Jamit Software 2012, http://www.jamit.com
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this file,
# You can obtain one at http://mozilla.org/MPL/2.0/.
###########################################################################
@set_time_limit(280);
ini_set('session.gc_maxlifetime', 60 * 60 * 4);
// 4 hours
require '../config.php';
require "admin_common.php";
//ini_set (session.use_trans_sid, false);
JB_admin_header('Admin->Translation / Editing Tool');
$label = array();
$sql = "SELECT * FROM lang WHERE lang_code='" . jb_escape_sql($_REQUEST['target_lang']) . "' ";
$result = JB_mysql_query($sql) or die(mysql_error());
$row = mysql_fetch_array($result, MYSQL_ASSOC);
$lang_filename = $row['lang_filename'];
$lang_name = $row['name'];
include jb_get_english_default_dir() . "english_default.php";
// main english default
JBPLUG_append_english_default_labels();
// require the english_defult.php files for the modules
JB_theme_append_english_default_labels();
$source_label = $label;
// default english labels
include jB_get_lang_dir() . $lang_filename;
$dest_label = $label;
// dest labels
// preload the source code, preg the hash key and use it as a key for the line
Пример #18
0
function JB_expire_post($post_id)
{
    $post_id = (int) $post_id;
    $sql = "UPDATE posts_table SET expired='Y' where post_id='" . jb_escape_sql($post_id) . "' ";
    JB_mysql_query($sql) or $DB_ERROR = mysql_error();
    JBPLUG_do_callback('expire_post', $post_id);
    // col val is post_id
    if (JB_EMAIL_POST_EXP_SWITCH == 'YES') {
        // Send Expiration email
        $Form = JB_get_DynamicFormObject(1);
        $Form->load($post_id);
        $TITLE = $Form->get_raw_template_value("TITLE");
        $DATE = JB_get_formatted_date($Form->get_template_value("DATE"));
        $POSTED_BY_ID = $Form->get_value('user_id');
        // get the employer
        $sql = "SELECT * FROM employers WHERE ID='" . jb_escape_sql($POSTED_BY_ID) . "' ";
        $emp_result = jb_mysql_query($sql);
        $emp_row = mysql_fetch_array($emp_result);
        // get the email template
        $template_result = JB_get_email_template(210, $emp_row['lang']);
        $t_row = mysql_fetch_array($template_result);
        $to_address = $emp_row['Email'];
        $to_name = JB_get_formatted_name($emp_row['FirstName'], $emp_row['LastName']);
        $subject = $t_row['EmailSubject'];
        $message = $t_row['EmailText'];
        $from_name = $t_row['EmailFromName'];
        $from_address = $t_row['EmailFromAddress'];
        $message = str_replace("%LNAME%", $emp_row['LastName'], $message);
        $message = str_replace("%FNAME%", $emp_row['FirstName'], $message);
        $message = str_replace("%SITE_NAME%", JB_SITE_NAME, $message);
        $message = str_replace("%SITE_URL%", JB_BASE_HTTP_PATH, $message);
        $message = str_replace("%SITE_CONTACT_EMAIL%", JB_SITE_CONTACT_EMAIL, $message);
        $message = str_replace("%POST_TITLE%", $TITLE, $message);
        $message = str_replace("%POST_DATE%", $DATE, $message);
        $message = str_replace("%VIEWS%", $Form->get_value('hits'), $message);
        $message = str_replace("%APPS%", $Form->get_value('applications'), $message);
        $message = strip_tags($message);
        // plugin can change the recipient
        JBPLUG_do_callback('expire_post_set_recipient_email', $to_address);
        JBPLUG_do_callback('expire_post_set_recipient_name', $to_name);
        // Place the email on the queue!
        JB_queue_mail($to_address, $to_name, $from_address, $from_name, $subject, $message, '', 210);
    }
}
Пример #19
0
</font></td>
    <td><font face="Arial" size="2"><?php 
        echo $row['Username'];
        ?>
</font></td>
    <td><font face="Arial" size="2"><?php 
        echo $row['Email'];
        ?>
</font></td>
	<td><font face="Arial" size="2"><?php 
        echo $row['CompName'];
        ?>
</font></td>
	<td><?php 
        $now = gmdate("Y-m-d H:i:s");
        $sql = "SELECT * FROM `posts_table` WHERE `user_id`='" . jb_escape_sql($row['ID']) . "' AND expired='N' ";
        $result2 = JB_mysql_query($sql);
        $count = mysql_num_rows($result2);
        if ($count > 0) {
            echo "<a href='posts.php?show_emp=" . $row['ID'] . "'>" . $count . "</a>";
        } else {
            echo "N";
        }
        //echo $row[Notification2];
        ?>
	</td>
    <td><font face="Arial" size="2"><?php 
        echo $row['Newsletter'];
        ?>
    </font></td>
    <td><?php 
Пример #20
0
$row = mysql_fetch_array($result, MYSQL_ASSOC);
$label["c_index_greeting"] = str_replace("%SITE_NAME%", JB_escape_html(JB_SITE_NAME), $label["c_index_greeting"]);
$label["c_index_greeting"] = str_replace("%USERNAME%", JB_escape_html($_SESSION['JB_Username']), $label["c_index_greeting"]);
$label["c_index_greeting"] = str_replace("%FIRST_NAME%", JB_escape_html($row['FirstName']), $label["c_index_greeting"]);
$label["c_index_greeting"] = str_replace("%LAST_NAME%", JB_escape_html($row['LastName']), $label["c_index_greeting"]);
?>
<h3 style="text-align:center"><?php 
echo $label["c_index_greeting"];
?>
</h3>
<?php 
JBPLUG_do_callback('candidates_index_top', $A = false);
if (JB_display_motd('U', 80)) {
    echo '<br>';
}
$sql = "SELECT `hits`, `status` FROM `resumes_table` WHERE `user_id`='" . jb_escape_sql($_SESSION['JB_ID']) . "'";
$result = JB_mysql_query($sql);
$row = mysql_fetch_array($result, MYSQL_ASSOC);
$count = $row['hits'];
if ($count != '') {
    if ($row['status'] == 'ACT') {
        $str = $label["c_index_resume_act"];
    } else {
        $str = $label["c_index_resume_sus"];
    }
    $label["c_index_views"] = str_replace("%COUNT%", $count, $label["c_index_views"]);
    $str = '<p style="text-align:center">' . $str . ' ' . $label["c_index_views"] . '</p>';
    JB_display_info_box($label["c_index_status"], $str, 80);
    ?>

Пример #21
0
 function insert_job($employer_id)
 {
     // get guid
     $element = $this->FMD->getOption('guid');
     // get key of guid element
     $guid = $this->clean_data($this->data[$element]['data']);
     // check to see if GUID is unique
     $sql = "SELECT post_id FROM `posts_table` WHERE `guid`='" . jb_escape_sql($guid) . "' ";
     $result = jb_mysql_query($sql);
     if (mysql_num_rows($result) > 0) {
         // return the existing post_id
         $this->echo_import_error('Post ' . jb_escape_html($guid) . ' already exists');
         return array_pop(mysql_fetch_row($result));
     }
     // check if enough credits
     if (JB_POSTING_FEE_ENABLED == 'YES' && $this->FMD->getOption('deduct_credits') > 0) {
         $sql = "SELECT `ID` FROM `employers` WHERE (`posts_balance` - " . jb_escape_sql($this->FMD->getOption('deduct_credits')) . ") >= 0 AND `ID`='" . jb_escape_sql($employer_id) . "' ";
         $result = jb_mysql_query($sql);
         if (mysql_num_rows($result) == 0) {
             $this->set_import_error('Not enough credits for employer id:' . $employer_id);
             return false;
         }
     }
     // get the fiels part of the INSERT query
     $sql_fields = $this->get_sql_insert_fields(1);
     if ($sql_fields === false) {
         return false;
     }
     // get the values part of the INSERT query
     $sql_values = $this->get_sql_insert_values(1);
     if ($sql_values === false) {
         return false;
     }
     // post_date
     $element = $this->FMD->getOption('post_date');
     $post_date = $this->data[$element]['data'];
     if ($time = strtotime($post_date)) {
         $post_date = gmdate("Y-m-d H:i:s", $time);
     } else {
         $post_date = gmdate("Y-m-d H:i:s");
         // post as now
     }
     // post_mode
     $element = $this->FMD->getOption('post_mode');
     // get it from the feed
     $post_mode = $this->data[$element]['data'];
     if ($post_mode == '' || $post_mode != 'normal' || $post_mode != 'free' || $post_mode != 'premium') {
         if (JB_POSTING_FEE_ENABLED == 'YES') {
             // not present in the feed, default to normal.
             $post_mode = 'normal';
         }
     }
     // approval
     $element = $this->FMD->getOption('approved');
     $approved = $this->data[$element]['data'];
     if ($approved != 'N' && $approved != 'Y') {
         // get the setting from 'map fields'
         $approved = $this->FMD->getOption('default_approved');
         if ($approved != 'N' && $approved != 'Y') {
             // get the setting from Admin->Main Config
             if (JB_POSTS_NEED_APPROVAL == 'NO') {
                 $approved = 'Y';
             } else {
                 $approved = 'N';
             }
         }
     }
     // application type
     // get app_url
     $element = $this->FMD->getOption('app_url');
     // get key of guid element
     $app_url = $this->clean_data($this->data[$element]['data']);
     //echo $this->FMD->getOption('default_app_type'); die();
     if ($app_url != false) {
         $app_type = "R";
         // redirect
     } elseif ($this->FMD->getOption('default_app_type')) {
         $app_type = $this->FMD->getOption('default_app_type');
     } else {
         $app_type = "N";
         // app_type can be: O=online R = Url, N = None,
     }
     $sql = "INSERT INTO `posts_table` ( `guid`, `post_date`, `user_id`, `approved`, `expired`, `post_mode`, `app_type`, `app_url` " . $sql_fields . ") VALUES ( '" . jb_escape_sql($guid) . "', '" . $post_date . "', '" . $employer_id . "', '" . jb_escape_sql($approved) . "', 'N', '" . jb_escape_sql($post_mode) . "', '" . jb_escape_sql($app_type) . "', '" . jb_escape_sql($app_url) . "' " . $sql_values . ") ";
     //echo $sql.'<br>'."\n";
     $result = jb_mysql_query($sql);
     $post_id = jb_mysql_insert_id();
     $this->log_entry('Inserted Job | ID:' . $post_id . ' | GUID:' . $guid . ' | Emp.ID:' . $employer_id);
     // deduct credits
     if (JB_POSTING_FEE_ENABLED == 'YES' && $this->FMD->getOption('deduct_credits') > 0) {
         $sql = "UPDARE `employers` SET `posts_balance`= (`posts_balance` - " . jb_escape_sql($this->FMD->getOption('deduct_credits')) . ") WHERE `ID`='" . jb_escape_sql($employer_id) . "' ";
         $result = jb_mysql_query($sql);
     }
     return $post_id;
 }
Пример #22
0
function JB_set_employer_session(&$emp_row)
{
    $_SESSION['JB_ID'] = $emp_row['ID'];
    $_SESSION['JB_FirstName'] = $emp_row['FirstName'];
    $_SESSION['JB_LastName'] = $emp_row['LastName'];
    $_SESSION['JB_Username'] = $emp_row['Username'];
    $_SESSION['Rank'] = $emp_row['Rank'];
    $_SESSION['JB_Domain'] = "EMPLOYER";
    $_SESSION['JB_Base'] = JB_BASE_HTTP_PATH;
    if ($row['lang'] != '') {
        $_SESSION['LANG'] = $emp_row['lang'];
    }
    $now = gmdate("Y-m-d H:i:s");
    $sql = "UPDATE `employers` SET `login_date`='{$now}', `last_request_time`='{$now}', `logout_date`=0, `login_count`=`login_count`+1 WHERE `Username`='" . jb_escape_sql(addslashes($emp_row['Username'])) . "' ";
    JB_mysql_query($sql) or die(mysql_error());
}
Пример #23
0
    ?>
"></td></tr>
<tr><td colspan="2">
<input type="submit" value="Apply to All" name="set_global"></td></tr>
</table>
</form>

<hr>

<?php 
}
if ($_REQUEST['submit'] != '') {
    if (JB_validate_mail($_REQUEST['EmailFromAddress'])) {
        $sql = "UPDATE email_templates SET EmailText='" . jb_escape_sql($_REQUEST['EmailText']) . "', EmailFromAddress='" . jb_escape_sql($_REQUEST['EmailFromAddress']) . "', EmailFromName='" . jb_escape_sql($_REQUEST['EmailFromName']) . "', EmailSubject='" . jb_escape_sql($_REQUEST['EmailSubject']) . "', `sub_template`='" . jb_escape_sql($_REQUEST['sub_template']) . "' WHERE EmailID='" . jb_escape_sql($_REQUEST['EmailID']) . "' ";
        $result = JB_mysql_query($sql) or die(mysql_error());
        $sql = "REPLACE INTO `email_template_translations` (`EmailID`, `lang`, `EmailText`, `EmailFromAddress`, `EmailFromName`, EmailSubject, `sub_template`) VALUES (" . jb_escape_sql($_REQUEST['EmailID']) . ", '" . jb_escape_sql($_SESSION["LANG"]) . "', '" . jb_escape_sql($_REQUEST['EmailText']) . "', '" . jb_escape_sql($_REQUEST['EmailFromAddress']) . "', '" . jb_escape_sql($_REQUEST['EmailFromName']) . "', '" . jb_escape_sql($_REQUEST['EmailSubject']) . "', '" . jb_escape_sql($_REQUEST['sub_template']) . "')";
        $result = JB_mysql_query($sql) or die(mysql_error());
        JB_format_email_translation_table();
        $JBMarkup->ok_msg('Template Saved.');
    } else {
        $JBMarkup->ok_msg('Error: From email address is invalid');
    }
}
function email_config_form($email_id)
{
    $result = JB_get_email_template($email_id, $_SESSION['LANG']);
    $row = mysql_fetch_array($result, MYSQL_ASSOC);
    if ($row['EmailFromAddress'] == '') {
        $row['EmailFromAddress'] = JB_SITE_CONTACT_EMAIL;
    }
    if ($row['EmailFromName'] == '') {
Пример #24
0
     die;
 }
 $data = JB_load_post_data($post_id);
 if ($_SESSION['JB_ID'] != '' && $_SESSION['JB_Domain'] == 'CANDIDATE' || JB_ONLINE_APP_SIGN_IN != 'YES') {
     $sql = "SELECT app_id FROM applications WHERE post_id='" . jb_escape_sql($post_id) . "' AND user_id='" . jb_escape_sql($_SESSION['JB_ID']) . "' ";
     $result = JB_mysql_query($sql) or die(mysql_error());
     $row = mysql_fetch_array($result, MYSQL_ASSOC);
     if ($row['app_id'] != '') {
         echo $label["app_already_applied"] . "<br>";
     } else {
         // increment the application count
         $sql = "UPDATE `posts_table` SET `applications`=`applications`+1 WHERE `post_id`='" . jb_escape_sql($post_id) . "' ";
         JB_mysql_query($sql) or die(mysql_error());
     }
     // load the users' resume (if one exists)
     $sql = "SELECT resume_id FROM resumes_table WHERE user_id='" . jb_escape_sql($_SESSION['JB_ID']) . "'";
     $resume_result = JB_mysql_query($sql) or die(mysql_error());
     $resume_row = mysql_fetch_array($resume_result, MYSQL_ASSOC);
     if ($resume_row['resume_id'] != '') {
         require_once dirname(__FILE__) . "/include/resumes.inc.php";
         $resume_data = JB_load_resume_data($resume_row['resume_id']);
     }
     if ($data['post_mode'] != 'premium') {
         // standard post?
         if (JB_ONLINE_APP_REVEAL_STD == 'YES' && $resume_data['anon'] == 'Y') {
             // reveal candidate's resume, even if hidden?
             JB_grant_request($resume_data['user_id'], $data['user_id']);
         }
     } elseif ($data['post_mode'] == 'premium') {
         // premium posts?
         if (JB_ONLINE_APP_REVEAL_PREMIUM == 'YES' && $resume_data['anon'] == 'Y') {
Пример #25
0
            $EmailMessage = str_replace("%SITE_CONTACT_EMAIL%", JB_SITE_CONTACT_EMAIL, $EmailMessage);
            $EmailMessage = str_replace("%SITE_NAME%", JB_SITE_NAME, $EmailMessage);
            $EmailMessage = str_replace("%SITE_LOGO_URL%", JB_SITE_LOGO_URL, $EmailMessage);
            $EmailMessage = str_replace("%RESUME_ALERTS%", $resume_alert_list_text, $EmailMessage);
            $EmailMessage = str_replace("%RESUME_ALERT%", '', $EmailMessage);
            // for compatibility with older version
            $EmailMessage = str_replace("%KEYWORDS_LINE%", $resume_alert_list_text, $EmailMessage);
            // deprecated, use %RESUME_ALERTS% instead
            $EmailMessage = str_replace("%EMPLOYER_LINK%", $_clink, $EmailMessage);
            $text_message = html_entity_decode($EmailMessage);
            $text_message = strip_tags($text_message);
            // send the sucker...
            if ($DO_SEND == "YES") {
                // mark as sent
                $now = gmdate("Y-m-d H:i:s");
                $sql = "UPDATE `employers` SET `alert_last_run`='{$now}' WHERE `ID`='" . jb_escape_sql($user_row['ID']) . "'";
                JB_mysql_query($sql) or die(mysql_error() . $sql);
                if (JB_mysql_affected_rows() > 0) {
                    // place on the queue
                    JB_queue_mail($to_address, $to_name, $e_row['EmailFromAddress'], $e_row['EmailFromName'], $subject, $text_message, $html_message, $e_row['EmailID']);
                }
            }
        }
        // end IF $msg_body
    }
    // if valid email
}
// close while loop
if ($_REQUEST['from_admin'] && strpos($_SERVER['PHP_SELF'], 'admin') !== false) {
    echo "The execution of the 'admin/resumealerts.php' script completed. You may check the <a href='email_queue.php'>outgoing mail queue</a>";
    $DO_SEND = "YES";
Пример #26
0
 function save_config()
 {
     $sql = "REPLACE INTO jb_config (`key`, val) VALUES ('_2CO_SID', '" . $_REQUEST['_2co_sid'] . "')";
     JB_mysql_query($sql) or die(mysql_error() . $sql);
     //$sql = "REPLACE INTO jb_config (`key`, val, descr) VALUES ('_2CO_PRODUCT_ID', '1', '# Your 2CO seller ID number.')";
     //JB_mysql_query($sql);
     $sql = "REPLACE INTO jb_config (`key`, val) VALUES ('_2CO_DEMO', '" . jb_escape_sql($_REQUEST['_2co_demo']) . "')";
     JB_mysql_query($sql);
     $sql = "REPLACE INTO jb_config (`key`, val) VALUES ('_2CO_SECRET_WORD', '" . jb_escape_sql($_REQUEST['_2co_secret_word']) . "')";
     JB_mysql_query($sql);
     $sql = "REPLACE INTO jb_config (`key`, val) VALUES ('_2CO_PAYMENT_ROUTINE', '" . jb_escape_sql($_REQUEST['_2co_payment_routine']) . "')";
     JB_mysql_query($sql);
     $sql = "REPLACE INTO jb_config (`key`, val) VALUES ('_2CO_X_RECEIPT_LINK_URL', '" . jb_escape_sql($_REQUEST['_2co_x_receipt_link_url']) . "')";
     JB_mysql_query($sql);
     $sql = "REPLACE INTO jb_config (`key`, val) VALUES ('_2CO_CANDIDATE_X_RECEIPT_LINK_URL', '" . jb_escape_sql($_REQUEST['_2co_candidate_x_receipt_link_url']) . "')";
     JB_mysql_query($sql);
 }
Пример #27
0
 $ALM->list_cell_open();
 echo JB_get_formatted_date(JB_get_local_time($row['app_date']));
 $ALM->list_cell_close();
 $ALM->list_cell_open();
 echo $ALM->get_open_link('apps.php?post_id=' . $row['post_id'], $extra_attr);
 echo JB_escape_html($row['data1']);
 echo $ALM->get_close_link();
 $ALM->list_cell_close();
 $ALM->list_cell_open();
 $sql2 = "SELECT * FROM users where ID='" . jb_escape_sql($row['user_id']) . "'";
 $result2 = JB_mysql_query($sql2) or die(mysql_error());
 $candidate_row = mysql_fetch_array($result2);
 $sql3 = "SELECT * FROM resumes_table where user_id='" . jb_escape_sql($row['user_id']) . "'";
 $result3 = JB_mysql_query($sql3) or die(mysql_error());
 $resume_row = mysql_fetch_array($result3);
 $sql4 = "SELECT * FROM posts_table where post_id='" . jb_escape_sql($row['post_id']) . "'";
 $result4 = JB_mysql_query($sql4) or die(mysql_error());
 $post_row = mysql_fetch_array($result4);
 $candidate_row['FormattedName'] = jb_escape_html(jb_get_formatted_name($candidate_row['FirstName'], $candidate_row['LastName']));
 $candidate_row['user_id'] = $candidate_row['ID'];
 // 'anon' If Y, then resume is anonumous and fields are restricted.
 // Here use $PForm to process the field restrictions
 $PForm->set_value('anon', $resume_row['anon']);
 if ($resume_row['anon'] == 'Y') {
     if (JB_ONLINE_APP_REVEAL_PREMIUM == 'YES' && $post_row['post_mode'] == 'premium') {
         $PForm->set_value('anon', 'N');
         // can show anonymous fields
     }
     if (JB_ONLINE_APP_REVEAL_STD == 'YES' && $post_row['post_mode'] != 'premium') {
         $PForm->set_value('anon', 'N');
         // can show anonymous fields
Пример #28
0
function JB_format_currency($amount, $cur_code)
{
    global $cached_code;
    global $cached_res;
    if (func_num_args() > 2) {
        $show_code = func_get_arg(2);
    }
    $sql = "SELECT * FROM currencies WHERE code='" . jb_escape_sql($cur_code) . "' ";
    $result = JB_mysql_query($sql) or die(mysql_error());
    $row = mysql_fetch_array($result, MYSQL_ASSOC);
    if ($show_code) {
        $show_code = " " . $row['code'];
    }
    $amount = number_format($amount, $row['decimal_places'], $row['decimal_point'], $row['thousands_sep']);
    $amount = $row['sign'] . "" . $amount . $show_code;
    return $amount;
}
Пример #29
0
                JB_update_post_category_count($post_data);
            }
        }
        JB_finalize_post_updates();
        $label['employer_manager_expired_posts'] = str_replace('%COUNT%', $i, $label['employer_manager_expired_posts']);
        $JBMarkup->ok_msg($label["employer_manager_expired_posts"]);
    } else {
        $JBMarkup->error_msg($label["employer_manager_not_selected_exp"]);
    }
}
if (isset($_REQUEST['undo_expire'])) {
    $post_id = (int) $_REQUEST['post_id'];
    $post_data = JB_load_post_data($post_id);
    if ($post_data['user_id'] == $_SESSION['JB_ID']) {
        // is it owned by the person who logged in?
        $sql = "UPDATE posts_table SET expired='N' where post_id='" . jb_escape_sql($post_id) . "' ";
        JB_mysql_query($sql) or $DB_ERROR = mysql_error();
        JB_update_post_category_count($post_data);
    }
    JB_finalize_post_updates();
    $JBMarkup->ok_msg($label['post_unexpire_ok']);
}
jbplug_do_callback('post_manager_action', $A = false);
JB_render_box_top(95, $label['employer_manager_head']);
// set fees flag
if (JB_POSTING_FEE_ENABLED == 'YES' || JB_PREMIUM_POSTING_FEE_ENABLED == 'YES') {
    $_FEES_ENABLED = "YES";
}
###################
JBEmployer::display_credit_status();
JB_render_box_bottom();
Пример #30
0
 function generate_search_sql($_SEARCH_INPUT = null)
 {
     global $label;
     // from the languages file.
     if (!is_array($_SEARCH_INPUT)) {
         $_SEARCH_INPUT = $_REQUEST;
         // get the search input that was posted
     }
     JBPLUG_do_callback('generate_search_sql_before', $where_sql, $this->form_id, $_SEARCH_INPUT);
     if ($where_sql) {
         return $where_sql;
     }
     // $where_sql was generated by a plugin
     if ($_SEARCH_INPUT['action'] == 'search') {
         foreach ($this->tag_to_search as $key => $val) {
             $name = $this->tag_to_search[$key]['field_id'];
             switch ($this->tag_to_search[$key]['field_type']) {
                 case 'IMAGE':
                 case 'FILE':
                 case 'YOUTUBE':
                     if ($_SEARCH_INPUT[$name] != '') {
                         $where_sql .= " AND (`" . $name . "`) != '' ";
                     }
                     break;
                 case 'SELECT':
                     if ($_SEARCH_INPUT[$name] != '') {
                         $where_sql .= "  AND (\t`" . $name . "` = '" . JB_escape_sql($_SEARCH_INPUT[$name]) . "') ";
                     }
                     break;
                 case 'CHECK':
                     $tmp = '';
                     $comma = '';
                     ## process all possible options
                     $sql = "SELECT * from codes where field_id='" . JB_escape_sql($name) . "' ";
                     $code_result = JB_mysql_query($sql) or die(mysql_error());
                     $i = 0;
                     while ($code = mysql_fetch_array($code_result, MYSQL_ASSOC)) {
                         $val = $code['field_id'] . "-" . $code['code'];
                         if ($_SEARCH_INPUT[$val] != '') {
                             if ($i > 0) {
                                 $comma = 'OR';
                             }
                             $tmp .= $comma . " `{$name}` LIKE '%" . JB_escape_sql($code['code']) . "%' ";
                             $i++;
                         }
                     }
                     if ($i > 0) {
                         $where_sql .= "  AND (" . $tmp . ") ";
                     }
                     break;
                 case 'MSELECT':
                     $tmp = '';
                     $comma = '';
                     $selected_codes = array();
                     $selected_codes = $_SEARCH_INPUT[$name];
                     for ($i = 0; $i < sizeof($selected_codes); $i++) {
                         if ($i > 0) {
                             $comma = 'OR';
                         }
                         $tmp .= $comma . " `{$name}` LIKE '%" . JB_escape_sql($selected_codes[$i]) . "%' ";
                     }
                     if ($i > 0) {
                         $where_sql .= "  AND (" . $tmp . ") ";
                     }
                     break;
                 case 'CATEGORY':
                     $where_range = '';
                     $range_or = '';
                     //$_SEARCH_INPUT[$name] can either be an array of numbers & string 'all',
                     // or a scalar string all or scalar number
                     if (!is_array($_SEARCH_INPUT[$name]) && trim($_SEARCH_INPUT[$name]) == '') {
                         break;
                     }
                     // init the $search-set & $cat_ids_str as strings
                     // similar to: JB_search_category_tree_for_posts()
                     $search_set = '';
                     if (is_array($_SEARCH_INPUT[$name])) {
                         // if the category is a multiple select!
                         foreach ($_SEARCH_INPUT[$name] as $key => $val) {
                             if (!is_numeric($val) && $val != 'all') {
                                 // validate
                                 break;
                             }
                         }
                         $cat_ids_str = implode(',', $_SEARCH_INPUT[$name]);
                     } else {
                         $cat_ids_str = (int) $_SEARCH_INPUT[$name];
                     }
                     if (strpos($cat_ids_str, 'all') !== false) {
                         // return all categories
                         break;
                         // no need to filter
                     }
                     $sql = "SELECT search_set FROM categories WHERE category_id IN(" . jb_escape_sql($cat_ids_str) . ") ";
                     $result2 = JB_mysql_query($sql) or die(mysql_error());
                     $search_set = $cat_ids_str;
                     // search_set does not include the current category
                     while ($row2 = mysql_fetch_row($result2)) {
                         $search_set .= ',' . $row2[0];
                     }
                     // optimize the search set: remove duplicates & range it
                     $set = explode(',', $search_set);
                     sort($set, SORT_NUMERIC);
                     $prev = '';
                     // this removes duplicates
                     foreach ($set as $key => $val) {
                         if ($val == $prev) {
                             unset($set[$key]);
                         }
                         $prev = $val;
                     }
                     // sort again because after removing
                     // duplicates the keys were like swiss cheeze
                     sort($set, SORT_NUMERIC);
                     // Now this is the fun part!
                     // The code below summarizes the $set array
                     // which is a list of numbers in to rangers
                     for ($i = 0; $i < sizeof($set); $i++) {
                         $start = $set[$i];
                         // 6
                         //$end = $set[$i];
                         for ($j = $i + 1; $j < sizeof($set); $j++) {
                             // advance the array index $j if the sequnce
                             // is +1
                             if ($set[$j - 1] != $set[$j] - 1) {
                                 // is it in sequence
                                 $end = $set[$j - 1];
                                 break;
                             }
                             $i++;
                             $end = $set[$i];
                         }
                         if ($end == '') {
                             $end = $set[$i];
                         }
                         if ($start != $end && $end != '') {
                             $where_range .= " {$range_or}  ((`" . $name . "` >= {$start}) AND (`" . $name . "` <= {$end})) ";
                         } elseif ($start != '') {
                             $where_range .= " {$range_or}  (`" . $name . "` = {$start} ) ";
                         }
                         $start = '';
                         $end = '';
                         $range_or = "OR";
                     }
                     $where_sql .= " AND ({$where_range}) ";
                     break;
                 case 'SKILL_MATRIX':
                     if (trim($_SEARCH_INPUT[$name . 'name']) != '') {
                         if (!is_numeric($_SEARCH_INPUT[$name . 'rating'])) {
                             $_SEARCH_INPUT[$name . 'rating'] = '0';
                         }
                         if (!is_numeric($_SEARCH_INPUT[$name . 'years'])) {
                             $_SEARCH_INPUT[$name . 'years'] = '0';
                         }
                         $where_sql .= " AND t2.name LIKE '" . JB_escape_sql(trim($_SEARCH_INPUT[$name . 'name'])) . "' AND t2.years >= " . JB_escape_sql($_SEARCH_INPUT[$name . 'years']) . " AND t2.rating >= " . JB_escape_sql($_SEARCH_INPUT[$name . 'rating']) . " ";
                     }
                     break;
                 case 'DATE':
                     $day = $_REQUEST[$name . "d"];
                     $month = $_REQUEST[$name . "m"];
                     $year = $_REQUEST[$name . "y"];
                     if ($year != '' && $month != '' && $day != '') {
                         // convert to ISO format
                         $value = "{$year}-{$month}-{$day}";
                         $where_sql .= " AND (`{$name}` >= '" . JB_escape_sql($value) . "') ";
                     }
                     break;
                 case 'DATE_CAL':
                     $value = $_SEARCH_INPUT[$name];
                     if ($value != '') {
                         // convert to ISO format before putting it through a search
                         $value = JB_SCWDate_to_ISODate($value);
                         $where_sql .= " AND (`{$name}` >= '" . JB_escape_sql($value) . " 00:00:00') ";
                     }
                     break;
                 case 'TIME':
                     $value = $_SEARCH_INPUT[$name];
                     $time = strtotime($value);
                     // gmt
                     $time = $time - 3600 * JB_GMT_DIF;
                     $later_time = $time + 3600 * 24;
                     // 24 hours later
                     $where_sql .= " AND ( \n\t\t\t\t\t\t\t\t\t\t\t\t(\n\t\t\t\t\t\t\t\t\t\t\t\t\t`{$name}` > '" . gmdate("Y-m-d H:i:s", $time) . "'\n\t\t\t\t\t\t\t\t\t\t\t\t) \n\t\t\t\t\t\t\t\t\t\t\t\tAND\n\t\t\t\t\t\t\t\t\t\t\t\t(\n\t\t\t\t\t\t\t\t\t\t\t\t\t`{$name}` < '" . gmdate("Y-m-d H:i:s", $later_time) . "'\n\t\t\t\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\t\t\t)\t\t\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\t\t\t ";
                     break;
                 default:
                     $custom_sql = '';
                     $value = $_SEARCH_INPUT[$name];
                     JBPLUG_do_callback('generate_search_sql', $custom_sql, $this->tag_to_search[$key], $value);
                     if ($custom_sql != '') {
                         $where_sql .= $custom_sql;
                     } else {
                         if ($value != '') {
                             $list = preg_split("/[\\s,]+/", $value);
                             for ($i = 1; $i < sizeof($list); $i++) {
                                 $or .= " AND (`{$name}` like '%" . JB_escape_sql($list[$i]) . "%')  ";
                             }
                             $where_sql .= " AND ((`{$name}` like '%" . JB_escape_sql($list[0]) . "%')  {$or})";
                         }
                     }
                     break;
             }
             // end switch
         }
         // end foreach
     }
     // end serach
     JBPLUG_do_callback('generate_search_sql_after', $where_sql, $this->form_id, $_SEARCH_INPUT);
     return $where_sql;
 }