コード例 #1
0
 /**
  * Проверяем введенную ссылку на валидность.
  * 
  * @return bool
  */
 public function validateLink()
 {
     if ($this->link == '') {
         return true;
     }
     return url_validate($this->link, true);
 }
コード例 #2
0
ファイル: stdf3.php プロジェクト: amage/fl-ru-damp
/**
 * проверяет href в теге A на валидность
 * @param strint $url - тег A который надо проверить
 * если ссылка не валидная, то возвращается тег A без атрибутов, но с текстом (<a>текст</a>)
 */
function cleanHref($url)
{
    //$match = preg_match("~href=.?([\"\'])(.*?)\\1~", $url, $matches);
    $match = preg_match("~href=(.*?)[\\s|>]~", $url, $matches);
    if (!$match) {
        return preg_replace('~<a[^>]*>([^<]*)</a>~', '$1', $url);
    }
    $hrefs = array_slice($matches, 1);
    foreach ($hrefs as $href) {
        $href = trim($href, "'");
        $href = trim($href, '"');
        // если ссылка не валидная то оставляем тег без ссылки
        if (!url_validate($href, true)) {
            return preg_replace('~<a[^>]*>([^<]*)</a>~', '$1', $url);
        } else {
            $url = preg_replace("~<a[^>]*>~", '<a href="' . $href . '">', $url);
        }
    }
    return $url;
}
コード例 #3
0
 public function completeData($type_role = 1)
 {
     if ($this->isDisable()) {
         header("Location: /wizard/registration/?step=1");
         exit;
     }
     require_once $_SERVER['DOCUMENT_ROOT'] . "/classes/employer.php";
     require_once $_SERVER['DOCUMENT_ROOT'] . "/classes/freelancer.php";
     require_once $_SERVER['DOCUMENT_ROOT'] . "/classes/city.php";
     require_once $_SERVER['DOCUMENT_ROOT'] . "/classes/country.php";
     require_once $_SERVER['DOCUMENT_ROOT'] . "/classes/blogs.php";
     require_once $_SERVER['DOCUMENT_ROOT'] . "/classes/commune.php";
     $themes_blogs = blogs::getRandomThemes(5);
     $themes_commune = commune::getRandomCommunes(3);
     $month = array('1' => 'января', '2' => 'февраля', '3' => 'марта', '4' => 'апреля', '5' => 'мая', '6' => 'июня', '7' => 'июля', '8' => 'августа', '9' => 'сентября', '10' => 'октября', '11' => 'ноября', '12' => 'декабря');
     if ($type_role == step_wizard_registration::TYPE_WIZARD_EMP) {
         $user = new employer();
         $checkPRO = $this->checkWizardPRO(array(step_employer::OP_CODE_PRO));
         $pro_emp = $checkPRO['id'] > 0 ? 1 : 0;
         if ($pro_emp) {
             $week_pro = round($checkPRO['ammount'] / 10);
         }
     } else {
         $user = new freelancer();
         $checkPRO = $this->checkWizardPRO(step_freelancer::getOperationCodePRO());
         $pro_frl = $checkPRO['id'] > 0 ? 1 : 0;
         if ($pro_frl) {
             $op_code = $checkPRO['op_code'];
         }
     }
     $user->GetUserByUID(wizard::getUserIDReg());
     $info_for_reg = unserialize($user->info_for_reg);
     $uname = $user->uname;
     $usurname = $user->usurname;
     $sex = $user->sex == 't' ? 1 : ($user->sex == 'f' ? 0 : -1);
     $birthday = strtotime($user->birthday);
     if ($birthday) {
         $bday = date('d', $birthday);
         $bmonth = (int) date('m', $birthday);
         $bmonth_value = $month[$bmonth];
         $byear = date('Y', $birthday);
     } else {
         $bday = '';
         $bmonth = (int) date('m', $birthday);
         $bmonth_value = $month[$bmonth];
         $byear = '';
     }
     $city = $user->city;
     if ($city) {
         $city_value = city::GetCityName($city);
     }
     $country = $user->country;
     if ($country) {
         $country_value = country::GetCountryName($country);
     }
     if ($type_role == step_wizard_registration::TYPE_WIZARD_EMP) {
         $company = $user->compname;
         $about_company = $user->company;
         $logo_name = $user->logo;
         $dir = "users/" . substr($user->login, 0, 2) . "/" . $user->login . "/logo/";
         $logo_path = WDCPREFIX . "/" . $dir . $user->logo;
     }
     $info['site'] = $this->loadMultiVal('site', 'site', $user);
     $info['email'] = $this->loadMultiVal('second_email', 'email', $user);
     $info['phone'] = $this->loadMultiVal('phone', 'phone', $user);
     $info['icq'] = $this->loadMultiVal('icq', 'icq', $user);
     $info['skype'] = $this->loadMultiVal('skype', 'skype', $user);
     $info['jabber'] = $this->loadMultiVal('jabber', 'jabber', $user);
     $info['lj'] = $this->loadMultiVal('ljuser', 'lj', $user);
     $action = __paramInit('string', null, 'action');
     if ($action == 'upd_info') {
         $info_for_reg = $_POST['info_for_reg'];
         if ($info_for_reg['email_0'] !== null) {
             $info_for_reg['second_email'] = $info_for_reg['email_0'];
             unset($info_for_reg['email_0']);
         }
         if ($info_for_reg['phone_0'] !== null) {
             $info_for_reg['phone'] = $info_for_reg['phone_0'];
             unset($info_for_reg['phone_0']);
         }
         if ($info_for_reg['site_0'] !== null) {
             $info_for_reg['site'] = $info_for_reg['site_0'];
             unset($info_for_reg['site_0']);
         }
         if ($info_for_reg['lj_0'] !== null) {
             $info_for_reg['ljuser'] = $info_for_reg['lj_0'];
             unset($info_for_reg['lj_0']);
         }
         if ($info_for_reg['jabber_0'] !== null) {
             $info_for_reg['jabber'] = $info_for_reg['jabber_0'];
             unset($info_for_reg['jabber_0']);
         }
         if ($info_for_reg['skype_0'] !== null) {
             $info_for_reg['skype'] = $info_for_reg['skype_0'];
             unset($info_for_reg['skype_0']);
         }
         if ($info_for_reg['icq_0'] !== null) {
             $info_for_reg['icq'] = $info_for_reg['icq_0'];
             unset($info_for_reg['icq_0']);
         }
         if ($info_for_reg['compname'] !== null) {
             $info_for_reg['company'] = $info_for_reg['compname'];
             unset($info_for_reg['compname']);
         }
         $info_for_reg = array_map('intval', $info_for_reg);
         $user->info_for_reg = serialize($info_for_reg);
         $uname = __paramInit('string', null, 'uname', null, 21);
         $usurname = __paramInit('string', null, 'usurname', null, 21);
         if ($uname == '') {
             $error['uname'] = "Поле заполнено некорректно";
         }
         if ($usurname == '') {
             $error['usurname'] = "Поле заполнено некорректно";
         }
         if (!preg_match("/^[-a-zA-Zа-яёА-ЯЁ]+\$/", $uname)) {
             $error['uname'] = "Поле заполнено некорректно";
         } else {
             $user->uname = $uname;
         }
         if (!preg_match("/^[-a-zA-Zа-яёА-ЯЁ]+\$/", $usurname)) {
             $error['usurname'] = "Поле заполнено некорректно";
         } else {
             $user->usurname = $usurname;
         }
         $sex = __paramInit('int', null, 'sex', 1);
         // по умолчанию мужской пол
         $user->sex = $sex == 1 ? 't' : 'f';
         $bday = __paramInit('int', null, 'bday', null);
         $bmonth = __paramInit('int', null, 'bmonth_db_id', 1);
         $bmonth_value = __paramInit('string', null, 'bmonth');
         $byear = __paramInit('int', null, 'byear', null);
         if ($bday != null && $byear != null) {
             if (!is_numeric($bday) || !is_numeric($byear) || !checkdate($bmonth, $bday, $byear) || $byear < 1945 || $byear > date('Y')) {
                 $error['birthday'] = "Поле заполнено некорректно";
             } else {
                 $user->birthday = dateFormat("Y-m-d", $byear . "-" . $bmonth . "-" . $bday);
             }
         } else {
             $user->birthday = "1910-01-01";
         }
         if (!$error['birthday'] && $user->birthday && date("Y", strtotime($user->birthday)) >= date("Y")) {
             $error['birthday'] = "Поле заполнено некорректно";
         }
         $city = __paramInit('int', null, 'city_db_id', 0);
         $city_value = __paramInit('string', null, 'city', false);
         $country = __paramInit('int', null, 'country_db_id', 0);
         $country_value = __paramInit('string', null, 'country', false);
         if ($city == 0 && strlen($city_value) != 0) {
             $error['city'] = 'Поле заполнено некорректно';
         }
         if ($country == 0 && strlen($country_value) != 0) {
             $error['country'] = 'Поле заполнено некорректно';
         }
         $user->country = $country;
         $user->city = $city;
         $company = __paramInit('string', null, 'company') ? substr(__paramInit('string', null, 'company'), 0, 64) : '';
         $about_company = __paramInit('string', null, 'about_company');
         $user->compname = $company;
         if (strlen($about_company) > 500) {
             $error['company'] = "Количество знаков в тексте о компании превышает допустимое значение";
         } else {
             $user->company = $about_company;
         }
         $logo_id = __paramInit('int', null, 'logo_company');
         $logo_name = __paramInit('string', null, 'logo_name');
         if ($logo_name) {
             $user->logo = $logo_name;
             $user->Update(wizard::getUserIDReg(), $res);
         }
         $info['site'] = $this->initMultiVal('site');
         $info['email'] = $this->initMultiVal('email');
         $info['phone'] = $this->initMultiVal('phone');
         $info['icq'] = $this->initMultiVal('icq');
         $info['skype'] = $this->initMultiVal('skype');
         $info['jabber'] = $this->initMultiVal('jabber');
         $info['lj'] = $this->initMultiVal('lj');
         if (!empty($info['site'])) {
             foreach ($info['site'] as $i => $value) {
                 $name = 'site' . ($i != 0 ? "_{$i}" : "");
                 if (!url_validate(addhttp($value), true) && trimhttp($value) != '') {
                     $error[$name] = "Поле заполнено некорректно";
                 } else {
                     $user->{$name} = addhttp($value);
                 }
             }
         }
         if (!empty($info['email'])) {
             foreach ($info['email'] as $i => $value) {
                 if ($i == 0) {
                     $name_save = "second_email";
                 } else {
                     $name_save = "email_{$i}";
                 }
                 $name = 'email' . ($i != 0 ? "_{$i}" : "");
                 if (!is_email($value) && $value != '') {
                     $error[$name] = "Поле заполнено некорректно";
                 } else {
                     $user->{$name_save} = $value;
                 }
             }
         }
         if (!empty($info['phone'])) {
             foreach ($info['phone'] as $i => $value) {
                 $name = 'phone' . ($i != 0 ? "_{$i}" : "");
                 if (!preg_match("/^[-+0-9)( #]*\$/", $value)) {
                     $error[$name] = "Поле заполнено некорректно";
                 } else {
                     $user->{$name} = $value;
                 }
             }
         }
         if (!empty($info['icq'])) {
             foreach ($info['icq'] as $i => $value) {
                 $name = 'icq' . ($i != 0 ? "_{$i}" : "");
                 if (!preg_match("/^[-0-9\\s]*\$/", $value) && !is_email($value)) {
                     $error[$name] = "Поле заполнено некорректно";
                 } else {
                     $user->{$name} = $value;
                 }
             }
         }
         if (!empty($info['skype'])) {
             foreach ($info['skype'] as $i => $value) {
                 $name = 'skype' . ($i != 0 ? "_{$i}" : "");
                 $user->{$name} = $value;
             }
         }
         if (!empty($info['jabber'])) {
             foreach ($info['jabber'] as $i => $value) {
                 $name = 'jabber' . ($i != 0 ? "_{$i}" : "");
                 if (strlen($value) > 255) {
                     $error[$name] = "Количество знаков превышает допустимое значение";
                 } else {
                     $user->{$name} = $value;
                 }
             }
         }
         if (!empty($info['lj'])) {
             foreach ($info['lj'] as $i => $value) {
                 if ($i == 0) {
                     $name_save = "ljuser";
                 } else {
                     $name_save = "lj_{$i}";
                 }
                 $name = 'lj' . ($i != 0 ? "_{$i}" : "");
                 if (!preg_match("/^[a-zA-Z0-9_-]*\$/", $value)) {
                     $error[$name] = "Поле заполнено некорректно";
                 } else {
                     $user->{$name_save} = $value;
                 }
             }
         }
         if ($type_role == step_wizard_registration::TYPE_WIZARD_EMP) {
             $pro_emp = __paramInit('int', null, 'pro-emp', false);
             if ($pro_emp) {
                 $week_pro = round(__paramInit('int', null, 'week_pro', 0));
             }
         } else {
             $ammount = 0;
             $pro_frl = __paramInit('int', null, 'pro-frl', false);
             if ($pro_frl) {
                 $pro = __paramInit('string', null, 'pro', -1);
                 switch ($pro) {
                     case "1week":
                         $op_code = 76;
                         $ammount = 7;
                         break;
                     case "1":
                         $op_code = 48;
                         $ammount = 19;
                         break;
                     case "3":
                         $op_code = 49;
                         $ammount = 54;
                         break;
                     case "6":
                         $op_code = 50;
                         $ammount = 102;
                         break;
                     case "12":
                         $op_code = 51;
                         $ammount = 180;
                         break;
                     case "-1":
                     default:
                         $ammount = 0;
                         break;
                 }
             }
         }
         if (!$error && wizard::getUserIDReg()) {
             $error['save'] = $user->Update(wizard::getUserIDReg(), $res);
             if (!$error['save']) {
                 if ($type_role == step_wizard_registration::TYPE_WIZARD_EMP) {
                     $ammount = $week_pro * 10;
                     if ($ammount > 0) {
                         $checkPRO = $this->checkWizardPRO(step_employer::OP_CODE_PRO);
                         if ($checkPRO['id'] > 0) {
                             $update = array("ammount" => $ammount);
                             wizard_billing::editPaidOption($update, $checkPRO['id']);
                         } else {
                             $insert = array("wiz_uid" => step_wizard::getWizardUserID(), "op_code" => step_employer::OP_CODE_PRO, "type" => 3, "ammount" => $ammount, "parent" => wizard::getUserIDReg());
                             wizard_billing::addPaidOption($insert);
                         }
                     } else {
                         $sql = "DELETE FROM wizard_billing WHERE wiz_uid = ? AND op_code = ?";
                         $this->_db->query($sql, step_wizard::getWizardUserID(), step_employer::OP_CODE_PRO);
                     }
                 } else {
                     // Чистим
                     $sql = "DELETE FROM wizard_billing WHERE wiz_uid = ? AND op_code IN (?l)";
                     $this->_db->query($sql, step_wizard::getWizardUserID(), step_freelancer::getOperationCodePRO());
                     if ($ammount > 0) {
                         $insert = array("wiz_uid" => step_wizard::getWizardUserID(), "op_code" => $op_code, "type" => 4, "ammount" => $ammount, "parent" => wizard::getUserIDReg());
                         wizard_billing::addPaidOption($insert);
                     }
                 }
                 $this->parent->setCompliteStep(true);
                 $this->parent->setNextStep($this->parent->getPosition() + 1);
                 header("Location: /wizard/registration/");
                 exit;
             }
         }
         if ($logo_id > 0) {
             $file = new CFile($logo_id);
             $logo_path = WDCPREFIX . "/" . $file->path . $file->name;
         }
     }
     include $_SERVER['DOCUMENT_ROOT'] . "/wizard/registration/steps/tpl.step.info.php";
 }
コード例 #4
0
function getFavicon($url)
{
    // start by fetching the contents of the URL they left...
    if ($html = @file_get_contents($url)) {
        if (preg_match('/<link[^>]+rel="(?:shortcut )?icon"[^>]+?href="([^"]+?)"/si', $html, $matches)) {
            // Attempt to grab a favicon link from their webpage url
            $linkUrl = html_entity_decode($matches[1]);
            if (substr($linkUrl, 0, 1) == '/') {
                $urlParts = parse_url($url);
                $faviconURL = $urlParts['scheme'] . '://' . $urlParts['host'] . $linkUrl;
            } else {
                if (substr($linkUrl, 0, 7) == 'http://') {
                    $faviconURL = $linkUrl;
                } else {
                    if (substr($url, -1, 1) == '/') {
                        $faviconURL = $url . $linkUrl;
                    } else {
                        $faviconURL = $url . '/' . $linkUrl;
                    }
                }
            }
        } else {
            // If unsuccessful, attempt to "guess" the favicon location
            $urlParts = parse_url($url);
            $faviconURL = $urlParts['scheme'] . '://' . $urlParts['host'] . '/favicon.ico';
        }
        // Run a test to see if what we have attempted to get actually exists.
        if ($faviconURL_exists = url_validate($faviconURL)) {
            return $faviconURL;
        }
    }
    // Finally, if we haven't 'returned' yet then there is nothing to see here.
    return false;
}
コード例 #5
0
/**
 * Сохранение работы в портфолио
 * 
 * @param object $objResponse xajaxResponse
 * @param string $rec_id идентификатор записи
 * @param string $rec_type тип записи
 * @param array $aForm массив данных
 * @param string $sDrawFunc имя функции для выполнения после сохранения
 */
function _admEditPortfolioSaveForm(&$objResponse, $rec_id = '', $rec_type = '', $aForm = array(), $sDrawFunc = '')
{
    require_once $_SERVER['DOCUMENT_ROOT'] . '/classes/user_content.php';
    require_once $_SERVER['DOCUMENT_ROOT'] . '/classes/professions.php';
    require_once $_SERVER['DOCUMENT_ROOT'] . '/classes/portfolio.php';
    require_once $_SERVER['DOCUMENT_ROOT'] . '/classes/users.php';
    $max_time_value = 100;
    //стоимость работы из портфолио
    $max_portf_cost[0] = 100000;
    // usd
    $max_portf_cost[1] = 100000;
    // euro
    $max_portf_cost[2] = 5000000;
    // rur
    $max_portf_cost[3] = 100000;
    // fm
    $user = new users();
    $user->GetUserByUID($aForm['user_id']);
    // инициализация
    $aPortf = portfolio::GetPortfById($rec_id);
    $alert = array();
    $maxlen = $aForm['is_video'] ? 80 : 120;
    $name = substr($aForm['pname'], 0, $maxlen);
    $name = change_q_x($name, false, true, '', false, false);
    $name = $name ? $name : '';
    $descr = substr(change_q_new(trim(stripslashes($aForm['descr']))), 0, 1500);
    $prof = intval($aForm['prof']);
    $new_prof = intval($aForm['new_prof']);
    $prj_id = $rec_id;
    $cost = intval(str_replace(' ', '', $aForm['pcost']) * 100) / 100;
    $cost_type = intval($aForm['pcosttype']);
    $time_value = intval(trim($aForm['ptime']));
    $time_type = intval($aForm['ptimeei']);
    $is_video = $aForm['is_video'] ? 't' : 'f';
    $video_link = $aForm['is_video'] ? stripslashes(trim($aForm['v_video_link'])) : '';
    $link = $aForm['is_video'] ? '' : addhttp(trim(substr(change_q_x($aForm['link'], true), 0, 150)));
    $link = $link ? $link : '';
    $make_position = $aForm['make_position'];
    $make_position_num = trim($aForm['make_position_num']);
    $update_prev = intval($aForm['upd_prev']);
    $prev_type = intval($aForm['prev_type']);
    $del_prev = intval($aForm['del_prev']);
    $new_position = NULL;
    $pict = substr(change_q_new(trim(stripslashes($aForm['pict']))), 0, 1500);
    $prev_pict = substr(change_q_new(trim(stripslashes($aForm['prev_pict']))), 0, 1500);
    if ($new_prof != $prof) {
        $new_position = 0;
    }
    if (isset($make_position)) {
        switch ($make_position) {
            case 'first':
                $new_position = 1;
                break;
            case 'last':
                $new_position = 0;
                break;
            case 'num':
            default:
                $new_position = intval($make_position_num);
                $new_position = $new_position <= 0 ? 1 : $new_position;
                break;
        }
    }
    // валидация (нумерация алертов как в первоначальном варианте радактирования и новый нулевой)
    if (!$name || strlen(trim(stripslashes($aForm['pname']))) > 80) {
        $alert[1] = 'Поле заполнено некорректно';
    }
    if ($link != '' && !url_validate($link, true)) {
        $alert[6] = 'Поле заполнено некорректно';
    }
    if ($is_video == 't') {
        $v_video_link = video_validate($video_link);
        if (!$v_video_link) {
            $alert[206] = "Поле заполнено некорректно";
        } else {
            $video_link = preg_replace("/^http:\\/\\//", '', $v_video_link);
        }
    }
    if ($cost < 0 || $cost > $max_portf_cost[$cost_type]) {
        $alert[4] = 'Стоимость должна быть в пределе от 0 ' . view_range_cost2(0, $max_portf_cost[$cost_type], '', '', false, $cost_type) . ($cost_type != 2 ? '.' : '');
    }
    if ($time_value < 0 || $time_value > $max_time_value) {
        $alert[5] = 'Временные затраты должны быть в пределе от 0 до ' . $max_time_value . '.';
    }
    if ($new_prof != $prof && ($new_prof == professions::CLIENTS_PROF_ID || $new_prof == professions::BEST_PROF_ID) && portfolio::CountAll($aForm['user_id'], $new_prof, true) >= portfolio::MAX_BEST_WORKS) {
        $alert[0] = 'Превышено количество работ в этом разделе';
    }
    // сохраняем
    if (!$alert) {
        require_once $_SERVER['DOCUMENT_ROOT'] . '/classes/messages.php';
        $sReason = _parseReason($aForm['user_id'], $aForm['adm_edit_text']);
        $portf = new portfolio();
        $portf->EditPortf($aForm['user_id'], $name, $img, $sm_img, $link, $descr, $new_prof, $cost, $cost_type, $time_type, $time_value, $prev_type, $prj_id, $file_error, $preview_error, $new_position, 0, $video_link, $update_prev, $_SESSION['uid'], $pict, $prev_pict, $user->login, $sReason);
        if ($del_prev) {
            $portf->DelPict($user->login, $prj_id, 0);
        }
        messages::portfolioModifiedNotification($aPortf, $user, $sReason);
        $content_id = user_content::MODER_PORTFOLIO;
        _admEditAfterAll($objResponse, $content_id, $rec_id, $rec_type, $sDrawFunc, $aForm);
    } else {
        _setErrors($objResponse, $alert, array(0 => 'prof', 1 => 'pname', 2 => 'descr', 4 => 'pcost', 5 => 'ptime', 6 => 'link', 206 => 'video_link'), $sDrawFunc);
    }
}
コード例 #6
0
ファイル: public.server.php プロジェクト: kapai69/fl-ru-damp
/**
 * формирует превью проекта на главной странице.
 */
function GetPreview($data)
{
    $objResponse = new xajaxResponse();
    require_once $_SERVER['DOCUMENT_ROOT'] . '/classes/projects.php';
    require_once $_SERVER['DOCUMENT_ROOT'] . '/classes/attachedfiles.php';
    require_once $_SERVER['DOCUMENT_ROOT'] . '/classes/CFile.php';
    require_once $_SERVER['DOCUMENT_ROOT'] . '/classes/HTML/projects_lenta.php';
    require_once $_SERVER['DOCUMENT_ROOT'] . '/classes/project_exrates.php';
    require_once $_SERVER['DOCUMENT_ROOT'] . '/classes/memBuff2.php';
    $kind = 1;
    $memBuff = new memBuff();
    $htmlLenta = $memBuff->get('projectsLentaHTML');
    if (!$htmlLenta) {
        $prj = new new_projects();
        $prjs = $prj->getProjects($num_prjs, -1, 1, false, null, true);
        foreach ($prjs as &$proj) {
            // стираем принадлежность проекта к пользователю, чтобы не появилось кнопок РЕДАКТИРОВАТЬ и пр.
            unset($proj['user_id']);
        }
        unset($proj);
        $htmlPrj = new HTMLProjects();
        $htmlPrj->template = '/projects/tpl.lenta.new.php';
        $prj_content = $htmlPrj->ShowProjects($num_prjs, $prjs, 1, 1, null, true);
        $prfs = new professions();
        $profs = $prfs->GetAllProfessions('', 0, 1);
        // подложка с лентой проектов
        ob_start();
        include $_SERVER['DOCUMENT_ROOT'] . '/templates/main.php';
        $htmlLenta = ob_get_clean();
        // кэшируем ленту проектов
        $memBuff->set('projectsLentaHTML', $htmlLenta, 1800);
    }
    // подготавливаем данные для шаблона в ленту проектов
    $row = array();
    $row['kind'] = __paramValue('int', $data['kind']);
    $row['cost'] = __paramValue('int', $data['cost']);
    $row['currency'] = __paramValue('int', $data['currency_db_id']);
    $row['priceby'] = __paramValue('int', $data['priceby_db_id']);
    $row['name'] = stripslashes(__paramValue('html', $data['name'], null, true));
    $contacts = array('phone' => array('name' => 'Телефон', 'value' => ''), 'site' => array('name' => 'Сайт', 'value' => ''), 'icq' => array('name' => 'ICQ', 'value' => ''), 'skype' => array('name' => 'Skype', 'value' => ''), 'email' => array('name' => 'E-mail', 'value' => ''));
    if (isset($data['contacts'])) {
        foreach ($data['contacts'] as $name => $value) {
            if (!isset($contacts[$name])) {
                continue;
            }
            switch ($name) {
                case 'site':
                    if (!url_validate(ltrim(ltrim($value, 'http://'), 'https://')) && trim($value) != '') {
                        $error["contact_{$name}"] = 'Поле заполнено некорректно';
                    }
                    if (strpos($value, 'htt') === false && trim($value) != '') {
                        $value = 'http://' . $value;
                    }
                    break;
                case 'email':
                    if (!is_email($value) && trim($value) != '') {
                        $error["contact_{$name}"] = 'Поле заполнено некорректно';
                    }
                    break;
            }
            $contacts[$name]['value'] = __paramValue('htmltext', stripslashes($value));
        }
        $row['contacts'] = serialize($contacts);
    }
    $descrFull = stripslashes(__paramValue('html', $data['descr'], null, true));
    $descr = preg_replace('/^ /', "", $descrFull);
    $descr = preg_replace("/(\n) /", "\$1", $descr);
    $descr = reformat(strip_tags(htmlspecialchars(LenghtFormatEx(htmlspecialchars_decode($descr, ENT_QUOTES), 180), ENT_QUOTES), '<br />'), 50, 1, 0, 1);
    $descr = preg_replace("//", '&nbsp;', $descr);
    $row['descr'] = $descr;
    $row['t_is_payed'] = $data['logo_ok'] || $data['top_ok'];
    $row['t_is_ontop'] = __paramValue('bool', $data['top_ok']);
    $row['t_pro_only'] = $data['pro_only'] ? 't' : 'f';
    $row['t_verify_only'] = $data['verify_only'] ? 't' : 'f';
    $row['t_urgent'] = $data['urgent'] ? 't' : 'f';
    $row['t_hide'] = $data['hide'] ? 't' : 'f';
    $row['create_date'] = date('Y-m-d H:i', strtotime(date('Y-m-d H:i:s')) - 120);
    // делаем дату публикации 2 минуты назад
    $row['end_date'] = __paramValue('string', $data['end_date']);
    $row['win_date'] = __paramValue('string', $data['win_date']);
    $row['country'] = __paramValue('int', $data['project_location_columns'][0]);
    $row['city'] = __paramValue('int', $data['project_location_columns'][1]);
    list($row['country_name'], $row['city_name']) = explode(': ', __paramValue('string', $data['location']));
    $logoOK = __paramValue('bool', $data['logo_ok']);
    $topOK = __paramValue('bool', $data['top_ok']);
    $row['link'] = __paramValue('string', $data['link']);
    if ($logoOK) {
        $logoAttach = new attachedfiles($data['logo_attachedfiles_session']);
        $logoFiles = $logoAttach->getFiles(array(1));
        if (count($logoFiles)) {
            $logoFile = array_pop($logoFiles);
            // загружено может быть несколько файлов, берем последний
            $logoCFile = new CFile($logoFile['id']);
        } elseif (__paramValue('int', $data['logo_file_id'])) {
            $logoCFile = new CFile(__paramValue('int', $data['logo_file_id']));
        }
        $row['logo_name'] = $logoCFile->name;
        $row['logo_path'] = $logoCFile->path;
    }
    $is_ajax = true;
    // подготовка данных для подробной страницы проекта
    $project = $row;
    $categories = array();
    for ($i = 0; $i < 3; ++$i) {
        $categoryID = __paramValue('int', $data['project_profession' . $i . '_columns'][0]);
        $subcategoryID = __paramValue('int', $data['project_profession' . $i . '_spec_columns'][0]);
        if ($categoryID || $subcategoryID) {
            $categories[] = array('category_id' => $categoryID, 'subcategory_id' => $subcategoryID);
        }
    }
    $project['spec_txt'] = projects::_getSpecsStr($categories, ' / ', ', ', true);
    $project['ico_payed'] = $logoOK;
    $project['is_upped'] = $topOK;
    $project['descr'] = $descrFull;
    $project['logo_id'] = $logoCFile->id;
    $project['prefer_sbr'] = __paramValue('bool', $data['prefer_sbr']) ? 't' : 'f';
    $project['urgent'] = __paramValue('bool', $data['urgent']) ? 't' : 'f';
    $project['hide'] = __paramValue('bool', $data['hide']) ? 't' : 'f';
    if (trim($project['contacts']) != '') {
        $contacts_employer = unserialize($project['contacts']);
        $empty_contacts_employer = 0;
        foreach ($contacts_employer as $name => $contact) {
            if (trim($contact['value']) == '') {
                $empty_contacts_employer++;
            }
        }
        $is_contacts_employer_empty = count($contacts_employer) == $empty_contacts_employer;
    }
    $isPreview = true;
    $project_exRates = project_exrates::GetAll();
    $translate_exRates = array(0 => 2, 1 => 3, 2 => 4, 3 => 1);
    ob_start();
    include $_SERVER['DOCUMENT_ROOT'] . '/public/new/tpl.preview.php';
    ?>
    <?php 
    $htmlProject = ob_get_clean();
    $objResponse->assign('project_preview_lenta', 'innerHTML', $htmlLenta);
    $objResponse->assign('project_preview_content', 'innerHTML', $htmlProject);
    $objResponse->script('Public.showPreview()');
    return $objResponse;
}
コード例 #7
0
ファイル: functions.php プロジェクト: wangroot/Tiny-Tiny-RSS
/**
 * Try to determine the favicon URL for a feed.
 * adapted from wordpress favicon plugin by Jeff Minard (http://thecodepro.com/)
 * http://dev.wp-plugins.org/file/favatars/trunk/favatars.php
 * 
 * @param string $url A feed or page URL
 * @access public
 * @return mixed The favicon URL, or false if none was found.
 */
function get_favicon_url($url)
{
    if ($html = @fetch_file_contents($url)) {
        if (preg_match('/<link[^>]+rel="(?:shortcut )?icon"[^>]+?href="([^"]+?)"/si', $html, $matches)) {
            // Attempt to grab a favicon link from their webpage url
            $linkUrl = html_entity_decode($matches[1]);
            if (substr($linkUrl, 0, 1) == '/') {
                $urlParts = parse_url($url);
                $faviconURL = $urlParts['scheme'] . '://' . $urlParts['host'] . $linkUrl;
            } else {
                if (substr($linkUrl, 0, 7) == 'http://') {
                    $faviconURL = $linkUrl;
                } else {
                    $pos = strrpos($url, "/");
                    // no "/" in url or "/" is part of "://"
                    if ($pos === false || $pos == strpos($url, "://") + 2) {
                        $faviconURL = $url . '/' . $linkUrl;
                    } else {
                        $faviconURL = substr($url, 0, $pos + 1) . $linkUrl;
                    }
                }
            }
        } else {
            // If unsuccessful, attempt to "guess" the favicon location
            $urlParts = parse_url($url);
            $faviconURL = $urlParts['scheme'] . '://' . $urlParts['host'] . '/favicon.ico';
        }
    }
    // Run a test to see if what we have attempted to get actually exists.
    if (USE_CURL_FOR_ICONS || url_validate($faviconURL)) {
        return $faviconURL;
    } else {
        return false;
    }
}
コード例 #8
0
ファイル: index.php プロジェクト: Nikitian/fl-ru-damp
     $error_flag = 1;
     if ($is_video == 'f') {
         $enum = 1;
     } else {
         $enum = 201;
     }
     $alert[$enum] = "Поле заполнено некорректно";
 }
 //if (!($link || $prj_pict || $descr)) { $error_flag = 1; $alert[2] = "Поле заполнено некорректно"; }
 //if (($link != '') && (!eregi("^((http|https|ftp)://){0,1}((([a-zа-я0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,6}))|(([0-9]{1,3}\.){3}([0-9]{1,3})))((/|\?)[a-z0-9~#%&'_\+=:\?\.-]*)*)$", $link)))
 //{
 //  $error_flag = 1;
 //  $alert[6] = 'Поле заполнено некорректно. Неверный формат ссылки.';
 //}
 //$link = preg_replace("/^http:\/\//","",$link);
 if ($link != '' && !url_validate($link, true)) {
     $error_flag = 1;
     $alert[6] = "Поле заполнено некорректно";
 }
 if ($is_video == 't') {
     $v_video_link = video_validate($video_link);
     if (!$v_video_link) {
         $error_flag = 1;
         $alert[206] = "Поле заполнено некорректно";
     } else {
         $video_link = preg_replace("/^http:\\/\\//", "", $v_video_link);
     }
 }
 if ($cost < 0 || $cost > $max_portf_cost[$cost_type]) {
     $error_flag = 1;
     if ($is_video == 'f') {
コード例 #9
0
 /**
  * Обработка данных в шаге порфтоило
  * 
  * @return string 
  */
 public function actionProcessingPortfolio()
 {
     $error = array();
     $type = __paramInit('int', null, 'spec_column_id');
     $spec = __paramInit('int', null, 'spec_db_id');
     $spec_name = __paramInit('string', null, 'spec');
     if ($type == 0) {
         $error['spec'] = 'Вы должны выбрать свою специализацию';
     } else {
         $data['spec_orig'] = professions::GetProfessionOrigin($spec);
     }
     $data['spec'] = $spec;
     $data['exp'] = __paramInit('int', null, 'exp');
     $data['cost_hour'] = __paramInit('float', null, 'cost_hour');
     $data['cost_type_hour'] = __paramInit('int', null, 'currency_hour_db_id');
     $curr_hour_name = __paramInit('string', null, 'currency_hour');
     $data['cost_month'] = __paramInit('float', null, 'cost_month');
     $data['cost_type_month'] = __paramInit('int', null, 'currency_month_db_id');
     $curr_month_name = __paramInit('string', null, 'currency_month');
     $data['resume'] = __paramInit('int', null, 'resume_id');
     $data['info'] = stripslashes(__paramInit('string', null, 'info', ''));
     if (strlen($data['info']) > 4000) {
         $error['info'] = 'Исчерпан лимит символов для этого поля (4000 символов)';
     }
     $data['in_office'] = $_POST['in_office'] == 1 ? 1 : 0;
     if ($data['resume'] > 0) {
         $resume = new CFile($data['resume']);
     }
     if ($data['exp'] < 0 || $data['exp'] > step_freelancer::MAX_YEAR_VALUE) {
         $error['exp'] = 'Недопустимое значение. Опыт работы должен быть в пределе от 0 до ' . step_freelancer::MAX_YEAR_VALUE . '.';
     }
     if ($data['cost_hour'] < 0 || $data['cost_hour'] > $this->MAX_COST_HOUR[$data['cost_type_hour']]) {
         $error['cost_hour'] = 'Недопустимое значение. Стоимость часа работы должна быть в пределе ' . view_range_cost2(0, $this->MAX_COST_HOUR[$data['cost_type_hour']], '', '', false, $data['cost_type_hour'] . '.');
     }
     if ($data['cost_month'] < 0 || $data['cost_month'] > $this->MAX_COST_MONTH[$data['cost_type_month']]) {
         $error['cost_month'] = 'Недопустимое значение. Стоимость месяца работы должна быть в пределе ' . view_range_cost2(0, $this->MAX_COST_MONTH[$data['cost_type_month']], '', '', false, $data['cost_type_month']) . '.';
     }
     if (count($error) <= 0) {
         $insert['portfolio'] = serialize($data);
         $this->parent->saveFieldsInfo($insert);
     }
     // Обрабатываем порфтолио
     if (is_array($_POST['name'])) {
         foreach ($_POST['name'] as $k => $value) {
             $value = __paramValue('string', stripslashes($value));
             $descr = __paramValue('string', stripslashes($_POST['descr'][$k]));
             $id = __paramValue('int', $_POST['id'][$k]);
             // id работы, если он есть
             $link = __paramValue('string', stripslashes($_POST['link'][$k]));
             $link = preg_replace("/^http:\\/\\//", "", trim($link));
             if ($value == '' && $descr == '' && $link == '' && empty($_POST['pict_id'][$k])) {
                 continue;
             }
             if (is_empty_html($value)) {
                 $error['portf' . $k]['name'] = "Введите название работы";
             }
             if (strlen($descr) > 1500) {
                 $error['descr' . $k]['name'] = "Исчерпан лимит символов для этого поля (1500 символов)";
             }
             if ($link != '' && !url_validate($link)) {
                 $error['portf' . $k]['link'] = "Поле заполнено некорректно";
             }
             $portf_insert[] = array("name" => $value, "pict_id" => $_POST['pict_id'][$k] > 0 ? intval($_POST['pict_id'][$k]) : null, "link" => $link, "prof_id" => $spec, "wiz_uid" => $this->getWizardUserID(), "descr" => $descr, "id" => $id);
         }
     }
     if (count($error) <= 0) {
         if (count($portf_insert) > 0) {
             $ids = $this->createWorks($portf_insert);
         }
         $this->parent->setCompliteStep(true);
         $this->parent->setNextStep($this->parent->getPosition() + 1);
         header("Location: /wizard/registration/");
         exit;
     }
     $this->request = $data;
     $this->portf_insert = $portf_insert;
     return $error;
 }
コード例 #10
0
ファイル: traffic_stat.php プロジェクト: kapai69/fl-ru-damp
 /**
  * Инициализирует поля класса входящими параметрами и выполняет валидацию данных.
  */
 public function initDomainFromParams()
 {
     $this->bDomainSet = true;
     // флаг установки полей
     $this->sDomainNameError = '';
     // Сообщение об ошибке
     $this->sDomainIdError = '';
     // Сообщение об ошибке
     $this->sDomainId = __paramInit('int', 'id', 'id', 0);
     // ID домена при редактировании
     $this->sDomainName = trim(__paramInit('string', 'name', 'name', ''));
     // Домен
     $this->sDomainActive = __paramInit('int', 'is_active', 'is_active', 0);
     // Используется в данный момент
     $this->sDomainActive = $this->sDomainActive ? 't' : 'f';
     preg_match('#^(?:https?://)?([^/]+)#i', $this->sDomainName, $aMatches);
     $this->sDomainName = $aMatches[1];
     if (empty($this->sDomainName) || !url_validate($this->sDomainName)) {
         $this->sDomainNameError = 'Поле заполнено некорректно';
     } else {
         $sQuery = 'SELECT id FROM traffic_stat_domains WHERE name = ? AND id <> ?i';
         if ($GLOBALS['DB']->val($sQuery, $this->sDomainName, $this->sDomainId)) {
             $this->sDomainNameError = 'Такой домен уже существует';
         }
     }
 }
コード例 #11
0
ファイル: users.php プロジェクト: kapai69/fl-ru-damp
 /**
  * Проверяем контакты введенные пользователем.
  * 
  * @param type $post_contacts
  * @param type $contacts
  *
  * @return string
  */
 public static function validateContacts($post_contacts, &$contacts)
 {
     $error = array();
     foreach ($post_contacts as $name => $value) {
         if (!isset($contacts[$name])) {
             continue;
         }
         switch ($name) {
             case 'phone':
                 //                    if (!preg_match('/^[+]*?[0-9\\s]{9,17}$/', $value) && trim($value) != '') {
                 //                        $error["contact_{$name}"] = 'Поле заполнено некорректно';
                 //                    }
                 break;
             case 'site':
                 if (!url_validate(ltrim(ltrim($value, 'http://'), 'https://')) && trim($value) != '') {
                     $error["contact_{$name}"] = 'Поле заполнено некорректно';
                 }
                 if (strpos($value, 'htt') === false && trim($value) != '') {
                     $value = 'http://' . $value;
                 }
                 break;
             case 'email':
                 if (!is_email($value) && trim($value) != '') {
                     $error["contact_{$name}"] = 'Поле заполнено некорректно';
                 }
                 break;
         }
         $contacts[$name]['value'] = __paramValue('htmltext', stripslashes($value));
     }
     return $error;
 }
コード例 #12
0
ファイル: ArtDB.php プロジェクト: kyuumeitai/cardgen
 private function collectImages(&$images, $path, $name)
 {
     global $config;
     // Look for a file with no picture number.
     $fileName = $path . $name . $this->ext;
     if ($config['art.debug']) {
         echo "\nLooking for art: {$fileName}";
         if (url_validate($fileName)) {
             echo ' *found*';
         }
         echo "\n";
     }
     if (url_validate($fileName)) {
         $images[$fileName] = true;
     }
     // Find all images with picture numbers.
     $i = 1;
     while (true) {
         $fileName = $this->findImage($path, $name, $i);
         if ($fileName) {
             $images[$fileName] = true;
         } else {
             break;
         }
         $i++;
     }
     return $images;
 }
コード例 #13
0
 }
 if ($advice['cost_sum'] >= sbr_stages::MIN_COST_RUR_PDRD) {
     $budget = $advice['cost_sum'];
     $bitDisabled = $bitDisabled | '00010';
 }
 if (!$isReqvsFilled) {
     $bitDisabled = $bitDisabled | '00001';
 }
 // Проверяем все обязательные поля на заполненность + заполненность вкладки Финансы
 $isBtnDisabled = !(($bitDisabled & $bitEnabled) == $bitEnabled);
 if (isset($_POST['save'])) {
     $id_advice = intval($_POST['paid_advice_id']);
     $link = trimhttp(trim($_POST['link_work']));
     $budget = round(floatval($_POST['sum_rub']), 2);
     $is_link = $link != "";
     if (!url_validate($link) && $is_link) {
         $error['doc_result_link'] = 1;
     }
     if ($budget < sbr_stages::MIN_COST_RUR_PDRD) {
         $error['budget'] = 1;
     }
     $attached = $_FILES['attachedfiles_file'];
     $old_attached = $_POST['files_uploaded_id'];
     if (trim($attached['name'][1]) == "" && (int) $old_attached[1] <= 0) {
         $error['doc_contract'] = 1;
     }
     if (trim($attached['name'][2]) == "" && (int) $old_attached[2] <= 0) {
         $error['doc_tz'] = 1;
     }
     if (trim($attached['name'][3]) == "" && !$is_link && (int) $old_attached[3] <= 0) {
         $error['doc_result'] = 1;
コード例 #14
0
ファイル: index.php プロジェクト: Nikitian/fl-ru-damp
 }
 // more site
 if ($frl->site_1 = change_q(substr(addhttp(trim($_POST['site_1'])), 0, 96), true)) {
     if (!url_validate($frl->site_1, true)) {
         $error_flag = 1;
         $alert[41] = "Поле заполнено некорректно";
     }
 }
 if ($frl->site_2 = change_q(substr(addhttp(trim($_POST['site_2'])), 0, 96), true)) {
     if (!url_validate($frl->site_2, true)) {
         $error_flag = 1;
         $alert[42] = "Поле заполнено некорректно";
     }
 }
 if ($frl->site_3 = change_q(substr(addhttp(trim($_POST['site_3'])), 0, 96), true)) {
     if (!url_validate($frl->site_3, true)) {
         $error_flag = 1;
         $alert[43] = "Поле заполнено некорректно";
     }
 }
 // more site
 $frl->icq = substr(strip_tags(trim($_POST['icq'])), 0, 96);
 if (strlen($frl->jabber = __paramInit('string', NULL, 'jabber', '')) > 3071) {
     $error_flag = 1;
     $alert['jabber'] = "Количество знаков превышает допустимое значение";
 }
 // more jabber
 if (strlen($frl->jabber_1 = __paramInit('string', NULL, 'jabber_1', '')) > 3071) {
     $error_flag = 1;
     $alert['51'] = "Количество знаков превышает допустимое значение";
 }
コード例 #15
0
 $output = str_replace("{date-elapsed}", aj_elapsed($comment_arr[0]), $output);
 $output = str_replace("{date}", langdate($config_timestamp_comment, $comment_arr[0]), $output);
 if ($isurl == "yes") {
     $comment_arr[2] = run_filters('news-comment-display-url', $comment_arr[2]);
 } elseif ($comment_arr[2] != "none") {
     $comment_arr[2] = run_filters('news-comment-display-email', $comment_arr[2]);
 }
 # Favatar support
 if ($isurl == "yes" && $comment_arr[2] != "none" && strpos($output, "{favatar}")) {
     $favatar = getFavicon($comment_arr[2]);
     if ($favatar) {
         $output = str_replace("{favatar}", "<img alt=\"Favatar\" src=\"{$favatar_url}\" width=\"16\" height=\"16\" class=\"favatar_image\" />", $output);
     } else {
         $urlParts = parse_url($comment_arr[2]);
         $faviconURL = $urlParts['scheme'] . '://' . $urlParts['host'] . '/favicon.ico';
         if (url_validate($faviconURL)) {
             $output = str_replace("{favatar}", "<img alt=\"Favatar\" src=\"{$faviconURL}\" width=\"16\" height=\"16\" class=\"favatar_image\" />", $output);
         } else {
             $output = str_replace("{favatar}", "", $output);
         }
     }
 } elseif ($isurl == "no" || $comment_arr[2] == "none") {
     $output = str_replace("{favatar}", "", $output);
 }
 $output = str_replace("{comment-id}", $comment_arr[0], $output);
 $output = str_replace("{comment}", "<a id=\"" . "C" . $comment_arr[0] . "\"></a>{$comment_arr['4']}", $output);
 # {comnum} & altcolors
 if ($i % 2 == 0) {
     $com_alternating = "cn_comment_odd";
 } else {
     $com_alternating = "cn_comment_even";
コード例 #16
0
ファイル: portfolio.php プロジェクト: kapai69/fl-ru-damp
 public function validateWork($params)
 {
     $portf_cost = self::$portf_cost;
     foreach ($params as $name => $value) {
         switch ($name) {
             case 'video':
                 if ($value != '') {
                     if (!video_validate($value)) {
                         $error[$name] = 'Поле заполнено некорректно. Введите корректную ссылку на видео.';
                     }
                 }
                 break;
             case 'work_name':
                 if ($value == '') {
                     $error[$name] = 'Поле заполнено некорректно. Введите название.';
                 }
                 if (strlen(trim(stripslashes($value))) > 120) {
                     $error[$name] = 'Поле заполнено некорректно. Название должно содержать не более 120 символов.';
                 }
                 break;
             case 'link':
                 if ($value != '' && !url_validate($value, true)) {
                     $error[$name] = 'Поле заполнено некорректно. Введите корректную ссылку.';
                 }
                 break;
             case 'work_cost':
                 $cost_type = $params['work_cost_type_db_id'];
                 if ($value < 0 || $value > self::$portf_cost[$cost_type]) {
                     $error[$name] = 'Поле заполнено некорректно. Стоимость должна быть в пределе от 0 ' . view_range_cost2(0, self::$portf_cost[$cost_type], '', '', false, $cost_type) . ($cost_type != 2 ? '.' : '');
                 }
                 break;
             case 'time_cost':
                 if ($value < 0 || $value > self::MAX_TIME_VALUE) {
                     $error[$name] = 'Поле заполнено некорректно. Временные затраты должны быть в пределе от 0 до ' . self::MAX_TIME_VALUE . '.';
                 }
                 break;
         }
     }
     return $error;
 }