Esempio n. 1
0
/**
 * Вернуть контактные данные фрилансера если есть доступ их смотреть
 * 
 * @param type $login
 * @param type $hash
 * @return \xajaxResponse
 */
function getContactsInfo($login, $hash)
{
    $objResponse = new xajaxResponse();
    if ($hash === paramsHash(array($login))) {
        $freelancer = new freelancer();
        $freelancer->GetUser($login);
        if ($freelancer->uid > 0 && !is_emp($freelancer->role) && is_view_contacts($freelancer->uid) && is_contacts_not_empty($freelancer)) {
            require_once $_SERVER['DOCUMENT_ROOT'] . '/classes/template.php';
            require_once $_SERVER['DOCUMENT_ROOT'] . '/classes/country.php';
            require_once $_SERVER['DOCUMENT_ROOT'] . '/classes/city.php';
            require_once ABS_PATH . '/classes/statistic/StatisticFactory.php';
            require_once ABS_PATH . '/classes/users.php';
            $html = Template::render($_SERVER['DOCUMENT_ROOT'] . '/user/contacts_info.php', array('user' => $freelancer));
            $ga = StatisticFactory::getInstance('GA');
            $ga->queue('event', array('uid' => isset($_SESSION['uid']) ? $_SESSION['uid'] : 0, 'cid' => users::getCid(), 'category' => 'Freelancer', 'action' => 'show_contacts', 'label' => "{'login': '******'}"));
            $objResponse->assign('contacts_info_block', 'innerHTML', $html);
        }
    }
    return $objResponse;
}
Esempio n. 2
0
 function stats()
 {
     jincimport('statistics.statisticfactory');
     jincimport('core.newsletterfactory');
     $session = JFactory::getSession();
     $config = JFactory::getConfig();
     $tzoffset = $config->getValue('config.offset');
     $id = JRequest::getInt('id', 0);
     $stat_type = JRequest::getInt('stat_type', 0);
     $time_type = JRequest::getInt('time_type', 0);
     $start_date = JRequest::getString('start_date');
     $end_date = JRequest::getString('end_date');
     $sdate = JFactory::getDate($start_date, $tzoffset);
     $edate = JFactory::getDate($end_date, $tzoffset);
     $stat = StatisticFactory::getStatistic($stat_type, $time_type, $sdate->toUNIX(), $edate->toUNIX(), $id);
     $values = $stat->getValues();
     $legend = $stat->getTimeValues();
     $session->set('stats.values', $values);
     $session->set('stats.legend', $legend);
     $timeline = $stat->getTimeLine();
     JRequest::setVar('start_date', $timeline->getStartTime());
     JRequest::setVar('end_date', $timeline->getEndTime());
     $stattypes = StatisticFactory::getTypeList();
     $timetypes = StatisticFactory::getTimeList();
     $time_format = $timeline->getJFormat();
     JRequest::setVar('view', 'stats');
     $view = $this->getView('stats', 'html');
     $ninstance = NewsletterFactory::getInstance();
     if ($newsletters = $ninstance->loadNames()) {
         $empty_filter = array("id" => "0", "name" => JText::_('COM_JINC_SELECT_NEWSLETTER'));
         array_unshift($newsletters, $empty_filter);
     } else {
         $newsletters = array(array("id" => "0", "name" => JText::_('COM_JINC_SELECT_NEWSLETTER')));
     }
     $view->assignRef('time_format', $time_format);
     $view->assignRef('stattypes', $stattypes);
     $view->assignRef('timetypes', $timetypes);
     $view->assignRef('newsletters', $newsletters);
     parent::display();
 }
Esempio n. 3
0
ini_set('max_execution_time', 0);
ini_set('memory_limit', '512M');
if (!isset($_SERVER['DOCUMENT_ROOT']) || !strlen($_SERVER['DOCUMENT_ROOT'])) {
    $_SERVER['DOCUMENT_ROOT'] = rtrim(realpath(pathinfo(__FILE__, PATHINFO_DIRNAME) . '/../../'), '/');
}
require_once $_SERVER['DOCUMENT_ROOT'] . "/classes/stdf.php";
require_once ABS_PATH . '/classes/statistic/StatisticFactory.php';
/*
$ga = StatisticFactory::getInstance('GA');
$ga->queue('event', array(
    'uid' => rand(1,100),
    'cid' => md5('solt-uid-' . rand(1,100)),
     'category' => 'Freelancer',
     'action' => 'registration'
));
*/
$cid = md5('test');
$data = array('category' => 'Freelancer', 'action' => 'registration');
try {
    $ga = StatisticFactory::getInstance('GA', array('cid' => $cid, 'sc' => 'start', 'cd5' => 888));
    $res = $ga->call('event', $data);
    $url = $ga->getLastRequest()->getBaseUrlWithQuery();
    print_r($url);
    exit;
    print_r($res->getCoreResponse()->getHeaders());
    print_r($res->getCoreResponse()->getContent());
    exit;
} catch (Exception $e) {
    print_r($e->getMessage());
}
exit;
Esempio n. 4
0
 /**
  * Метод вызывается после успешной регистации
  */
 protected function afterSuccessRegistation($newuser)
 {
     if (!$newuser || $newuser->uid <= 0) {
         return false;
     }
     $_SESSION['reg_role'] = is_emp($newuser->role) ? 'customer' : 'freelancer';
     //Отправить в очередь события регистрации для GA
     require_once ABS_PATH . '/classes/statistic/StatisticFactory.php';
     require_once ABS_PATH . '/classes/users.php';
     $ga = StatisticFactory::getInstance('GA');
     $ga->queue('event', array('uid' => $newuser->uid, 'cid' => users::getCid(), 'category' => $_SESSION['reg_role'], 'action' => 'registration_finished'));
     return true;
 }
Esempio n. 5
0
 public function process_event(&$event)
 {
     $message = false;
     $cid = (string) @$event->data['cid'];
     try {
         $options = array('cid' => $cid, 'sc' => 'start', 'cd1' => $cid);
         if (isset($event->data['uid']) && $event->data['uid'] > 0) {
             $options['cd5'] = $event->data['uid'];
         }
         unset($event->data['uid']);
         $ga = StatisticFactory::getInstance('GA', $options);
         switch ($event->type) {
             case 'service_payed':
                 $is_emp = (bool) @$event->data['is_emp'];
                 $label = (string) @$event->data['label'];
                 $ammount = floatval(@$event->data['ammount']);
                 $ga->serviceWasPayed($is_emp, $label, $ammount, $cid);
                 break;
             case 'project_answer':
                 $project_kind_ident = (string) @$event->data['project_kind_ident'];
                 $offer_count = (int) @$event->data['offer_count'];
                 $is_pro = (bool) @$event->data['is_pro'];
                 $offer_id = @$event->data['offer_id'];
                 $ga->projectAnwer($cid, $project_kind_ident, $offer_count, $is_pro);
                 break;
             case 'newsletter_projects_open_hit':
                 $type = (int) @$event->data['type'];
                 $label = (string) @$event->data['label'];
                 $timestamp = (int) @$event->data['timestamp'];
                 if ($type == 1) {
                     $ga->newsletterNewProjectsOpenHitEmp($label, $timestamp);
                 } else {
                     $ga->newsletterNewProjectsOpenHitFrl($label, $timestamp);
                 }
                 break;
                 //Обрабатываем методы которые поддерживает $ga инстанс
                 //Обычно это типовые методы типа GA::event
             //Обрабатываем методы которые поддерживает $ga инстанс
             //Обычно это типовые методы типа GA::event
             default:
                 unset($event->data['cid']);
                 $ga->call($event->type, $event->data);
                 break;
         }
         //Запись событий в лог
         if (is_object($ga) && method_exists($ga, 'getLastRequest')) {
             require_once ABS_PATH . '/classes/log.php';
             $log = new log('statistic/' . SERVER . '-%d%m%Y.log');
             $suffix = '';
             if (isset($offer_id) && !empty($offer_id)) {
                 $suffix = " offer_id={$offer_id}";
             }
             $log->writeln(date('d.m.Y H:i:s') . ' - ' . $ga->getLastRequest()->getBaseUrlWithQuery() . $suffix);
         }
     } catch (Exception $e) {
         $message = 'Ошибка: ' . $e->getMessage();
     }
     if ($message) {
         $data = '';
         foreach ($event->data as $key => $value) {
             $data .= $key . '=' . $value . '; ';
         }
         $log_message = sprintf(self::LOG_FORMAT, $event->type, $data, $message);
         $this->log->notice(iconv('CP1251', 'UTF-8', $log_message));
         //Повторить через 60 сек
         //$event->retry_delay = 60;
         //return PGQ_EVENT_RETRY;
     }
     return PGQ_EVENT_OK;
 }
Esempio n. 6
0
        $back_url = !empty($customRedirect) ? $customRedirect : (isset($_SESSION['ref_uri']) ? urldecode($_SESSION['ref_uri']) : null);
        if ($id == users::AUTH_STATUS_2FA) {
            if (!empty($customRedirect)) {
                $_SESSION['2fa_redirect'] = array('redirectUri' => $customRedirect);
            }
            //Редирект на 2ой атап авторизации
            $back_url = '/auth/second/';
        } elseif (!$back_url) {
            $back_url = is_emp() ? '/' : '/projects/';
        }
        //Успешная авторизация
        if ($id > 0) {
            //Отправляем в очередь событие об успешной авторизации
            if ($type = $opauthModel->getShortType()) {
                require_once ABS_PATH . '/classes/statistic/StatisticFactory.php';
                $ga = StatisticFactory::getInstance('GA');
                $ga->queue('event', array('uid' => $id, 'cid' => users::getCid(), 'category' => is_emp() ? 'customer' : 'freelancer', 'action' => 'authorization_passed', 'label' => $type));
            }
        }
    } else {
        $_SESSION['opauth_error'] = 'Данный аккаунт социальной сети уже привязан к другому пользователю';
    }
    header("Location: {$back_url}");
    exit;
} else {
    if ($type == OpauthHelper::ACTION_REGISTER) {
        $registrationData = OpauthHelper::getRegistrationData($response);
        $postedRole = $emp_redirect ? registration::ROLE_EMPLOYER : __paramInit('int', null, 'role_db_id');
        $postedEmail = __paramInit('string', null, 'email');
        $postedLogin = __paramInit('string', null, 'login');
        if ($postedRole && $postedEmail && $postedLogin) {
Esempio n. 7
0
 /**
  * Проверка авторизации и установка ошибки или URL для перехода
  * 
  * @param type $data
  * @return boolean
  */
 public function isValid($data)
 {
     if ($valid = parent::isValid($data)) {
         $data = $this->getValues();
         $autologin = isset($data['autologin']) && $data['autologin'] == 1;
         $pwd = users::hashPasswd($data['passwd']);
         $uid = login($data['login'], $pwd, $autologin);
         switch ($uid) {
             case self::UID_FAIL:
                 $valid = false;
                 $this->getElement('login')->addError(self::FAIL_LOGIN_MSG);
                 break;
             case self::UID_BANNED:
                 $_SESSION['rand'] = csrf_token();
                 $this->redirect_to = sprintf(self::REDIRECT_URL_BANNED, $data['login'], $_SESSION['rand']);
                 break;
             case self::UID_INNACTIVE:
                 $this->redirect_to = self::REDIRECT_URL_INACTIVE;
                 break;
             case self::UID_DENYIP:
                 $this->redirect_to = sprintf(self::REDIRECT_URL_DENYIP, $data['login']);
                 break;
             case users::AUTH_STATUS_2FA:
                 $this->redirect_to = self::REDIRECT_URL_2FA;
                 break;
             default:
                 //Успешная авторизация
                 if ($uid > 0) {
                     $default_location = is_emp() ? '/tu/' : '/projects/';
                     $ref_uri = isset($_SESSION['ref_uri']) ? urldecode($_SESSION['ref_uri']) : null;
                     $ref_uri = !$ref_uri ? $default_location : $ref_uri;
                     $location = HTTP_PFX . $_SERVER['HTTP_HOST'] . $ref_uri;
                     // #0012501
                     $location = preg_replace("/\\/router\\.php\\?pg=/", "", $location);
                     // #0011589
                     if (strpos($location, '/remind/') || strpos($location, 'inactive.php') || strpos($location, 'checkpass.php') || strpos($location, '/registration/') || strpos($location, 'fbd.php')) {
                         $location = $default_location;
                     }
                     session_write_close();
                     //Отправляем в очередь событие об успешной авторизации
                     require_once ABS_PATH . '/classes/statistic/StatisticFactory.php';
                     require_once ABS_PATH . '/classes/users.php';
                     $ga = StatisticFactory::getInstance('GA');
                     $ga->queue('event', array('uid' => $uid, 'cid' => users::getCid(), 'category' => is_emp() ? 'customer' : 'freelancer', 'action' => 'authorization_passed', 'label' => 'email'));
                     $this->redirect_to = $location;
                 }
         }
     }
     return $valid;
 }
Esempio n. 8
0
 /**
  * @todo: замена NewProj
  * 
  * Рассылка о новых проектах за предыдущий день. Вызывается раз в день из hourly.php
  * 
  * @param array $uids - массив идентификаторов пользователей, которых нужно исключить
  *
  * @return int количество получивших рассылку
  */
 public function NewProj2($uids = array())
 {
     $show_pro_limit = 25;
     $show_limit = 25;
     $projects = projects::GetNewProjectsPreviousDay($error, true);
     $groups = professions::GetAllGroupsLite(true);
     $page = 0;
     $count = 0;
     $projects_count = count($projects);
     if (!$projects_count) {
         return false;
     }
     //Получаем баннеры
     $settings = new settings();
     $banner_file = $settings->GetVariable('newsletter', 'banner_file');
     $banner_link = $settings->GetVariable('newsletter', 'banner_link');
     $this->subject = 'Новые проекты на FL.ru';
     $this->message = Template::render($_SERVER['DOCUMENT_ROOT'] . '/templates/mail/new_projects/project_layout.tpl.php', array('projects' => '%MESSAGE%', 'host' => $GLOBALS['host'], 'title' => '%TITLE%', 'unsubscribe_url' => '%UNSUBSCRIBE_URL%', 'date' => strtotime('- 1 day'), 'track_url' => '%TRACK_URL%'));
     $this->recipient = '';
     $massId = $this->send('text/html');
     $project_ids = array();
     foreach ($projects as $i => $prj) {
         $descr = $prj['descr'];
         $descr = htmlspecialchars($descr, ENT_QUOTES, 'CP1251', false);
         $descr = reformat(LenghtFormatEx($descr, 180), 50, 0, 1);
         $price = $prj['cost'] ? CurToChar($prj['cost'], $prj['currency']) . getPricebyProject($prj['priceby']) : null;
         $projects[$i]['html'] = Template::render($_SERVER['DOCUMENT_ROOT'] . '/templates/mail/new_projects/project.tpl.php', array('url' => $GLOBALS['host'] . getFriendlyURL('project', array('id' => $prj['id'], 'name' => $prj['name'])), 'name' => $prj['name'] ? reformat(htmlspecialchars($prj['name'], ENT_QUOTES, 'CP1251', false), 50, 0, 1) : '', 'descr' => $descr, 'host' => $GLOBALS['host'], 'project_kind' => $prj['kind'], 'project_pro_only' => $prj['pro_only'] == 't', 'project_verify_only' => $prj['verify_only'] == 't', 'project_urgent' => $prj['urgent'] == 't', 'price' => $price, 'end_date' => $prj['end_date'], 'create_date' => $prj['create_date'], 'utm_param' => '%UTM_PARAM%'));
         $project_ids[] = $prj['id'];
     }
     //Собираем юзеров у которых есть ответы на новые проекты
     $offers_exist = array();
     $offers = projects_offers::AllFrlOffersByProjectIDs($project_ids);
     if (count($offers)) {
         foreach ($offers as $offer) {
             if (!isset($offers_exist[$offer['project_id']])) {
                 $offers_exist[$offer['project_id']] = array();
             }
             $offers_exist[$offer['project_id']][$offer['user_id']] = true;
         }
     }
     $strtotime_3y_ago = strtotime('- 3 year');
     $strtotime_1y_ago = strtotime('- 1 year');
     $strtotime_1w_ago = strtotime('- 1 week');
     $current_date = time();
     $current_date_sufix = '_' . date('dmy', $current_date);
     //format:_270314
     $statistics = array();
     while ($users = freelancer::GetPrjRecps($error, ++$page, 200, $uids)) {
         $this->recipient = array();
         foreach ($users as $user) {
             //Если ли у фрилансера уточнение по категориям
             $is_mailer_str = strlen($user['mailer_str']) > 0;
             $subj = array();
             if ($is_mailer_str) {
                 foreach ($groups as $group) {
                     if (freelancer::isSubmited($user['mailer_str'], array(array('category_id' => $group['id'])))) {
                         $subj[$group['id']] = $group['name'];
                     }
                 }
             }
             $message_pro = '';
             $cnt_pro = 0;
             $message = '';
             $cnt = 0;
             $cnt_submited = 0;
             $cnt_user_submited = 0;
             foreach ($projects as $prj) {
                 //Подписан ли фрилансер на специализацию к которой относится проект
                 if ($is_mailer_str && !freelancer::isSubmited($user['mailer_str'], $prj['specs'])) {
                     continue;
                 }
                 //Считаем все проекты по выбранным специализациям
                 ++$cnt_submited;
                 //Условия не попадания в письмо
                 if ($prj['is_blocked'] == 't' || $prj['closed'] == 't' || $prj['state'] == projects::STATE_MOVED_TO_VACANCY || $prj['kind'] == projects::KIND_PERSONAL) {
                     continue;
                 }
                 //Если у фрилансера ответ на проект то не добавляем его в рассылку
                 if (isset($offers_exist[$prj['id']][$user['uid']])) {
                     continue;
                 }
                 if ($prj['pro_only'] == 't') {
                     if ($cnt_pro < $show_pro_limit) {
                         $message_pro .= $prj['html'];
                         ++$cnt_pro;
                     }
                 } else {
                     if ($cnt < $show_limit) {
                         $message .= $prj['html'];
                         ++$cnt;
                     }
                 }
                 ++$cnt_user_submited;
             }
             $message = $message_pro . $message;
             if (empty($message)) {
                 continue;
             }
             if ($cnt_user_submited <= $show_pro_limit + $show_limit) {
                 $cnt_submited = $cnt_user_submited;
             }
             //Формирует UTM метки аналитики
             $reg_date = strtotime($user['reg_date']);
             $reg_year = date('Y', $reg_date);
             $utm_content = $reg_date >= $strtotime_1w_ago ? '_new' : $reg_year;
             //$utm_content = ($user['reg_days_ago'] > 7)?$user['reg_date_year']:'_new';
             $utm_param = $this->_addUtmUrlParams('email', 'free' . $utm_content, 'day_projects' . $current_date_sufix);
             $message = str_replace('%UTM_PARAM%', $utm_param, $message);
             //Собираем шаблон
             $message = Template::render($_SERVER['DOCUMENT_ROOT'] . '/templates/mail/new_projects/project_list.tpl.php', array('projects' => $message, 'spec_list' => implode(' / ', $subj), 'setup_url' => $GLOBALS['host'] . "/users/{$user['login']}/setup/mailer/", 'other_count' => $cnt_submited - $cnt_pro - $cnt, 'more_url' => $GLOBALS['host'] . $utm_param, 'banner_file' => $banner_file, 'banner_link' => $banner_link));
             if (!$user['unsubscribe_key']) {
                 $user['unsubscribe_key'] = users::GetUnsubscribeKey($user['login']);
             }
             /*
             $date = strtotime($projects[0]['post_date']);
             $date = date( 'j', $date ) . ' ' . monthtostr(date('n', $date),true);
             */
             $projects_count_txt = $cnt_submited . ' ' . plural_form($cnt_submited, array('новый', 'новых', 'новых')) . ' ' . plural_form($cnt_submited, array('проект', 'проекта', 'проектов'));
             //$title = "{$projects_count_txt} за {$date}";
             $last_time = strtotime($user['last_time']);
             if ($last_time < $strtotime_3y_ago) {
                 $utm_content = '_3y';
             } elseif ($last_time >= $strtotime_3y_ago && $last_time <= $strtotime_1y_ago) {
                 $utm_content = '_1-3y';
             } elseif ($reg_date < $strtotime_1w_ago) {
                 $utm_content = '_1y';
             }
             /*
              * @todo: EXTRACT медленней
              
             if($user['last_years_ago'] > 0){
                $utm_content = ($user['last_years_ago'] > 3)?'_3y':'_1-3y';
             }else{
                $utm_content = ($user['reg_days_ago'] > 7)?'_1y':'_new';
             }
             */
             //Накапливаем статистику
             $stat_idx = $reg_date >= $strtotime_1w_ago ? 'new' : $reg_year;
             ++$statistics[$stat_idx];
             $this->recipient[] = array('email' => $user['uname'] . ' ' . $user['usurname'] . ' [' . $user['login'] . '] <' . $user['email'] . '>', 'extra' => array('USER_NAME' => $user['uname'], 'USER_SURNAME' => $user['usurname'], 'USER_LOGIN' => $user['login'], 'MESSAGE' => $message, 'UNSUBSCRIBE_URL' => "/unsubscribe/?type=new_projects&ukey={$user['unsubscribe_key']}" . $this->_addUtmUrlParams('email', 'free' . $utm_content, 'unsubscr_day_projects' . $current_date_sufix), 'TITLE' => $projects_count_txt, 'TRACK_URL' => $GLOBALS['host'] . StatisticHelper::track_url(0, $stat_idx, $current_date, $user['login'] . $user['uid'])));
             ++$count;
         }
         $this->bind($massId, true);
     }
     //Собранную статистику отправляем в GA
     $statistics['total'] = $count;
     $ga = StatisticFactory::getInstance('GA');
     $ga->newsletterNewProjectsFrl($statistics, $current_date);
     return $count;
 }