Esempio n. 1
0
 function delete_saved_resumes($user_id, $resume_ids)
 {
     $user_id = (int) $user_id;
     if (is_array($resume_ids) && sizeof($resume_ids) > 0) {
         foreach ($resume_ids as $resume_id) {
             $resume_id = (int) $resume_id;
             $sql = "DELETE FROM `saved_resumes` WHERE resume_id='" . jb_escape_sql($resume_id) . "' AND user_id='" . jb_escape_sql($user_id) . "' ";
             jb_mysql_query($sql);
         }
         return true;
     }
     return false;
 }
Esempio n. 2
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);
    }
}
Esempio n. 3
0
function jb_parse_csv($lines, $table_name = '')
{
    //$delimiter = empty($options['delimiter']) ? "," : $options['delimiter'];
    //$to_object = empty($options['to_object']) ? false : true;
    $delimiter = ",";
    $to_object = false;
    $expr = "/,(?=(?:[^\"]*\"[^\"]*\")*(?![^\"]*\"))/";
    // added
    $lines = explode("\n", $lines);
    $cols = array_shift($lines);
    $field_names = explode($delimiter, $cols);
    foreach ($lines as $line) {
        // Skip the empty line
        if (empty($line)) {
            continue;
        }
        $fields = preg_split($expr, trim($line));
        // added
        $fields = preg_replace("/^\"(.*)\"\$/", "\$1", $fields);
        //added
        //$fields = explode($delimiter, $line);
        $_res = $to_object ? new stdClass() : array();
        foreach ($field_names as $key => $f) {
            $f = trim($f);
            $key = trim($key);
            if (preg_match('#^".+"$#', $fields[$key])) {
                // if string is quoted
                $fields[$key] = trim($fields[$key], '"');
            }
            $fields[$key] = str_replace('""', '"', $fields[$key]);
            // escaped quotes
            $_res[$f] = $fields[$key];
        }
        $res[] = $_res;
    }
    if ($table_name != '') {
        // check that the columns correspond to the database
        $sql = "SELECT {$cols} FROM {$table_name} limit 1 ";
        $result = jb_mysql_query($sql) or $res = false;
    }
    return $res;
}
Esempio n. 4
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);
        }
    }
}
Esempio n. 5
0
    // sort descending by default
}
if ($_REQUEST['order_by'] == '' || !JB_is_field_valid($_REQUEST['order_by'], 5)) {
    // by default, order by the post_date
    $order = " `SignupDate` ";
} else {
    $order = " `" . jb_escape_sql($_REQUEST['order_by']) . "` ";
}
$_REQUEST['offset'] = (int) $_REQUEST['offset'];
if ($_REQUEST['offset'] < 0) {
    $_REQUEST['offset'] = abs($_REQUEST['offset']);
}
$records_per_page = 20;
$sql = "select SQL_CALC_FOUND_ROWS * FROM `users` WHERE 1=1 " . $where_sql . " ORDER BY {$order} " . jb_escape_sql($ord) . "  LIMIT " . jb_escape_sql($_REQUEST['offset']) . ", " . jb_escape_html($records_per_page) . "";
$result = JB_mysql_query($sql) or die(mysql_error());
$row = mysql_fetch_row(jb_mysql_query("SELECT FOUND_ROWS()"));
$count = $row[0];
if ($_REQUEST['action'] == 'search') {
    $q_string = JB_generate_candidate_q_string();
}
if ($count > 0) {
    // calculate number of pages & current page
    $pages = ceil($count / $records_per_page);
    $cur_page = $_REQUEST['offset'] / $records_per_page;
    $cur_page++;
    ?>

<center><b><?php 
    echo mysql_num_rows($result);
    ?>
 Candidate's Accounts Returned (<?php 
Esempio n. 6
0
function jb_get_variable($var)
{
    $sql = "SELECT * from jb_variables WHERE `key`='" . jb_escape_sql($var) . "' ";
    $result = jb_mysql_query($sql);
    if ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
        return $row['val'];
    }
}
Esempio n. 7
0
function JB_update_post_category_counters($leaf_cat_id, $field_id, $search_set = '')
{
    static $level;
    $level++;
    $row = jb_get_category($leaf_cat_id);
    if (strlen(trim($search_set)) == 0) {
        $sql = "SELECT search_set FROM categories WHERE  category_id='" . jb_escape_sql($leaf_cat_id) . "' AND search_set != '' ";
        $result = jb_mysql_query($sql);
        if (mysql_num_rows($result) > 0) {
            $search_set = array_pop(mysql_fetch_row($result));
        }
    }
    if (strlen($search_set) > 0) {
        $search_set .= ',' . $leaf_cat_id;
    } else {
        $search_set = $leaf_cat_id;
    }
    $search_set_sql = JB_get_optimized_search_set_query($search_set, $field_id);
    $sql = "SELECT count(*) FROM posts_table WHERE  approved='Y' AND expired='N' " . $search_set_sql . " ";
    $result = JB_mysql_query($sql) or die(mysql_error() . $sql);
    $row = mysql_fetch_row($result);
    $count = $row[0];
    $sql = "UPDATE categories SET obj_count='{$count}' WHERE category_id='" . jb_escape_sql($leaf_cat_id) . "' AND form_id=1 ";
    JB_mysql_query($sql) or die(mysql_error() . $sql);
    // go down the tree to the root
    $sql = "SELECT category_id, parent_category_id, search_set FROM categories WHERE category_id='" . jb_escape_sql($leaf_cat_id) . "' ";
    $result = JB_mysql_query($sql) or die(mysql_error() . $sql);
    if ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
        if (mysql_num_rows($result) > 0) {
            $sql = "SELECT category_id, search_set from categories WHERE category_id='" . jb_escape_sql($row['parent_category_id']) . "' ";
            $result = JB_mysql_query($sql) or die(mysql_error());
            if (mysql_num_rows($result) > 0) {
                $row = mysql_fetch_array($result, MYSQL_ASSOC);
                JB_update_post_category_counters($row['category_id'], $field_id, $row['search_set']);
            }
        }
    }
    $level--;
}
 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;
 }
Esempio n. 9
0
function JB_expire_short_URLs()
{
    // expire urls which were not accessed within the last 90 days
    $now = gmdate("Y-m-d H:i:s");
    $sql = "DELETE FROM short_urls WHERE DATE_SUB('{$now}', INTERVAL 90 DAY) > `date` ";
    jb_mysql_query($sql);
}
Esempio n. 10
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;
}
Esempio n. 11
0
 //$users[$i];
 $from = $your_email;
 // Enter your email adress here
 $msg = "" . $label['taf_msg_to'] . " {$to_name} <{$to_email}>\r\n" . $label['taf_msg_from'] . " {$your_name} <{$your_email}>\r\n\r\n" . str_replace('%SITE_NAME%', JB_SITE_NAME, $label['taf_msg_line']) . "\r\n\r\n" . $label['taf_msg_link'] . "\r\n" . "{$url}\r\n\r\n" . $label['taf_msg_comments'] . "\r\n" . $message;
 // to discourage spam, include IP of sender:
 $ip = $_SERVER['REMOTE_ADDR'];
 if (!empty($_SERVER['X-FORWARDED-FOR'])) {
     $ip = $_SERVER['REMOTE_ADDR'];
 }
 $msg .= "---\nX-Sender-IP: " . $ip;
 echo $label['taf_sending_email'];
 // anti-spam, we check the email queue, find the last 10 emails in the last 5 minutes
 // then we silently discard if matches our basic checks
 $discard = false;
 $sql = "SELECT * FROM `mail_queue` WHERE `template_id` =46 AND mail_date > DATE_SUB( NOW( ) , INTERVAL 5 MINUTE ) LIMIT 10 ";
 $result = jb_mysql_query($sql);
 if (mysql_num_rows($result) > 0) {
     $score = 0;
     $max_score = 40;
     // adjust this when adjusting the score rules below
     while ($row = mysql_fetch_array($result)) {
         if ($row['subject'] === $subject) {
             // repeat subject
             $score += 2;
         }
         if (strpos($row['message'], $your_name) !== false) {
             // re-used name
             $score++;
         }
         if (strpos($row['message'], $your_email) !== false) {
             // re-used email
Esempio n. 12
0
function JB_schema_change_table($form_id, $field_id, $new_field_type, $field_label)
{
    $form_id = (int) $form_id;
    $field_id = (int) $field_id;
    $table_name = JB_get_table_name_by_id($form_id);
    preg_match('#\\d#', mysql_get_server_info(), $m);
    if ($m[0] > 5 && strlen($field_label) > 0) {
        // mysql v5 or higher?
        $comment = "COMMENT '" . addslashes($field_label) . "'";
    }
    // get the old definition. Delete auxillary fields
    $sql = "SELECT * FROM `form_fields` WHERE `form_id`='" . JB_escape_sql($form_id) . "' AND `field_id`='" . JB_escape_sql($field_id) . "' ";
    $result = jb_mysql_query($sql);
    $row = mysql_fetch_array($result);
    $old_def = JB_get_definition($row['field_type']);
    // $old_field_type = $row['field_type']
    if (is_array($old_def)) {
        // drop auxillary fields
        foreach ($old_def as $postfix => $data_type) {
            $sql = "ALTER TABLE `{$table_name}` DROP `" . $field_id . "_" . $postfix . "` ";
            JB_mysql_query($sql);
        }
    }
    //
    $new_def = JB_get_definition($new_field_type);
    if (is_array($new_def)) {
        // create auxillary fields
        foreach ($new_def as $postfix => $data_type) {
            $sql = "ALTER TABLE `{$table_name}` ADD `" . $field_id . "_" . $postfix . "` " . $data_type;
            JB_mysql_query($sql);
        }
    }
    $sql = "ALTER TABLE " . $table_name . " CHANGE `" . JB_escape_sql($field_id) . "` `" . JB_escape_sql($field_id) . "` " . JB_get_definition($new_field_type) . " {$comment} ";
    JBPLUG_do_callback('schema_change_table', $sql, $form_id, $field_id, $new_field_type, $field_label);
    //plugins can alter the sql
    JB_mysql_query($sql);
    JB_cache_del_keys_for_form($form_id);
    return true;
}
Esempio n. 13
0
function multiple_query($q)
{
    global $jb_mysql_link;
    $queries = query_parser($q);
    $n = count($queries);
    $results = array();
    for ($i = 0; $i < $n; $i++) {
        $results[$i] = array(jb_mysql_query($queries[$i]), mysql_errno(), mysql_error(), $queries[$i]);
    }
    return $results;
}
Esempio n. 14
0
function JB_list_profiles($admin = false, $order, $offset)
{
    global $label;
    // languages array
    $records_per_page = 40;
    // process search result
    if ($_REQUEST['action'] == 'search') {
        $q_string = JB_generate_q_string(3);
        $where_sql = JB_generate_search_sql(3);
    }
    // JB_DATE_FORMAT(`adate`, '%d-%b-%Y') AS formatted_date
    $order = $_REQUEST['order_by'];
    if ($_REQUEST['ord'] == 'asc') {
        $ord = 'ASC';
    } elseif ($_REQUEST['ord'] == 'desc') {
        $ord = 'DESC';
    } else {
        $ord = 'DESC';
        // sort descending by default
    }
    if ($order == '' || !JB_is_field_valid($order, 3)) {
        // by default, order by the post_date
        $order = " `profile_date` ";
    } else {
        $order = " `" . jb_escape_sql($order) . "` ";
    }
    $offset = (int) $_REQUEST['offset'];
    if ($offset < 0) {
        $offset = abs($offset);
    }
    $sql = "Select SQL_CALC_FOUND_ROWS *, DATE_FORMAT(`profile_date`, '%d-%b-%Y') AS formatted_profile_date FROM `profiles_table` WHERE 1=1  {$where_sql} ORDER BY {$order} {$ord} LIMIT {$offset}, {$records_per_page}";
    //echo "[".$sql."]";
    $result = JB_mysql_query($sql) or die(mysql_error());
    ############
    # get the count
    /*
    	$count = mysql_num_rows($result);
    if ($count > $records_per_page) {
    	mysql_data_seek($result, $offset);
    }
    */
    $row = mysql_fetch_row(jb_mysql_query("SELECT FOUND_ROWS()"));
    $count = $row[0];
    if ($count > 0) {
        if ($pages == 1) {
        } else {
            $pages = ceil($count / $records_per_page);
            $cur_page = $_REQUEST['offset'] / $records_per_page;
            $cur_page++;
            echo '<p class="nav_page_links">';
            //echo "Page $cur_page of $pages - ";
            $label["navigation_page"] = str_replace("%CUR_PAGE%", $cur_page, $label["navigation_page"]);
            $label["navigation_page"] = str_replace("%PAGES%", $pages, $label["navigation_page"]);
            echo "<span > " . $label["navigation_page"] . "</span> ";
            $nav = JB_nav_pages_struct($result, $q_string, $count, $records_per_page);
            $LINKS = 10;
            JB_render_nav_pages($nav, $LINKS, $q_string, $show_emp, $cat);
            echo "</p>";
        }
        ?>
		<table style="margin: 0 auto; width:100%; border:0px; background-color:d9d9d9; " cellspacing="1" cellpadding="5" >
		<tr bgcolor="#EAEAEA">
		<?php 
        if ($admin == true) {
            echo '<td>&nbsp;</td>';
            JBPLUG_do_callback('profile_list_head_admin_action', $A = false);
        }
        JBPLUG_do_callback('profile_list_head_user_action', $A = false);
        JB_echo_list_head_data(3, $admin);
        ?>
		
		</tr>

		<?php 
        $i = 0;
        $ProfileForm =& JB_get_DynamicFormObject(3);
        while (($row = mysql_fetch_array($result, MYSQL_ASSOC)) && $i < $records_per_page) {
            $ProfileForm->set_values($row);
            $i++;
            ?>
			  <tr bgcolor="<?php 
            echo JB_LIST_BG_COLOR;
            ?>
" onmouseover="old_bg=this.getAttribute('bgcolor');this.setAttribute('bgcolor', '<?php 
            echo JB_LIST_HOVER_COLOR;
            ?>
', 0);" onmouseout="this.setAttribute('bgcolor', old_bg, 0);">
	
			  <?php 
            if ($admin == true) {
                echo '<td>';
                ?>
			 <input style="font-size: 8pt" type="button" value="Delete" onClick="if (!confirmLink(this, 'Delete, are you sure?')) {return false;} window.location='<?php 
                echo htmlentities($_SERVER['PHP_SELF']);
                ?>
?action=delete&amp;profile_id=<?php 
                echo $row['profile_id'];
                ?>
'"><br>
				<input type="button" style="font-size: 8pt" value="Edit" onClick="window.location='<?php 
                echo htmlentities($_SERVER['PHP_SELF']);
                ?>
?action=edit&amp;profile_id=<?php 
                echo $row['profile_id'];
                ?>
'">

				<?php 
                echo '</td>';
                JBPLUG_do_callback('profile_list_data_admin_action', $A = false);
            }
            JBPLUG_do_callback('profile_list_data_user_action', $A = false);
            JB_echo_proile_list_data($admin);
            ?>


		</tr>
		  <?php 
            //$data[file_photo] = '';
            // $new_name='';
        }
        echo "</table>";
    } else {
        echo "<p class='profiles_no_result'>" . $label["profiles_not_found"] . "</p>";
    }
}
Esempio n. 15
0
function showSubcat($c)
{
    //global $connection;
    global $JobsFiller_default_l;
    global $JobsFiller_default_k;
    $query = " SELECT *, categories.category_id as CID, seo_keys FROM categories LEFT JOIN JobsFiller_keywords ON categories.category_id = JobsFiller_keywords.category_id  WHERE parent_category_id = '{$c}' and form_id=1 ORDER BY list_order, category_name ASC ";
    $result = jb_mysql_query($query) or die(mysql_error());
    //echo "<b>cateid:".$row2[1]."  $query </b>";
    if (mysql_num_rows($result) == 0) {
        $query = " SELECT kw, loc, categories.category_id as CID, seo_keys FROM categories LEFT JOIN JobsFiller_keywords ON categories.category_id = JobsFiller_keywords.category_id  WHERE categories.category_id = '{$c}' and form_id=1 ";
        $result = jb_mysql_query($query) or die(mysql_error());
        $row = mysql_fetch_array($result, MYSQL_ASSOC);
        if (trim($row['loc']) == '') {
            $row['loc'] = $JobsFiller_default_l;
        }
        if (trim($row['kw']) == '') {
            $row['kw'] = $row['seo_keys'];
        }
        if (trim($row['kw']) == '') {
            // still empty?
            $row['kw'] = JB_getCatName($row['CID']);
            //$JobsFiller_default_k;
        }
        ?>
	What: <input size='36' type="text" value="<?php 
        echo jb_escape_html($row['kw']);
        ?>
" name='kw_<?php 
        echo $row['CID'];
        ?>
'>
	Where: <input size='36' type="text" value="<?php 
        echo jb_escape_html($row['loc']);
        ?>
" name='loc_<?php 
        echo $row['CID'];
        ?>
'><br>
	<?php 
    } else {
        $x = 0;
        echo "<br><div style='margin-left: 20px;'>";
        while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
            $x++;
            if ($x > SHOW_SUBCATS) {
                break;
            }
            //if  ($row['allow_records']=='N') echo "<b>&#8224;</b>";
            echo "<A HREF=" . $_SERVER['PHP_SELF'] . "?cat=" . $row['CID'] . "><font color=#0000FF>" . jb_escape_html($row['category_name']) . "</font></A> ";
            //;echo "<small>(ID: ". ($row[0]).")</small>";
            if (trim($row['loc']) == '') {
                $row['loc'] = $JobsFiller_default_l;
            }
            if (trim($row['kw']) == '') {
                $row['kw'] = $row['seo_keys'];
            }
            if (trim($row['kw']) == '') {
                // still empty?
                //$row['kw'] = $JobsFiller_default_k;
                $row['kw'] = JB_getCatName($row['CID']);
            }
            ?>
		What: <input size='35' type="text" value="<?php 
            echo jb_escape_html($row['kw']);
            ?>
" name='kw_<?php 
            echo $row['CID'];
            ?>
'>
		Where: <input size='35' type="text" value="<?php 
            echo jb_escape_html($row['loc']);
            ?>
" name='loc_<?php 
            echo $row['CID'];
            ?>
'>
		<br>

		<?php 
            // does this category have sub-categories?
            $query = " SELECT * FROM categories LEFT JOIN JobsFiller_keywords ON categories.category_id = JobsFiller_keywords.category_id  WHERE parent_category_id = '" . $row['CID'] . "' ORDER BY list_order, category_name ASC ";
            $result2 = jb_mysql_query($query);
            if (mysql_num_rows($result2) > 0) {
                echo "<br>";
                $row2 = mysql_fetch_row($result2);
                ?>
		  <table style="margin-left: 15px;" cellspacing="1" border="0" width="100%">

		<?php 
                showAllCat($row['CID'], 1);
                ?>

		</table>
		<?php 
            }
        }
    }
    echo "</div>";
}
Esempio n. 16
0
function JB_generate_category_option_list($category_id, $selected, &$options_arr, &$Markup)
{
    global $mode;
    static $depth;
    static $path;
    if (is_null($Markup)) {
        // use JBDynamicFormMarkup.php template class
        // (otherwise it will use the one passed as $Markup)
        $Markup =& JB_get_DynamicFormMarkupObject();
    }
    $depth++;
    if ($path === null) {
        $path = array();
    }
    // Not cached. Compute options using this recursive function
    if ($_SESSION['LANG'] == '') {
        $sql = "SELECT * FROM categories WHERE parent_category_id='" . JB_escape_sql($category_id) . "'  ORDER by list_order, category_name ";
    } else {
        $sql = "SELECT *, t2.category_name as NAME FROM categories as t1, cat_name_translations as t2 WHERE t1.category_id=t2.category_id AND t1.parent_category_id='" . JB_escape_sql($category_id) . "' AND t2.lang='" . JB_escape_sql($_SESSION['LANG']) . "'  ORDER by t1.list_order, t2.category_name  ";
    }
    $result = jb_mysql_query($sql);
    if (mysql_num_rows($result) > 0) {
        while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
            if ($mode == 'edit') {
                $row['search_set'] = $row['category_id'];
            }
            // Generate The option data
            $name = '';
            if (JB_INDENT_CATEGORY_LIST == 'YES' && $depth > 1) {
                for ($i = 0; $i < $depth; $i++) {
                    $name .= $Markup->get_category_option_space();
                    //'&nbsp;&nbsp;';
                }
                $name .= $Markup->get_category_option_branch();
                //'|--&nbsp;';
            } else {
                foreach ($path as $val) {
                    $gt_html_ent = $Markup->get_category_option_arrow();
                    //' -&gt; ';
                    $name = $name . $val . $gt_html_ent;
                }
            }
            $name = $name . $row['NAME'];
            // changed so that value is the category id
            // this is because search_set became too long
            //$options_arr['value'][] = $row['search_set'];
            $options_arr['value'][] = $row['category_id'];
            // set the name
            $options_arr['a'][] = $row['allow_records'];
            if ($row['allow_records'] == 'Y' || $mode != 'edit') {
                $options_arr['name'][] = $name;
            } elseif ($mode == 'edit') {
                $options_arr['name'][] = '[' . $name . ' ' . $label['cat_option_choose_another'] . ']';
            }
            $options_arr['depth'][] = $depth;
            if ($row['has_child'] == 'Y') {
                $path[] = $row['NAME'];
                JB_generate_category_option_list($row['category_id'], $selected, $options_arr, $obj = null);
                $cat_options[$_SESSION['LANG']] = $options_arr;
            }
        }
    }
    array_pop($path);
    $depth--;
}
Esempio n. 17
0
function init_stat($report, &$stats)
{
    #A, C, R, E, P
    $result = jb_mysql_query(get_monthly_stat_query($report));
    while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
        $stats[$row['MYDATE']][$report] = $row['COUNT'];
    }
}
Esempio n. 18
0
function JB_send_request_granted_email($candidate_id, $employer_id)
{
    $user_id = (int) $candidate_id;
    $employer_id = (int) $employer_id;
    $sql = "SELECT FirstName, LastName, Password FROM users where `ID`='" . jb_escape_sql($candidate_id) . "' ";
    $result = jb_mysql_query($sql);
    $candidate_row = mysql_fetch_array($result, MYSQL_ASSOC);
    $sql = "SELECT FirstName, LastName, Email FROM employers where `ID`='" . jb_escape_sql($employer_id) . "' ";
    $result = jb_mysql_query($sql);
    $employer_row = mysql_fetch_array($result, MYSQL_ASSOC);
    // get the resume db link
    $sql = "SELECT resume_id FROM resumes_table WHERE user_id='" . jb_escape_sql($candidate_id) . "' AND `status`='ACT' ";
    $result = JB_mysql_query($sql) or die(mysql_error());
    if (mysql_num_rows($result) > 0) {
        $resume_row = mysql_fetch_array($result, MYSQL_ASSOC);
        $val = substr(md5($resume_row['resume_id'] . $candidate_row['Password'] . $candidate_id), 0, 10);
        $resume_db_link = JB_BASE_HTTP_PATH . JB_EMPLOYER_FOLDER . "search.php?resume_id=" . urlencode($resume_row['resume_id']) . "&id=" . urlencode($candidate_id) . "&key={$val}";
    } else {
        return false;
        // resume does not exist anymore...
    }
    $result = JB_get_email_template(44, $_SESSION['LANG']);
    $e_row = mysql_fetch_array($result, MYSQL_ASSOC);
    $text_message = $e_row['EmailText'];
    $from = $e_row['EmailFromAddress'];
    $from_name = $e_row['EmailFromName'];
    $subject = $e_row['EmailSubject'];
    $candidate_name = JB_get_formatted_name($candidate_row['FirstName'], $candidate_row['LastName']);
    $employer_name = JB_get_formatted_name($employer_row['FirstName'], $employer_row['LastName']);
    $to_name = $employer_name;
    $to_address = $employer_row['Email'];
    $text_message = str_replace("%SITE_NAME%", JB_SITE_NAME, $text_message);
    $text_message = str_replace("%SITE_URL%", JB_BASE_HTTP_PATH, $text_message);
    $text_message = str_replace("%RESUME_DB_LINK%", $resume_db_link, $text_message);
    $text_message = str_replace("%CAN_NAME%", $candidate_name, $text_message);
    $text_message = str_replace("%EMP_NAME%", $employer_name, $text_message);
    $subject = str_replace("%CAN_NAME%", $candidate_name, $subject);
    $subject = str_replace("%SITE_NAME%", JB_SITE_NAME, $subject);
    JB_queue_mail($to_address, $to_name, $e_row['EmailFromAddress'], $e_row['EmailFromName'], $subject, $text_message, $html_message, $e_row['EmailID']);
}
Esempio n. 19
0
if ($q_user_id != '') {
    $where_sql .= " {$and_sql} `user_id`='{$q_user_id}' AND `user_type`='{$q_user_type}' ";
    $and_sql = 'AND';
}
if ($and_sql) {
    $where_sql = " WHERE " . $where_sql;
}
$records_per_page = 40;
$offset = (int) $_REQUEST['offset'];
// this query will use the mail_date index.
$sql = "SELECT * FROM mail_queue  {$where_sql} order by mail_date DESC LIMIT {$offset}, {$records_per_page}  ";
$result = JB_mysql_query($sql) or die(mysql_error());
//$count = mysql_num_rows($result);
//$row = mysql_fetch_row(jb_mysql_query("SELECT FOUND_ROWS()"));
//$count = $row[0];
$row = mysql_fetch_row(jb_mysql_query("SELECT count(*) FROM mail_queue {$where_sql} "));
//$row[0];
$count = $row[0];
//if ($count > $records_per_page) {
//	mysql_data_seek($result, $_REQUEST['offset']);
//}
if ($count > $records_per_page) {
    $pages = ceil($count / $records_per_page);
    $cur_page = $_REQUEST['offset'] / $records_per_page;
    $cur_page++;
    echo "<center>";
    ?>
	<center><b><?php 
    echo $count;
    ?>
 Emails returned (<?php 
Esempio n. 20
0
function JB_get_employer_lang($user_id)
{
    $sql = "SELECT lang form employers WHERE user_id='" . jb_escape_sql($user_id) . "' ";
    $result = jb_mysql_query($sql);
    $row = mysql_fetch_array($result, MYSQL_ASSOC);
    return $row['lang'];
}
Esempio n. 21
0
 function enable()
 {
     if (!$this->is_enabled()) {
         parent::enable($this->plugin_name);
         if (!$this->does_field_exist('CareerJet_keywords', 'category_id')) {
             $sql = "CREATE TABLE `CareerJet_keywords` (\n\t\t\t\t\t  `category_id` int(11) NOT NULL default '0',\n\t\t\t\t\t  `kw` varchar(255) NOT NULL default '',\n\t\t\t\t\t  `loc` varchar(255) NOT NULL default '',  \n\t\t\t\t\t  PRIMARY KEY  (`category_id`)\n\t\t\t\t\t) ENGINE=MyISAM";
             jb_mysql_query($sql);
         }
     }
 }
Esempio n. 22
0
<p>

<?php 
$offset = (int) $_REQUEST['offset'];
$records_per_page = 20;
if ($post_id) {
    $where_sql = "employer_id='" . jb_escape_sql($_SESSION['JB_ID']) . "' AND post_id='" . jb_escape_sql($post_id) . "'";
    $sql = "SELECT * FROM applications WHERE {$where_sql} ORDER BY `app_date` DESC LIMIT {$offset}, {$records_per_page}";
} else {
    $where_sql = "employer_id='" . jb_escape_sql($_SESSION['JB_ID']) . "'";
    // order by posts and date
    $sql = "SELECT * FROM applications  WHERE {$where_sql} ORDER BY post_id DESC, `app_date` DESC LIMIT {$offset}, {$records_per_page}";
}
JBPLUG_do_callback('employer_apps_sql', $sql);
$result = JB_mysql_query($sql) or die(mysql_error());
$count = array_pop(mysql_fetch_row(jb_mysql_query("SELECT count(*) FROM applications WHERE {$where_sql} ")));
if (mysql_num_rows($result) > 0) {
    if ($post_id) {
        $data = $PForm->load($post_id);
        $PLM =& JB_get_PostListMarkupObject();
        $PLM->set_values($data);
        $TITLE = $PForm->get_template_value('TITLE');
        $DATE = JB_get_formatted_date($PForm->get_template_value('DATE'));
        if ($count == 1) {
            $str = $label['emp_app_post_title_singular'];
        } else {
            $str = $label['emp_app_post_title_plural'];
        }
        $str = str_replace('%TITLE%', '<a href="" ' . $PLM->get_new_window_js() . ' >' . jb_escape_html($TITLE) . '</a>', $str);
        $str = str_replace('%DATE%', jb_escape_html($DATE), $str);
        $str = str_replace('%COUNT%', $count, $str);
Esempio n. 23
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);
    }
}
Esempio n. 24
0
function JB_get_default_lang()
{
    static $default_lang;
    //global $jb_mysql_link;
    if (!isset($default_lang)) {
        $sql = "SELECT lang_code FROM lang WHERE `is_default`='Y' ";
        //$result = JB_mysql_query ($sql) or die (mysql_error());
        $result = jb_mysql_query($sql);
        $row = @mysql_fetch_array($result, MYSQL_ASSOC);
        $default_lang = $row['lang_code'];
        if (!$default_lang) {
            $default_lang = 'EN';
        }
        return $default_lang;
    } else {
        return $default_lang;
    }
}
function JB_free_posting_subscription_exists($type = 'S')
{
    if ($type == 'S') {
        $sql = "SELECT subscription_id FROM subscriptions WHERE can_post='Y' ";
    } else {
        $sql = "SELECT subscription_id FROM subscriptions WHERE can_post_premium='Y' ";
    }
    $result = jb_mysql_query($sql);
    if (mysql_num_rows($result) > 0) {
        return true;
    }
    return false;
}
Esempio n. 26
0
		</td></tr>
		</table>
		</form>
		<?php 
    }
    if ($_REQUEST['purge2'] != '') {
        $now = gmdate("Y-m-d H:i:s");
        $sql = "DELETE from applications where DATE_SUB('{$now}', INTERVAL '" . jb_escape_sql($_REQUEST['purge_days']) . "' DAY) > app_date ";
        $result = JB_mysql_query($sql) or die(mysql_error());
        $JBMarkup->ok_msg(JB_mysql_affected_rows() . " application(s) deleted from the system");
    }
    $offset = (int) $_REQUEST['offset'];
    $records_per_page = 4;
    $sql = "SELECT * FROM applications ORDER BY `app_date` DESC LIMIT {$offset}, {$records_per_page} ";
    $result = JB_mysql_query($sql) or die(mysql_error());
    $count = array_pop(mysql_fetch_row(jb_mysql_query("SELECT count(*) FROM applications ")));
    if (mysql_num_rows($result) > 0) {
        $result = JB_mysql_query($sql) or die(mysql_error());
        $nav = JB_nav_pages_struct($result, $q_string, $count, $records_per_page);
        $LINKS = 10;
        $ALM->nav_pages_start();
        JB_render_nav_pages($nav, $LINKS, $q_string, $show_emp, $cat);
        $ALM->nav_pages_end();
        $row['formatted_date'] = JB_get_formatted_date($row['app_date']);
        $ALM->open_form('form1');
        $ALM->list_start('joblist', 'list');
        $ALM->admin_list_controls();
        $ALM->list_head_open();
        // <tr>
        $ALM->list_head_admin_action('apps');
        $ALM->list_head_cell_open();
Esempio n. 27
0
    function config_form()
    {
        //
        ?>
		<form method="post" action="<?php 
        echo htmlentities($_SERVER['PHP_SELF']);
        ?>
">
		<table border="0" cellpadding="5" cellspacing="2" style="border-style:groove" id="AutoNumber1" width="100%" bgcolor="#FFFFFF">
		
		<tr>
			<td  colspan="2" bgcolor="#e6f2ea">
				<b>Jobs Filler - Configuration</b></td>
			
		</tr>

		<tr>
			<td  width="20%" bgcolor="#e6f2ea">
				<b>API key</b></td>
			<td  bgcolor="#e6f2ea"><input size="20" type="text" name='id' value="<?php 
        echo $this->config['id'];
        ?>
"> (Your api.jamit.com key, get it from http://api.jamit.com)
			</td>
		</tr>
		<!--
		<tr>
			<td  width="20%" bgcolor="#e6f2ea">
				<b>Country</b></td>
			<td  bgcolor="#e6f2ea"><select  name="c" value="<?php 
        echo $this->config['c'];
        ?>
">
			<option value="us" <?php 
        if ($this->config['c'] == "us") {
            echo ' selected ';
        }
        ?>
>US</option>
			<option value="ca" <?php 
        if ($this->config['c'] == "ca") {
            echo ' selected ';
        }
        ?>
>Canada</option>
			<option value="gb" <?php 
        if ($this->config['c'] == "gb") {
            echo ' selected ';
        }
        ?>
>Great Britain</option>
			<option value="de" <?php 
        if ($this->config['c'] == "de") {
            echo ' selected ';
        }
        ?>
>Germany</option>
			<option value="fr" <?php 
        if ($this->config['c'] == "fr") {
            echo ' selected ';
        }
        ?>
>France</option>
			<option value="es" <?php 
        if ($this->config['c'] == "es") {
            echo ' selected ';
        }
        ?>
>Spain</option>
			<option value="in" <?php 
        if ($this->config['c'] == "in") {
            echo ' selected ';
        }
        ?>
>India</option>
			<option value="ie" <?php 
        if ($this->config['c'] == "ie") {
            echo ' selected ';
        }
        ?>
>Ireland</option>
			<option value="nl" <?php 
        if ($this->config['c'] == "nl") {
            echo ' selected ';
        }
        ?>
>Netherlands</option>
			</select>
			</td>
		</tr>
		-->
		<tr>
			<td  width="20%" bgcolor="#e6f2ea">
				<b>Sources</b></td>
			<td  bgcolor="#e6f2ea">

		<?php 
        $this->api_cache_flush(1);
        // flush older than one day
        $params = array('pub' => $this->config['id']);
        $countries = $this->api_call_cached('get_country_list', $params);
        $params = array('pub' => $this->config['id']);
        $sources = $this->api_call_cached('get_source_list', $params);
        $params = array('pub' => $this->config['id']);
        $types = $this->api_call_cached('get_type_list', $params);
        echo '<p><b>Countries:</b> ';
        $pipe = '';
        if ('ALL' == $this->config['cnt']) {
            $sel = ' checked ';
        } else {
            $sel = '';
        }
        echo '<input ' . $sel . 'type="radio" name="cnt" value="ALL"> All, &nbsp;';
        foreach ($countries as $c) {
            //if (in_array($c, $this->config['cnt'])) {
            if ($c == $this->config['cnt']) {
                $sel = ' checked ';
            } else {
                $sel = '';
            }
            //echo $pipe.'<input '.$sel.' type="checkbox" name="cnt[]" value="'.$c.'"> '.$c;
            echo $pipe . '<input ' . $sel . ' type="radio" name="cnt" value="' . $c . '"> ' . $c;
            $pipe = ', &nbsp;';
        }
        echo '</p>';
        echo '<p><b>Sources:</b> ';
        $pipe = '';
        if ('ALL' == $this->config['src']) {
            $sel = ' checked ';
        } else {
            $sel = '';
        }
        echo '<input ' . $sel . 'type="radio" name="src" value="ALL"> All, &nbsp;';
        foreach ($sources as $s) {
            if ($s == $this->config['src']) {
                //if (in_array($s, $this->config['src'])) {
                $sel = ' checked ';
            } else {
                $sel = '';
            }
            //echo $pipe.'<input '.$sel.'type="checkbox" name="src[]" value="'.$s.'"> '.$s;
            echo $pipe . '<input ' . $sel . 'type="radio" name="src" value="' . $s . '"> ' . $s;
            $pipe = ', &nbsp;';
        }
        echo '</p>';
        echo '<p><b>Job Types:</b> ';
        $pipe = '';
        if ('ALL' == $this->config['typ']) {
            $sel = ' checked ';
        } else {
            $sel = '';
        }
        echo '<input ' . $sel . 'type="radio" name="typ" value="ALL"> All, &nbsp;';
        foreach ($types as $c) {
            //if (in_array($c, $this->config['cnt'])) {
            if ($c == $this->config['typ']) {
                $sel = ' checked ';
            } else {
                $sel = '';
            }
            //echo $pipe.'<input '.$sel.' type="checkbox" name="cnt[]" value="'.$c.'"> '.$c;
            echo $pipe . '<input ' . $sel . ' type="radio" name="typ" value="' . $c . '"> ' . $c;
            $pipe = ', &nbsp;';
        }
        echo '</p>';
        ?>
			</td>
		</tr>

				<tr>
			<td  width="20%" bgcolor="#e6f2ea">
				<b>Default Keyword(s)</b></td>
			<td  bgcolor="#e6f2ea"><input size="20" type="text" name='k' value="<?php 
        echo $this->config['k'];
        ?>
"> (By default the terms are AND'ed.)
			</td>
		</tr>
		<tr>
			<td  width="20%" bgcolor="#e6f2ea">
				<b>Default City</b></td>
			<td  bgcolor="#e6f2ea"><input size="20" type="text" name='l' value="<?php 
        echo $this->config['l'];
        ?>
"> (City is optional. e.g. Sydney)
			</td>
		</tr>
		<tr>
			<td  width="20%" bgcolor="#e6f2ea">
				<b>Search Field(s) for Keyword</b></td>
			<td  bgcolor="#e6f2ea">
			<select name="k_tag[]" multiple size="5">
				<!--<option value="">[Select]</option>-->
				<?php 
        echo $this->echo_tt_options($this->config['k_tag']);
        ?>
				</select> (The selected search parameters will be combined and used as the keywords for the search query sent to Indeed. If not selected or no keyword is searched, then it will default to the Main Keyword. Hold down the Ctrl key to select/unselect multiple items)
			</td>
		</tr>
		<tr>
			<td  width="20%" bgcolor="#e6f2ea">
				<b>Search Field(s) for Location</b></td>
			<td  bgcolor="#e6f2ea">
			<select name="l_tag[]" multiple size="5" >
				<!--<option value="">[Select]</option>-->
				<?php 
        echo $this->echo_tt_options($this->config['l_tag']);
        ?>
			</select> (The selected search parameters will be combined and used as the location for the search query sent to Indeed. If not selected or no location is searched, then it will default to the Main Location. Hold down the Ctrl key to select/unselect multiple items)
			</td>
		</tr>
		<td colspan="2" bgcolor="#e6f2ea">

			<table width="100%" border="0" cellSpacing="1" cellPadding="3" bgColor="#d9d9d9"  >

			<tr bgcolor="#e6f2ea">

					<h4>Source to Local field mappings</h4>

					<td width="10%" valign="top">
					<b>Local Fields</b> - Fields your job posting form. Fields marked with * are required.
					</td>

					<td valign="top">
					<b>Source Fields</b> - These fields are the original fields that are coming in from the feed
					</td>

				</tr>
			<?php 
        require_once "../include/posts.inc.php";
        $PForm =& JB_get_DynamicFormObject(1, 'global');
        $params = array('pub' => $this->config['id']);
        $in_fields = $this->api_call('get_field_list', $params);
        sort($in_fields);
        $sql = "SELECT *, t1.field_label AS FLABEL FROM form_field_translations as t1, form_fields as t2 WHERE t2.form_id=1 AND t2.field_id=t1.field_id AND field_type!='BLANK' AND field_type != 'SEPERATOR' AND lang='" . JB_escape_sql($_SESSION['LANG']) . "' order by section asc, field_sort asc  ";
        $result = jb_mysql_query($sql);
        while ($field = mysql_fetch_array($result, MYSQL_ASSOC)) {
            if ($field['template_tag'] == 'EMAIL') {
                continue;
            }
            ?>

				

				<tr bgcolor="e6f2ea">

					<td width="10%" nowrap valign="top">
						<span style="font-weight: bold; font-size: 10pt"><?php 
            echo $field['field_label'];
            if ($field['is_required'] == 'Y') {
                echo '<span style="color:red; font-size:18pt">*</span>';
            }
            ?>
</span> <?php 
            echo $field['field_type'] . ' (#' . $field['field_id'];
            ?>
)
					</td>

					<td >
						&lt;---<select <?php 
            if ($this->config['map'][$field['field_id']]) {
                ?>
 style="color:#008080; font-weight: bold" <?php 
            }
            ?>
 style="font-size: 12pt" type="select" name="map[]">
						<option value="" style="color:#008080; font-weight: bold">[Select Field]</option>
						<?php 
            foreach ($in_fields as $in_key => $in_field) {
                if ($this->config['map'][$field['field_id']] == $in_field) {
                    $sel = ' selected ';
                } else {
                    $sel = '';
                }
                echo '<option style="color:#008080; font-weight: bold" ' . $sel . 'value="' . $field['field_id'] . '=' . $in_field . '">' . $in_field . '</option>' . "\n";
            }
            ?>
						</select>
					</td>
				</tr>

			<?php 
        }
        ?>
			</table>


		</td>

		<tr>
			<td  width="20%" bgcolor="#e6f2ea">
				<b>Ad Code</b></td>
			<td  bgcolor="#e6f2ea">
				<small>Paste in the ad code HTML here, eg. Google Adsense</small>
				<textarea rows="10" style="width:100%" name="ad"><?php 
        echo htmlentities($this->config['ad']);
        ?>
</textarea>
			</td>
		</tr>
	<!--	
		<tr>
			<td  width="20%" bgcolor="#e6f2ea">
				<b>Channel</b></td>
			<td  bgcolor="#e6f2ea"><input size="15" type="text" name='ch' value="<?php 
        echo $this->config['ch'];
        ?>
"> (Optional. Used to track performance if you have more than one web site. Add a new channel in your Indeed publisher account by going to the XML Feed page)
			</td>
		</tr>
		
	--><!--	<tr>
			<td  width="20%" bgcolor="#e6f2ea">
				<b>Sort</b></td>
			<td  bgcolor="#e6f2ea"><input type="radio" name="so" <?php 
        if ($this->config['so'] == 'date') {
            echo ' checked ';
        }
        ?>
 value="date"> By Date Posted (default)<br>
			<input type="radio" name="so" <?php 
        if ($this->config['so'] == 'relevance') {
            echo ' checked ';
        }
        ?>
 value="relevance"> By Relevance<br>
			<input type="radio" name="so" <?php 
        if ($this->config['so'] == 'custom') {
            echo ' checked ';
        }
        ?>
 value="custom"> By relevance + Date Sorted (Jamit does additional sorting so that the relevant results are sorted by date. CPU intensive)
			</td>
		</tr>
	--><!--	<tr>
			<td  width="20%" bgcolor="#e6f2ea">
				<b>Site Type</b></td>
			<td  bgcolor="#e6f2ea"><input type="radio" name="st" <?php 
        if ($this->config['st'] == 'jobsite') {
            echo ' checked ';
        }
        ?>
 value="jobsite"> Job Site: To show jobs only from job board sites<br>
			<input type="radio" name="st" <?php 
        if ($this->config['st'] == 'employer') {
            echo ' checked ';
        }
        ?>
 value="employer">Show jobs only direct from employer sites<br>
			<input type="radio" name="st" <?php 
        if ($this->config['st'] == '') {
            echo ' checked ';
        }
        ?>
 value="">Show from all<br>
			</td>
		</tr>
	--><!--	<tr>
			<td  width="20%" bgcolor="#e6f2ea">
				<b>Job Type</b></td>
			<td  bgcolor="#e6f2ea">
			<input type="radio" name="jt" <?php 
        if ($this->config['jt'] == 'fulltime') {
            echo ' checked ';
        }
        ?>
 value="fulltime"> Get Full Time jobs<br>
			<input type="radio" name="jt" <?php 
        if ($this->config['jt'] == 'parttime') {
            echo ' checked ';
        }
        ?>
 value="parttime"> Get Part Time jobs<br>
			<input type="radio" name="jt" <?php 
        if ($this->config['jt'] == 'contract') {
            echo ' checked ';
        }
        ?>
 value="contract"> Get Contract jobs<br>
			<input type="radio" name="jt" <?php 
        if ($this->config['jt'] == 'internship') {
            echo ' checked ';
        }
        ?>
 value="internship"> Get Intership jobs<br>
			<input type="radio" name="jt" <?php 
        if ($this->config['jt'] == 'temporary') {
            echo ' checked ';
        }
        ?>
 value="temporary"> Get temporary jobs<br>
			<input type="radio" name="jt" <?php 
        if ($this->config['jt'] == '') {
            echo ' checked ';
        }
        ?>
 value=""> Get all types of jobs
			</td>
		</tr>
	--><!--	<tr>
			<td  width="20%" bgcolor="#e6f2ea">
				<b>Radius</b></td>
			<td  bgcolor="#e6f2ea"><input size="3" type="text" name='r' value="<?php 
        echo $this->config['r'];
        ?>
"> Distance from search location ("as the crow flies"). Default is 25.
			</td>
		</tr>
		--><!--<tr>
			<td  width="20%" bgcolor="#e6f2ea">
				<b>From Age</b></td>
			<td  bgcolor="#e6f2ea"><input size="3" type="text" name='age' value="<?php 
        echo $this->config['age'];
        ?>
"> (Number of days back to search. Default/Max is 30)
			</td>
		</tr>
--><!--
		<tr>
			<td  width="20%" bgcolor="#e6f2ea">
				<b>highlight</b></td>
			<td  bgcolor="#e6f2ea"><input type="radio" name="h" <?php 
        if ($this->config['h'] == '1') {
            echo ' checked ';
        }
        ?>
 value="1"> Yes, highlight keywords<br>
			<input type="radio" name="h" <?php 
        if ($this->config['h'] == '0') {
            echo ' checked ';
        }
        ?>
 value="0"> No)
			</td>
		</tr>
	--><!--
		<tr>
			<td  width="20%" bgcolor="#e6f2ea">
				<b>Filter Results</b></td>
			<td  bgcolor="#e6f2ea"><input type="radio" name="f" <?php 
        if ($this->config['f'] == '1') {
            echo ' checked ';
        }
        ?>
 value="1"> Yes, filter duplicate results<br>
			<input type="radio" name="f" <?php 
        if ($this->config['f'] == '0') {
            echo ' checked ';
        }
        ?>
 value="0"> No
			</td>
		</tr>
	--><!--
		<tr>
			<td  width="20%" bgcolor="#e6f2ea">
				<b>How to Back-fill?</b></td>
			<td  bgcolor="#e6f2ea">
			<input type="radio" name="fill" <?php 
        if ($this->config['fill'] == 'S') {
            echo ' checked ';
        }
        ?>
 value="S"> Stop after filling the first page<br>
			<input type="radio" name="fill" <?php 
        if ($this->config['fill'] == 'C') {
            echo ' checked ';
        }
        ?>
 value="C"> Continue to futher pages (if more results are available)
			</td>
		</tr>
-->
		

		
		<tr><td colspan="2">Advanced Settings</td>
		</tr>


	<tr>
      <td  bgcolor="#e6f2ea"><font face="Verdana" size="1">Use cURL (Y/N)</font></td>
      <td  bgcolor="#e6f2ea"><font face="Verdana" size="1">
       <br>
	   <?php 
        if (!function_exists('curl_init')) {
            echo ' Note: Your host does not suppor cURL. Options currently disabled <br>';
        }
        ?>
	  <input type="radio" name="curl" value="N" <?php 
        if (!function_exists('curl_init')) {
            echo ' disabled ';
        }
        ?>
 <?php 
        if ($this->config['curl'] == 'N') {
            echo " checked ";
        }
        ?>
 >No - Normally this option is best<br>
	  <input type="radio" name="curl" value="Y" <?php 
        if (!function_exists('curl_init')) {
            echo ' disabled ';
        }
        ?>
 <?php 
        if ($this->config['curl'] == 'Y') {
            echo " checked ";
        }
        ?>
 >Yes - If your hosting company blocked fsockopen() and has cURL, then use this option</font></td>
    </tr>

	<tr>
      <td  bgcolor="#e6f2ea"><font face="Verdana" size="1">cURL 
      Proxy URL</font></td>
      <td  bgcolor="#e6f2ea"><font face="Verdana" size="1">
      <input <?php 
        if (!function_exists('curl_init')) {
            echo ' disabled ';
        }
        ?>
 type="text" name="proxy" size="50" value="<?php 
        echo $this->config['proxy'];
        ?>
">Leave blank if your server does not need one. Contact your hosting company if you are not sure about which option to use. For GoDaddy it is: http://proxy.shr.secureserver.net:3128<br></font></td>
    </tr>
		<tr>
			<td  bgcolor="#e6f2ea" colspan="2"><font face="Verdana" size="1"><input type="submit" value="Save">
		</td>
		</tr>
		</table>
		<input type="hidden" name="plugin" value="<?php 
        echo jb_escape_html($_REQUEST['plugin']);
        ?>
">
		<input type="hidden" name="action" value="save">

		</form>
		<?php 
        if ($this->bug_test()) {
            echo "<p><font color='red'>PHP Bug warning: The system detected that your PHP version has a bug in the XML parser. This is not a bug in the Jamit Job Board, but a bug in 'libxml' that comes built in to PHP itself. An upgrade of PHP with the latest version of 'libxml' with  is recommended. This plugin contains a workaround for this bug - so it should still work...</font> For details about the bug, please see <a href='http://bugs.php.net/bug.php?id=45996'>http://bugs.php.net/bug.php?id=45996</a></p> ";
        }
        // check if fsockopen is disabled
        if (stristr(ini_get('disable_functions'), "fsockopen")) {
            JB_pp_mail_error("<p>fsockopen is disabled on this server. You can try to set this plugin to use cURL instead</p>");
        }
        ?>
		<b>Important:</b> After configuring Go here to <a href="p.php?p=JobsFiller&action=kw">Configure Category Keywords</a>
<p>
TROUBLE SHOOTING
<p>
> Keywords do not return any results?
Try your keyword on indeed.com first, before putting them in the job board.
<p>
> Page times out / does not fetch any results?
Your server must be able to make external connections to api.indeed.com
through port 80 (HTTP). This means that fsockopen must be enabled on
your host, and must be allowed to make external connections.
<p>
- I see warning/errors messages saying that 'argument 2' is missing.
This has been reported and can be fixed if you open the include/lists.inc.php
file and locate the following code:
<p>
JBPLUG_do_callback('job_list_data_val', $val, $template_tag);
<p>
and change to:
<p>
JBPLUG_do_callback('job_list_data_val', $val, $template_tag, $a);
<p>
- Can I make the links open in a new window?
<p>
Nope.. Indeed rules are that in order to record the click, it must use their 
onmousedown event to call their javascript, and the javascripts 
prevents the link from opening in a new window.
<p>
- It still does not work
<p>
Please check the requirements - requires Jamit Job Board 3.5.0 or higher
Please also check with your hosting company that your server
is allowed to use fsockopen or Curl
		 <?php 
    }
Esempio n. 28
0
function JB_compute_export_elements_has_child($schema_id = false)
{
    // get all the export elements that have a child
    // by joining the table with itself
    if ($schema_id) {
        $schema_id_sql = " AND t1.schema_id='" . jb_escape_sql($schema_id) . "' ";
    }
    $sql = " SELECT t1.element_id AS EL_ID\nFROM xml_export_elements AS t1, xml_export_elements AS t2\nWHERE t1.element_id = t2.parent_element_id {$schema_id_sql}\nGROUP BY EL_ID ";
    $result = jb_mysql_query($sql);
    while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
        $sql = "UPDATE xml_export_elements SET has_child='Y' WHERE element_id='" . jb_escape_sql($row['EL_ID']) . "' ";
        jb_mysql_query($sql);
    }
    // now set the remaining NULL to 'N'
    $sql = "UPDATE xml_export_elements SET has_child='N' WHERE has_child IS NULL ";
    jb_mysql_query($sql);
}
Esempio n. 29
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)) {
        if ($row[0] == $field) {
            return true;
        }
    }
    return false;
}
Esempio n. 30
0
    $sql = "UPDATE membership_invoices SET member_end='{$d_next_month}' WHERE invoice_id = '" . jb_escape_sql($_REQUEST['invoice_id']) . "' ";
    jb_mysql_query($sql);
    $JBMarkup->ok_msg('Added 1 month');
}
if ($_REQUEST['sub_month'] != '') {
    $invoice_row = JB_get_membership_invoice_row($_REQUEST['invoice_id']);
    $t_end = strtotime($invoice_row['member_end']);
    $t_next_month = mktime(date('H', $t_end), date('i', $t_end), date('s', $t_end), date('n', $t_end) - 1, date('j', $t_end), date('Y', $t_end));
    $d_next_month = gmdate("Y-m-d H:i:s", $t_next_month);
    $sql = "UPDATE membership_invoices SET member_end='{$d_next_month}' WHERE invoice_id = '" . jb_escape_sql($_REQUEST['invoice_id']) . "' ";
    jb_mysql_query($sql);
    $JBMarkup->ok_msg('Subtracted 1 month');
}
if ($_REQUEST['never_expire'] != '') {
    $sql = "UPDATE membership_invoices SET months_duration='0' WHERE invoice_id = '" . jb_escape_sql($_REQUEST['invoice_id']) . "' ";
    jb_mysql_query($sql);
    $JBMarkup->ok_msg('Set to never expire');
}
if ($_REQUEST['expire'] != '') {
    $invoice_row = JB_get_membership_invoice_row($_REQUEST['invoice_id']);
    JB_expire_membership($invoice_row, $send_email = false);
    $JBMarkup->ok_msg('Subscription expired');
}
if ($_REQUEST['reactivate'] != '') {
    $invoice_row = JB_get_membership_invoice_row($_REQUEST['invoice_id']);
    $now = gmdate("Y-m-d H:i:s");
    $sql = "UPDATE membership_invoices SET `status`='Completed', `processed_date`='{$now}' WHERE invoice_id='" . jb_escape_sql($_REQUEST['invoice_id']) . "'";
    $result = JB_mysql_query($sql) or JB_mail_error("[{$sql}]" . mysql_error());
    JB_start_membership($invoice_row);
    $JBMarkup->ok_msg('Subscription reactivated');
}