Exemplo n.º 1
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
         global $post_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;
         }
         //echo "temp keys: $temp_keys<br>";
         //echo "temp loc: $temp_loc<br>";
     }
     ############################################################################
     $params = array('pub' => $this->config['id'], 'q' => $keyword_q, 'l' => $location_q, 'start' => $start, 'limit' => $this->config['lim'], 'cnt' => $this->config['cnt'], 'src' => $this->config['src'], 'typ' => $this->config['typ'], 'inv' => $this->invisible);
     if ($result = $this->api_call('search', $params)) {
         $this->posts = $result['posts'];
         $this->total_results = $result['total_results'];
     } else {
         //echo 'failed api_call';
         //
     }
 }
Exemplo n.º 2
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 inputted 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 separate 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;
         }
     }
     ############################################################################
     $channel = '&chnl=' . urlencode($this->config['ch']);
     $sort = $this->config['so'];
     if ($sort == 'custom') {
         $sort = 'relevance';
     }
     $req = 'publisher=' . $this->config['id'] . '&q=' . urlencode($keyword_q) . '&l=' . urlencode($location_q) . '&sort=' . $sort . '&radius=' . $this->config['r'] . '&st=' . $this->config['st'] . '&jt=' . $this->config['jt'] . '&start=' . $start . '&limit=' . $this->config['lim'] . '&fromage=' . $this->config['age'] . '&highlight=' . $this->config['h'] . '&filter=' . $this->config['f'] . '&latlong=1&userip=' . urlencode($ip_addr) . '&useragent=' . urlencode($user_agent) . '&co=' . $this->config['c'] . $channel . '&v=2';
     $host = $this->config['s'];
     //'api.indeed.com';
     $get = '/ads/apisearch?' . $req;
     // for testing:
     //$host = '127.0.0.1';
     //$get = '/JamitJobBoard-3.5.0a/include/plugins/IndeedXML/sample.xml?'.$req;
     //echo $get;
     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 IndeedXMLParser($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";
     }
 }
Exemplo n.º 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";
     		}
     */
 }
Exemplo n.º 4
0
function JB_get_list_template_value($field, $val, $admin, $form_id = 1)
{
    $LM =& JB_get_ListMarkupObject($form_id);
    $Form =& JB_get_DynamicFormObject($form_id);
    // it is assumed that this function is called in 'view' mode
    // the viewer id and type is unknown so null is passed
    if ($Form->process_field_restrictions($field, null, null, $admin)) {
        // Its a restricted field, eg anonymous, blocked or member's only
        return $Form->get_value($field['field_id']);
    }
    switch ($field['field_type']) {
        case 'TIME':
            // convert timestamp to local time zone
            // using the raw value stored in the record
            if ($val != '0000-00-00 00:00:00') {
                $val = JB_get_local_time($Form->get_value($field['field_id']) . ' GMT');
            }
            break;
        case 'EDITOR':
            $val = strip_tags($val);
            $val = jb_escape_html($val);
            if (!$admin) {
                $val = JB_email_at_replace($val);
            }
            break;
        case 'IMAGE':
            if (JB_image_thumb_file_exists($Form->get_value($field['field_id']))) {
                $val = $LM->get_img_html($Form->get_value($field['field_id']));
            }
            break;
        case "CURRENCY":
            if ($val > 0) {
                $val = JB_escape_html(JB_format_currency($Form->get_value($field['field_id']), JB_get_default_currency()));
            } else {
                $val = '';
            }
            break;
        case "CATEGORY":
            $val = jb_escape_html(JB_getCatName($Form->get_value($field['field_id'])));
            break;
        case "RADIO":
            $val = jb_escape_html(JB_getCodeDescription($field['field_id'], $Form->get_value($field['field_id'])));
            break;
        case "SELECT":
            $val = jb_escape_html(JB_getCodeDescription($field['field_id'], $Form->get_value($field['field_id'])));
            break;
        case "MSELECT":
        case "CHECK":
            $vals = explode(",", $Form->get_value($field['field_id']));
            $comma = '';
            $str = '';
            if (sizeof($vals) > 0) {
                foreach ($vals as $v) {
                    $str .= $comma . jb_escape_html(JB_getCodeDescription($field['field_id'], $v));
                    $comma = ", ";
                }
            }
            $val = $str;
            break;
        case "DATE":
        case "DATE_CAL":
            if ($val != '0000-00-00 00:00:00') {
                $val = JB_get_local_time($Form->get_value($field['field_id']) . " GMT");
                $val = JB_get_formatted_date($val);
            } else {
                $val = '';
            }
            break;
        case "SKILL_MATRIX":
            $sql = "SELECT name FROM skill_matrix_data where object_id='" . JB_escape_sql($Form->get_value('resume_id')) . "' ";
            $result = JB_mysql_query($sql) or die(mysql_error());
            $val = '';
            $comma = '';
            while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
                $val .= $comma . $row['name'];
                $comma = ", ";
            }
            break;
        default:
            // plugins can alter the data in the cell to be
            // be presented on the list in a custom manner
            $args = array('val' => &$val, 'has_changed' => false, 'field' => &$field, 'form_id' => $form_id, 'data' => $Form->get_values());
            JBPLUG_do_callback('get_list_template_value', $args);
            // This hook was added in 3.6, allows plugins to modify the cell data based on $field, eg. $field['field_type'], the plugin should set 'has_changed' to true if the data in 'val' was changed.
            if ($args['has_changed']) {
                // has it changed?
                return $val;
            }
            // if not modified by plugin
            $val = jb_escape_html($val);
            if (!$admin) {
                $val = JB_email_at_replace($val);
            }
    }
    return $val;
}
Exemplo n.º 5
0
 function do_request($pageNum, $wSize, $ignoreCnt = 0)
 {
     if ($pageNum < 1 || $wSize <= 0) {
         // invalid values
         return false;
     }
     $user_agent = $_SERVER['HTTP_USER_AGENT'];
     $ip_addr = $_SERVER['REMOTE_ADDR'];
     ############################################################################
     # Process the keywords
     // Set the default keywords.
     // These will be overwritten if user inputted 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 separate 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;
         }
         //echo "temp keys: $temp_keys<br>";
         //echo "temp loc: $temp_loc<br>";
     }
     ############################################################################
     $sort = $this->config['so'];
     if ($sort == 'custom') {
         $sort = 'rd';
     }
     $host = $this->config['s'];
     switch ($this->config['c']) {
         case 'kr':
             $host = 'api.simplyhired.kr';
             break;
         case 'jp':
             $host = 'api.simplyhired.jp';
             break;
         case 'in':
             $host = 'api.simplyhired.co.in';
             break;
         case 'cn':
             $host = 'api.simplyhired.cn';
             break;
         case 'uk':
             $host = 'api.simplyhired.co.uk';
             break;
         case 'ch':
             $host = 'api.simplyhired.ch';
             break;
         case 'es':
             $host = 'api.simplyhired.es';
             break;
         case 'nl':
             $host = 'api.simplyhired.nl';
             break;
         case 'it':
             $host = 'api.simplyhired.it';
             break;
         case 'ie':
             $host = 'api.simplyhired.ie';
             break;
         case 'de':
             $host = 'api.simplyhired.de';
             break;
         case 'fr':
             $host = 'api.simplyhired.fr';
             break;
         case 'be':
             $host = 'api.simplyhired.be';
             break;
         case 'at':
             $host = 'api.simplyhired.at';
             break;
         case 'mx':
             $host = 'api.simplyhired.mx';
             break;
         case 'ca':
             $host = 'api.simplyhired.ca';
             break;
         case 'br':
             $host = 'api.simplyhired.com.br';
             break;
         case 'au':
             $host = 'api.simplyhired.com.au';
             break;
         case 'us':
             $host = 'api.simplyhired.com';
             $ssty = 1;
         default:
             // not supported...
             $host = 'api.simplyhired.com';
     }
     // use this string for SimplyHired version v1
     /*
     $req = '/q-'.urlencode($keyword_q).'/l-'.urlencode($location_q).'/mi-'.$this->config['r'].'/sb-'.$sort.'/ws-'.$wSize.'/pn-'.$pageNum;
     $get = '/a/jobs/xml-v1'.$req;
     */
     // use this string for SimplyHired version v2
     $req = '/q-' . urlencode($keyword_q) . '/l-' . urlencode($location_q) . '/mi-' . $this->config['r'] . '/sb-' . $sort . '/ws-' . $wSize . '/pn-' . $pageNum . '/?pshid=' . $this->config['id'] . '&ssty=' . $this->config['ssty'] . '&cflg=r&purl=' . urlencode($this->selfURL());
     $get = '/a/jobs-api/xml-v2' . $req;
     //echo $req;
     /* for DEBUGGING
     		$host = 'localhost';
     		$get  = '/jamit/jobboard/include/plugins/SimplyHiredXML/sample.xml';
     		*/
     //echo $host . $get; // for DEBUGGING
     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) {
             $start = false;
             while (!feof($fp)) {
                 // skip the header
                 $res = fgets($fp);
                 if (strpos($res, "<?xml") !== false) {
                     $start = true;
                 }
                 if ($start) {
                     break;
                 }
             }
             // parse the xml file to get the posts
             $parser = new SimplyHiredXMLParser($fp);
             $this->posts = $parser->get_posts();
             $this->total_results = $parser->total_results;
             // custom compare function for usort()
             if (!function_exists('sh_my_cmp')) {
                 // custom compare function for usort()
                 function sh_my_cmp($a, $b)
                 {
                     return strcmp($b["date"], $a["date"]);
                 }
             }
             // sort the results by date
             if ($this->config['so'] == 'custom') {
                 usort($this->posts, 'sh_my_cmp');
             }
             ////////////////////////////////////////////////
             // how many results to ignore? (remove from array, so that we don't show duplicate results)
             if ($ignoreCnt > 0) {
                 $n = 0;
                 foreach ($this->posts as $key => $val) {
                     if ($key < $ignoreCnt) {
                         unset($this->posts[$key]);
                     }
                     $n++;
                 }
             }
         } else {
             echo 'failed to send header';
         }
         fclose($fp);
         if ($this->config['curl'] == 'Y') {
             $this->curl_cleanup($fp);
         }
     } else {
         echo "cannot connect to {$host}";
     }
 }
Exemplo n.º 6
0
function JBXM_get_filtered_data(&$element_row, &$feed_row, &$data, $field_id = '')
{
    if ($field_id == '') {
        $field_id = $feed_row['field_settings'][$element_row['element_id']];
    }
    $val = trim($data[$field_id]);
    if ($field_id == 'summary') {
        // generate a summary.
        // get the raw description
        global $post_tag_to_field_id;
        $description = trim($data[$post_tag_to_field_id['DESCRIPTION']['field_id']]);
        // truncate it and strip any tags
        $val = str_replace('&nbsp;', ' ', JB_truncate_html_str(strip_tags($description), JB_POSTS_DESCRIPTION_CHARS, $trunc_str_len));
        return $val;
    }
    $field_type = $feed_row['field_settings']['ft_' . $element_row['element_id']];
    if ($element_row['strip_tags'] == 'Y') {
        $val = strip_tags($val);
        $from_html = array("&nbsp;", "  ", "\n\n", "\r\n\r\n");
        $to_text = array(" ", " ", "\n", "\n");
        $val = str_replace($from_html, $to_text, $val);
    }
    if ($element_row['truncate'] > 0) {
        $val = JB_truncate_html_str($val, $element_row['truncate'], $trunc_str_len, false);
    }
    switch ($field_type) {
        case 'MSELECT':
        case 'CHECK':
            if ($element_row['qualify_codes'] == 'Y') {
                $vals = explode(",", $val);
                $comma = '';
                $str;
                if (sizeof($vals) > 0) {
                    foreach ($vals as $v) {
                        $str .= $comma . JB_getCodeDescription($field_id, $v);
                        $comma = ", ";
                    }
                }
                $val = $str;
            }
            break;
        case 'SELECT':
        case 'RADIO':
            if ($element_row['qualify_codes'] == 'Y') {
                $val = JB_getCodeDescription($field_id, $val);
            }
            break;
        case 'CATEGORY':
            if ($element_row['qualify_cats'] == 'Y') {
                $val = JB_getCatName($val);
            }
            break;
        case 'FILE':
            if ($feed_row['export_with_url'] == 'Y') {
                $val = JB_FILE_PATH . $val;
            }
            break;
        case 'IMAGE':
            if ($feed_row['export_with_url'] == 'Y') {
                $val = JB_IM_PATH . $val;
            }
            break;
        case 'PLUGIN':
            JBPLUG_do_callback('JBXM_get_filtered_data', $val, $feed_row);
            break;
    }
    if ($element_row['is_boolean'] == 'Y') {
        $match = $feed_row['field_settings']['boolean_p_' . $element_row['element_id']];
        if ($field_type == 'MSELECT' || $field_type == 'RADIO') {
            if (strpos(strtolower($val), strtolower($match)) !== false) {
                $val = 'true';
            } else {
                $val = 'false';
            }
        } else {
            if (strtolower($val) == strtolower($match)) {
                $val = 'true';
            } else {
                $val = 'false';
            }
        }
    }
    return $val;
}
Exemplo n.º 7
0
function JB_form_mselect_field($field_id, $selected, $size, $mode)
{
    $DFM =& JB_get_DynamicFormMarkupObject($mode);
    if (JB_CODE_ORDER_BY == 'BY_NAME') {
        $order_by = 'description';
    } else {
        $order_by = 'code';
    }
    $selected_codes = explode(",", $selected);
    if ($mode == 'view') {
        require_once dirname(__FILE__) . "/code_functions.php";
        foreach ($selected_codes as $code) {
            echo $comma . JB_getCodeDescription($field_id, $code);
            $comma = ', ';
        }
    } else {
        // load in the options and display them
        if (!($codes_list = jb_cache_get('codes_list_fid_' . $field_id . '_ord_' . $order_by . '_lang_' . $_SESSION['LANG']))) {
            if ($_SESSION['LANG'] != '') {
                $sql = "SELECT * FROM `codes_translations` WHERE `field_id`='" . JB_escape_sql($field_id) . "' and lang='" . JB_escape_sql($_SESSION['LANG']) . "' order by '" . JB_escape_sql($order_by) . "'";
            } else {
                $sql = "SELECT * FROM `codes` WHERE `field_id`='" . JB_escape_sql($field_id) . "' order by '" . JB_escape_sql($order_by) . "'";
            }
            $result = JB_mysql_query($sql) or die(mysql_error());
            while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
                $codes_list[] = $row;
            }
            jb_cache_set('codes_list_fid_' . $field_id . '_ord_' . $order_by . '_lang_' . $_SESSION['LANG'], $codes_list);
        }
        $DFM->multiple_select_open($field_id, $size);
        foreach ($codes_list as $row) {
            if (in_array($row['code'], $selected_codes)) {
                $checked = " selected ";
            } else {
                $checked = "";
            }
            if ($mode == 'view') {
                //$disabled = " disabled  ";
            } else {
                $disabled = "";
            }
            $DFM->multiple_select_option($row, $checked);
        }
        $DFM->multiple_select_close();
    }
}
Exemplo n.º 8
0
 function get_template_value($tmpl, $admin = false, $raw = false)
 {
     $val = '';
     $field_id = $this->tag_to_field_id[$tmpl]['field_id'];
     if (!isset($this->data[$field_id])) {
         $this->data[$field_id] = '';
     }
     if ($raw) {
         // return without any post-processing
         return $this->data[$field_id];
     }
     /* Hook here for your plugin to bypass this function
      * Tip: Your plugin can use $this object like this: 
      * $obj = JB_get_DynamicFormObject($form_id)
      * $field_id = $this->tag_to_field_id[$tmpl]['field_id'];
      * ...
      */
     $val = false;
     JBPLUG_do_callback('get_template_value', $val, $this->form_id, $tmpl, $admin);
     if ($val !== false) {
         return $val;
     }
     if ($this->process_field_restrictions($tmpl, $this->viewer_id, $this->viewer_type, $admin)) {
         // Its a restricted field, eg anonymous, blocked or member's only
         return $this->data[$field_id];
     }
     // it is assumed that this function is called in 'view' mode
     /*if (JB_process_field_restrictions($this->data, $this->tag_to_field_id[$tmpl], 'view', $admin)) {
     			// Its a restricted field, eg anonymous, blocked or member's only
     			return $this->data[$field_id]; 
     		} */
     switch ($this->tag_to_field_id[$tmpl]['field_type']) {
         case "URL":
             $val = $this->data[$field_id];
             if (strlen($val) > 0) {
                 if (strpos($val, 'http://') === false && strpos($val, 'https://') === false) {
                     $val = 'http://' . $val;
                 }
                 $val = JB_escape_html($val);
                 // no html allowed in this field
             }
             break;
         case "IMAGE":
             if (!JB_image_thumb_file_exists($this->data[$field_id])) {
                 $val = $label['employer_resume_list_no_image'];
             } else {
                 $val = $this->data[$field_id];
             }
             break;
         case "NUMERIC":
         case "INTEGER":
             $val = jb_escape_html($this->data[$field_id]);
             // no html allowed in this field
             break;
         case "CURRENCY":
             if ($val > 0) {
                 $val = JB_escape_html(JB_format_currency($this->data[$field_id], JB_get_default_currency()));
             } else {
                 $val = '';
             }
             break;
         case "CATEGORY":
             $val = jb_escape_html(JB_getCatName($this->data[$field_id]));
             break;
         case "RADIO":
             $val = jb_escape_html(JB_getCodeDescription($field_id, $this->data[$field_id]));
             break;
         case "SELECT":
             $val = jb_escape_html(JB_getCodeDescription($field_id, $this->data[$field_id]));
             break;
         case "MSELECT":
         case "CHECK":
             $vals = explode(",", $this->data[$field_id]);
             $comma = '';
             $str = '';
             if (sizeof($vals) > 0) {
                 foreach ($vals as $v) {
                     $str .= $comma . jb_escape_html(JB_getCodeDescription($field_id, $v));
                     $comma = ", ";
                 }
             }
             $val = $str;
             break;
         case "TIME":
             if ($this->data[$field_id] != '0000-00-00 00:00:00') {
                 // convert the time to a local time zone
                 $val = JB_get_local_time($this->data[$field_id] . " GMT");
             }
             break;
         case "DATE":
         case "DATE_CAL":
             if ($this->data[$field_id] != '0000-00-00 00:00:00') {
                 $val = JB_get_local_time($this->data[$field_id] . " GMT");
                 $val = JB_get_formatted_date($val);
             } else {
                 $val = '';
             }
             break;
         case "SKILL_MATRIX":
             $sql = "SELECT name FROM skill_matrix_data where object_id='" . JB_escape_sql($this->data['resume_id']) . "' ";
             $result = JB_mysql_query($sql) or die(mysql_error());
             $val = '';
             $comma = '';
             while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
                 $val .= $comma . $row['name'];
                 $comma = ", ";
             }
             break;
         case "TIME":
             // time is used for post_date, resume_date, signup_date, profile_date, etc..
             $val = JB_get_local_time($this->data[$field_id] . " GMT");
             // the time is always stored as GMT
             break;
         case 'TEXTAREA':
         case "TEXT":
             $val = JB_escape_html($this->data[$field_id]);
             // no html allowed in this field
             break;
         case "EDITOR":
             // HTML is allowed for this field
             //assuming that input was sanitized and only allowed HTML is included
             $val = $this->data[$field_id];
             break;
         case 'GMAP':
             $val = 'lat:' . $this->data[$field_id . '_lat'] . '/lng:' . $this->data[$field_id . '_lng'];
             break;
         default:
             $val = false;
             // A plugin can filter the $val value to be returned
             JBPLUG_do_callback('get_template_value_filter', $val, $this->tag_to_field_id[$tmpl]['field_type']);
             if ($val !== false) {
                 return $val;
             } else {
                 // $val is empty which means that it wasn't set by a plugin
                 // escape HTML just in case.
                 $val = JB_escape_html($this->data[$field_id]);
                 // no html allowed in this field
             }
             break;
     }
     if ($field_id == '') {
         //echo '<b>Configuration error: Failed to bind the "'.$tmpl.'" Template Tag. (not defined)</b> <br> ';
     }
     return $val;
 }