Esempio n. 1
0
 public static function getDetails($user_group_sid, $referenceUid = false)
 {
     $details = array(array('id' => 'featured', 'caption' => 'Featured', 'type' => 'boolean', 'length' => '20', 'is_required' => false, 'is_system' => true, 'order' => null), array('id' => 'active', 'caption' => 'Status', 'type' => 'list', 'list_values' => array(array('id' => '1', 'caption' => 'Active'), array('id' => '0', 'caption' => 'Not active')), 'length' => '10', 'is_required' => false, 'is_system' => true), array('id' => 'sendmail', 'caption' => "Don't send mailings", 'type' => 'boolean', 'length' => '1', 'is_required' => false, 'is_system' => true));
     $user_group_info = SJB_UserGroupManager::getUserGroupInfoBySID($user_group_sid);
     $email_confirmation = false;
     if (isset($user_group_info['email_confirmation'])) {
         $email_confirmation = $user_group_info['email_confirmation'];
     }
     if (SJB_UserGroupManager::isUserEmailAsUsernameInUserGroup($user_group_sid) || class_exists('SJB_SocialPlugin') && $referenceUid) {
         $userFields = array(array('id' => 'username', 'caption' => 'User name', 'type' => 'string', 'table_name' => 'users', 'length' => '20', 'is_required' => true, 'is_system' => true, 'order' => 0), array('id' => 'password', 'caption' => 'Password', 'type' => 'password', 'length' => '20', 'is_required' => true, 'is_system' => true, 'order' => 2), array('id' => 'email', 'caption' => 'Email', 'type' => 'unique_email', 'table_name' => 'users', 'length' => '20', 'is_required' => true, 'is_system' => true, 'order' => 1, 'email_confirmation' => $email_confirmation));
     } else {
         $userFields = array(array('id' => 'username', 'caption' => 'User name', 'type' => 'unique_string', 'table_name' => 'users', 'length' => '20', 'validators' => array('SJB_IdValidator', 'SJB_UniqueSystemValidator'), 'is_required' => true, 'is_system' => true, 'order' => 0), array('id' => 'password', 'caption' => 'Password', 'type' => 'password', 'length' => '20', 'is_required' => true, 'is_system' => true, 'order' => 1), array('id' => 'email', 'caption' => 'Email', 'type' => 'unique_email', 'table_name' => 'users', 'length' => '20', 'is_required' => true, 'is_system' => true, 'order' => 2, 'email_confirmation' => $email_confirmation));
     }
     $details = array_merge($userFields, $details);
     $extra_details = SJB_UserProfileFieldManager::getFieldsInfoByUserGroupSID($user_group_sid);
     foreach ($extra_details as $key => $extra_detail) {
         if ($extra_detail['type'] == 'monetary' || $extra_detail['type'] == 'complex') {
             $extra_details[$key]['is_system'] = false;
         } else {
             $extra_details[$key]['is_system'] = true;
         }
     }
     $details = array_merge($details, $extra_details);
     if (SJB_PluginManager::isPluginActive('CaptchaPlugin') && SJB_System::getSettingByName('registrationCaptcha') == 1 && SJB_System::getURI() == '/registration/') {
         $details_captcha = array(array('id' => 'captcha', 'caption' => 'Enter code from image', 'type' => 'captcha', 'length' => '20', 'is_required' => true, 'is_system' => false));
         $details = array_merge($details, $details_captcha);
     }
     return $details;
 }
Esempio n. 2
0
 public static function getDetails($listing_type_sid, $pageID = 0)
 {
     $system_details = array(array('id' => 'featured', 'caption' => 'Featured', 'type' => 'boolean', 'length' => '20', 'is_required' => false, 'is_system' => true, 'order' => null), array('id' => 'priority', 'caption' => 'Priority Listing', 'type' => 'boolean', 'length' => '20', 'is_required' => false, 'is_system' => true, 'order' => null));
     $listing_field_manager = new SJB_ListingFieldManager();
     $common_details = $listing_field_manager->getCommonListingFieldsInfo($pageID);
     $extra_details = $listing_field_manager->getListingFieldsInfoByListingType($listing_type_sid, $pageID);
     $details = array_merge($common_details, $extra_details);
     foreach ($details as $key => $detail) {
         $details[$key]['is_system'] = true;
         if ($detail['type'] == 'complex' || $detail['id'] == 'ApplicationSettings') {
             $details[$key]['is_system'] = false;
         } elseif ($detail['id'] == 'access_type') {
             $details[$key]['is_system'] = true;
             $details[$key]['list_values'] = array(array('id' => 'everyone', 'caption' => 'Everyone'), array('id' => 'no_one', 'caption' => 'No one'), array('id' => 'only', 'caption' => 'Only selected employers'), array('id' => 'except', 'caption' => 'Everyone except selected employers'));
         }
     }
     $details = array_merge($system_details, $details);
     $isPageLast = SJB_PostingPagesManager::isLastPageByID($pageID, $listing_type_sid);
     if ($isPageLast) {
         $status_details = array(array('id' => 'status', 'caption' => 'Approve Status', 'type' => 'list', 'list_values' => array(array('id' => 'pending', 'caption' => 'Pending'), array('id' => 'approved', 'caption' => 'Approved'), array('id' => 'rejected', 'caption' => 'Rejected')), 'is_required' => false, 'is_system' => true, 'order' => 1000000));
         $details = array_merge($details, $status_details);
         $rejectReasonDetails = array(array('id' => 'reject_reason', 'caption' => 'Reject Reason', 'type' => 'text', 'is_required' => false, 'is_system' => true, 'order' => 1000000));
         $details = array_merge($details, $rejectReasonDetails);
         if (SJB_PluginManager::isPluginActive('CaptchaPlugin') && SJB_System::getSettingByName('postJobCaptcha') && strpos(SJB_System::getURI(), '/add-listing/') === 0) {
             $details_captcha = array(array('id' => 'captcha', 'caption' => 'Enter code from image', 'type' => 'captcha', 'length' => '20', 'is_required' => true, 'is_system' => true, 'order' => 10000000));
             $details = array_merge($details, $details_captcha);
         }
     }
     return $details;
 }
 public static function init()
 {
     if (SJB_System::getSettingByName('google_TrackingID') != '') {
         $page_head = '<script type="text/javascript">' . 'var _gaq = _gaq || [];' . '_gaq.push(["_setAccount", "' . SJB_System::getSettingByName('google_TrackingID') . '"]);' . '_gaq.push(["_addOrganic", "images.yandex.ru", "text"]);' . '_gaq.push(["_addOrganic", "images.google.ru", "q"]);' . '_gaq.push(["_addOrganic", "go.mail.ru", "q"]);' . '_gaq.push(["_addOrganic", "gogo.ru", "q"]);' . '_gaq.push(["_addOrganic", "nova.rambler.ru", "query"]);' . '_gaq.push(["_addOrganic", "rambler.ru", "words"]);' . '_gaq.push(["_addOrganic", "google.com.ua", "q"]);' . '_gaq.push(["_addOrganic", "search.ua", "q"]);' . '_gaq.push(["_setDomainName", "none"]);' . '_gaq.push(["_setAllowLinker", true]);' . '_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>';
         $head = SJB_System::getPageHead();
         SJB_System::setPageHead($head . ' ' . $page_head);
     }
 }
 public function initialize()
 {
     self::$object = new Google_Client();
     self::$object->setApplicationName('Google+ PHP SJB Application');
     self::$object->setClientId(SJB_System::getSettingByName('oauth2_client_id'));
     self::$object->setClientSecret(SJB_System::getSettingByName('client_secret'));
     self::$object->setRedirectUri(SJB_System::getSystemSettings('SITE_URL') . '/social/?network=google_plus');
     self::$object->setDeveloperKey(SJB_System::getSettingByName('developer_key'));
     self::$object->setScopes($this->scopes);
     return $this->getProfileInformation();
 }
Esempio n. 5
0
 public function execute()
 {
     if (class_exists('SJB_SocialPlugin') && in_array('linkedin', SJB_SocialPlugin::getAvailablePlugins()) && SJB_Settings::getSettingByName('li_allowShareJobs')) {
         if (SJB_SocialPlugin::getProfileObject()) {
             $listing = SJB_Request::getVar('listing');
             $tp = SJB_System::getTemplateProcessor();
             $tp->assign('articleUrl', urlencode(SJB_System::getSystemSettings('SITE_URL') . '/display-job/' . $listing['id'] . '/'));
             $tp->assign('articleTitle', urlencode($listing['Title']));
             $tp->assign('articleSummary', urlencode($listing['JobDescription']));
             $tp->assign('articleSource', urlencode(SJB_System::getSettingByName('site_title')));
             $tp->display('linkedin_share_button.tpl');
         }
     }
 }
Esempio n. 6
0
 /**
  * 
  * @param SJB_PageConfig $page_config
  */
 public static function getPage($page_config)
 {
     SJB_System::setPageTitle($page_config->getPageTitle());
     SJB_System::setGlobalTemplateVariable('user_page_uri', $page_config->getPageUri());
     SJB_System::setPageKeywords($page_config->getPageKeywords());
     SJB_System::setPageDescription($page_config->getPageDescription());
     if ($page_config->getMainContentFunction() == 'add_listing') {
         $passed_parameters_via_uri = SJB_Request::getVar('passed_parameters_via_uri', false);
         if ($passed_parameters_via_uri) {
             $passed_parameters_via_uri = SJB_UrlParamProvider::getParams();
             if (isset($passed_parameters_via_uri[2])) {
                 $page_config->setMainContentFunction('add_listing_step');
             }
         }
     }
     $maincontent = SJB_System::executeFunction($page_config->getMainContentModule(), $page_config->getMainContentFunction(), $page_config->getParameters(), $page_config->getPageUri());
     if ($page_config->hasRawOutput()) {
         return $maincontent;
     }
     $page_templates_set_name = SJB_System::getSystemSettings('PAGE_TEMPLATES_MODULE_NAME');
     $template_supplier = new SJB_TemplateSupplier($page_templates_set_name);
     $tp = new SJB_TemplateProcessor($template_supplier);
     // assign 'highlight_templates' variable to main or index template
     if (SJB_Settings::getSettingByName('highlight_templates') == 1 && SJB_Request::getVar('admin_mode', false, 'COOKIE')) {
         $tp->assign('highlight_templates', true);
     }
     if ($errors = SJB_Error::getErrorContent()) {
         SJB_FlashMessages::getInstance()->addWarning($errors);
     }
     $tp->assign('MAIN_CONTENT', $maincontent);
     $tp->registerGlobalVariables();
     $tp->assign('sjb_version', SJB_System::getSystemSettings('SJB_VERSION'));
     $template = $page_config->getPageTemplate();
     $template_supplier->addContainerTemplate($template);
     if (SJB_Request::isAjax()) {
         $template = SJB_System::getSettingByName('default_page_template_by_http');
     } elseif (SJB_FormBuilderManager::getIfBuilderModeIsSet()) {
         $template = 'index_b.tpl';
     } else {
         if (empty($template)) {
             $template = SJB_Settings::getSettingByName('DEFAULT_PAGE_TEMPLATE');
         }
     }
     return $tp->fetch($template);
 }
 public static function displayBlogContent()
 {
     if (SJB_System::getSettingByName('display_blog_on_homepage') && SJB_System::getSettingByName('rss_url_for_wordpress') !== '') {
         $url = SJB_System::getSettingByName('rss_url_for_wordpress');
         try {
             $feed = Zend_Feed::import($url);
         } catch (Exception $ex) {
             $feed = array();
         }
         $i18n = SJB_I18N::getInstance();
         $items = array();
         foreach ($feed as $feedItem) {
             $date = new Zend_Date($feedItem->pubDate(), DATE_RSS, 'en_US');
             $item = array('date' => $feedItem->pubDate() ? $i18n->getDate($date->toString()) : '', 'title' => $feedItem->title(), 'description' => $feedItem->description(), 'link' => $feedItem->link());
             $items[] = $item;
         }
         return $items;
     }
 }
 public function execute()
 {
     $tp = SJB_System::getTemplateProcessor();
     $action = SJB_Request::getVar('action');
     $template = 'task_scheduler_settings.tpl';
     $isPseudoCronEnabled = intval(SJB_Settings::getSettingByName('isPseudoCronEnabled')) == 1;
     if (SJB_Request::getVar('command', null, 'post') == 'manage-pseudo-cron') {
         SJB_Settings::updateSetting('isPseudoCronEnabled', SJB_Request::getVar('isEnabled', 'off', 'post') == 'on' ? '1' : '0');
         SJB_Settings::updateSetting('numberOfPageViewsToExecCronIfExceeded', SJB_Request::getVar('numberOfPageViewsToExecCronIfExceeded', null, 'post'));
         SJB_HelperFunctions::redirect(SJB_System::getSystemSettings('SITE_URL') . '/task-scheduler-settings');
     }
     $tp->assign('isPseudoCronEnabled', $isPseudoCronEnabled);
     $numberOfPageViewsToExecCronIfExceeded = intval(SJB_Settings::getSettingByName('numberOfPageViewsToExecCronIfExceeded'));
     $tp->assign('cronPath', SJB_BASE_DIR . 'cron/index.php');
     $tp->assign('numberOfPageViewsToExecCronIfExceeded', $numberOfPageViewsToExecCronIfExceeded);
     if ($action != 'log_view') {
         $last_executed_date = SJB_System::getSettingByName('task_scheduler_last_executed_date');
         $expired_listings_id = SJB_ListingManager::getExpiredListingsSID();
         $count_expired_listings = count($expired_listings_id);
         $expired_contracts_id = SJB_ContractManager::getExpiredContractsID();
         $count_expired_contracts = count($expired_contracts_id);
         $res = SJB_DB::query("SELECT * FROM `task_scheduler_log` ORDER BY `sid` DESC LIMIT 1");
         $tp->assign('last_executed_date', $last_executed_date);
         $tp->assign('task_scheduler_log', array_pop($res));
     } else {
         $log_file = array();
         $res = SJB_DB::query("SELECT `log_text` FROM `task_scheduler_log` ORDER BY `sid` DESC LIMIT 30");
         foreach ($res as $record) {
             $text = $record['log_text'];
             if ($text) {
                 $log_file[] = $text;
             }
         }
         $tp->assign('log_content', $log_file);
         $template = 'task_scheduler_log_view.tpl';
     }
     $tp->display($template);
 }
Esempio n. 9
0
 public function execute()
 {
     $page_id = SJB_Request::getVar('pageid', null);
     if ($page_id) {
         $tp = SJB_System::getTemplateProcessor();
         $i18n = SJB_I18N::getInstance();
         $lang = SJB_Request::getVar('lang', $i18n->getCurrentLanguage());
         $staticContent = SJB_StaticContent::getStaticContentByIDAndLang($page_id, $lang);
         if (empty($staticContent)) {
             $def_lang = SJB_System::getSettingByName('i18n_default_language');
             $staticContent = SJB_StaticContent::getStaticContentByIDAndLang($page_id, $def_lang);
         }
         if (!empty($staticContent)) {
             if ($page_id == '404') {
                 $isLoggedIn = SJB_Authorization::isUserLoggedIn();
                 if ($isLoggedIn) {
                     $listingTypesInfo = SJB_ListingTypeManager::getAllListingTypesInfo();
                     $currentUserInfo = SJB_Authorization::getCurrentUserInfo();
                     $userGroupinfo = SJB_UserGroupManager::getUserGroupInfoBySID($currentUserInfo['user_group_sid']);
                     $acl = SJB_Acl::getInstance();
                     $tp->assign('acl', $acl);
                     $tp->assign('listingTypesInfo', $listingTypesInfo);
                     $tp->assign('userGroupInfo', $userGroupinfo);
                 }
                 $staticContent['content'] = htmlspecialchars_decode($staticContent['content']);
                 $tp->assign('isLoggedIn', $isLoggedIn);
             }
             if (empty($staticContent['content'])) {
                 // Null создаёт ошибку в smarty
                 $staticContent['content'] = '';
             }
             $tp->assign('staticContent', $staticContent['content']);
             $tp->display('static_content.tpl');
         }
     }
 }
Esempio n. 10
0
 public static function getResolvedUserGroupsByNetwork($socNetwork = null)
 {
     if (!$socNetwork) {
         $socNetwork = self::getNetwork();
     }
     return explode(',', SJB_System::getSettingByName($socNetwork . '_userGroup'));
 }
Esempio n. 11
0
 /**
  * @return bool
  */
 private function isCaptchaEnable()
 {
     $isCaptcha = false;
     if (SJB_PluginManager::isPluginActive('CaptchaPlugin') && SJB_Session::getValue('CURRENT_THEME') != 'mobile') {
         $userType = SJB_System::getSystemSettings('SYSTEM_ACCESS_TYPE') != SJB_System::getSystemSettings('ADMIN_ACCESS_TYPE') ? 'user' : 'admin';
         $captchaSettingName = '';
         if (!($currentFunction = SJB_Request::getVar('currentFunction'))) {
             $currentFunction = SJB_Array::get(SJB_System::getModuleManager()->getCurrentFunction(), 1);
         }
         switch ($currentFunction) {
             case 'apply_now':
                 $captchaSettingName = 'contactUserCaptcha';
                 break;
             case 'flag_listing':
                 $captchaSettingName = 'flagListingCaptcha';
                 break;
             case 'tell_friend':
                 $captchaSettingName = 'tellFriendCaptcha';
                 break;
             case 'contact_form':
                 $captchaSettingName = 'contactUsCaptcha';
                 break;
             default:
                 if (SJB_System::getSettingByName('captcha_max_allowed_auth_attempts') != 0) {
                     if (SJB_Session::getValue($userType . 'LoginCounter') >= SJB_System::getSettingByName('captcha_max_allowed_auth_attempts')) {
                         $isCaptcha = true;
                         if (SJB_Session::getValue($userType . 'LoginCounter') == SJB_System::getSettingByName('captcha_max_allowed_auth_attempts')) {
                             SJB_Session::setValue($userType . 'LoginCounter', SJB_Session::getValue($userType . 'LoginCounter') + 1);
                             $this->isNotValidate = true;
                         }
                     }
                 }
         }
         if (!$isCaptcha) {
             $isCaptcha = SJB_System::getSettingByName($captchaSettingName) == 1;
         }
     }
     return $isCaptcha;
 }
Esempio n. 12
0
 function uploadImage($image_file_name, $image_caption)
 {
     $image_info = getimagesize($image_file_name);
     // $image_info['2'] = 1 {GIF}, 2 {JPG}, 3 {PNG}, 4 {SWF}, 5 {PSD}, 6 {BMP}, 7 {TIFF}, 8 {TIFF}, 9 {JPC}, 10 {JP2}, 11 {JPX}
     if ($image_info['2'] >= 1 && $image_info['2'] <= 3) {
         if ($image_info['2'] == 1) {
             $image_resource = imagecreatefromgif($image_file_name);
         } elseif ($image_info['2'] == 2) {
             $image_resource = imagecreatefromjpeg($image_file_name);
         } else {
             $image_resource = imagecreatefrompng($image_file_name);
         }
         $picture_max_size['width'] = SJB_System::getSettingByName('listing_picture_width');
         $picture_max_size['height'] = SJB_System::getSettingByName('listing_picture_height');
         $picture_resource = $this->getResizedImageResource($image_resource, $picture_max_size);
         $thumb_max_size['width'] = SJB_System::getSettingByName('listing_thumbnail_width');
         $thumb_max_size['height'] = SJB_System::getSettingByName('listing_thumbnail_height');
         $thumb_resource = $this->getResizedImageResource($image_resource, $thumb_max_size);
         $max_order = SJB_DB::queryValue("SELECT MAX(`order`) FROM listings_pictures WHERE `listing_sid` = ?n", $this->listing_sid);
         $max_order = empty($max_order) ? 0 : $max_order;
         $order = $max_order + 1;
         $upload_file_directory = SJB_System::getSystemSettings('UPLOAD_FILES_DIRECTORY');
         $picture_sid = SJB_DB::query("INSERT INTO listings_pictures" . " SET `listing_sid` = ?n, `caption` = ?s, `order` = ?n", $this->listing_sid, mb_substr($image_caption, 0, 255), $order);
         $picture_file_basename = 'picture_' . $picture_sid . '.jpg';
         $thumb_file_basename = 'thumb_' . $picture_sid . '.jpg';
         $picture_name = $upload_file_directory . "/pictures/" . $picture_file_basename;
         $thumb_name = $upload_file_directory . "/pictures/" . $thumb_file_basename;
         imagejpeg($picture_resource, $picture_name);
         imagejpeg($thumb_resource, $thumb_name);
         SJB_DB::query("UPDATE listings_pictures SET `picture_saved_name` = ?s, `thumb_saved_name` = ?s WHERE sid = ?n", $picture_file_basename, $thumb_file_basename, $picture_sid);
         $this->setListingPictureAmount($this->getPicturesAmount());
     } else {
         $this->error = 'NOT_SUPPORTED_IMAGE_FORMAT';
         return false;
     }
 }
Esempio n. 13
0
 public function execute()
 {
     $tp = SJB_System::getTemplateProcessor();
     $tp->assign('terms_of_use_check', SJB_System::getSettingByName('terms_of_use_check'));
     $user_group_id = SJB_Request::getVar('user_group_id', null);
     $form_submitted = isset($_REQUEST['action']) && $_REQUEST['action'] == 'register';
     if (!is_null($user_group_id)) {
         $user_group_sid = SJB_UserGroupManager::getUserGroupSIDByID($user_group_id);
         /**
          * check if registration is allowed for this UserGroup
          */
         if (!SJB_SocialPlugin::ifRegistrationIsAllowedByUserGroupSID($user_group_sid)) {
             return null;
         }
         $user_group_info = SJB_UserGroupManager::getUserGroupInfoBySID($user_group_sid);
         $user = SJB_ObjectMother::createUser($_REQUEST, $user_group_sid);
         $user->deleteProperty('active');
         $user->deleteProperty('featured');
         $errors = array();
         // social plugin
         if ($form_submitted) {
             SJB_Event::dispatch('SocialPlugin_AddListingFieldsIntoRegistration', $user, true);
             SJB_Event::dispatch('MakeRegistrationFieldsNotRequired_SocialPlugin', $user, true);
         } else {
             SJB_Event::dispatch('PrepareRegistrationFields_SocialPlugin', $user, true);
             SJB_Event::dispatch('SocialPlugin_AddListingFieldsIntoRegistration', $user, true);
             SJB_Event::dispatch('FillRegistrationData_Plugin', $user, true);
         }
         $registration_form = SJB_ObjectMother::createForm($user);
         $registration_form->registerTags($tp);
         if ($form_submitted && $registration_form->isDataValid($errors)) {
             SJB_Event::dispatch('FillRegistrationData_Plugin', $user, true);
             SJB_Event::dispatch('AddReferencePluginDetails', $user, true);
             $user->deleteProperty('captcha');
             $user->deleteProperty('active');
             $user->deleteProperty('featured');
             SJB_UserManager::saveUser($user);
             SJB_Statistics::addStatistics('addUser', $user->getUserGroupSID(), $user->getSID(), false, 0, 0, false, 0, SJB_SocialPlugin::getNetwork());
             SJB_Statistics::addStatistics('addUser' . SJB_SocialPlugin::getNetwork(), $user->getUserGroupSID(), $user->getSID(), false, 0, 0, false, 0, SJB_SocialPlugin::getNetwork());
             // subscribe user on default product
             $defaultProduct = SJB_UserGroupManager::getDefaultProduct($user_group_sid);
             $availableProductIDs = SJB_ProductsManager::getProductsIDsByUserGroupSID($user_group_sid);
             if ($defaultProduct && in_array($defaultProduct, $availableProductIDs)) {
                 $contract = new SJB_Contract(array('product_sid' => $defaultProduct));
                 $contract->setUserSID($user->getSID());
                 $contract->saveInDB();
             }
             SJB_SocialPlugin::sendUserSocialRegistrationLetter($user);
             // notify administrator
             SJB_AdminNotifications::sendAdminUserRegistrationLetter($user);
             // Activation
             $isSendActivationEmail = SJB_UserGroupManager::isSendActivationEmail($user_group_sid);
             $isApproveByAdmin = SJB_UserGroupManager::isApproveByAdmin($user_group_sid);
             if ($isApproveByAdmin) {
                 SJB_UserManager::setApprovalStatusByUserName($user->getUserName(), 'Pending');
             }
             if ($isSendActivationEmail) {
                 $isSent = SJB_Notifications::sendUserActivationLetter($user->getSID());
                 if ($isSent) {
                     $tp->display('../users/registration_confirm.tpl');
                 } else {
                     $tp->display('../users/registration_failed_to_send_activation_email.tpl');
                 }
             } else {
                 if (!$isSendActivationEmail && $isApproveByAdmin) {
                     SJB_UserManager::setApprovalStatusByUserName($user->getUserName(), 'Pending');
                     $tp->display('../users/registration_pending.tpl');
                 } else {
                     SJB_UserManager::activateUserByUserName($user->getUserName());
                     $errors = array();
                     SJB_Authorization::login($user->getUserName(), $user->getPropertyValue('password'), false, $errors, false);
                     // save access token, profile info for synchronization
                     SJB_SocialPlugin::postRegistration();
                     $tp->assign('socialNetwork', SJB_SocialPlugin::getNetwork());
                     $pageId = !empty($user_group_info['after_registration_redirect_to']) ? $user_group_info['after_registration_redirect_to'] : '';
                     $redirectUrl = SJB_UserGroupManager::getRedirectUrlByPageID($pageId);
                     SJB_HelperFunctions::redirect($redirectUrl);
                 }
             }
         } else {
             // social plugin
             SJB_Event::dispatch('PrepareRegistrationFields_SocialPlugin', $user, true);
             if (SJB_UserGroupManager::isUserEmailAsUsernameInUserGroup($user_group_sid)) {
                 $user->deleteProperty('username');
             }
             $registration_form = SJB_ObjectMother::createForm($user);
             if ($form_submitted) {
                 $registration_form->isDataValid($errors);
             }
             $registration_form->registerTags($tp);
             $registration_form_template = '../users/registration_form.tpl';
             if (isset($_REQUEST['reg_form_template'])) {
                 $registration_form_template = $_REQUEST['reg_form_template'];
             } elseif (!empty($user_group_info['reg_form_template'])) {
                 $registration_form_template = $user_group_info['reg_form_template'];
             }
             $form_fields = $registration_form->getFormFieldsInfo();
             $user_group_info = SJB_UserGroupManager::getUserGroupInfoBySID($user_group_sid);
             $tp->assign('user_group_info', $user_group_info);
             $tp->assign('errors', $errors);
             $tp->assign('user_group_id', $user_group_id);
             $tp->assign('form_fields', $form_fields);
             $metaDataProvider = SJB_ObjectMother::getMetaDataProvider();
             $tp->assign('METADATA', array('form_fields' => $metaDataProvider->getFormFieldsMetadata($form_fields)));
             $tp->assign('socialRegistration', true);
             $tp->assign('userTree', true);
             $tp->display($registration_form_template);
         }
     } else {
         $userGroupsSIDs = SJB_SocialPlugin::getResolvedUserGroupsByNetwork();
         $user_groups_info = array();
         foreach ($userGroupsSIDs as $groupSID) {
             array_push($user_groups_info, SJB_UserGroupManager::getUserGroupInfoBySID($groupSID));
         }
         /*
          * if there is only one group available for registration
          * redirect user directly on Registration Fields page
          */
         if (count($user_groups_info) === 1 && !empty($user_groups_info[0]['id'])) {
             SJB_HelperFunctions::redirect(SJB_System::getSystemSettings('SITE_URL') . '/registration-social/?user_group_id=' . $user_groups_info[0]['id']);
         }
         $tp->assign('user_groups_info', $user_groups_info);
         $tp->display('registration_choose_user_group_social.tpl');
     }
 }
Esempio n. 14
0
 public function execute()
 {
     $this->redirectToListingByKeywords();
     // SEO friendly URL for company profile
     $m = array();
     $isCompanyProfilePage = false;
     if (preg_match('#/company/([0-9]+)/.*#', SJB_Navigator::getURI(), $m)) {
         $isCompanyProfilePage = true;
         $params = SJB_FixedUrlParamProvider::getParams($_REQUEST);
         if (!empty($params)) {
             $aliasUsername = SJB_UserManager::getUserNameByUserSID($m[1]);
             if (!empty($aliasUsername)) {
                 $_REQUEST['username']['equal'] = $aliasUsername;
                 $_REQUEST['anonymous']['equal'] = 0;
             }
         }
     }
     if (!empty($_REQUEST['username']['equal']) && is_int($_REQUEST['username']['equal'])) {
         $aliasUsername = SJB_UserManager::getUserNameByUserSID(intval($_REQUEST['username']['equal']));
         if (!empty($aliasUsername)) {
             $_REQUEST['username']['equal'] = $aliasUsername;
         }
     }
     $listingTypeId = SJB_Request::getVar('listing_type_id', 0);
     if (!$listingTypeId) {
         $listingTypeId = isset($_REQUEST['listing_type']['equal']) ? $_REQUEST['listing_type']['equal'] : SJB_Session::getValue('listing_type_id');
     }
     if ($listingTypeId) {
         $_REQUEST['listing_type']['equal'] = $listingTypeId;
     }
     $action = SJB_Request::getVar('action', 'search');
     //XSS defense
     $searchId = SJB_Request::getVar('searchId', false);
     if ($searchId && !is_numeric($searchId)) {
         $_REQUEST['searchId'] = false;
     }
     $request = $_REQUEST;
     if (SJB_System::getSettingByName('turn_on_refine_search_' . $listingTypeId)) {
         switch ($action) {
             case 'refine':
                 $searchID = SJB_Request::getVar('searchId', false);
                 unset($request['searchId']);
                 $criteria_saver = new SJB_ListingCriteriaSaver($searchID);
                 $request = SJB_RefineSearch::mergeCriteria($criteria_saver->getCriteria(), $request);
                 break;
             case 'undo':
                 $param = SJB_Request::getVar('param', false);
                 $field_type = SJB_Request::getVar('type', false);
                 $value = SJB_Request::getVar('value', false);
                 if ($param && $field_type && $value) {
                     $searchID = SJB_Request::getVar('searchId', false);
                     unset($request['searchId']);
                     $criteria_saver = new SJB_ListingCriteriaSaver($searchID);
                     $criteria = $criteria_saver->criteria;
                     if (isset($criteria[$param][$field_type])) {
                         switch ($field_type) {
                             case 'geo':
                                 if ($criteria[$param][$field_type]['location'] == $value) {
                                     unset($criteria[$param]);
                                 }
                                 break;
                             case 'monetary':
                                 if ($criteria[$param][$field_type]['not_less'] == $value) {
                                     $criteria[$param][$field_type]['not_less'] = "";
                                 }
                                 if ($criteria[$param][$field_type]['not_more'] == $value) {
                                     $criteria[$param][$field_type]['not_more'] = "";
                                 }
                                 break;
                             case 'tree':
                                 // search params incoming as string, where params separated by ','
                                 // we need to undo one of them
                                 $params = explode(',', $criteria[$param][$field_type]);
                                 $params = array_flip($params);
                                 unset($params[$value]);
                                 $params = array_flip($params);
                                 $criteria[$param][$field_type] = implode(',', $params);
                                 break;
                             default:
                                 if (is_array($criteria[$param][$field_type])) {
                                     foreach ($criteria[$param][$field_type] as $key => $val) {
                                         if ($val == $value) {
                                             unset($criteria[$param][$field_type][$key]);
                                         }
                                     }
                                 } else {
                                     unset($criteria[$param]);
                                 }
                                 break;
                         }
                     }
                     $criteria['default_sorting_field'] = $request['default_sorting_field'];
                     $criteria['default_sorting_order'] = $request['default_sorting_order'];
                     $criteria['default_listings_per_page'] = $request['default_listings_per_page'];
                     $criteria['results_template'] = $request['results_template'];
                     $request = array_merge($criteria, $request);
                 }
                 break;
         }
     }
     $searchResultsTP = new SJB_SearchResultsTP($request, $listingTypeId, false, true);
     $searchResultsTP->usePriority(true);
     $template = SJB_Request::getVar("results_template", "search_results.tpl");
     $allowViewContactInfo = false;
     if (!empty($_REQUEST['username']['equal'])) {
         $pageID = 'contact_info';
         $username = $_REQUEST['username']['equal'];
         if (SJB_UserManager::isUserLoggedIn()) {
             $current_user = SJB_UserManager::getCurrentUser();
             if (SJB_ContractManager::isPageViewed($current_user->getSID(), $pageID, $username) || $this->acl->isAllowed('view_' . $listingTypeId . '_contact_info') && in_array($this->acl->getPermissionParams('view_' . $listingTypeId . '_contact_info'), array('', '0'))) {
                 $allowViewContactInfo = true;
             } elseif ($this->acl->isAllowed('view_' . $listingTypeId . '_contact_info')) {
                 $viewContactInfo['count_views'] = 0;
                 $contractIDs = $current_user->getContractID();
                 $numberOfContactViewed = SJB_ContractManager::getNumbeOfPagesViewed($current_user->getSID(), $contractIDs, $pageID);
                 foreach ($contractIDs as $contractID) {
                     if ($this->acl->getPermissionParams('view_' . $listingTypeId . '_contact_info', $contractID, 'contract')) {
                         $params = $this->acl->getPermissionParams('view_' . $listingTypeId . '_contact_info', $contractID, 'contract');
                         if (isset($viewContactInfo['count_views'])) {
                             $viewContactInfo['count_views'] += $params;
                             $viewContactInfo['contract_id'] = $contractID;
                         }
                     }
                 }
                 if ($viewContactInfo && $viewContactInfo['count_views'] > $numberOfContactViewed) {
                     $allowViewContactInfo = true;
                     SJB_ContractManager::addViewPage($current_user->getSID(), $pageID, $username, $viewContactInfo['contract_id']);
                 }
             }
         } elseif ($this->acl->isAllowed('view_' . $listingTypeId . '_contact_info')) {
             $allowViewContactInfo = true;
         }
     }
     $tp = $searchResultsTP->getChargedTemplateProcessor();
     SJB_Statistics::addSearchStatistics($searchResultsTP->getListingSidCollectionForCurrentPage(), $listingTypeId);
     $userForm = null;
     if ($isCompanyProfilePage) {
         $user = SJB_UserManager::getObjectBySID(intval($m[1]));
         $userForm = new SJB_Form($user);
         $userForm->registerTags($tp);
     }
     $errors = array();
     if (!empty($searchResultsTP->pluginErrors)) {
         foreach ($searchResultsTP->pluginErrors as $err) {
             $errors[] = $err;
         }
     }
     $tp->assign('errors', $errors);
     $tp->assign('is_company_profile_page', $isCompanyProfilePage);
     $tp->assign("listing_type_id", $listingTypeId);
     $tp->assign('allowViewContactInfo', $allowViewContactInfo);
     if ($userForm) {
         $tp->assign('form_fields', $userForm->getFormFieldsInfo());
     }
     $tp->display($template);
 }
Esempio n. 15
0
 function _getChargedTemplateProcessor(&$listings_structure)
 {
     $tp = SJB_System::getTemplateProcessor();
     $searchCriteria = $this->criteria_saver->getCriteria();
     $listing_type_info = SJB_ListingTypeManager::getListingTypeInfoBySID($this->listing_type_sid);
     if (!empty($listing_type_info['show_brief_or_detailed'])) {
         $is_show_brief_or_detailed = $listing_type_info['show_brief_or_detailed'];
         $show_brief_or_detailed = $this->criteria_saver->getBriefOrDetailedSearch();
         $tp->assign("is_show_brief_or_detailed", $is_show_brief_or_detailed);
         $tp->assign("show_brief_or_detailed", $show_brief_or_detailed);
     }
     $keywordsHighlight = '';
     if (isset($searchCriteria['keywords']) && SJB_System::getSettingByName('use_highlight_for_keywords')) {
         foreach ($searchCriteria['keywords'] as $type => $keywords) {
             $keywordsTrim = trim($keywords);
             if (!empty($keywordsTrim)) {
                 switch ($type) {
                     case 'like':
                     case 'exact_phrase':
                         $keywordsHighlight = json_encode($keywords);
                         break;
                     case 'all_words':
                     case 'any_words':
                         $keywordsHighlight = json_encode(explode(' ', $keywords));
                         break;
                     case 'boolean':
                         $keywordsHighlight = json_encode(SJB_BooleanEvaluator::parse($keywords, true));
                         break;
                 }
             }
         }
     }
     $view = !empty($this->requested_data['view']) ? $this->requested_data['view'] : 'list';
     $tp->assign("keywordsHighlight", $keywordsHighlight);
     $tp->assign("sorting_field", $this->listing_search_structure['sorting_field']);
     $tp->assign("sorting_order", $this->listing_search_structure['sorting_order']);
     $tp->assign("listing_search", $this->listing_search_structure);
     $tp->assign("listings", $listings_structure);
     $tp->assign("searchId", $this->searchId);
     $tp->assign("view_on_map", SJB_System::getSettingByName('view_on_map'));
     $tp->assign("view", $view);
     $listing = new SJB_Listing(array(), $this->listing_type_sid);
     $user = new SJB_User(array());
     $listing_structure_meta_data = SJB_ListingManager::createMetadataForListing($listing, $user);
     if (isset($searchCriteria['username']['equal'])) {
         $userSID = SJB_UserManager::getUserSIDbyUsername($searchCriteria['username']['equal']);
         $user = SJB_UserManager::getObjectBySID($userSID);
         $userInfo = !empty($user) ? SJB_UserManager::createTemplateStructureForUser($user) : null;
         $tp->assign("userInfo", $userInfo);
     }
     if (isset($searchCriteria['listing_type']['equal']) && SJB_System::getSettingByName('turn_on_refine_search_' . $searchCriteria['listing_type']['equal']) && $this->useRefine) {
         $tp->assign("refineSearch", true);
     }
     $metaDataProvider = SJB_ObjectMother::getMetaDataProvider();
     $metadata = array("listing" => $metaDataProvider->getMetaData($listing_structure_meta_data));
     $tp->assign("METADATA", $metadata);
     return $tp;
 }
Esempio n. 16
0
 public function execute()
 {
     $logged_in = false;
     $tp = SJB_System::getTemplateProcessor();
     $shoppingCart = SJB_Request::getVar('shopping_cart', false);
     $proceedToPosting = SJB_Request::getVar('proceed_to_posting', false);
     $productSID = SJB_Request::getVar('productSID', false);
     $listingTypeID = SJB_Request::getVar('listing_type_id', false);
     $errors = array();
     if (SJB_Authorization::isUserLoggedIn() && !isset($_REQUEST['as_user'])) {
         $tp->display('already_logged_in.tpl');
     } else {
         $template = SJB_Request::getVar('template', 'login.tpl');
         $page_config = SJB_System::getPageConfig(SJB_System::getURI());
         if (SJB_Request::getVar('action', false) == 'login') {
             $username = SJB_Request::getVar('username');
             $password = SJB_Request::getVar('password');
             $keep_signed = SJB_Request::getVar('keep', false);
             $login_as_user = false;
             if (isset($_REQUEST['as_user'])) {
                 $login_as_user = true;
                 if (SJB_UserManager::getCurrentUserSID()) {
                     SJB_Authorization::logout();
                 }
             }
             // redirect user to the home page if it's login page or to the same page otherwise
             if (SJB_Request::getVar('return_url', false) != false) {
                 $redirect_url = base64_decode(SJB_Request::getVar('return_url'));
                 if (!empty($proceedToPosting)) {
                     $redirect_url .= '&proceed_to_posting=1&productSID=' . $productSID;
                 }
             } else {
                 if ($page_config->module == 'users' && $page_config->function == 'login') {
                     $redirect_url = SJB_System::getSystemSettings("SITE_URL") . "/my-account/";
                 } else {
                     $redirect_url = SJB_System::getSystemSettings("SITE_URL") . SJB_System::getURI();
                 }
             }
             if (SJB_UserManager::getCurrentUserSID()) {
                 $logged_in = true;
             } else {
                 SJB_UserManager::login($username, $password, $errors, false, $login_as_user);
                 if ($errors) {
                     if (is_null(SJB_Session::getValue('userLoginCounter'))) {
                         SJB_Session::setValue('userLoginCounter', 1);
                     } else {
                         SJB_Session::setValue('userLoginCounter', SJB_Session::getValue('userLoginCounter') + 1);
                     }
                 }
                 if (SJB_Captcha::getInstance($tp, $_REQUEST)->isValid($errors) && empty($errors)) {
                     $logged_in = SJB_Authorization::login($username, $password, $keep_signed, $errors, $login_as_user);
                 }
             }
             if ($logged_in && !$shoppingCart) {
                 SJB_HelperFunctions::redirect($redirect_url);
             }
             $tp->assign('logged_in', $logged_in);
         }
         $return_url = SJB_Request::getVar('return_url', $page_config->function != 'login' && $page_config->function != 'search_form' ? base64_encode(SJB_Navigator::getURIThis()) : false);
         if (!filter_var(SJB_System::getSystemSettings("SITE_URL") . base64_decode($return_url), FILTER_VALIDATE_URL, FILTER_FLAG_PATH_REQUIRED)) {
             $return_url = '';
         }
         $tp->assign('shopping_cart', $shoppingCart);
         $tp->assign('proceedToPosting', $proceedToPosting);
         $tp->assign('productSID', $productSID);
         $tp->assign('listingTypeID', $listingTypeID);
         $tp->assign('return_url', $return_url);
         $tp->assign('ajaxRelocate', SJB_Request::getVar('ajaxRelocate', false));
         $tp->assign('errors', $errors);
         $tp->assign('adminEmail', SJB_System::getSettingByName('system_email'));
         $tp->display($template);
     }
 }
Esempio n. 17
0
    private function runTaskScheduler()
    {
        // Deactivate Expired Listings & Send Notifications
        $listingsExpiredID = SJB_ListingManager::getExpiredListingsSID();
        foreach ($listingsExpiredID as $listingExpiredID) {
            SJB_ListingManager::deactivateListingBySID($listingExpiredID, true);
            $listing = SJB_ListingManager::getObjectBySID($listingExpiredID);
            $listingInfo = SJB_ListingManager::createTemplateStructureForListing($listing);
            if (SJB_UserNotificationsManager::isUserNotifiedOnListingExpiration($listing->getUserSID())) {
                SJB_Notifications::sendUserListingExpiredLetter($listingInfo);
            }
            // notify admin
            SJB_AdminNotifications::sendAdminListingExpiredLetter($listingInfo);
        }
        $listingsDeactivatedID = array();
        if (SJB_Settings::getSettingByName('automatically_delete_expired_listings')) {
            $listingsDeactivatedID = SJB_ListingManager::getDeactivatedListingsSID();
            foreach ($listingsDeactivatedID as $listingID) {
                SJB_ListingManager::deleteListingBySID($listingID);
            }
        }
        SJB_ListingManager::unFeaturedListings();
        SJB_ListingManager::unPriorityListings();
        SJB_Cache::getInstance()->clean('matchingAnyTag', array(SJB_Cache::TAG_LISTINGS));
        /////////////////////////// Send remind notifications about expiration of LISTINGS
        // 1. get user sids and days count of 'remind listing notification' setting = 1 from user_notifications table
        // 2. foreach user:
        //   - get listings with that expiration remind date
        //   - check every listing sid in DB table of sended. If sended - remove from send list
        //   - send notification with listings to user
        //   - write listings sid in DB table of sended notifications
        $notificationData = SJB_UserNotificationsManager::getUsersAndDaysOnListingExpirationRemind();
        foreach ($notificationData as $elem) {
            $userSID = $elem['user_sid'];
            $days = $elem['days'];
            $listingSIDs = SJB_ListingManager::getListingsIDByDaysLeftToExpired($userSID, $days);
            if (empty($listingSIDs)) {
                continue;
            }
            $listingsInfo = array();
            // check listings remind sended
            foreach ($listingSIDs as $key => $sid) {
                if (SJB_ListingManager::isListingNotificationSended($sid)) {
                    unset($listingSIDs[$key]);
                    continue;
                }
                $info = SJB_ListingManager::getListingInfoBySID($sid);
                $listingsInfo[$sid] = $info;
            }
            if (!empty($listingsInfo)) {
                // now only unsended listings we have in array
                // send listing notification
                foreach ($listingSIDs as $sid) {
                    SJB_Notifications::sendRemindListingExpirationLetter($userSID, $sid, $days);
                }
                // write listing id in DB table of sended notifications
                SJB_ListingManager::saveListingIDAsSendedNotificationsTable($listingSIDs);
            }
        }
        // Send Notifications for Expired Contracts
        $contractsExpiredID = SJB_ContractManager::getExpiredContractsID();
        foreach ($contractsExpiredID as $contractExpiredID) {
            $contractInfo = SJB_ContractManager::getInfo($contractExpiredID);
            $productInfo = SJB_ProductsManager::getProductInfoBySID($contractInfo['product_sid']);
            $userInfo = SJB_UserManager::getUserInfoBySID($contractInfo['user_sid']);
            $serializedExtraInfo = unserialize($contractInfo['serialized_extra_info']);
            if (!empty($serializedExtraInfo['featured_profile']) && !empty($userInfo['featured'])) {
                $contracts = SJB_ContractManager::getAllContractsInfoByUserSID($userInfo['sid']);
                $isFeatured = 0;
                foreach ($contracts as $contract) {
                    if ($contract['id'] != $contractExpiredID) {
                        $serializedExtraInfo = unserialize($contract['serialized_extra_info']);
                        if (!empty($serializedExtraInfo['featured'])) {
                            $isFeatured = 1;
                        }
                    }
                }
                if (!$isFeatured) {
                    SJB_UserManager::removeFromFeaturedBySID($userInfo['sid']);
                }
            }
            if (SJB_UserNotificationsManager::isUserNotifiedOnContractExpiration($contractInfo['user_sid'])) {
                SJB_Notifications::sendUserContractExpiredLetter($userInfo, $contractInfo, $productInfo);
            }
            // notify admin
            SJB_AdminNotifications::sendAdminUserContractExpiredLetter($userInfo['sid'], $contractInfo, $productInfo);
            SJB_ContractManager::deleteContract($contractExpiredID, $contractInfo['user_sid']);
        }
        //////////////////////// Send remind notifications about expiration of contracts
        // 1. get user sids and days count of 'remind subscription notification' setting = 1 from user_notifications table
        // 2. foreach user:
        //   - get contracts with that expiration remind date
        //   - check every contract sid in DB table of sended. If sended - remove from send list
        //   - send notification with contracts to user
        //   - write contract sid in DB table of sended contract notifications
        $notificationData = SJB_UserNotificationsManager::getUsersAndDaysOnSubscriptionExpirationRemind();
        foreach ($notificationData as $elem) {
            $userSID = $elem['user_sid'];
            $days = $elem['days'];
            $contractSIDs = SJB_ContractManager::getContractsIDByDaysLeftToExpired($userSID, $days);
            if (empty($contractSIDs)) {
                continue;
            }
            $contractsInfo = array();
            // check contracts sended
            foreach ($contractSIDs as $key => $sid) {
                if (SJB_ContractManager::isContractNotificationSended($sid)) {
                    unset($contractSIDs[$key]);
                    continue;
                }
                $info = SJB_ContractManager::getInfo($sid);
                $info['extra_info'] = !empty($info['serialized_extra_info']) ? unserialize($info['serialized_extra_info']) : '';
                $contractsInfo[$sid] = $info;
            }
            if (!empty($contractsInfo)) {
                // now only unsended contracts we have in array
                // send contract notification
                foreach ($contractSIDs as $sid) {
                    SJB_Notifications::sendRemindSubscriptionExpirationLetter($userSID, $contractsInfo[$sid], $days);
                }
                // write contract id in DB table of sended contract notifications
                SJB_ContractManager::saveContractIDAsSendedNotificationsTable($contractSIDs);
            }
        }
        // delete applications with no employer and job seeker
        $emptyApplications = SJB_DB::query('SELECT `id` FROM `applications` WHERE `show_js` = 0 AND `show_emp` = 0');
        foreach ($emptyApplications as $application) {
            SJB_Applications::remove($application['id']);
        }
        // NEWS
        $expiredNews = SJB_NewsManager::getExpiredNews();
        foreach ($expiredNews as $article) {
            SJB_NewsManager::deactivateItemBySID($article['sid']);
        }
        // LISTING XML IMPORT
        SJB_XmlImport::runImport();
        // UPDATE PAGES WITH FUNCTION EQUAL BROWSE(e.g. /browse-by-city/)
        SJB_BrowseDBManager::rebuildBrowses();
        //-------------------sitemap generator--------------------//
        SJB_System::executeFunction('miscellaneous', 'sitemap_generator');
        // CLEAR `error_log` TABLE
        $errorLogLifetime = SJB_System::getSettingByName('error_log_lifetime');
        $lifeTime = strtotime("-{$errorLogLifetime} days");
        if ($lifeTime > 0) {
            SJB_DB::query('DELETE FROM `error_log` WHERE `date` < ?t', $lifeTime);
        }
        SJB_Settings::updateSetting('task_scheduler_last_executed_date', $this->currentDate);
        $this->tp->assign('expired_listings_id', $listingsExpiredID);
        $this->tp->assign('deactivated_listings_id', $listingsDeactivatedID);
        $this->tp->assign('expired_contracts_id', $contractsExpiredID);
        $this->tp->assign('notified_saved_searches_id', $this->notifiedSavedSearchesSID);
        $schedulerLog = $this->tp->fetch('task_scheduler_log.tpl');
        SJB_HelperFunctions::writeCronLogFile('task_scheduler.log', $schedulerLog);
        SJB_DB::query('INSERT INTO `task_scheduler_log`
			(`last_executed_date`, `notifieds_sent`, `expired_listings`, `expired_contracts`, `log_text`)
			VALUES ( NOW(), ?n, ?n, ?n, ?s)', count($this->notifiedSavedSearchesSID), count($listingsExpiredID), count($contractsExpiredID), $schedulerLog);
        SJB_System::getModuleManager()->executeFunction('social', 'linkedin');
        SJB_System::getModuleManager()->executeFunction('social', 'facebook');
        SJB_System::getModuleManager()->executeFunction('classifieds', 'linkedin');
        SJB_System::getModuleManager()->executeFunction('classifieds', 'facebook');
        SJB_System::getModuleManager()->executeFunction('classifieds', 'twitter');
        SJB_Event::dispatch('task_scheduler_run');
    }
Esempio n. 18
0
 /**
  * @param array $findZipCodes
  * @param string $city
  * @return string
  */
 private function getQueryForZipCodesByRadius(array $findZipCodes, $city)
 {
     $geoLocation = new SJB_GeoLocation();
     $radiusSearchUnit = SJB_System::getSettingByName('radius_search_unit');
     if ($city) {
         $minLatitude = $maxLatitude = $findZipCodes[0]['latitude'];
         $minLongitude = $maxLongitude = $findZipCodes[0]['longitude'];
         $stateCode = $findZipCodes[0]['state_code'];
         $countrySid = $findZipCodes[0]['country_sid'];
         foreach ($findZipCodes as $zipCode) {
             if ($stateCode != $zipCode['state_code'] || $countrySid != $zipCode['country_sid']) {
                 return '';
             } else {
                 $zipLatitude = $zipCode['latitude'];
                 $zipLongitude = $zipCode['longitude'];
                 if ($zipLatitude < $minLatitude) {
                     $minLatitude = $zipLatitude;
                 } else {
                     if ($zipLatitude > $maxLatitude) {
                         $maxLatitude = $zipLatitude;
                     }
                 }
                 if ($zipLongitude < $minLongitude) {
                     $minLongitude = $zipLongitude;
                 } else {
                     if ($zipLongitude > $maxLongitude) {
                         $maxLongitude = $zipLongitude;
                     }
                 }
             }
         }
         $distance = SJB_LocationManager::getDistanceBetweenPointsInKm($minLatitude, $minLongitude, $maxLatitude, $maxLongitude);
         $distance /= 2;
         $distance += $radiusSearchUnit == 'kilometers' ? $this->value['radius'] : $this->value['radius'] * 1.60934;
         $centralLatitude = ($minLatitude + $maxLatitude) / 2;
         $centralLongitude = ($minLongitude + $maxLongitude) / 2;
         $centralLocation = $geoLocation->fromDegrees($centralLatitude, $centralLongitude);
         $query = SJB_LocationManager::findPlacesWithinDistance($centralLocation, $distance);
         $query .= " AND (`city` != '" . SJB_DB::quote($city) . "')";
     } else {
         $query = array();
         $distance = $radiusSearchUnit == 'kilometers' ? $this->value['radius'] : $this->value['radius'] * 1.60934;
         foreach ($findZipCodes as $zipCode) {
             $myLocation = $geoLocation->fromDegrees($zipCode['latitude'], $zipCode['longitude']);
             $query[] = SJB_LocationManager::findPlacesWithinDistance($myLocation, $distance);
         }
         $query = implode(' OR ', $query);
     }
     return "SELECT `name` FROM `locations` WHERE {$query}";
 }
Esempio n. 19
0
 function uploadFiles($file_id, $subField)
 {
     if (is_null($this->uploaded_file_id)) {
         return false;
     } else {
         if (!empty($_FILES[$file_id]['name'])) {
             $results = array();
             foreach ($_FILES[$file_id]['name'][$subField] as $key => $subFile) {
                 if ($_FILES[$file_id]['error'][$subField][$key]) {
                     $this->error = $this->getErrorId($_FILES[$file_id]['error'][$subField][$key]);
                     $results[$key] = '';
                     continue;
                 }
                 $file_basename = $subFile;
                 $ext = substr($file_basename, 1 + strrpos($file_basename, "."));
                 $file_valid_types = explode(',', SJB_System::getSettingByName('file_valid_types'));
                 if (!in_array(strtolower($ext), $file_valid_types)) {
                     $this->error = 'INVALID_FILE_TYPE';
                     return false;
                 }
                 list($file_name, $saved_file_name) = self::getArrayOfFileNames($file_basename);
                 if (move_uploaded_file($_FILES[$file_id]['tmp_name'][$subField][$key], $file_name)) {
                     SJB_UploadFileManager::deleteUploadedFileByID($this->uploaded_file_id . '_' . $key);
                     SJB_DB::query("INSERT INTO uploaded_files(id, file_name, file_group, saved_file_name, mime_type, creation_time)" . " VALUES(?s, ?s, ?s, ?s, ?s, ?s)", $this->uploaded_file_id . '_' . $key, $subFile, $this->file_group, $saved_file_name, $_FILES[$file_id]['type'][$subField][$key], time());
                     $results[$key] = $this->uploaded_file_id . '_' . $key;
                 }
             }
         }
         return $results;
     }
 }
Esempio n. 20
0
 /**
  * Output buffer handler. Using to catch fatal errors
  *
  * @param string $output
  * @return string
  */
 public static function fatalErrorHandler($output)
 {
     // free piece of memory
     // this was reserved in SJB_System::init() before output buffering
     unset($GLOBALS['fatal_error_reserve_buffer']);
     // RE to determine is there was an error.
     $prefix = ini_get('error_prepend_string');
     $suffix = ini_get('error_append_string');
     $reg = '{^(.*)(' . preg_quote($prefix, '{}') . "<br />\r?\n<b>(\\w+ error)</b>: \\s*" . '(.*?)' . ' in <b>)(.*?)(</b>' . ' on line <b>)(\\d+)(</b><br />' . "\r?\n" . preg_quote($suffix, '{}') . ')()$' . '}s';
     $matches = null;
     if (!preg_match($reg, $output, $matches)) {
         return $output;
     }
     list(, $content, $beforeFile, $error, $msg, $file, $beforeLine, $line, $afterLine, $tail) = $matches;
     $siteURL = SJB_System::getSystemSettings('SITE_URL');
     $errorMode = SJB_System::getSettingByName('error_control_mode');
     $errorText = '';
     if ($errorMode == 'debug') {
         $errorText = "<b>{$error}</b>:  {$msg} in <b>{$file}</b> on line <b>{$line}</b><br />";
     }
     $outHTML = "\n\t\t<html>\n\t\t\t<head>\n\t\t\t\t<link rel=\"stylesheet\" href=\"{$siteURL}/templates/_system/errors/errors.css\" type=\"text/css\">\n\t\t\t</head>\n\t\t\t<body>\n\t\t\t\t<p class=\"error\">Fatal error! Your request can not be executed!</p>\n\t\t\t\t{$errorText}\n\t\t\t</body>\n\t\t</html>";
     SJB_Error::writeToLog(array(array('level' => 'E_ERROR', 'message' => $msg, 'file' => $file, 'line' => $line, 'backtrace' => '')));
     return $outHTML;
 }
Esempio n. 21
0
 /**
  * Shutdown function
  */
 public static function shutdownFunction()
 {
     // get errors handle settings
     $errorLogging = SJB_System::getSettingByName('error_logging');
     $errorLevel = SJB_System::getSettingByName('error_log_level');
     if ($errorLogging) {
         $errors = SJB_Error::getRuntimeErrors($errorLevel);
         if (!empty($errors)) {
             SJB_Error::writeToLog($errors);
         }
     }
 }
Esempio n. 22
0
 public function execute()
 {
     $tp = SJB_System::getTemplateProcessor();
     $display_form = new SJB_Form();
     $display_form->registerTags($tp);
     $current_user = SJB_UserManager::getCurrentUser();
     $errors = array();
     $template = SJB_Request::getVar('display_template', 'display_listing.tpl');
     $tcpdfError = SJB_Request::getVar('error', false);
     $action = substr($template, 0, -4);
     $listing_id = SJB_Request::getVar("listing_id");
     if (isset($_REQUEST['passed_parameters_via_uri'])) {
         $passed_parameters_via_uri = SJB_UrlParamProvider::getParams();
         $listing_id = isset($passed_parameters_via_uri[0]) ? $passed_parameters_via_uri[0] : null;
     }
     if (is_null($listing_id) && SJB_FormBuilderManager::getIfBuilderModeIsSet()) {
         $listing_type_id = SJB_Request::getVar('listing_type_id');
         $listing_id = SJB_ListingManager::getListingIDByListingTypeID($listing_type_id);
     }
     if (is_null($listing_id)) {
         $errors['UNDEFINED_LISTING_ID'] = true;
     } elseif (is_null($listing = SJB_ListingManager::getObjectBySID($listing_id)) || !SJB_ListingManager::isListingAccessableByUser($listing_id, SJB_UserManager::getCurrentUserSID())) {
         $errors['WRONG_LISTING_ID_SPECIFIED'] = true;
     } elseif (!$listing->isActive() && $listing->getUserSID() != SJB_UserManager::getCurrentUserSID()) {
         $errors['LISTING_IS_NOT_ACTIVE'] = true;
     } elseif (($listingStatus = SJB_ListingManager::getListingApprovalStatusBySID($listing_id)) != 'approved' && SJB_ListingTypeManager::getWaitApproveSettingByListingType($listing->listing_type_sid) == 1 && $listing->getUserSID() != SJB_UserManager::getCurrentUserSID()) {
         $errors['LISTING_IS_NOT_APPROVED'] = true;
     } elseif (SJB_ListingTypeManager::getListingTypeIDBySID($listing->listing_type_sid) == 'Resume' && ($template == 'display_job.tpl' or SJB_System::getURI() == '/print-job/') || SJB_ListingTypeManager::getListingTypeIDBySID($listing->listing_type_sid) == 'Job' && ($template == 'display_resume.tpl' or SJB_System::getURI() == '/print-resume/')) {
         $errors['WRONG_DISPLAY_TEMPLATE'] = true;
     } else {
         $listing_type_id = SJB_ListingTypeManager::getListingTypeIDBySID($listing->listing_type_sid);
         if (SJB_System::getURI() == '/print-listing/') {
             SJB_HelperFunctions::redirect(SJB_System::getSystemSettings('SITE_URL') . '/print-' . strtolower($listing_type_id) . '/?listing_id=' . $listing_id);
             exit;
         }
         $listing->addPicturesProperty();
         $display_form = new SJB_Form($listing);
         $display_form->registerTags($tp);
         $form_fields = $display_form->getFormFieldsInfo();
         $listingOwner = SJB_UserManager::getObjectBySID($listing->user_sid);
         if ($action !== 'print_listing') {
             SJB_ListingManager::incrementViewsCounterForListing($listing_id, $listing);
         }
         $listing_structure = SJB_ListingManager::createTemplateStructureForListing($listing, array('comments', 'ratings'));
         $filename = SJB_Request::getVar('filename', false);
         if ($filename) {
             $file = SJB_UploadFileManager::openFile($filename, $listing_id);
             $errors['NO_SUCH_FILE'] = true;
         }
         $metaDataProvider = SJB_ObjectMother::getMetaDataProvider();
         $tp->assign("METADATA", array("listing" => $metaDataProvider->getMetaData($listing_structure['METADATA']), "form_fields" => $metaDataProvider->getFormFieldsMetadata($form_fields)));
         $comments = array();
         $comments_total = '';
         if (SJB_Settings::getSettingByName('show_comments') == '1') {
             $comments = SJB_CommentManager::getEnabledCommentsToListing($listing_id);
             $comments_total = count($comments);
         }
         $searchId = SJB_Request::getVar("searchId", "");
         $page = SJB_Request::getVar("page", "");
         $criteria_saver = new SJB_ListingCriteriaSaver($searchId);
         $searchCriteria = $criteria_saver->getCriteria();
         $keywordsHighlight = '';
         if (isset($searchCriteria['keywords']) && SJB_System::getSettingByName('use_highlight_for_keywords')) {
             foreach ($searchCriteria['keywords'] as $type => $keywords) {
                 switch ($type) {
                     case 'like':
                     case 'exact_phrase':
                         $keywordsHighlight = json_encode($keywords);
                         break;
                     case 'all_words':
                     case 'any_words':
                         $keywordsHighlight = json_encode(explode(' ', $keywords));
                         break;
                     case 'boolean':
                         $keywordsHighlight = json_encode(SJB_BooleanEvaluator::parse($keywords, true));
                         break;
                 }
             }
         }
         $prevNextIds = $criteria_saver->getPreviousAndNextObjectID($listing_id);
         $search_criteria_structure = $criteria_saver->createTemplateStructureForCriteria();
         //permissions contact info
         $acl = SJB_Acl::getInstance();
         $permission = 'view_' . $listing_type_id . '_contact_info';
         $allowViewContactInfo = false;
         if (SJB_UserManager::isUserLoggedIn()) {
             if (SJB_ContractManager::isPageViewed($current_user->getSID(), $permission, $listing_id) || $acl->isAllowed($permission) && in_array($acl->getPermissionParams($permission), array('', '0'))) {
                 $allowViewContactInfo = true;
             } elseif ($acl->isAllowed($permission)) {
                 $viewContactInfo['count_views'] = 0;
                 $contractIDs = $current_user->getContractID();
                 $numberOfContactViewed = SJB_ContractManager::getNumbeOfPagesViewed($current_user->getSID(), $contractIDs, $permission);
                 foreach ($contractIDs as $contractID) {
                     if ($acl->getPermissionParams($permission, $contractID, 'contract')) {
                         $params = $acl->getPermissionParams($permission, $contractID, 'contract');
                         $viewsLeft = SJB_ContractManager::getNumbeOfPagesViewed($current_user->getSID(), array($contractID), $permission);
                         if (isset($viewContactInfo['count_views']) && is_numeric($params)) {
                             $viewContactInfo['count_views'] += $params;
                             if ($params > $viewsLeft) {
                                 $viewContactInfo['contract_id'] = $contractID;
                             }
                         }
                     }
                 }
                 if ($viewContactInfo && $viewContactInfo['count_views'] > $numberOfContactViewed) {
                     $allowViewContactInfo = true;
                     SJB_ContractManager::addViewPage($current_user->getSID(), $permission, $listing_id, $viewContactInfo['contract_id'], $listing->getListingTypeSID());
                 }
             }
             $user_group_id = SJB_UserGroupManager::getUserGroupIDBySID($current_user->getUserGroupSID());
             if ($allowViewContactInfo && $user_group_id == 'JobSeeker' && $listing_type_id == 'Job') {
                 SJB_UserManager::saveRecentlyViewedListings($current_user->getSID(), $listing_id);
             }
         } elseif ($acl->isAllowed($permission)) {
             $allowViewContactInfo = true;
         }
         $tp->assign("keywordsHighlight", $keywordsHighlight);
         $tp->assign('allowViewContactInfo', $allowViewContactInfo);
         $tp->assign('show_rates', SJB_Settings::getSettingByName('show_rates'));
         $tp->assign("isApplied", SJB_Applications::isApplied($listing_id, SJB_UserManager::getCurrentUserSID()));
         $tp->assign('show_rates', SJB_Settings::getSettingByName('show_rates'));
         $tp->assign('show_comments', SJB_Settings::getSettingByName('show_comments'));
         $tp->assign('comments', $comments);
         $tp->assign('comments_total', $comments_total);
         $tp->assign('listing_id', $listing_id);
         $tp->assign("form_fields", $form_fields);
         $tp->assign('video_fields', SJB_HelperFunctions::takeMediaFields($form_fields));
         $tp->assign('uri', base64_encode(SJB_Navigator::getURIThis()));
         $tp->assign('listingOwner', $listingOwner);
         $listing_structure = SJB_ListingManager::newValueFromSearchCriteria($listing_structure, $criteria_saver->criteria);
         // SJB-1197: ajax autoupload.
         // Fix to view video from temporary uploaded storage.
         $sessionFilesStorage = SJB_Session::getValue('tmp_uploads_storage');
         // NEED TO CHECK FOR COMPLEX PARENT AND COMPLEX STEP PARAMETERS!
         $complexParent = SJB_Request::getVar('complexParent');
         $complexStep = SJB_Request::getVar('complexEnum');
         $fieldId = SJB_Request::getVar('field_id');
         $isComplex = false;
         if ($complexParent && $complexStep) {
             $fieldId = $complexParent . ":" . $fieldId . ":" . $complexStep;
             $isComplex = true;
         }
         $tempFileValue = SJB_Array::getPath($sessionFilesStorage, "listings/{$listing_id}/{$fieldId}");
         if ($isComplex) {
             $uploadFileManager = new SJB_UploadFileManager();
             $fileLink = $uploadFileManager->getUploadedFileLink($tempFileValue['file_id']);
             $tp->assign('videoFileLink', $fileLink);
         } else {
             if (!empty($tempFileValue)) {
                 $fileUniqueId = isset($tempFileValue['file_id']) ? $tempFileValue['file_id'] : '';
                 if (!empty($fileUniqueId)) {
                     $upload_manager = new SJB_UploadFileManager();
                     // file structure for videoplayer
                     $fileInfo = array('file_url' => $upload_manager->getUploadedFileLink($fileUniqueId), 'file_name' => $upload_manager->getUploadedFileName($fileUniqueId), 'saved_file_name' => $upload_manager->getUploadedSavedFileName($fileUniqueId), 'file_id' => $fileUniqueId);
                     $listing_structure[$fieldId] = $fileInfo;
                 }
             }
         }
         // SJB-1197
         // GOOGLE MAP SEARCH RESULTS CUSTOMIZATION
         $zipCode = '';
         if (!empty($listing_structure['Location']['ZipCode'])) {
             $zipCode = $listing_structure['Location']['ZipCode'];
         }
         // get 'latitude' and 'longitude' from zipCode field, if it not set
         $latitude = isset($listing_structure['latitude']) ? $listing_structure['latitude'] : '';
         $longitude = isset($listing_structure['longitude']) ? $listing_structure['longitude'] : '';
         if (!empty($zipCode) && empty($latitude) && empty($longitude)) {
             $result = SJB_DB::query("SELECT * FROM `locations` WHERE `name` = ?s LIMIT 1", $zipCode);
             if ($result) {
                 $listing_structure['latitude'] = $result[0]['latitude'];
                 $listing_structure['longitude'] = $result[0]['longitude'];
             }
         } elseif (!empty($listing_structure['Location']['City']) && !empty($listing_structure['Location']['State']) && !empty($listing_structure['Location']['Country'])) {
             $address = $listing_structure['Location']['City'] . ', ' . $listing_structure['Location']['State'] . ', ' . $listing_structure['Location']['Country'];
             $address = urlencode($address);
             $cache = SJB_Cache::getInstance();
             $parameters = array('City' => $listing_structure['Location']['City'], 'State' => $listing_structure['Location']['State'], 'Country' => $listing_structure['Location']['Country']);
             $hash = md5('google_map' . serialize($parameters));
             $data = $cache->load($hash);
             $geoCod = '';
             if (!$data) {
                 try {
                     $geoCod = SJB_HelperFunctions::getUrlContentByCurl("http://maps.googleapis.com/maps/api/geocode/json?address={$address}&sensor=false");
                     $geoCod = json_decode($geoCod);
                     if ($geoCod->status == 'OK') {
                         $cache->save($geoCod, $hash);
                     }
                 } catch (Exception $e) {
                     $backtrace = SJB_Logger::getBackTrace();
                     SJB_Error::writeToLog(array(array('level' => 'E_USER_WARNING', 'message' => $e->getMessage(), 'file' => $e->getFile(), 'line' => $e->getLine(), 'backtrace' => sprintf("BACKTRACE:\n [%s]", join("<br/>\n", $backtrace)))));
                 }
             } else {
                 $geoCod = $data;
             }
             try {
                 if (!is_object($geoCod)) {
                     throw new Exception("Map object nave not been Created");
                 }
                 if ($geoCod->status !== 'OK') {
                     throw new Exception("Status is not OK");
                 }
                 $location = $geoCod->results[0]->geometry->location;
                 $listing_structure['latitude'] = $location->lat;
                 $listing_structure['longitude'] = $location->lng;
             } catch (Exception $e) {
                 $backtrace = SJB_Logger::getBackTrace();
                 SJB_Error::writeToLog(array(array('level' => 'E_USER_WARNING', 'message' => $e->getMessage(), 'file' => $e->getFile(), 'line' => $e->getLine(), 'backtrace' => sprintf("BACKTRACE:\n [%s]", join("<br/>\n", $backtrace)))));
             }
         }
         if (SJB_Request::getVar('view')) {
             $tp->assign('listings', array($listing_structure));
         }
         $tp->filterThenAssign("listing", $listing_structure);
         $tp->assign("prev_next_ids", $prevNextIds);
         $tp->assign("searchId", $searchId);
         $tp->assign("page", $page);
         $tp->filterThenAssign("search_criteria", $search_criteria_structure);
         $tp->filterThenAssign("search_uri", $criteria_saver->getUri());
         if ($field_id = SJB_Request::getVar('field_id')) {
             // SJB-825
             $complexEnum = SJB_Request::getVar('complexEnum', null, 'GET');
             $complexFieldID = SJB_Request::getVar('complexParent', null, 'GET');
             if (!is_null($complexEnum) && !is_null($complexFieldID)) {
                 $videoFileID = $complexFieldID . ':' . $field_id . ':' . $complexEnum . '_' . $listing_id;
                 $videoFileLink = SJB_UploadFileManager::getUploadedFileLink($videoFileID);
                 if ($videoFileLink) {
                     $tp->assign('videoFileLink', $videoFileLink);
                 }
             }
             // SJB-825
             $tp->assign('field_id', $field_id);
         } else {
             if (SJB_Request::getVar('action', false) == 'download_pdf_version') {
                 $formBuilder = SJB_FormBuilderManager::getFormBuilder(SJB_FormBuilderManager::FORM_BUILDER_TYPE_PDF, $listing_type_id);
                 $formBuilder->setChargedTemplateProcessor($tp);
                 $tpl = 'resume_to_pdf.tpl';
                 if ($listing_structure['anonymous'] == '1') {
                     $filename = 'Anonymous User_' . $listing_structure['Title'] . '.pdf';
                 } else {
                     $filename = $listing_structure['user']['FirstName'] . ' ' . $listing_structure['user']['LastName'] . '_' . $listing_structure['Title'] . '.pdf';
                 }
                 try {
                     $html = $tp->fetch($tpl);
                     $html = preg_replace('/<div[^>]*>/', '', $html);
                     $html = str_replace('</div>', '', $html);
                     SJB_HelperFunctions::html2pdf($html, $filename, str_replace('http://', '', SJB_HelperFunctions::getSiteUrl()));
                     exit;
                 } catch (Exception $e) {
                     SJB_Error::writeToLog($e->getMessage());
                     SJB_HelperFunctions::redirect(SJB_System::getSystemSettings("SITE_URL") . '/display-resume/' . $listing_id . '/?error=TCPDF_ERROR');
                 }
             } else {
                 $formBuilder = SJB_FormBuilderManager::getFormBuilder(SJB_FormBuilderManager::FORM_BUILDER_TYPE_DISPLAY, $listing_type_id);
                 $formBuilder->setChargedTemplateProcessor($tp);
             }
         }
     }
     if ($errors) {
         foreach ($errors as $k => $v) {
             switch ($k) {
                 case 'TCPDF_ERROR':
                 case 'UNDEFINED_LISTING_ID':
                 case 'WRONG_LISTING_ID_SPECIFIED':
                 case 'LISTING_IS_NOT_ACTIVE':
                 case 'LISTING_IS_NOT_APPROVED':
                     $header = $_SERVER['SERVER_PROTOCOL'] . ' 404  Not Found';
                     $header_status = "Status: 404  Not Found";
                     header($header_status);
                     header($header);
                     SJB_System::setGlobalTemplateVariable('page_not_found', true);
                     break;
             }
         }
     }
     $tp->assign('errors', $errors);
     $tp->assign('tcpdfError', $tcpdfError);
     $tp->display($template);
 }
Esempio n. 23
0
 public static function deleteFileFromFtp($fileName)
 {
     $host = SJB_System::getSettingByName('backup_ftp_host');
     $user = SJB_System::getSettingByName('backup_ftp_user');
     $password = SJB_System::getSettingByName('backup_ftp_password');
     $ftpDirectory = SJB_System::getSettingByName('backup_ftp_directory');
     $ftpDirectory = $ftpDirectory . $fileName;
     $connect = @ftp_connect($host);
     if ($connect) {
         if (@ftp_login($connect, $user, $password)) {
             if (ftp_size($connect, $ftpDirectory) > 0) {
                 ftp_delete($connect, $ftpDirectory);
             }
             ftp_close($connect);
         } else {
             ftp_close($connect);
         }
     }
 }
Esempio n. 24
0
 public function execute()
 {
     $tp = SJB_System::getTemplateProcessor();
     $errors = array();
     $registration_form_template = 'registration_form.tpl';
     if (SJB_Authorization::isUserLoggedIn()) {
         $tp->display('already_logged_in.tpl');
         return;
     }
     $tp->assign('terms_of_use_check', SJB_System::getSettingByName('terms_of_use_check'));
     $user_group_id = SJB_Request::getVar('user_group_id', null);
     if (!is_null($user_group_id)) {
         $user_group_sid = SJB_UserGroupManager::getUserGroupSIDByID($user_group_id);
         if (empty($user_group_sid)) {
             $errors['NO_SUCH_USER_GROUP_IN_THE_SYSTEM'] = 1;
         }
     }
     $this->setSessionValueForRedirectAfterRegister();
     if (!is_null($user_group_id) && empty($errors)) {
         $user_group_info = SJB_UserGroupManager::getUserGroupInfoBySID($user_group_sid);
         $user = SJB_ObjectMother::createUser($_REQUEST, $user_group_sid);
         if (SJB_Request::isAjax() || 'true' == SJB_Request::getVar('isajaxrequest')) {
             $field = SJB_Request::getVar('type');
             if ('email' == $field) {
                 $user->getProperty($field)->type->disableEmailConfirmation();
             }
             echo $user->getProperty($field)->isValid();
             exit;
         }
         $user->deleteProperty('active');
         $user->deleteProperty('featured');
         $form_submitted = SJB_Request::getVar('action', false) == 'register';
         if (class_exists('MobilePlugin') && MobilePlugin::isMobileThemeOn()) {
             $user->prepareRegistrationFields();
         }
         $registration_form = SJB_ObjectMother::createForm($user);
         $registration_form->registerTags($tp);
         if (SJB_UserGroupManager::isUserEmailAsUsernameInUserGroup($user_group_sid) && $form_submitted) {
             $email = $user->getPropertyValue('email');
             if (is_array($email)) {
                 $email = $email['original'];
             }
             $user->setPropertyValue('username', $email);
         }
         if ($form_submitted && $registration_form->isDataValid($errors)) {
             $user->deleteProperty('captcha');
             $defaultProduct = SJB_UserGroupManager::getDefaultProduct($user_group_sid);
             SJB_UserManager::saveUser($user);
             SJB_Statistics::addStatistics('addUser', $user->getUserGroupSID(), $user->getSID());
             $availableProductIDs = SJB_ProductsManager::getProductsIDsByUserGroupSID($user_group_sid);
             if ($defaultProduct && in_array($defaultProduct, $availableProductIDs)) {
                 $contract = new SJB_Contract(array('product_sid' => $defaultProduct));
                 $contract->setUserSID($user->getSID());
                 $contract->saveInDB();
             }
             // >>> SJB-1197
             // needs to check session for ajax-uploaded files, and set it to user profile
             $formToken = SJB_Request::getVar('form_token');
             $tmpUploadsStorage = SJB_Session::getValue('tmp_uploads_storage');
             if (!empty($formToken)) {
                 $tmpUploadedFields = SJB_Array::getPath($tmpUploadsStorage, $formToken);
                 if (!is_null($tmpUploadsStorage) && is_array($tmpUploadedFields)) {
                     // prepare user profile fields array
                     $userProfileFieldsInfo = SJB_UserProfileFieldManager::getAllFieldsInfo();
                     $userProfileFields = array();
                     foreach ($userProfileFieldsInfo as $field) {
                         $userProfileFields[$field['id']] = $field;
                     }
                     // look for temporary values
                     foreach ($tmpUploadedFields as $fieldId => $fieldInfo) {
                         // check field ID for valid ID in user profile fields
                         if (!array_key_exists($fieldId, $userProfileFields) || empty($fieldInfo)) {
                             continue;
                         }
                         $fieldType = $userProfileFields[$fieldId]['type'];
                         $profilePropertyId = $fieldId . '_' . $user->getSID();
                         switch (strtolower($fieldType)) {
                             case 'video':
                             case 'file':
                                 // change temporary file ID
                                 SJB_DB::query("UPDATE `uploaded_files` SET `id` = ?s WHERE `id` = ?s", $profilePropertyId, $fieldInfo['file_id']);
                                 // set value of user property to new uploaded file
                                 $user->setPropertyValue($fieldId, $profilePropertyId);
                                 break;
                             case 'logo':
                                 // change temporary file ID and thumb ID
                                 SJB_DB::query("UPDATE `uploaded_files` SET `id` = ?s WHERE `id` = ?s", $profilePropertyId, $fieldInfo['file_id']);
                                 SJB_DB::query("UPDATE `uploaded_files` SET `id` = ?s WHERE `id` = ?s", $profilePropertyId . '_thumb', $fieldInfo['file_id'] . '_thumb');
                                 // set value of user property to new uploaded file
                                 $user->setPropertyValue($fieldId, $profilePropertyId);
                                 break;
                             default:
                                 break;
                         }
                         $tmpUploadsStorage = SJB_Array::unsetValueByPath($tmpUploadsStorage, "{$formToken}/{$fieldId}");
                     }
                     // save user with new values
                     SJB_UserManager::saveUser($user);
                     // clean temporary storage
                     $tmpUploadsStorage = SJB_Array::unsetValueByPath($tmpUploadsStorage, "{$formToken}");
                     // CLEAR TEMPORARY SESSION STORAGE
                     SJB_Session::setValue('tmp_uploads_storage', $tmpUploadsStorage);
                 }
             }
             // <<< SJB-1197
             // notifying administrator
             SJB_AdminNotifications::sendAdminUserRegistrationLetter($user);
             // Activation
             $isSendActivationEmail = SJB_UserGroupManager::isSendActivationEmail($user_group_sid);
             $isApproveByAdmin = SJB_UserGroupManager::isApproveByAdmin($user_group_sid);
             if ($isApproveByAdmin) {
                 SJB_UserManager::setApprovalStatusByUserName($user->getUserName(), 'Pending');
             }
             if ($isSendActivationEmail) {
                 $fromAnonymousShoppingCart = SJB_Session::getValue('fromAnonymousShoppingCart');
                 SJB_Session::unsetValue('fromAnonymousShoppingCart');
                 $isSent = SJB_Notifications::sendUserActivationLetter($user->getSID(), $fromAnonymousShoppingCart ? true : false);
                 if ($isSent) {
                     $registration_form_template = 'registration_confirm.tpl';
                 } else {
                     SJB_FlashMessages::getInstance()->addWarning('ERROR_SEND_ACTIVATION_EMAIL');
                     $registration_form_template = 'registration_failed_to_send_activation_email.tpl';
                 }
             } else {
                 if (!$isSendActivationEmail && $isApproveByAdmin) {
                     SJB_UserManager::setApprovalStatusByUserName($user->getUserName(), 'Pending');
                     $registration_form_template = 'registration_pending.tpl';
                 } else {
                     SJB_UserManager::activateUserByUserName($user->getUserName());
                     if (!SJB_SocialPlugin::getProfileSocialID($user->getSID())) {
                         SJB_Notifications::sendUserWelcomeLetter($user->getSID());
                     }
                     SJB_Authorization::login($user->getUserName(), $_REQUEST['password']['original'], false, $errors);
                     $proceedToPosting = SJB_Session::getValue('proceed_to_posting');
                     if ($proceedToPosting) {
                         $redirectUrl = SJB_HelperFunctions::getSiteUrl() . '/add-listing/?listing_type_id=' . SJB_Session::getValue('listing_type_id') . '&proceed_to_posting=' . $proceedToPosting . '&productSID=' . SJB_Session::getValue('productSID');
                     } else {
                         $pageId = !empty($user_group_info['after_registration_redirect_to']) ? $user_group_info['after_registration_redirect_to'] : '';
                         $redirectUrl = SJB_UserGroupManager::getRedirectUrlByPageID($pageId);
                     }
                     SJB_HelperFunctions::redirect($redirectUrl);
                 }
             }
         } else {
             if (SJB_UserGroupManager::isUserEmailAsUsernameInUserGroup($user_group_sid)) {
                 $user->deleteProperty('username');
             }
             $registration_form = SJB_ObjectMother::createForm($user);
             $registration_form->registerTags($tp);
             $registration_form_template = 'registration_form.tpl';
             if (isset($_REQUEST['reg_form_template'])) {
                 $registration_form_template = $_REQUEST['reg_form_template'];
             } elseif (!empty($user_group_info['reg_form_template'])) {
                 $registration_form_template = $user_group_info['reg_form_template'];
             }
             $form_fields = $registration_form->getFormFieldsInfo();
             // define default template with ajax checking
             $registration_form->setDefaultTemplateByFieldName('email', 'email_ajaxchecking.tpl');
             $registration_form->setDefaultTemplateByFieldName('username', 'unique_string.tpl');
             // use specific template for user profile video
             $registration_form->setDefaultTemplateByFieldName('video', 'video_profile.tpl');
             $user_group_info = SJB_UserGroupManager::getUserGroupInfoBySID($user_group_sid);
             $tp->assign('user_group_info', $user_group_info);
             $tp->assign('errors', $errors);
             $tp->assign('form_fields', $form_fields);
             $metaDataProvider = SJB_ObjectMother::getMetaDataProvider();
             $tp->assign('METADATA', array('form_fields' => $metaDataProvider->getFormFieldsMetadata($form_fields)));
         }
     } else {
         $registration_form_template = 'registration_choose_user_group.tpl';
         $user_groups_info = SJB_UserGroupManager::getAllUserGroupsInfo();
         $tp->assign('user_groups_info', $user_groups_info);
     }
     $tp->assign('userTree', true);
     $tp->assign('errors', $errors);
     $tp->display($registration_form_template);
 }
Esempio n. 25
0
 public function execute()
 {
     $errors = array();
     $field_errors = array();
     $tp = SJB_System::getTemplateProcessor();
     $loggedIn = SJB_UserManager::isUserLoggedIn();
     $current_user_sid = SJB_UserManager::getCurrentUserSID();
     $controller = new SJB_SendListingInfoController($_REQUEST);
     $isDataSubmitted = false;
     $jobInfo = SJB_ListingManager::getListingInfoBySID($controller->getListingID());
     if ($controller->isListingSpecified()) {
         if ($controller->isDataSubmitted()) {
             if (SJB_Captcha::getInstance($tp, $_REQUEST)->isValid($errors)) {
                 // получим уникальный id для файла в uploaded_files
                 $file_id_current = 'application_' . md5(microtime());
                 $upload_manager = new SJB_UploadFileManager();
                 $upload_manager->setFileGroup('files');
                 $upload_manager->setUploadedFileID($file_id_current);
                 $file_name = $upload_manager->uploadFile('file_tmp');
                 $id_file = $upload_manager->fileId;
                 $post = $controller->getData();
                 $listingId = 0;
                 $post['submitted_data']['questionnaire'] = '';
                 if (isset($post['submitted_data']['id_resume'])) {
                     $listingId = $post['submitted_data']['id_resume'];
                 }
                 $mimeType = isset($_FILES['file_tmp']['type']) ? $_FILES['file_tmp']['type'] : '';
                 if (isset($_FILES['file_tmp']['size']) && $file_name != '' && $_FILES['file_tmp']['size'] == 0) {
                     $errors['FILE_IS_EMPTY'] = 'The uploaded file should not be blank';
                 }
                 if (!empty($_FILES['file_tmp']['name'])) {
                     $fileFormats = explode(',', SJB_System::getSettingByName('file_valid_types'));
                     $fileInfo = pathinfo($_FILES['file_tmp']['name']);
                     if (!isset($fileInfo['extension']) || !in_array(strtolower($fileInfo['extension']), $fileFormats)) {
                         $errors['NOT_SUPPORTED_FILE_FORMAT'] = strtolower($fileInfo['extension']) . ' ' . SJB_I18N::getInstance()->gettext(null, 'is not in an acceptable file format');
                     }
                 }
                 if ($file_name == '' && $listingId == 0) {
                     $canAppplyWithoutResume = false;
                     SJB_Event::dispatch('CanApplyWithoutResume', $canAppplyWithoutResume);
                     if (!$canAppplyWithoutResume) {
                         $errors['APPLY_INPUT_ERROR'] = 'Please select file or resume';
                     }
                 } else {
                     if (SJB_Applications::isApplied($post['submitted_data']['listing_id'], $current_user_sid) && !is_null($current_user_sid)) {
                         $errors['APPLY_APPLIED_ERROR'] = 'You already applied';
                     }
                 }
                 $res = false;
                 $listing_info = '';
                 $notRegisterUserData = $_POST;
                 $score = 0;
                 // для зарегестрированного пользователя получим поля email и name
                 // для незарегестрированных - поля name и email приходят с формы
                 if ($loggedIn === true) {
                     $userData = SJB_UserManager::getCurrentUserInfo();
                     $post['submitted_data']['username'] = isset($userData['username']) ? $userData['username'] : '';
                     $post['submitted_data']['LastName'] = isset($userData['LastName']) ? $userData['LastName'] : '';
                     $post['submitted_data']['FirstName'] = isset($userData['FirstName']) ? $userData['FirstName'] : '';
                     $post['submitted_data']['name'] = $post['submitted_data']['FirstName'] . ' ' . $post['submitted_data']['LastName'];
                     $post['submitted_data']['email'] = $userData['email'];
                 }
                 if (!empty($jobInfo['screening_questionnaire'])) {
                     $questions = new SJB_Questions($_REQUEST, $jobInfo['screening_questionnaire']);
                     $add_form = new SJB_Form($questions);
                     $add_form->registerTags($tp);
                     $add_form->isDataValid($field_errors);
                     $tp->assign('field_errors', $field_errors);
                     if (!$field_errors) {
                         $result = array();
                         $properties = $questions->getProperties();
                         $countAnswers = 0;
                         foreach ($properties as $key => $val) {
                             if ($val->type->property_info['type'] == 'boolean') {
                                 switch ($val->value) {
                                     case 0:
                                         $val->value = 'No';
                                         break;
                                     case 1:
                                         $val->value = 'Yes';
                                         break;
                                 }
                             }
                             $result[$val->caption] = $val->value;
                             if (isset($val->type->property_info['list_values'])) {
                                 foreach ($val->type->property_info['list_values'] as $list_values) {
                                     if (is_array($val->value)) {
                                         foreach ($val->value as $value) {
                                             if ($value == $list_values['id'] && $list_values['score'] != 'no') {
                                                 $score += $list_values['score'];
                                                 $countAnswers++;
                                             }
                                         }
                                     } else {
                                         if ($val->value == $list_values['id'] && $list_values['score'] != 'no') {
                                             $score += $list_values['score'];
                                             $countAnswers++;
                                         }
                                     }
                                 }
                             }
                         }
                         if ($countAnswers === 0) {
                             $score = 0.0;
                         } else {
                             $score = round($score / $countAnswers, 2);
                         }
                         $post['submitted_data']['questionnaire'] = serialize($result);
                     }
                 }
                 if (count($errors) == 0 && count($field_errors) == 0) {
                     $res = SJB_Applications::create($post['submitted_data']['listing_id'], $current_user_sid, isset($post['submitted_data']['id_resume']) ? $post['submitted_data']['id_resume'] : '', $post['submitted_data']['comments'], $file_name, $mimeType, $id_file, isset($post['submitted_data']['anonymous']) ? $post['submitted_data']['anonymous'] : '0', $notRegisterUserData, $post['submitted_data']['questionnaire'], $score);
                     if ($res) {
                         SJB_Statistics::addStatistics('apply', $post['submitted_data']['listing_id'], $res);
                     }
                     if (isset($post['submitted_data']['id_resume']) && $post['submitted_data']['id_resume'] != 0) {
                         $listing_info = SJB_ListingManager::getListingInfoBySID($post['submitted_data']['id_resume']);
                         $emp_sid = SJB_ListingManager::getUserSIDByListingSID($post['submitted_data']['listing_id']);
                         $accessible = SJB_ListingManager::isListingAccessableByUser($post['submitted_data']['id_resume'], $emp_sid);
                         if (!$accessible) {
                             SJB_ListingManager::setListingAccessibleToUser($post['submitted_data']['id_resume'], $emp_sid);
                         }
                     }
                     if (!empty($file_name)) {
                         $file_name = 'files/files/' . $file_name;
                     }
                     SJB_Notifications::sendApplyNow($post, $file_name, $listing_info, $current_user_sid, $notRegisterUserData, $score);
                     if (!empty($jobInfo['screening_questionnaire'])) {
                         $questionnaire = SJB_ScreeningQuestionnaires::getInfoBySID($jobInfo['screening_questionnaire']);
                         if ($questionnaire) {
                             $passing_score = 0;
                             switch ($questionnaire['passing_score']) {
                                 case 'acceptable':
                                     $passing_score = 1;
                                     break;
                                 case 'good':
                                     $passing_score = 2;
                                     break;
                                 case 'very_good':
                                     $passing_score = 3;
                                     break;
                                 case 'excellent':
                                     $passing_score = 4;
                                     break;
                             }
                         }
                         if ($score >= $passing_score && $questionnaire['send_auto_reply_more'] == 1) {
                             if (!empty($questionnaire['email_text_more'])) {
                                 SJB_Notifications::userAutoReply($jobInfo, $current_user_sid, $questionnaire['email_text_more'], $notRegisterUserData);
                             }
                         } elseif ($score < $passing_score && $questionnaire['send_auto_reply_less'] == 1) {
                             if (!empty($questionnaire['email_text_less'])) {
                                 SJB_Notifications::userAutoReply($jobInfo, $current_user_sid, $questionnaire['email_text_less'], $notRegisterUserData);
                             }
                         }
                     }
                 }
                 if ($res === false) {
                     $errors['APPLY_ERROR'] = 'Cannot apply';
                 }
                 $isDataSubmitted = true;
             }
         }
         if (!empty($jobInfo['screening_questionnaire'])) {
             $questions = new SJB_Questions($_REQUEST, $jobInfo['screening_questionnaire']);
             $add_form = new SJB_Form($questions);
             $add_form->registerTags($tp);
             $form_fields = $add_form->getFormFieldsInfo();
             $tp->assign('form_fields', $form_fields);
             $tp->assign('questionsObject', $questions);
         }
         if ($loggedIn) {
             $listing_type_sid = SJB_ListingTypeManager::getListingTypeSIDByID('Resume');
             $wait_approve = SJB_ListingTypeManager::getWaitApproveSettingByListingType($listing_type_sid);
             $approve_status = '';
             if ($wait_approve) {
                 $approve_status = "AND `l`.`status` = 'approved'";
             }
             $result = SJB_DB::query("SELECT `l`.`sid` , `l`.`Title` FROM `listings` as `l`\n\t\t\t\tLEFT JOIN `listing_types` as `lt` ON (`lt`.`sid` = `l`.`listing_type_sid`)\n\t\t\t\tWHERE `lt`.`id` = 'Resume' {$approve_status} AND `l`.`user_sid` = {$current_user_sid} AND `l`.`active`");
             $resume = array();
             foreach ($result as $val) {
                 $resume[$val['sid']] = $val['Title'];
             }
             $tp->assign('resume', $resume);
         }
         $tp->assign('listing', $jobInfo);
     } else {
         $errors['UNDEFINED_LISTING_ID'] = true;
     }
     $tp->assign('request', $_REQUEST);
     $tp->assign('errors', $errors);
     $tp->assign('listing_id', $controller->getListingID());
     $tp->assign('is_data_submitted', $isDataSubmitted);
     $tp->display('apply_now.tpl');
 }
Esempio n. 26
0
 public function execute()
 {
     $tp = SJB_System::getTemplateProcessor();
     $tp->assign('adminEmail', SJB_System::getSettingByName('notification_email'));
     $tp->display('user_banned.tpl');
 }