public function action_index() { $this->auto_render = FALSE; // Sitemap instance. $sitemap = new Sitemap(); // New basic sitemap. $sitemap_url = new Sitemap_URL(); // Set base url $base_url = "http://{$this->config['global']['server_domain']}/"; // Config urls $urls = array(array('url' => $base_url, 'frequency' => 'daily'), array('url' => $base_url . 'contact', 'frequency' => 'yearly'), array('url' => $base_url . 'about', 'frequency' => 'yearly'), array('url' => $base_url . 'contact', 'frequency' => 'yearly')); // Adds categories urls $categories = ORM::factory('category')->find_all(); foreach ($categories as $category) { $urls[] = array('url' => $base_url . '?&category_id=' . $category->id, 'frequency' => 'daily'); } // Adds jobtypes urls $jobtypes = ORM::factory('jobtype')->find_all(); foreach ($jobtypes as $jobtype) { $urls[] = array('url' => $base_url . '?&jobtype_id=' . $jobtype->id, 'frequency' => 'daily'); } // Get all active ads $ads = ORM::factory('ad'); $ads = $ads->where('active', '=', 1)->limit(500)->offset(0)->order_by('id', 'DESC')->find_all()->as_array('id', 'title'); foreach ($ads as $id => $title) { $urls[] = array('url' => Helper_Utils::get_ad_url($title, $id), 'frequency' => 'yearly'); } // Adds each url to the sitemap xml structure foreach ($urls as $url) { $sitemap_url->set_loc($url['url'])->set_last_mod(time())->set_change_frequency($url['frequency'])->set_priority(1); $sitemap->add($sitemap_url); } // Render the output. $output = $sitemap->render(); // __toString is also supported. header('Content-Type: text/xml'); echo $sitemap; die; }
/** * It will perfome a search on the ads table * * $res = Model_Ad::search(array( * 'search_string' => "php, london", * 'telecommute' => 1, * 'jobtype_id' => 3, * 'category_id' => 2, * 'limit' => 50, * 'offset' => 0, * 'fields' => array('id', 'title'), * )); * * @param Array $args * @return Array */ public static function search($args) { // Merge default args $args = array_merge(array('search_string' => '', 'telecommute' => 0, 'jobtype_id' => 0, 'jobboard_id' => 0, 'category_id' => 0, 'limit' => 50, 'offset' => 0, 'created_after' => 0, 'random_order' => false, 'fields' => array()), $args); // Loads application config file $config = Kohana::$config->load('application'); // Create the client, tell it where the server // is and how long to wait for a response. $sphinx = new Helper_Sphinx(); $sphinx->SetServer('localhost', 9312); $sphinx->SetConnectTimeout(1); // Use the exteneded v2 match type $sphinx->SetMatchMode(SPH_MATCH_BOOLEAN); // Set order & limit if ($args['search_string'] != "") { $sphinx->SetSortMode(SPH_SORT_EXTENDED, 'created_at DESC, highlight DESC'); } else { $sphinx->SetSortMode(SPH_SORT_EXTENDED, 'created_at DESC'); } $sphinx->SetLimits($args['offset'], $args['limit']); // Give me back the results as an array $sphinx->SetArrayResult(true); // Select only with telecommute if ($args['telecommute'] > 0) { $sphinx->SetFilter("telecommute", array(1)); } // Select only with jobtype_id if ($args['jobtype_id'] > 0) { $sphinx->SetFilter("jobtype_id", array($args['jobtype_id'])); } // Select only with jobboard_id if ($args['jobboard_id'] > 0) { $sphinx->SetFilter("jobboard_id", array($args['jobboard_id'])); } // Select only with category_id if ($args['category_id'] > 0) { $sphinx->SetFilter("category_id", array($args['category_id'])); } // Select only ads more recentent than created_after if ($args['created_after'] > 0) { $sphinx->SetFilterRange('created_at', $args['created_after'], strtotime('now')); } // Set random order if ($args['random_order']) { $sphinx->setSortMode(SPH_SORT_EXTENDED, '@random'); } // Perfom the query against sphinx server $sphinx_results = $sphinx->Query($args['search_string'], 'ads'); $rows = array(); $words = array(); // check if there's any results if ($sphinx_results['total'] > 0) { $ids = ''; // prepare the rows ID's to be used against mysql query for ($i = 0; $i < count($sphinx_results['matches']); $i++) { $ids .= $sphinx_results['matches'][$i]['id']; if ($i < count($sphinx_results['matches']) - 1) { $ids .= ','; } } // Merge the array so it can be included in the SQL query $fields = implode(',', $args['fields']); // Get the ID rows from MySQL $rows = DB::query(Database::SELECT, "SELECT {$fields} FROM\n\t\t\t\tads WHERE id IN({$ids}) AND active = 1 ORDER BY FIELD(id, {$ids}) ")->execute()->as_array(); // Get all the keywords if (isset($sphinx_results['words'])) { foreach ($sphinx_results['words'] as $key => $value) { $words[] = $key; } } // Cleans and formats data foreach ($rows as $key => $ad) { $rows[$key]['created_at'] = Helper_Datetime::format($ad['created_at'], $config['ad']['date_format']); $rows[$key]['is_new'] = Helper_Datetime::is_new($ad['created_at'], $config['ad']['is_new_days']); $rows[$key]['jobtype'] = ORM::factory('jobtype', $ad['jobtype_id'])->name; $rows[$key]['jobboard'] = ORM::factory('jobboard', $ad['jobboard_id'])->name; $rows[$key]['url'] = Helper_Utils::get_ad_url($ad['title'], $ad['id']); $rows[$key]['title'] = Text::limit_chars($ad['title'], 55, '...'); if (in_array('company_logo', $args['fields'])) { if (!$ad['company_logo']) { $rows[$key]['company_logo'] = 'default'; } $rows[$key]['company_logo'] = Helper_Utils::static_path('media/uploads/' . $rows[$key]['company_logo'] . '_thumb.png'); } $title[] = $rows[$key]['title']; unset($rows[$key]['jobtype_id']); } } return array('rows' => $rows, 'total' => $sphinx_results['total'], 'words' => $words); }
<!-- Ad-header --> <div id="ad-head"> <!-- ad-header-left --> <div id="ad-header-left"> <div class="row-fluid"> <!-- company-logo --> <?php if ($ad->company_logo) { ?> <div id="company-logo" class="span2" > <br/> <?php echo HTML::image(Helper_Utils::static_path('media/uploads/' . $ad->company_logo . '.png'), array('title' => $ad->company_name, 'class' => 'img-rounded')); ?> </div> <?php } ?> <!-- ./company-logo --> <!-- Basic information --> <div class="span8" > <h1><?php echo ucwords($ad->title); ?> </h1> <?php if ($ad->company_name) { ?> <h4><i class="icon-parents"></i> <?php echo $ad->company_name;
are registered trademarks of 3heap, LLC.</span> <span>All text and design is copyright © <?php echo "Y"; ?> 3heap, LLC. All rights reserved.</span> </div> </div> </div> </div> </div> </div> <!-- ./Footer --> <?php foreach ($scripts as $file) { echo HTML::script(Helper_Utils::static_path($file)), PHP_EOL; } ?> <script type="text/javascript"> var _gaq = _gaq || []; _gaq.push(['_setAccount', 'UA-796354-15']); _gaq.push(['_setDomainName', '.gowork.at']); _gaq.push(['_trackPageview']); (function() { var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true; ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js'; var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s); })(); </script> </body>
static function send_tweet($ad) { $config = Kohana::$config->load('application'); Email::send($config['facebook']['email'], $config['global']['email_feed'], $ad->title . " (" . $ad->location . ") - " . Helper_Utils::get_ad_url($ad->title, $ad->id), NULL); }
<div class="box rounded" > <span>WHY USE GOWORK@ ?</span> <hr /> <ul class="why-use-us"> <li><span class="imap normal star"></span><strong>Top ads</strong><br/> We include the best job boars on the net.</li> <li><span class="imap normal globe"></span><strong>Global</strong><br/> Find the best jobs from the best companies in the world.</li> <li><span class="imap normal search"></span><strong>Amazing search</strong><br/> Search, filter and save your search to be included on daily/weekly email reports. Or just save it as RSS Feed URL</li> </ul> </div> <div class="box"> <?php echo HTML::image(Helper_Utils::static_path('media/img/jobboards.png'), array('title' => 'Jobboards we include', 'alt' => 'Jobboards we include')); ?> </div> <div class="box"> <div class="addthis_toolbox addthis_32x32_style addthis_default_style"> <a class="addthis_button_facebook_follow" addthis:userid="goworkat"></a> <a class="addthis_button_twitter_follow" addthis:userid="goworkat"></a> <a class="addthis_button_tumblr_follow" addthis:url="http://blog.gowork.at"></a> <a class="addthis_button_rss_follow" addthis:url="/feed"></a> </div> <script type="text/javascript" src="//s7.addthis.com/js/300/addthis_widget.js#pubid=xa-5117919251421879"></script> </div>
/** * Show the complete page * */ public function action_complete() { // Check for a valid AD session form $session = Session::instance(); $temp_ad = $session->get('ad_created_id'); // Redirects user to homepage if (!$temp_ad) { $this->request->redirect('/'); } $ad = ORM::factory('ad', $temp_ad); $amount = $this->config['ad']['price_base']; if (1 == $ad->highlight) { $amount += $this->config['ad']['price_highlight']; } // Deleted session $session->delete('ad_created_id'); // Updates Facebook & twitter Email::send($this->config['facebook']['email'], '*****@*****.**', "New " . $ad->category->name . " job: " . $ad->title . " (" . $ad->location . ") - " . Helper_Utils::get_ad_url($ad->title, $ad->id), NULL); // Sends an email notification to the user $title = "Your job ad is ready [{$ad->title}]"; $name = 'User'; if ($ad->company_name) { $name = $ad->company_name; } $template = View::factory('emails/new_ad', array('title' => $title, 'name' => $name, 'url' => Helper_Utils::get_ad_url($ad->title, $ad->id), 'ad_title' => $ad->title))->render(); Email::send($ad->email, '*****@*****.**', $title, $template); // Send a copy to admin Email::send('*****@*****.**', '*****@*****.**', $title, $template); // Shows template $this->template->title = __('Thank you'); $this->template->content = View::factory('payment/complete', array('price_base' => $this->config['ad']['price_base'], 'price_highlight' => $this->config['ad']['price_highlight'], 'highlight' => $ad->highlight, 'url' => Helper_Utils::get_ad_url($ad->title, $ad->id), 'amount' => $amount)); }
/** * It will send notifications to users if their search params match * 1000 emails at a time. */ public function action_send_notifications() { // Get CLI params $options = CLI::options('frequency'); // Die if no --frequency= param is not found or not a number if (!isset($options['frequency']) || !is_numeric($options['frequency'])) { die("Insuficient params.\n"); } // Get all users with the correct frequency number if ($options['frequency'] == 0) { $time_interval = strtotime("-1 day"); $title = 'Daily'; $frequency_type = 'day'; } else { $time_interval = strtotime("-1 week"); $title = 'Weekly'; $frequency_type = 'week'; } // Execute query $rows = ORM::factory('mailinglist')->where('frequency', '=', $options['frequency'])->where(DB::expr('UNIX_TIMESTAMP(last_checked)'), '<=', $time_interval)->limit(1000)->find_all(); // If no rows found die if (!count($rows) > 0) { die("No rows to process.\n"); } // Updates all rows tothe current date, to avoid sending duplication // from other cron workers foreach ($rows as $row) { $current_row = ORM::factory('mailinglist', $row->id); $current_row->last_checked = date("Y-m-d h:i:s", strtotime("now")); $current_row->save(); } // Start fetching data and send to users foreach ($rows as $row) { // Tries to unserialize search string, if something's wrong // the row will be deleted try { // Conver string into an array $search_array = unserialize($row->saved_search); } catch (Exception $e) { echo 'Invalid search_array: ' . $e->getMessage() . "\n"; $row->delete(); continue; } // Tries to fetch ads from search engine try { // Fetch data from database $ads = Model_Ad::search(array('search_string' => arr::get($search_array, 'search_string'), 'offset' => 0, 'created_after' => $time_interval, 'telecommute' => arr::get($search_array, 'telecommute'), 'jobboard_id' => arr::get($search_array, 'jobtype_id'), 'category_id' => arr::get($search_array, 'category_id'), 'jobtype_id' => arr::get($search_array, 'jobtype_id'), 'fields' => array('id', 'title', 'telecommute', 'jobtype_id', 'description', 'company_name', 'company_logo', 'highlight', 'location', 'created_at', 'jobboard_id'))); } catch (Exception $e) { echo 'Could not get any data from search server: ' . $e->getMessage() . "\n"; } // Prepares the email if ($ads['total'] > 0) { foreach ($ads['rows'] as $key => $ad) { $ads['rows'][$key]['link'] = $ads['rows'][$key]['url']; $ads['rows'][$key]['description'] = $ads['rows'][$key]['description']; unset($ads['rows'][$key]['url']); } $filter = arr::get($search_array, 'search_string'); if (arr::get($search_array, 'telecommute')) { $filter .= ", Telecommute"; } if (arr::get($search_array, 'jobtype_id')) { $jobtype = ORM::factory('jobtype', arr::get($search_array, 'jobtype_id')); $filter .= ", " . $jobtype->name; } if (arr::get($search_array, 'category_id')) { $category = ORM::factory('category', arr::get($search_array, 'category_id')); $filter .= ", " . $category->name; } $template = View::factory('emails/mailing', array('ads' => $ads, 'title' => $title . " Report", 'frequency_type' => $frequency_type, 'filter' => $filter, 'unsubscribe_link' => "http://" . Helper_Utils::get_server_domain() . "/mailinglist/remove/?email=" . $row->email . "&id=" . $row->id))->render(); // Send it to user $this->config = Kohana::$config->load('application'); $this->config['global']['email_feed']; Email::send($row->email, $this->config['global']['email_feed'], $title . " Report", $template, TRUE); } } exit(0); }
/** * Sets the ad to ACTIVE and sends out emails to users * @param Integer $ad_id */ private function approve_payment($ad_id) { if (is_numeric($ad_id) && $ad_id > 0) { $ad = ORM::factory('ad', $ad_id); // Set ad to active if ($ad) { $ad->active = 1; $ad->_valid = TRUE; $ad->save(); $ad = ORM::factory('ad', $ad_id); // Updates Facebook & twitter Helper_Utils::send_tweet($ad); // Sends an email notification to the user $title = "Your job ad is ready [{$ad->title}]"; $name = 'User'; if ($ad->company_name) { $name = $ad->company_name; } $amount = $this->config['paypal'][$ad->discount_code]['price_base']; if (1 == $ad->highlight) { $amount += $this->config['paypal'][$ad->discount_code]['price_highlight']; } $template = View::factory('emails/new_ad', array('title' => $title, 'name' => $name, 'url' => Helper_Utils::get_ad_url($ad->title, $ad->id), 'ad_title' => $ad->title, 'id' => $ad->id, 'highlight' => $ad->highlight, 'discount_code' => $ad->discount_code, 'price_base' => $this->config['paypal'][$ad->discount_code]['price_base'], 'price_highlight' => $this->config['paypal'][$ad->discount_code]['price_highlight'], 'amount' => $amount))->render(); Email::send($ad->email, $this->config['global']['email_support'], $title, $template, TRUE); // Send a copy to admin Email::send($this->config['global']['email_support'], $this->config['global']['email_support'], $title, $template, TRUE); } } }
<ul class="guarantee"> <li><span class="imap star seal_guarantee"></span> If you are not happy we will <strong>refund you</strong> within <strong>30 days</strong> after your ad has been approved. No questions asked. <?php echo HTML::anchor('/contact', 'More info'); ?> </li> </ul> </div> <div class="box"> <h3>YOUR AD WILL BE FEATURED AT</h3> <hr /> <?php echo HTML::image(Helper_Utils::static_path('media/img/websites.png'), array('title' => 'Where your ad will be featured at')); ?> </div> <div class="box"> <h3>SECURE TRANSACTION</h3> <hr /> <ul class="secure-transaction"> <li><span class="imap normal lock"></span> <strong>Feel safe when buying your new Ad</strong> Everytime you create a new ad you’re accesing a secure part of our site using a valid and registred SSL certificate. None of your information is kept with us except the job ad form data. </li> </ul>
<div class="row-fluid"> <div class="span8 main-content"> <h1>About</h1> <div class="row-fluid"> <div class="span3"> <?php echo HTML::image(Helper_Utils::static_path('media/img/henrique_barroso.png'), array('id' => 'ceo', 'title' => 'Henrique Barroso - Founder/CEO of 3heap LLC', 'height' => 170, 'width' => 130)); ?> </div> <div class="span9"> <blockquote class="pull-right lead"> “...where hackers and startups meet to work together on amazing projects...” </blockquote> <p><span class="lead">What's Gowork@ ?</span></p> <strong>Gowork@</strong> was born out of the necessity to have a good job board aggregator that could include awesome search engine and give to users specific job ads that are relevant to their needs. <br><br> <p>So with this in mind, <strong>Gowork@</strong> was created. To help people looking for IT jobs all in one place.</p> <p> <hr> <p><span class="lead">Who am I ?</span></p> I've been a developer for almost 10 years, and I started doing freelance in 2009 before creating <?php echo HTML::anchor('http://www.3heap.com/', '3heap'); ?> . <br><br> I understand the needs that a developer have to find amazing, legit and creative companies, as I also understand companies that want the best from the best.<br/><br/>
/** * Shows an add */ public function action_view($url = null) { // Regex the url and get the ID if (!$url || !preg_match("/-(\\d*)\$/i", $url, $matches)) { throw new HTTP_Exception_404('Job not found', array('page' => $url)); } // Is numeric ? if (!is_numeric($matches[1])) { throw new HTTP_Exception_404('Job not found', array('page' => $url)); } // Creates ORM Object $ad = ORM::factory('ad', $matches[1]); // Makes sure the date is still new and the ad is set to active = 1 if (!$ad->id || !$ad->active == 1) { throw new HTTP_Exception_404('Job not found', array('page' => $url)); } // Parse URL's into A tags $ad->description = Helper_Utils::link_url($ad->description); // Get similiar jobs if any using cookie saved variables $similiar_ads = $this->search(array('limit' => 5, 'random_order' => true, 'search_string' => arr::get(null, 'search_string', Cookie::get('search_string')), 'jobtype_id' => arr::get(null, 'jobtype_id', $ad->jobtype_id), 'telecommute' => arr::get(null, 'telecommute', $ad->telecommute))); // If no ads were found in the previously query do a default one using just // the job type if (count($similiar_ads['ads']) === 0) { $similiar_ads = $this->search(array('limit' => 5, 'random_order' => true, 'jobtype_id' => arr::get(null, 'jobtype_id', $ad->jobtype_id))); } // show ad $this->template->title = __($ad->title); $this->template->description = Text::limit_words(strip_tags($ad->description), 80); $this->template->content = View::factory('ads/ad', array('ad' => $ad, 'config' => $this->config, 'similiar_ads' => $similiar_ads['ads'])); }
private function add_ad($fields) { $ad = ORM::factory('ad'); $fields = array('title' => $fields['title'], 'description' => $fields['description'], 'budget' => null, 'category_id' => null, 'jobtype_id' => $fields['jobtype_id'], 'contact' => $fields['contact'], 'category_id' => 2, 'location' => $fields['location'], 'company_name' => $fields['company_name'], 'company_url' => $fields['company_url'], 'telecommute' => $fields['telecommute'], 'created_at' => $fields['created_at'], 'email' => '*****@*****.**', 'company_logo' => $fields['company_logo'], 'jobboard_id' => $fields['jobboard_id']); $ad->set_fields($fields); $ad->active = 1; $ad->_valid = TRUE; $ad->save(); // Updates Facebook & twitter if ($this->config['stage'] == 'production') { $ad = ORM::factory('ad')->order_by('id', 'desc')->limit(1)->find(); Helper_Utils::send_tweet($ad); } }
} .job-ad { line-height:5px; margin-bottom:40px; } .footer { font-size:11px; color:#b7b7b7; } </style> </head> <body> <?php echo HTML::image(Helper_Utils::static_path("http://gowork.at/media/img/logo_small.png")); ?> <h1>Jobs of the <?php echo $frequency_type; ?> </h1> <hr> <span class="results_filter"> These are results for the matching filter: <strong><?php echo $filter; ?> </strong> </span> <br/><br/>