예제 #1
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);
        }
    }
}
예제 #2
0
 function clean_data($data)
 {
     $data = trim($data);
     if (strpos($data, '<![CDATA[') === 0) {
         // if is beginning with <![CDATA[
         // then transform the CDATA
         $data = str_replace(array('<![CDATA[', ']]>'), array('', ''), $data);
     } else {
         // Treat the data as XML Entities
         $trans = array('&lt;' => "<", '&amp;' => "&", '&gt;' => ">", '&quot;' => '"', '&apos;' => '\'');
         $data = strtr($data, $trans);
     }
     // convert the UTF-8 data to job board's internal format
     $data = JB_utf8_to_html($data);
     // Strip any unwanted tags and scrub data from potential
     // XSS attacks
     $data = JB_clean_str($data);
     return $data;
 }
예제 #3
0
 function do_request($start = '')
 {
     if ($start < 1) {
         // cannot have 0 or negative
         $start = '';
     }
     $user_agent = $_SERVER['HTTP_USER_AGENT'];
     $ip_addr = $_SERVER['REMOTE_ADDR'];
     ############################################################################
     # Process the keywords
     // Set the default keywords.
     // These will be overwritten if user inputed keywords are available
     $keyword_q = $this->config['k'];
     // default keywords
     $location_q = $this->config['l'];
     // default location
     if (is_numeric($_REQUEST['cat'])) {
         // fetch the category keywords
         $this->set_category_kw($_REQUEST['cat'], $keyword_q, $location_q);
     }
     if ($_REQUEST['action'] == 'search') {
         // search results, use one field for the where, and other fileld for location
         $PForm = JB_get_DynamicFormObject(1);
         $post_tag_to_search = $PForm->get_tag_to_search();
         // iterate through each search parameter
         foreach ($post_tag_to_search as $key => $tag) {
             // is the search parameter attached to the keyword or location?
             if (in_array($key, $this->config['k_tag']) || in_array($key, $this->config['l_tag'])) {
                 $val = $_REQUEST[$tag['field_id']];
                 // get what was searched for
                 if (strlen($temp_keys) > 0) {
                     $temp_keys_space = ' ';
                 }
                 if (strlen($temp_loc) > 0) {
                     $temp_loc_space = ' ';
                 }
                 // convert the code or category id in to a keyword
                 switch ($tag['field_type']) {
                     // multiple select fields and checkboxes
                     // if passed as an array, these keywords are combined with an OR
                     case 'MSELECT':
                     case 'CHECK':
                         if (is_array($val)) {
                             $str = '';
                             $or = '';
                             foreach ($val as $code) {
                                 $str .= $or . JB_getCodeDescription($tag['field_id'], $code);
                                 $or = ' or ';
                             }
                             $val = '(' . $str . ')';
                         } else {
                             $val = JB_getCodeDescription($tag['field_id'], $val);
                         }
                         break;
                     case 'SELECT':
                     case 'RADIO':
                         // Single select and radio buttons.
                         $val = JB_getCodeDescription($tag['field_id'], $val);
                         break;
                     case 'CATEGORY':
                         // grab the category config
                         // If multiple categories are selected then they
                         // are combined with an OR
                         $cat_keywords_temp = '';
                         $cat_location_temp = '';
                         $or = '';
                         $i_temp = 0;
                         if (is_array($val)) {
                             // multiple categories were searched
                             $or = '';
                             foreach ($val as $cat_id) {
                                 $i_temp++;
                                 $this->set_category_kw($cat_id, $kw_val, $loc_val);
                                 if ($this->is_kw_OK($kw_val)) {
                                     $cat_keywords_temp .= $or . $kw_val;
                                     // append using OR
                                     $or = ' OR ';
                                 }
                                 if ($this->is_loc_OK($loc_val)) {
                                     $cat_location_temp = $loc_val;
                                 }
                             }
                             if ($i_temp > 1) {
                                 $cat_keywords_temp = '(' . $cat_keywords_temp . ')';
                             } else {
                                 $cat_keywords_temp = $cat_keywords_temp;
                             }
                             //echo "keywords_temp: [$cat_keywords_temp] * [$cat_id]<br>got this: $kw_val $loc_val<br>";
                         } else {
                             $this->set_category_kw($val, $kw_val, $loc_val);
                             if ($this->is_kw_OK($kw_val)) {
                                 $cat_keywords_temp = $kw_val;
                             }
                             if ($this->is_loc_OK($loc_val)) {
                                 $cat_location_temp = $loc_val;
                             }
                         }
                         // add them to the keys that we are bulding
                         $temp_keys .= $temp_keys_space . $cat_keywords_temp;
                         // the location keys are placed in to a seperate string
                         $temp_cat_loc .= $temp_loc_space . $cat_location_temp;
                         $temp_key_space = ' ';
                         $temp_loc_space = ' ';
                         $val = '';
                         break;
                 }
                 // add the $val to the temp keywords
                 if (in_array($key, $this->config['k_tag'])) {
                     // keyword?
                     $val = trim($val);
                     if ($val != '') {
                         // concationate the 'what' keywords
                         $temp_keys .= $temp_keys_space . $val;
                     }
                 }
                 if (in_array($key, $this->config['l_tag'])) {
                     // location?
                     $val = trim($val);
                     if ($val != '') {
                         // concatinate the 'where' keywords
                         $temp_loc .= $temp_loc_space . $val;
                     }
                 }
             }
         }
         // end iterating through each parameter
         $temp_keys = trim($temp_keys);
         $temp_loc = trim($temp_loc);
         // overwrite the default value $keyword_q with the kewords that were searched
         if ($temp_keys != '') {
             $keyword_q = $temp_keys;
         }
         // Overwrite the default value $location_q with the location that was searched
         // The 'were' kywords get priority
         // If they are bank, then use the location keywords from the category if
         // available.
         if ($temp_loc != '') {
             $location_q = $temp_loc;
         } elseif ($temp_cat_loc != '') {
             // the 'where' keywords were empty, so perhaps they were set by a category?
             $location_q = $temp_cat_loc;
         }
     }
     $api = new Services_Careerjet($this->config['c']);
     $page = round($start / $this->config['lim']) + 1;
     $result = $api->search(array('keywords' => $keyword_q, 'location' => $location_q, 'page' => $page, 'affid' => $this->config['id'], 'pagesize' => $this->config['lim'], 'sort' => $this->config['so'], 'contracttype' => $this->config['jt'], 'contractperiod' => $this->config['jp']), array('curl' => $this->config['curl'], 'curl_proxy' => $this->config['proxy']));
     if ($result->type == 'JOBS') {
         //echo "Found ".$result->hits." jobs" ;
         //echo " on ".$result->pages." pages\n" ;
         //$jobs = $result->jobs ;
         foreach ($result->jobs as $job) {
             $this->posts[] = array('title' => JB_utf8_to_html($job->title), 'company ' => JB_utf8_to_html($job->company), 'city' => '', 'state ' => '', 'country ' => '', 'locations' => JB_utf8_to_html($job->locations), 'source' => JB_utf8_to_html($job->company), 'date' => JB_get_formatted_date(jb_get_local_time($job->date)), 'snippet' => JB_utf8_to_html($job->description), 'url' => $job->url, 'onmousedown' => '', 'guid' => $job->url);
             /*
             sample given by careerjet:	
             echo " URL:     ".$job->url."\n" ;
             echo " TITLE:   ".$job->title."\n" ;
             echo " LOC:     ".$job->locations."\n";
             echo " COMPANY: ".$job->company."\n" ;
             echo " SALARY:  ".$job->salary."\n" ;
             echo " DATE:    ".$job->date."\n" ;
             echo " DESC:    ".$job->description."\n" ;
             echo "\n" ;
             */
         }
         $this->total_results = $result->hits;
     }
     ############################################################################
     /*
     		$channel = '&chnl='.urlencode($this->config['ch']);
     		$sort = $this->config['so'];
     		if ($sort=='custom') {
     			$sort = 'relevance';
     		}
     $page = round($start / $this->config['lim']) +1;
     		
     		$req = 'partnerid='.$this->config['id'].'&k='.urlencode($keyword_q).'&l='.urlencode($location_q).'&order='.$sort.'&r='.$this->config['r'].'&page='.$page.'&jpp='.$this->config['lim'].'&days='.$this->config['age'].'&highlight='.$this->config['h'].'&ipaddress='.urlencode($ip_addr).'&useragent='.urlencode($user_agent).$channel;
     		
     		//echo $req;
     $host = $this->config['s'];//'api.indeed.com';
     		$get = '/jobs?'.$req;
     // for testing:
     		//$host = '127.0.0.1';
     		//$get = '/JamitJobBoard-3.5.0a/include/plugins/CareerJet/sample.xml?'.$req;
     if ($this->config['curl']=='Y') {
     			$fp = $this->curl_request($host, $get);		
     		} else {
     			$fp = @fsockopen ($host, 80, $errno, $errstr, 10);
     		}
     		
     		if ($fp) {
     		
     			if ($this->config['curl']=='Y') {
     				$sent = true;
     			} else {
     				$send  = "GET $get HTTP/1.0\r\n"; // dont need chunked so use HTTP/1.0
     				$send .= "Host: $host\r\n";
     				$send .= "User-Agent: Jamit Job Board (www.jamit.com)\r\n";
     				$send .= "Referer: ".JB_BASE_HTTP_PATH."\r\n";
     				$send .= "Content-Type: text/xml\r\n";
     				$send .= "Connection: Close\r\n\r\n"; 
     				$sent = fputs ($fp, $send, strlen($send) ); // get
     				
     			}
     			
     			if ($sent) { 
     			
     				
     				while (!feof($fp)) { // skip the header
     					$res = fgets ($fp);
     					if (strpos($res, "<?xml")!==false) break;
     				}
     				
     				// parse the xml file to get the posts
     				//$parser = new CareerJetParser($fp);
     				//$this->posts = $parser->get_posts();
     				//$this->total_results = $parser->total_results;
     		// custom compare function for usort()
     				function my_cmp($a, $b) {
     					return strcmp($b["date"], $a["date"]);
     				}
     		// sort the results by date
     				if ($this->config['so']=='custom') {
     					usort($this->posts, 'my_cmp');
     				}
     				
     			
     			} else {
     				//echo 'failed to send header';
     			}
     	fclose($fp);
     			if ($this->config['curl']=='Y') {
     				$this->curl_cleanup($fp);		
     			} 
     		} else {
     			//echo "cannot connect to $host";
     		}
     */
 }
예제 #4
0
function JB_echo_cat_seo_fields($id, $url, $fname, $title, $desc, $keys, $dir_name)
{
    //$url = urldecode($url);
    preg_match("#/([^/]+)\$#D", urldecode($url), $m);
    $matched_file_name = $m[1];
    if (!JB_get_cat_id_from_url($matched_file_name, $form_id = 1)) {
        $amb = true;
        // the url is ambiguous
        echo " <font color='red'>{$url} [Warning: ambiguous filename, please choose a unique filename below]</font> ";
    } else {
        $amb = false;
    }
    if ($fname == '') {
        $fname = $matched_file_name;
    }
    $fname = JB_utf8_to_html($fname);
    ?>

	<br>
	<b>Path / File:</b> <?php 
    echo JB_BASE_HTTP_PATH . JB_MOD_REWRITE_DIR;
    ?>
<input name='file_<?php 
    echo $id;
    ?>
' size='40' <?php 
    if ($amb) {
        echo ' style="background-color:#FCDEC9;" ';
    }
    ?>
 type='text' value="<?php 
    echo jb_escape_html($fname);
    ?>
"><br>
	<b>Title:</b> <input name='title_<?php 
    echo $id;
    ?>
' size='80' type='text' value="<?php 
    echo jb_escape_html($title);
    ?>
"><br>
	<b>Description:</b> <input name='desc_<?php 
    echo $id;
    ?>
' size='80' type='text' value="<?php 
    echo jb_escape_html($desc);
    ?>
"><br>
	<b>Keywords:</b> <input name="keys_<?php 
    echo $id;
    ?>
" size='80' type='text' value="<?php 
    echo jb_escape_html($keys);
    ?>
"><br>

	<?php 
}
예제 #5
0
 function endXML($parser, $name)
 {
     // Implode char data gathered by charXML() for the
     // element which is currently the ending element.
     // The char data needs to be converted from
     // from UTF-8 in to Latin 1 the char data
     $key = implode('|', $this->key_stack);
     if (is_array($this->char_data[$key])) {
         $data = implode('', $this->char_data[$key]);
     }
     $this->char_data[$key] = array();
     // clear the char data buffer
     if ($key == 'response|results|result|url') {
         // for some reason, the xml parser does not work well on some servers
         // this is a workaround to put an & between the parameters
         $data = preg_replace('/([a-z0-9])indpubnum=/', '$1&amp;indpubnum=', $data);
     }
     if ($key == 'response|totalresults') {
         $this->total_results = $data;
     }
     // convert xml entities to char
     // eg. &amp; to &, &lt; to <
     $data = $this->xml_decode_entities($data);
     // convert from UTF-8 to Latin-1 & HTML Entities
     $data = JB_utf8_to_html($data);
     $this->data[$key]['data'] = $data;
     // if this is the ending sequence element, eg. end of the </job> record
     // then import the data
     if ($key == $this->seq) {
         //JBPLUG_do_callback('xml_import_process_data', $this);
         $this->process_data();
     }
     // now we can pop the
     // element off the stack and decrease depth
     // to keep track of where we are in the document tree
     array_pop($this->key_stack);
     $this->depth--;
 }
예제 #6
0
 function process_data()
 {
     // convert date to mysql format
     $t = strtotime($this->data['shrs|rs|r|dp']['data']);
     $this->data['shrs|rs|r|dp']['data'] = gmdate('Y-m-d H:i:s', $t);
     $this->posts[] = array('title' => $this->data['shrs|rs|r|jt']['data'], 'company' => $this->data['shrs|rs|r|cn']['data'], 'loc' => $this->data['shrs|rs|r|loc']['data'], 'city' => JB_utf8_to_html($this->data['shrs|rs|r|loc']['attr'][0]['cty']), 'state' => JB_utf8_to_html($this->data['shrs|rs|r|loc']['attr'][0]['st']), 'county' => JB_utf8_to_html($this->data['shrs|rs|r|loc']['attr'][0]['county']), 'postal' => JB_utf8_to_html($this->data['shrs|rs|r|loc']['attr'][0]['postal']), 'region' => JB_utf8_to_html($this->data['shrs|rs|r|loc']['attr'][0]['region']), 'country' => JB_utf8_to_html($this->data['shrs|rs|r|country']['attr'][0]['country']), 'source' => $this->data['shrs|rs|r|src']['data'], 'date' => $this->data['shrs|rs|r|dp']['data'], 'snippet' => $this->data['shrs|rs|r|e']['data'], 'url' => $this->data['shrs|rs|r|src']['attr'][0]['url']);
     //print_r($this->posts);
     // clear the data array
     $this->data = array();
 }