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"; } */ }
function JB_complete_package_invoice($invoice_id, $payment_method = '') { $invoice_row = JB_get_product_invoice_row($invoice_id); if ($payment_method == '') { $payment_method = $invoice_row['payment_method']; } if (strtolower($invoice_row['status']) == 'confirmed' || strtolower($invoice_row['status']) == 'pending') { $now = gmdate("Y-m-d H:i:s"); $sql = "UPDATE package_invoices SET `status`='Completed', `payment_method`='" . jb_escape_sql($payment_method) . "', `processed_date`='{$now}' WHERE invoice_id='" . jb_escape_sql($invoice_id) . "'"; $result = JB_mysql_query($sql) or JB_mail_error("[{$sql}]" . mysql_error()); if ($invoice_row['reason'] != 'jb_credit_advanced') { // bank and check modules have the option to advance credits. If the credit was given in advance, then this invoice would have a jb_credit_advanced reason JB_add_posting_credits($invoice_row); } if (JB_EMAIL_ORDER_COMPLETED_SWITCH == 'YES') { // send conformation. // get the user's record to send to $sql = "Select * from employers WHERE ID='" . jb_escape_sql($invoice_row['employer_id']) . "'"; $result = JB_mysql_query($sql) or die(mysql_error()); $e_row = mysql_fetch_array($result, MYSQL_ASSOC); $template_r = JB_get_email_template(70, $e_row['lang']); $template = mysql_fetch_array($template_r); $msg = $template['EmailText']; $from = $template['EmailFromAddress']; $from_name = $template['EmailFromName']; $subject = $template['EmailSubject']; $msg = str_replace("%LNAME%", $e_row['LastName'], $msg); $msg = str_replace("%FNAME%", $e_row['FirstName'], $msg); $msg = str_replace("%SITE_NAME%", JB_SITE_NAME, $msg); $msg = str_replace("%INVOICE_CODE%", "P" . $invoice_row['invoice_id'], $msg); $msg = str_replace("%ITEM_NAME%", $invoice_row['item_name'], $msg); $msg = str_replace("%QUANTITY%", $invoice_row['posts_quantity'], $msg); $msg = str_replace("%INVOICE_AMOUNT%", JB_convert_to_default_currency_formatted($invoice_row['currency_code'], $invoice_row['amount']), $msg); $msg = str_replace("%PAYMENT_METHOD%", $payment_method, $msg); $msg = str_replace("%SITE_CONTACT_EMAIL%", JB_SITE_CONTACT_EMAIL, $msg); $msg = str_replace("%SITE_URL%", JB_BASE_HTTP_PATH, $msg); preg_match('#%INVOICE_TAX=\\[(.+?)\\]%#', $msg, $m); $tax_rate = $m[1]; $invoice_tax = $invoice_row['amount'] - $invoice_row['amount'] / (1.0 + $tax_rate); $invoice_tax = JB_convert_to_default_currency_formatted($invoice_row['currency_code'], $invoice_tax); $msg = str_replace($m[0], $invoice_tax, $msg); $msg = str_replace('$DATE%', jb_get_formatted_date(jb_get_local_time(date('Y-M-d'))), $msg); $to = $e_row['Email']; $to_name = JB_get_formatted_name($e_row['FirstName'], $e_row['LastName']); $email_id = JB_queue_mail($to, $to_name, $from, $from_name, $subject, $msg, '', 70); JB_process_mail_queue(1, $email_id); } } }