Example #1
0
 public function execute()
 {
     $tp = SJB_System::getTemplateProcessor();
     //how many error records get from log
     $recordsNum = SJB_Request::getVar('recordsNum', 10);
     $errorLog = SJB_Error::getErrorLog($recordsNum);
     $tp->assign('recordsNum', $recordsNum);
     $tp->assign('errorLog', $errorLog);
     $tp->display('view_error_log.tpl');
 }
Example #2
0
 public function execute()
 {
     $action = SJB_Request::getVar('action');
     $sessionUpdateData = SJB_Session::getValue(self::SESSION_UPDATE_TAG);
     if ($action == 'mark_as_closed') {
         if (is_array($sessionUpdateData)) {
             $sessionUpdateData['closed_by_user'] = true;
             SJB_Session::setValue(self::SESSION_UPDATE_TAG, $sessionUpdateData);
         }
         exit;
     }
     // check updates
     $serverUrl = SJB_System::getSystemSettings('SJB_UPDATE_SERVER_URL');
     $version = SJB_System::getSystemSettings('version');
     // CHECK FOR UPDATES
     $updateInfo = SJB_Session::getValue(self::SESSION_UPDATE_TAG);
     if (empty($updateInfo)) {
         // check URL for accessibility
         $ch = curl_init($serverUrl);
         curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5);
         curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
         curl_exec($ch);
         $urlInfo = curl_getinfo($ch);
         $availableVersion = array();
         $updateStatus = '';
         if ($urlInfo['http_code'] > 0) {
             // OK. Url is accessible - lets get update info
             try {
                 $client = new Zend_Rest_Client($serverUrl);
                 $result = $client->isUpdateAvailable($version['major'], $version['minor'], $version['build'], SJB_System::getSystemSettings('USER_SITE_URL'))->get();
                 if ($result->isSuccess()) {
                     $updateStatus = (string) $result->updateStatus;
                     switch ($updateStatus) {
                         case 'available':
                             $availableVersion = array('major' => (string) $result->version->major, 'minor' => (string) $result->version->minor, 'build' => (string) $result->version->build);
                             break;
                     }
                 }
             } catch (Exception $e) {
                 SJB_Error::writeToLog('Update Check: ' . $e->getMessage());
             }
         }
         $updateInfo = array('availableVersion' => $availableVersion, 'updateStatus' => $updateStatus);
         SJB_Session::setValue(self::SESSION_UPDATE_TAG, $updateInfo);
     } else {
         if (isset($updateInfo['availableVersion']) && !empty($updateInfo['availableVersion'])) {
             if ($updateInfo['availableVersion']['build'] <= $version['build']) {
                 $updateInfo = array('availableVersion' => $updateInfo['availableVersion'], 'updateStatus' => 'none');
             }
         }
     }
     echo json_encode($updateInfo);
     exit;
 }
Example #3
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);
 }
Example #4
0
 public function execute()
 {
     $tp = SJB_System::getTemplateProcessor();
     $displayForm = new SJB_Form();
     $displayForm->registerTags($tp);
     $invoiceSid = SJB_Request::getVar('sid', false);
     if (SJB_Request::getVar('error', false)) {
         SJB_FlashMessages::getInstance()->addWarning('TCPDF_ERROR');
     }
     $action = SJB_Request::getVar('action', false);
     $paymentGateway = SJB_Request::getVar('payment_gateway', false);
     $template = 'print_invoice.tpl';
     $currentUserSID = SJB_UserManager::getCurrentUserSID();
     $invoiceInfo = SJB_InvoiceManager::getInvoiceInfoBySID($invoiceSid);
     if ($invoiceInfo) {
         if ($currentUserSID == $invoiceInfo['user_sid']) {
             $taxInfo = SJB_TaxesManager::getTaxInfoBySID($invoiceInfo['tax_info']['sid']);
             $invoiceInfo = array_merge($invoiceInfo, $_REQUEST);
             if (is_array($taxInfo)) {
                 $taxInfo = array_merge($invoiceInfo['tax_info'], $taxInfo);
             } else {
                 $taxInfo = $invoiceInfo['tax_info'];
             }
             $invoice = new SJB_Invoice($invoiceInfo);
             $invoice->setSID($invoiceSid);
             $userInfo = SJB_UserManager::getUserInfoBySID($currentUserSID);
             $username = $userInfo['CompanyName'] . ' ' . $userInfo['FirstName'] . ' ' . $userInfo['LastName'];
             $user = SJB_UserManager::getObjectBySID($currentUserSID);
             $productsSIDs = SJB_ProductsManager::getProductsIDsByUserGroupSID($userInfo['user_group_sid']);
             $products = array();
             foreach ($productsSIDs as $key => $productSID) {
                 $product = SJB_ProductsManager::getProductInfoBySID($productSID);
                 $products[$key] = $product;
             }
             $displayForm = new SJB_Form($invoice);
             $displayForm->registerTags($tp);
             $show = true;
             if ($action == 'download_pdf_version' || $action == 'print') {
                 $show = false;
             }
             $tp->assign('show', $show);
             $tp->assign('products', $products);
             $tp->assign('invoice_sid', $invoiceSid);
             $tp->assign('invoice_status', $invoiceInfo['status']);
             $tp->assign('username', trim($username));
             $tp->assign('user_sid', $currentUserSID);
             $tp->assign('tax', $taxInfo);
             $userStructure = SJB_UserManager::createTemplateStructureForUser($user);
             $tp->assign('user', $userStructure);
             $tp->assign('include_tax', $invoiceInfo['include_tax']);
             if ($action == 'download_pdf_version') {
                 $template = 'invoice_to_pdf.tpl';
                 $filename = 'invoice_' . $invoiceSid . '.pdf';
                 try {
                     SJB_HelperFunctions::html2pdf($tp->fetch($template), $filename);
                     exit;
                 } catch (Exception $e) {
                     SJB_Error::writeToLog($e->getMessage());
                     SJB_HelperFunctions::redirect(SJB_System::getSystemSettings("SITE_URL") . '/print-invoice/?sid=' . $invoiceSid . '&action=print&error=TCPDF_ERROR');
                 }
             }
         } else {
             SJB_FlashMessages::getInstance()->addError('NOT_OWNER');
         }
     } else {
         SJB_FlashMessages::getInstance()->addError('WRONG_INVOICE_ID_SPECIFIED');
     }
     if ($paymentGateway) {
         $gatewaySID = SJB_PaymentGatewayManager::getSIDByID($paymentGateway);
         $gatewayInfo = SJB_PaymentGatewayManager::getInfoBySID($gatewaySID);
         $tp->assign('gatewayInfo', $gatewayInfo);
     }
     $tp->assign('paymentError', SJB_Request::getVar('payment_error', false));
     $tp->display($template);
 }
Example #5
0
 public function execute()
 {
     ini_set('max_execution_time', 0);
     $tp = SJB_System::getTemplateProcessor();
     $file_info = isset($_FILES['import_file']) ? $_FILES['import_file'] : null;
     $encodingFromCharset = SJB_Request::getVar('encodingFromCharset', 'UTF-8');
     $listingTypeID = SJB_Request::getVar('listing_type_id', null);
     $productSID = SJB_Request::getVar('product_sid', 0);
     $errors = array();
     if ($listingTypeID && $productSID) {
         $acl = SJB_Acl::getInstance();
         $resource = 'post_' . strtolower($listingTypeID);
         if (!$acl->isAllowed($resource, $productSID, 'product')) {
             $errors[] = 'You cannot import listings of this type under the selected product';
         }
     }
     if (!empty($file_info)) {
         $extension = SJB_Request::getVar('file_type');
         if (!SJB_ImportFile::isValidFileExtensionByFormat($extension, $file_info)) {
             $errors['DO_NOT_MATCH_SELECTED_FILE_FORMAT'] = true;
         }
     }
     if (empty($file_info) || $file_info['error'] || $errors) {
         if (isset($file_info['error']) && $file_info['error'] > 0) {
             $errors[SJB_UploadFileManager::getErrorId($file_info['error'])] = 1;
         }
         $listing_types = SJB_ListingTypeManager::getAllListingTypesInfo();
         $products = SJB_ProductsManager::getProductsByProductType('post_listings');
         $tp->assign("uploadMaxFilesize", SJB_UploadFileManager::getIniUploadMaxFilesize());
         $tp->assign('listing_types', $listing_types);
         $tp->assign('products', $products);
         $tp->assign('errors', $errors);
         $tp->assign('charSets', SJB_HelperFunctions::getCharSets());
         $tp->display('import_listings.tpl');
     } else {
         $i18n = SJB_I18N::getInstance();
         $csv_delimiter = SJB_Request::getVar('csv_delimiter', null);
         $activeStatus = SJB_Request::getVar('active', 0);
         $activationDate = SJB_Request::getVar('activation_date', date('Y-m-d'));
         $activationDate = $i18n->getInput('date', $activationDate);
         $non_existed_values_flag = SJB_Request::getVar('non_existed_values', null);
         $productInfo = SJB_ProductsManager::getProductInfoBySID($productSID);
         if (empty($productInfo['listing_duration'])) {
             $expirationDate = '';
         } else {
             $timestamp = strtotime($activationDate . ' + ' . $productInfo['listing_duration'] . ' days');
             $expirationDate = $i18n->getDate(date('Y-m-d', $timestamp));
         }
         $extension = $_REQUEST['file_type'];
         if ($extension == 'xls') {
             $import_file = new SJB_ImportFileXLS($file_info);
         } elseif ($extension == 'csv') {
             $import_file = new SJB_ImportFileCSV($file_info, $csv_delimiter);
         }
         $import_file->parse($encodingFromCharset);
         $listing = $this->CreateListing(array(), $listingTypeID);
         $imported_data = $import_file->getData();
         $isFileImported = true;
         $count = 0;
         $addedListingsSids = array();
         $nonExistentUsers = array();
         foreach ($imported_data as $key => $importedColumn) {
             if ($key == 1) {
                 $imported_data_processor = new SJB_ImportedDataProcessor($importedColumn, $listing);
                 continue;
             }
             if (!$importedColumn) {
                 continue;
             }
             $count++;
             $listingInfo = $imported_data_processor->getData($non_existed_values_flag, $importedColumn);
             $doc = new DOMDocument();
             foreach ($listing->getProperties() as $property) {
                 if ($property->getType() == 'complex' && !empty($listingInfo[$property->id])) {
                     $childFields = SJB_ListingComplexFieldManager::getListingFieldsInfoByParentSID($property->sid);
                     $doc->loadXML($listingInfo[$property->id]);
                     $results = $doc->getElementsByTagName($property->id . 's');
                     $listingInfo[$property->id] = array();
                     foreach ($results as $complexparent) {
                         $i = 1;
                         foreach ($complexparent->getElementsByTagName($property->id) as $result) {
                             $resultXML = simplexml_import_dom($result);
                             foreach ($childFields as $childField) {
                                 if (isset($resultXML->{$childField}['id'])) {
                                     $listingInfo[$property->id][$childField['id']][$i] = XML_Util::reverseEntities((string) $resultXML->{$childField}['id']);
                                 }
                             }
                             $i++;
                         }
                     }
                 } elseif ($property->getType() == 'monetary' && !empty($listingInfo[$property->id])) {
                     $value = $listingInfo[$property->id];
                     $listingInfo[$property->id] = array();
                     $listingInfo[$property->id]['value'] = $value;
                     $defaultCurrency = SJB_CurrencyManager::getDefaultCurrency();
                     $currencyCode = !empty($listingInfo[$property->id . "Currency"]) ? $listingInfo[$property->id . "Currency"] : $defaultCurrency['currency_code'];
                     $currency = SJB_CurrencyManager::getCurrencyByCurrCode($currencyCode);
                     $listingInfo[$property->id]['add_parameter'] = !empty($currency['sid']) ? $currency['sid'] : '';
                     if (isset($listingInfo[$property->id . "Currency"])) {
                         unset($listingInfo[$property->id . "Currency"]);
                     }
                 } elseif ($property->getType() == 'location') {
                     $locationFields = array($property->id . '.Country', $property->id . '.State', $property->id . '.City', $property->id . '.ZipCode');
                     $locationFieldAdded = array();
                     foreach ($locationFields as $locationField) {
                         if (array_key_exists($locationField, $listingInfo)) {
                             switch ($locationField) {
                                 case $property->id . '.Country':
                                     $value = SJB_CountriesManager::getCountrySIDByCountryName($listingInfo[$locationField]);
                                     if (!$value) {
                                         $value = SJB_CountriesManager::getCountrySIDByCountryCode($listingInfo[$locationField]);
                                     }
                                     break;
                                 case $property->id . '.State':
                                     $value = SJB_StatesManager::getStateSIDByStateName($listingInfo[$locationField]);
                                     if (!$value) {
                                         $value = SJB_StatesManager::getStateSIDByStateCode($listingInfo[$locationField]);
                                     }
                                     break;
                                 default:
                                     $value = $listingInfo[$locationField];
                                     break;
                             }
                             $listingInfo[$property->id][str_replace($property->id . '.', '', $locationField)] = $value;
                             $locationFieldAdded[] = str_replace($property->id . '.', '', $locationField);
                         }
                     }
                     if ($property->id == 'Location') {
                         $locationFields = array('Country', 'State', 'City', 'ZipCode');
                         foreach ($locationFields as $locationField) {
                             if (array_key_exists($locationField, $listingInfo) && !in_array($locationField, $locationFieldAdded) && !$listing->getProperty($locationField)) {
                                 switch ($locationField) {
                                     case 'Country':
                                         $value = SJB_CountriesManager::getCountrySIDByCountryName($listingInfo[$locationField]);
                                         if (!$value) {
                                             $value = SJB_CountriesManager::getCountrySIDByCountryCode($listingInfo[$locationField]);
                                         }
                                         break;
                                     case 'State':
                                         $value = SJB_StatesManager::getStateSIDByStateName($listingInfo[$locationField]);
                                         if (!$value) {
                                             $value = SJB_StatesManager::getStateSIDByStateCode($listingInfo[$locationField]);
                                         }
                                         break;
                                     default:
                                         $value = $listingInfo[$locationField];
                                         break;
                                 }
                                 $listingInfo[$property->id][$locationField] = $value;
                             }
                         }
                     }
                 }
             }
             $listing = $this->CreateListing($listingInfo, $listingTypeID);
             $pictures = array();
             if (isset($listingInfo['pictures'])) {
                 $listing->addPicturesProperty();
                 $explodedPictures = explode(';', $listingInfo['pictures']);
                 foreach ($explodedPictures as $picture) {
                     if (!empty($picture)) {
                         $pictures[] = $picture;
                     }
                 }
                 $listing->setPropertyValue('pictures', count($pictures));
             }
             $listing->addActiveProperty($activeStatus);
             $listing->addActivationDateProperty($activationDate);
             $listing->addExpirationDateProperty($expirationDate);
             SJB_ListingDBManager::setListingExpirationDateBySid($listing->sid);
             $listing->setProductInfo(SJB_ProductsManager::getProductExtraInfoBySID($productSID));
             $listing->setPropertyValue('access_type', 'everyone');
             $listing->setPropertyValue('status', 'approved');
             foreach ($listing->getProperties() as $property) {
                 if ($property->getType() == 'tree' && $property->value !== '') {
                     try {
                         $treeImportHelper = new SJB_FieldTreeImportHelper($property->value);
                         $treeValues = $treeImportHelper->parseAndGetValues();
                         $listing->setPropertyValue($property->id, $treeValues);
                         $listing->details->properties[$property->id]->type->property_info['value'] = $treeValues;
                     } catch (Exception $e) {
                         $listing->setPropertyValue($property->id, '');
                         $listing->details->properties[$property->id]->type->property_info['value'] = '';
                         SJB_Error::writeToLog('Listing Import. Tree Field Value Error: ' . $e->getMessage());
                     }
                 } elseif ($property->id == 'ApplicationSettings' && !empty($listingInfo['ApplicationSettings'])) {
                     if (preg_match("^[a-z0-9\\._-]+@[a-z0-9\\._-]+\\.[a-z]{2,}\$^iu", $listingInfo['ApplicationSettings'])) {
                         $listingInfo['ApplicationSettings'] = array('value' => $listingInfo['ApplicationSettings'], 'add_parameter' => 1);
                     } elseif (preg_match("^(https?:\\/\\/)^", $listingInfo['ApplicationSettings'])) {
                         $listingInfo['ApplicationSettings'] = array('value' => $listingInfo['ApplicationSettings'], 'add_parameter' => 2);
                     } else {
                         $listingInfo['ApplicationSettings'] = array('value' => '', 'add_parameter' => '');
                     }
                     //put empty if not valid email or url
                     $listing->details->properties[$property->id]->type->property_info['value'] = $listingInfo['ApplicationSettings'];
                 } elseif ($property->getType() == 'complex') {
                     $childFields = SJB_ListingComplexFieldManager::getListingFieldsInfoByParentSID($property->sid);
                     $complexChildValues = $property->value;
                     foreach ($childFields as $childField) {
                         if ($childField['type'] == 'complexfile' && !empty($complexChildValues[$childField['id']])) {
                             $fieldInfo = SJB_ListingComplexFieldManager::getFieldInfoBySID($childField['sid']);
                             if (!SJB_UploadFileManager::fileImport($listingInfo, $fieldInfo, $property->id)) {
                                 $isFileImported = false;
                             }
                         }
                         if ($property->type->complex->details->properties[$childField['id']]->value == null) {
                             $property->type->complex->details->properties[$childField['id']]->value = array(1 => '');
                             $property->type->complex->details->properties[$childField['id']]->type->property_info['value'] = array(1 => '');
                         }
                     }
                 }
                 // The import of files at import of listings
                 if (in_array($property->getType(), array('file', 'logo', 'video')) && $property->value !== '') {
                     $fieldInfo = SJB_ListingFieldDBManager::getListingFieldInfoByID($property->id);
                     if (!SJB_UploadFileManager::fileImport($listingInfo, $fieldInfo)) {
                         $isFileImported = false;
                     }
                 }
             }
             if ($non_existed_values_flag == 'add') {
                 $this->UpdateListValues($listing);
             }
             if ($listing->getUserSID()) {
                 SJB_ListingManager::saveListing($listing);
                 $listingSid = $listing->getSID();
                 SJB_Statistics::addStatistics('addListing', $listing->getListingTypeSID(), $listingSid);
                 SJB_ListingManager::activateListingBySID($listingSid, false);
                 if (!$this->fillGallery($listingSid, $pictures)) {
                     $isFileImported = false;
                 }
                 $addedListingsSids[] = $listingSid;
             } else {
                 $nonExistentUsers[] = $listingInfo['username'];
                 $count--;
             }
         }
         SJB_BrowseDBManager::addListings($addedListingsSids);
         SJB_ProductsManager::incrementPostingsNumber($productSID, count($addedListingsSids));
         if ($isFileImported && file_exists(SJB_System::getSystemSettings('IMPORT_FILES_DIRECTORY'))) {
             SJB_Filesystem::delete(SJB_System::getSystemSettings('IMPORT_FILES_DIRECTORY'));
         }
         $tp->assign('imported_listings_count', $count);
         $tp->assign('nonExistentUsers', $nonExistentUsers);
         $tp->display('import_listings_result.tpl');
     }
 }
Example #6
0
 /**
  * @return SimpleXMLElement
  * @throws Exception
  */
 public function getGroups()
 {
     if ($this->_accessToken && $this->_accessToken instanceof Zend_Oauth_Token_Access) {
         $client = $this->_accessToken->getHttpClient($this->_options);
         $client->setUri('http://api.linkedin.com/v1/people/~/group-memberships:(group:(id,name))');
         $client->setMethod(Zend_Http_Client::GET);
         $client->setParameterGet('count', 500);
         $response = $client->request();
         try {
             $data = $response->getBody();
             $xml = new SimpleXMLElement($data);
             if ($xml->getName() == 'error') {
                 throw new Exception("LinkedIn Error: {$data}");
             } else {
                 return $xml;
             }
         } catch (Exception $e) {
             SJB_Error::writeToLog($e->getMessage());
         }
     }
 }
Example #7
0
<?php

if (!function_exists('curl_init')) {
    $GLOBALS[SJB_SocialPlugin::SOCIAL_ACCESS_ERROR]['SOCIAL_ACCESS_ERROR'] = 'facebook';
    SJB_Error::writeToLog('Facebook needs the CURL PHP extension.');
    return null;
}
if (!function_exists('json_decode')) {
    $GLOBALS[SJB_SocialPlugin::SOCIAL_ACCESS_ERROR]['SOCIAL_ACCESS_ERROR'] = 'facebook';
    SJB_Error::writeToLog('Facebook needs the JSON PHP extension.');
    return null;
}
require_once 'facebook_social_plugin.php';
SJB_SocialPlugin::loadPlugin('facebook', $socPlugin = new FacebookSocialPlugin());
if ($socPlugin->getNetwork() === SJB_SocialPlugin::getNetwork()) {
    /*
     * login/logout
     */
    SJB_Event::handle('Login_Plugin', array('SJB_SocialPlugin', 'login'));
    SJB_Event::handle('Logout', array('SJB_SocialPlugin', 'logout'), 1000);
    /*
     * registration
     */
    SJB_Event::handle('FillRegistrationDataRequest_Plugin', array('FacebookSocialPlugin', 'fillRegistrationDataWithRequest'));
    SJB_Event::handle('FillRegistrationData_Plugin', array('SJB_SocialPlugin', 'fillRegistrationDataWithUser'));
    SJB_Event::handle('PrepareRegistrationFields_SocialPlugin', array('FacebookSocialPlugin', 'prepareRegistrationFields'));
    SJB_Event::handle('MakeRegistrationFieldsNotRequired_SocialPlugin', array('FacebookSocialPlugin', 'makeRegistrationFieldsNotRequired'));
    SJB_Event::handle('AddReferencePluginDetails', array('SJB_SocialPlugin', 'addReferenceDetails'));
    SJB_Event::handle('SocialPlugin_PostRegistrationActions', array('SJB_SocialPlugin', 'postRegistrationActions'));
    SJB_Event::handle('SocialPlugin_AddListingFieldsIntoRegistration', array('FacebookSocialPlugin', 'addListingFieldsIntoRegistration'));
    /*
Example #8
0
 function send($cron = false)
 {
     if (self::emailScheduling($cron)) {
         if (empty($this->recipient_email)) {
             return false;
         }
         try {
             $mailSettings = array('smtp' => SJB_Settings::getSettingByName('smtp'), 'smtp_host' => SJB_Settings::getSettingByName('smtp_host'), 'smtp_port' => SJB_Settings::getSettingByName('smtp_port'), 'smtp_sender' => SJB_Settings::getSettingByName('smtp_sender'), 'smtp_username' => SJB_Settings::getSettingByName('smtp_username'), 'smtp_password' => SJB_Settings::getSettingByName('smtp_password'), 'smtp_security' => SJB_Settings::getSettingByName('smtp_security'), 'sendmail_path' => SJB_Settings::getSettingByName('sendmail_path'), 'system_email' => SJB_Settings::getSettingByName('system_email'), 'FromName' => SJB_Settings::getSettingByName('FromName'));
             $mail = $this->prepareMail($mailSettings);
             $sent = $mail->Send();
             return array('status' => $sent);
         } catch (Exception $e) {
             SJB_Error::logError(E_WARNING, $e->getMessage(), $e->getFile(), $e->getLine());
         }
         return array('status' => false, 'error_msg' => $e->getMessage());
     }
     return !$cron;
 }
Example #9
0
 public static function getFiles($dir, $filter = ".", $recursive = true, $exclude = array(".svn", "CVS", ".", ".."))
 {
     $files = array();
     if (is_dir($dir)) {
         $dh = opendir($dir);
         if ($dh !== false) {
             while (($dirItem = readdir($dh)) !== false) {
                 $file = $dir . DS . $dirItem;
                 if (is_dir($file)) {
                     if ($recursive && !in_array($dirItem, $exclude)) {
                         $files = array_merge($files, SJB_Filesystem::getFiles($file, $filter, $recursive, $exclude));
                     }
                 } else {
                     if (preg_match("/{$filter}/", $dirItem) === 1) {
                         $files[] = $file;
                     }
                 }
             }
         } else {
             SJB_Error::add("Open directory error '{$dir}'");
         }
     } else {
         SJB_Error::add("Trying to take files from directory {$dir}");
     }
     return $files;
 }
Example #10
0
 /**
  * @return bool
  * @throws Exception
  */
 protected function resendEmails()
 {
     $emailsIDsToResend = SJB_Request::getVar('emails', array());
     if (!is_array($emailsIDsToResend)) {
         throw new Exception('Not valid params to resend email');
     }
     foreach ($emailsIDsToResend as $emailSID) {
         try {
             $this->resendEmailBySID($emailSID);
         } catch (Exception $e) {
             SJB_Error::writeToLog($e->getMessage() . ' Email Log ID:' . $emailSID);
             array_push($this->emailSIDsFaildToSend, $emailSID);
         }
     }
     if (!empty($this->emailSIDsFaildToSend)) {
         throw new Exception('The message(s) were not resent. Please check the settings');
     }
     return true;
 }
 /**
  * get SocialNetwork Profile info from facebook server
  * @param string $accessToken
  */
 public function _getProfileInfoByAccessToken($accessToken = null)
 {
     if ($accessToken) {
         self::$object->setAccessToken($accessToken);
     }
     try {
         self::$oProfile = self::$object->api('/me');
         self::$oProfile = new ArrayObject(self::$oProfile);
         self::$oProfile->setFlags(ArrayObject::ARRAY_AS_PROPS);
         self::$oSocialPlugin = $this;
         return true;
     } catch (Exception $e) {
         SJB_Error::writeToLog($e->getMessage());
     }
     return false;
 }
Example #12
0
 public function execute()
 {
     $tp = SJB_System::getTemplateProcessor();
     $template = 'edit_invoice.tpl';
     $errors = array();
     $invoiceErrors = array();
     $invoiceSID = SJB_Request::getVar('sid', false);
     $action = SJB_Request::getVar('action', false);
     $tcpdfError = SJB_Request::getVar('error', false);
     if ($tcpdfError) {
         $invoiceErrors[] = $tcpdfError;
     }
     $invoiceInfo = SJB_InvoiceManager::getInvoiceInfoBySID($invoiceSID);
     $user_structure = null;
     if ($invoiceInfo) {
         $product_info = array();
         if (array_key_exists('custom_info', $invoiceInfo['items'])) {
             $product_info = $invoiceInfo['items']['custom_info'];
         }
         $invoiceInfo = array_merge($invoiceInfo, $_REQUEST);
         $invoiceInfo['items']['custom_info'] = $product_info;
         $includeTax = $invoiceInfo['include_tax'];
         $invoice = new SJB_Invoice($invoiceInfo);
         $invoice->setSID($invoiceSID);
         $userSID = $invoice->getPropertyValue('user_sid');
         $userExists = SJB_UserManager::isUserExistsByUserSid($userSID);
         $subUserSID = $invoice->getPropertyValue('subuser_sid');
         if (!empty($subUserSID)) {
             $userInfo = SJB_UserManager::getUserInfoBySID($subUserSID);
             $username = $userInfo['username'] . '/' . $userInfo['email'];
         } else {
             $userInfo = SJB_UserManager::getUserInfoBySID($userSID);
             $username = $userInfo['FirstName'] . ' ' . $userInfo['LastName'] . ' ' . $userInfo['ContactName'] . ' ' . $userInfo['CompanyName'] . '/' . $userInfo['email'];
         }
         $taxInfo = $invoice->getPropertyValue('tax_info');
         $productsSIDs = SJB_ProductsManager::getProductsIDsByUserGroupSID($userInfo['user_group_sid']);
         $products = array();
         foreach ($productsSIDs as $key => $productSID) {
             $productInfo = SJB_ProductsManager::getProductInfoBySID($productSID);
             if (!empty($productInfo['pricing_type']) && $productInfo['pricing_type'] == 'volume_based') {
                 $volumeBasedPricing = $productInfo['volume_based_pricing'];
                 $minListings = min($volumeBasedPricing['listings_range_from']);
                 $maxListings = max($volumeBasedPricing['listings_range_to']);
                 $countListings = array();
                 for ($i = $minListings; $i <= $maxListings; $i++) {
                     $countListings[$i]['number_of_listings'] = $i;
                     for ($j = 1; $j <= count($volumeBasedPricing['listings_range_from']); $j++) {
                         if ($i >= $volumeBasedPricing['listings_range_from'][$j] && $i <= $volumeBasedPricing['listings_range_to'][$j]) {
                             $countListings[$i]['price'] = $volumeBasedPricing['price_per_unit'][$j];
                         }
                     }
                 }
                 $productInfo['count_listings'] = $countListings;
             }
             $products[$key] = $productInfo;
         }
         $addForm = new SJB_Form($invoice);
         $addForm->registerTags($tp);
         $tp->assign('userExists', $userExists);
         $tp->assign('products', $products);
         $tp->assign('invoice_sid', $invoiceSID);
         $tp->assign('include_tax', $includeTax);
         $tp->assign('username', trim($username));
         if ($action) {
             switch ($action) {
                 case 'save':
                 case 'apply':
                     $invoiceErrors = $invoice->isValid();
                     if (empty($invoiceErrors) && $addForm->isDataValid($errors)) {
                         $invoice->setFloatNumbersIntoValidFormat();
                         SJB_InvoiceManager::saveInvoice($invoice);
                         if ($action == 'save') {
                             SJB_HelperFunctions::redirect(SJB_System::getSystemSettings("SITE_URL") . '/manage-invoices/');
                         }
                     } else {
                         $invoiceDate = SJB_I18N::getInstance()->getInput('date', $invoice->getPropertyValue('date'));
                         $invoice->setPropertyValue('date', $invoiceDate);
                     }
                     $invoice->setFloatNumbersIntoValidFormat();
                     $taxInfo['tax_amount'] = SJB_I18N::getInstance()->getInput('float', $taxInfo['tax_amount']);
                     break;
                 case 'print':
                 case 'download_pdf_version':
                     $user = SJB_UserManager::getObjectBySID($userSID);
                     $user_structure = SJB_UserManager::createTemplateStructureForUser($user);
                     $template = 'print_invoice.tpl';
                     $username = SJB_Array::get($user_structure, 'CompanyName') . ' ' . SJB_Array::get($user_structure, 'FirstName') . ' ' . SJB_Array::get($user_structure, 'LastName');
                     $tp->assign('username', trim($username));
                     $tp->assign('user', $user_structure);
                     $tp->assign('tax', $taxInfo);
                     if ($action == 'download_pdf_version') {
                         $template = 'invoice_to_pdf.tpl';
                         $filename = 'invoice_' . $invoiceSID . '.pdf';
                         try {
                             SJB_HelperFunctions::html2pdf($tp->fetch($template), $filename);
                             exit;
                         } catch (Exception $e) {
                             SJB_Error::writeToLog($e->getMessage());
                             SJB_HelperFunctions::redirect(SJB_System::getSystemSettings("SITE_URL") . '/edit-invoice/?sid=' . $invoiceSID . '&error=TCPDF_ERROR');
                         }
                     }
                     break;
                 case 'send_invoice':
                     $result = SJB_Notifications::sendInvoiceToCustomer($invoiceSID, $userSID);
                     if ($result) {
                         echo SJB_I18N::getInstance()->gettext("Backend", "Invoice successfully sent");
                     } else {
                         echo SJB_I18N::getInstance()->gettext("Backend", "Invoice not sent");
                     }
                     exit;
                     break;
             }
         }
         $transactions = SJB_TransactionManager::getTransactionsByInvoice($invoiceSID);
         $tp->assign('tax', $taxInfo);
         $tp->assign('transactions', $transactions);
     } else {
         $tp->assign('action', 'edit');
         $errors[] = 'WRONG_INVOICE_ID_SPECIFIED';
         $template = 'errors.tpl';
     }
     $tp->assign("errors", array_merge($errors, $invoiceErrors));
     $tp->display($template);
 }
Example #13
0
 public function current()
 {
     $listing_structure = array();
     $info = current($this->array);
     if (is_numeric($info)) {
         $sid = $info;
         $cache = SJB_Cache::getInstance();
         $cacheID = md5('ListingIterator::SJB_ListingManager::getObjectBySID' . $sid);
         if ($cache->test($cacheID)) {
             $listing = $cache->load($cacheID);
         } else {
             $listing = SJB_ListingManager::getObjectBySID($sid);
             $cache->save($listing, $cacheID, array(SJB_Cache::TAG_LISTINGS));
         }
         $listing->addPicturesProperty();
         $cacheId = md5('SJB_ListingTypeManager::getListingTypeIDBySID' . $listing->getListingTypeSID());
         if (SJB_MemoryCache::has($cacheId)) {
             $listing_type = SJB_MemoryCache::get($cacheId);
         } else {
             $listing_type = SJB_ListingTypeManager::getListingTypeIDBySID($listing->getListingTypeSID());
             SJB_MemoryCache::set($cacheId, $listing_type);
         }
         $listing_structure = SJB_ListingManager::createTemplateStructureForListing($listing);
         $listing_structure = SJB_ListingManager::newValueFromSearchCriteria($listing_structure, $this->criteria);
         if ($this->user_logged_in) {
             $listing_structure['saved_listing'] = SJB_SavedListings::getSavedListingsByUserAndListingSid($this->current_user_sid, $listing->getID());
         }
         $listing_structure['activation_date'] = date('Y-m-d H:i:s', strtotime($listing_structure['activation_date']));
         $listing_structure['expiration_date'] = date('Y-m-d H:i:s', strtotime($listing_structure['expiration_date']));
         $listing_structure['listing_url'] = SJB_System::getSystemSettings('SITE_URL') . "/display-" . strtolower($listing_type) . "/" . $listing->getSID() . "/";
         if (isset($listing->details->properties['EmploymentType'])) {
             $employmentInfo = $listing->details->properties['EmploymentType']->type->property_info;
             $employmentTypes = array();
             $employment = explode(",", $employmentInfo['value']);
             foreach ($employmentInfo['list_values'] as $type) {
                 $empType = str_replace(" ", "", $type['caption']);
                 $employmentTypes[$empType] = 0;
                 if (in_array($type['id'], $employment)) {
                     $employmentTypes[$empType] = 1;
                 }
             }
             $listing_structure['myEmploymentType'] = $employmentTypes;
         }
         // GOOGLE MAP SEARCH RESULTS CUSTOMIZATION
         if ($this->view == 'map') {
             $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) {
                     $current_coordinates = array($result[0]['latitude'], $result[0]['longitude']);
                     if (in_array($current_coordinates, self::$coordinates)) {
                         self::$index += 0.0001;
                     }
                     $listing_structure['latitude'] = $result[0]['latitude'] + self::$index;
                     $listing_structure['longitude'] = $result[0]['longitude'] + self::$index;
                     self::$coordinates = array_merge(self::$coordinates, array($current_coordinates));
                 }
             } 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);
                 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;
                     $current_coordinates = array($location->lat, $location->lng);
                     if (in_array($current_coordinates, self::$coordinates)) {
                         self::$index += 0.0001;
                     }
                     $listing_structure['latitude'] = $location->lat + self::$index;
                     $listing_structure['longitude'] = $location->lng + self::$index;
                     self::$coordinates = array_merge(self::$coordinates, array($current_coordinates));
                 } 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)))));
                 }
             }
         }
     } elseif ($info) {
         $listing_structure = $info;
     }
     return $listing_structure;
 }
Example #14
0
 public function execute()
 {
     $tp = SJB_System::getTemplateProcessor();
     $display_form = new SJB_Form();
     $display_form->registerTags($tp);
     $errors = array();
     $criteria_saver = new SJB_ListingCriteriaSaver('MyListings');
     $listingSID = SJB_Request::getVar("listing_id");
     if (isset($_REQUEST['passed_parameters_via_uri'])) {
         $passed_parameters_via_uri = SJB_UrlParamProvider::getParams();
         $listingSID = isset($passed_parameters_via_uri[0]) ? $passed_parameters_via_uri[0] : null;
     }
     $template = SJB_Request::getVar('display_template', 'display_listing.tpl');
     if (is_null($listingSID)) {
         $errors['UNDEFINED_LISTING_ID'] = true;
     } elseif (is_null($listing = SJB_ListingManager::getObjectBySID($listingSID))) {
         $errors['WRONG_LISTING_ID_SPECIFIED'] = true;
     } elseif (!$listing->isActive() && $listing->getUserSID() != SJB_UserManager::getCurrentUserSID()) {
         $errors['LISTING_IS_NOT_ACTIVE'] = true;
     } else {
         $listing->addPicturesProperty();
         if ($listing->getUserSID() != SJB_UserManager::getCurrentUserSID()) {
             $errors['NOT_OWNER'] = true;
         }
         $display_form = new SJB_Form($listing);
         $display_form->registerTags($tp);
         $form_fields = $display_form->getFormFieldsInfo();
         $listingOwner = SJB_UserManager::getObjectBySID($listing->user_sid);
         // listing preview @author still
         $listingTypeSID = $listing->getListingTypeSID();
         $listingTypeID = SJB_ListingTypeManager::getListingTypeIDBySID($listingTypeSID);
         if (SJB_Request::getInstance()->page_config->uri == '/' . strtolower($listingTypeID) . '-preview/') {
             if (!empty($_SERVER['HTTP_REFERER']) && (stristr($_SERVER['HTTP_REFERER'], 'edit-' . $listingTypeID) || stristr($_SERVER['HTTP_REFERER'], 'clone-job'))) {
                 $tp->assign('referer', $_SERVER['HTTP_REFERER']);
             } else {
                 $lastPage = SJB_PostingPagesManager::getPagesByListingTypeSID($listingTypeSID);
                 $lastPage = array_pop($lastPage);
                 $tp->assign('referer', SJB_System::getSystemSettings('SITE_URL') . '/add-listing/' . $listingTypeID . '/' . $lastPage['page_id'] . '/' . $listing->getSID());
             }
             $tp->assign('checkouted', SJB_ListingManager::isListingCheckOuted($listing->getSID()));
             $tp->assign('contract_id', $listing->contractID);
         }
         $listingStructure = SJB_ListingManager::createTemplateStructureForListing($listing, array('comments', 'ratings'));
         $filename = SJB_Request::getVar('filename', false);
         if ($filename) {
             SJB_UploadFileManager::openFile($filename, $listingSID);
             $errors['NO_SUCH_FILE'] = true;
         }
         $prev_and_next_listing_id = $criteria_saver->getPreviousAndNextObjectID($listingSID);
         $metaDataProvider = SJB_ObjectMother::getMetaDataProvider();
         $tp->assign('METADATA', array('listing' => $metaDataProvider->getMetaData($listingStructure['METADATA']), 'form_fields' => $metaDataProvider->getFormFieldsMetadata($form_fields)));
         $comments = '';
         $comments_total = '';
         if (SJB_Settings::getSettingByName('show_comments') == '1') {
             $comments = SJB_CommentManager::getEnabledCommentsToListing($listingSID);
             $comments_total = count($comments);
         }
         $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', $listingSID);
         $tp->assign('form_fields', $form_fields);
         $tp->assign('video_fields', SJB_HelperFunctions::takeMediaFields($form_fields));
         $tp->filterThenAssign("listing", $listingStructure);
         $tp->assign('prev_next_ids', $prev_and_next_listing_id);
         $tp->assign('preview_listing_sid', SJB_Request::getVar('preview_listing_sid'));
         $tp->assign('listingOwner', $listingOwner);
         if (SJB_Request::getVar('action', false) == 'download_pdf_version') {
             $formBuilder = SJB_FormBuilderManager::getFormBuilder(SJB_FormBuilderManager::FORM_BUILDER_TYPE_PDF, SJB_Array::getPath($listingStructure, 'type/id'));
             $formBuilder->setChargedTemplateProcessor($tp);
             $tpl = 'resume_to_pdf.tpl';
             $filename = $listingStructure['user']['FirstName'] . ' ' . $listingStructure['user']['LastName'] . '_' . $listingStructure['Title'] . '.pdf';
             try {
                 $tp->assign('myListing', 1);
                 $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") . '/my-resume-details/' . $listingSID . '/?error=TCPDF_ERROR');
             }
         } else {
             $formBuilder = SJB_FormBuilderManager::getFormBuilder(SJB_FormBuilderManager::FORM_BUILDER_TYPE_DISPLAY, SJB_Array::getPath($listingStructure, 'type/id'));
             $formBuilder->setChargedTemplateProcessor($tp);
         }
     }
     $search_criteria_structure = $criteria_saver->createTemplateStructureForCriteria();
     $tp->filterThenAssign('search_criteria', $search_criteria_structure);
     $tp->assign('errors', $errors);
     $tp->assign('myListing', true);
     $tp->display($template);
 }
Example #15
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);
         }
     }
 }
Example #16
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;
 }
 public function revokeToken()
 {
     $response = self::$object->revoke();
     if ($response === TRUE) {
         unset($_SESSION['sn']['authorized']);
         unset($_SESSION[self::NETWORK_ID]);
         // revocation successful, clear session
         unset($_SESSION['oauth'][self::NETWORK_ID]);
         if (empty($_SESSION['oauth'][self::NETWORK_ID])) {
             // session destroyed
         } else {
             SJB_Error::writeToLog('Error clearing user\'s session');
         }
     } else {
         SJB_Error::writeToLog("Error revoking user's token:\n\nRESPONSE:\n\n" . print_r($response, TRUE) . "\n\nLINKEDIN OBJ:\n\n" . print_r(self::$object, TRUE));
     }
 }
Example #18
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);
 }
Example #19
0
 /**
  * @param string|bool $patchCode
  */
 private static function logMysqlErrors($patchCode)
 {
     $mysqlErrors = SJB_DB::getMysqlError();
     $mysqlErrors = implode('<br />', $mysqlErrors);
     $errorMessage = 'Can\'t install patch &quot;' . $patchCode . '&quot;<br /><b>reason:</b>' . $mysqlErrors . '<br />';
     SJB_Error::writeToLog(array(array('level' => 'E_WARNING', 'message' => $errorMessage, 'file' => self::UPDATE_DB_FILE)));
 }
Example #20
0
<?php

if (!extension_loaded('openssl')) {
    $GLOBALS[SJB_SocialPlugin::SOCIAL_ACCESS_ERROR]['SOCIAL_ACCESS_ERROR'] = 'linkedin';
    SJB_Error::writeToLog('Linkedin Social Plugin needs the "openssl" PHP extension.');
    return null;
}
require_once 'linkedin_social_plugin.php';
SJB_SocialPlugin::loadPlugin('linkedin', new LinkedinSocialPlugin());
if (LinkedinSocialPlugin::getNetwork() === SJB_SocialPlugin::getNetwork()) {
    SJB_Event::handle('Login_Plugin', array('SJB_SocialPlugin', 'login'));
    SJB_Event::handle('Logout', array('SJB_SocialPlugin', 'logout'), 1000);
    /*
     * REGISTRATION
     */
    SJB_Event::handle('FillRegistrationData_Plugin', array('SJB_SocialPlugin', 'fillRegistrationDataWithUser'));
    SJB_Event::handle('PrepareRegistrationFields_SocialPlugin', array('SJB_SocialPlugin', 'prepareRegistrationFields'));
    SJB_Event::handle('MakeRegistrationFieldsNotRequired_SocialPlugin', array('LinkedinSocialPlugin', 'makeRegistrationFieldsNotRequired'));
    SJB_Event::handle('SocialPlugin_AddListingFieldsIntoRegistration', array('SJB_SocialPlugin', 'addListingFieldsIntoRegistration'));
    SJB_Event::handle('AddReferencePluginDetails', array('SJB_SocialPlugin', 'addReferenceDetails'));
    /*
     * LISTING AUTOFILL SYNCHRONIZATION
     */
    SJB_Event::handle('SocialSynchronization', array('SJB_SocialPlugin', 'autofillListing'));
    SJB_Event::handle('SocialSynchronizationForm', array('SJB_SocialPlugin', 'autofillListingForm'));
    SJB_Event::handle('SocialSynchronizationFields', array('SJB_SocialPlugin', 'autofillListingFields'));
    SJB_Event::handle('SocialSynchronizationFieldsOnPostingPages', array('SJB_SocialPlugin', 'autofillListingFieldsOnPostingPages'));
}