Esempio n. 1
0
function getUserPhoto()
{
    $objResponse = new xajaxResponse();
    $udata = users::getUserShortInfoFinInfo(get_uid(false));
    if (!$udata['no_foto']) {
        $ufoto = WDCPREFIX . '/users/' . $_SESSION['login'] . '/foto/' . get_unanimated_gif($_SESSION['login'], $udata['record']['photo']);
    } else {
        $ufoto = WDCPREFIX . '/images/no_foto_b.png';
    }
    //@todo: top_payed.php более неиспользуется
    //$objResponse->script('TopPayed.adImgPath = "'.$ufoto.'";');
    $objResponse->script('$("payfoto").set("src","' . $ufoto . '")');
    return $objResponse;
}
 /**
  * Поиск пользователей и компаний.
  *
  * @param $s     - поисковая строка
  * @param $limit - сколько записей запрашивать
  * @param $userType - фильтр результатов поиска  0: искать и фриленсеров и работодателей,   
  *                                               1: искать только фриленсеров,
  *                                               2: искать только работодателей,
  * @param $scope    - определяет, где искать     0:   в СБР/контактах и общем списке пользователей,
  *                                               1:   в СБР/контактах,
  *                                               2:   в общем списке пользователей
  * @param $is_delete - искать удаленных пользователей или нет
  * */
 private function getUsersAndCompany($s, $limit = ' ALL ', $userType = 0, $scope = 0, $is_delete = true)
 {
     require_once $_SERVER['DOCUMENT_ROOT'] . '/classes/letters.php';
     $s = iconv('UTF-8', 'WINDOWS-1251//IGNORE', $s);
     $s = substr($s, 0, 40);
     $rows = array();
     if ($scope != 1) {
         if ($s != '') {
             $rows = users::GetUsersBySubstringInFinInfo($s, $limit, $moreUsers);
             //$DB->cache(600)->rows($cmd);
             $map = array();
             foreach ($rows as $k => $i) {
                 $i['uname'] = str_replace(array('onerror', 'onload', '<script'), array('', '', ''), $i['uname']);
                 $i['uname'] = iconv('WINDOWS-1251', 'UTF-8//IGNORE', htmlspecialchars_decode($i['uname']));
                 $i['usurname'] = '';
                 $i['address'] = str_replace(array('onerror', 'onload', '<script'), array('', '', ''), $i['address']);
                 $i['address'] = iconv('WINDOWS-1251', 'UTF-8//IGNORE', "{$i['country']}, {$i['city']}, {$i['index']}, {$i['address']}");
                 $i['photo'] = str_replace(array('onerror', 'onload', '<script'), array('', '', ''), $i['photo']);
                 $i['photo'] = get_unanimated_gif($i['login'], $i['photo']);
                 $i['path'] = 'users/' . substr($i['login'], 0, 2) . '/' . $i['login'] . '/foto/';
                 $i['name'] = str_replace(array('onerror', 'onload', '<script'), array('', '', ''), $i['name']);
                 $i['name'] = iconv('WINDOWS-1251', 'UTF-8//IGNORE', htmlspecialchars_decode($i['name']));
                 $i['country'] = iconv('WINDOWS-1251', 'UTF-8//IGNORE', htmlspecialchars_decode($i['country']));
                 $i['city'] = iconv('WINDOWS-1251', 'UTF-8//IGNORE', htmlspecialchars_decode($i['city']));
                 $i['isContacts'] = 1;
                 if ($i['photo'] === null || $i['path'] === null) {
                     $i['photo'] = '/images/temp/small-pic.gif';
                 }
                 $rows[$k] = $i;
                 $map[$i['uid']] = $k;
             }
             $moreUsers -= $limit;
             if ($moreUsers < 0) {
                 $moreUsers = 0;
             }
         }
     }
     //get company list
     $companies = letters::getCompanies($s, $limit);
     if ($companies['data']) {
         foreach ($companies['data'] as $company) {
             if ($company['frm_type']) {
                 $company['name'] = $company['frm_type'] . ' "' . $company['name'] . '"';
             }
             $i['uid'] = $company['id'];
             $company['name'] = str_replace(array('onerror', 'onload', '<script'), array('', '', ''), $company['name']);
             $i['uname'] = iconv('WINDOWS-1251', 'UTF-8//IGNORE', htmlspecialchars_decode($company['name']));
             $company['address'] = str_replace(array('onerror', 'onload', '<script'), array('', '', ''), $company['address']);
             $company['index'] = str_replace(array('onerror', 'onload', '<script'), array('', '', ''), $company['index']);
             $company['city_title'] = str_replace(array('onerror', 'onload', '<script'), array('', '', ''), $company['city_title']);
             $i['address'] = iconv('WINDOWS-1251', 'UTF-8//IGNORE', "{$company['country_title']}, {$company['city_title']}, {$company['index']}, {$company['address']}");
             $i['name'] = iconv('WINDOWS-1251', 'UTF-8//IGNORE', htmlspecialchars_decode($i['name']));
             $i['country'] = iconv('WINDOWS-1251', 'UTF-8//IGNORE', htmlspecialchars_decode($i['country']));
             $i['city'] = iconv('WINDOWS-1251', 'UTF-8//IGNORE', htmlspecialchars_decode($i['city']));
             $i['usurname'] = '';
             $i['login'] = '';
             $i['photo'] = '';
             $i['isContacts'] = 0;
             $i['isCompany'] = 1;
             $rows[] = $i;
         }
     }
     $moreCompany = intval($companies['count']) - intval(count($companies['data']));
     //сюда запишем N из фразы "Показаны первые M из N компаний"
     $result = $rows;
     $data = array('list' => $result, 'counters' => array('moreContacts' => $moreUsers, 'moreUsers' => $moreCompany), 'dav' => WDCPREFIX);
     return json_encode($data);
 }
Esempio n. 3
0
 /**
  * Назначить логотип к проекту
  * 
  * @param object file  Файл логотипа (@see CFile)
  * @return string|integer Сообщение об ошибке. либо 0
  */
 function setLogoNew(CFile $file)
 {
     $this->delLogo();
     $this->_tmpFiles[] = $file->name;
     $file_name = get_unanimated_gif($_SESSION['login'], $file->name, $file->path);
     $this->_tmpFiles[] = $file_name;
     $this->_logo = array('id' => $file->id, 'path' => $file->path, 'name' => $file->name, 'size' => $file->size, 'ftype' => $file->getext());
     return 0;
 }
Esempio n. 4
0
function view_image_file($filename, $login, $dir, $params = array())
{
    if ($params['template'] == '') {
        $params['template'] = '%s';
    }
    if ($filename == '') {
        return "";
    }
    $l_dir = substr($login, 0, 2) . "/" . $login;
    $path = "users/{$l_dir}/{$dir}/" . $filename;
    $cfile = new CFile($path);
    $width = $cfile->image_size['width'];
    $height = $cfile->image_size['height'];
    $type = $cfile->image_size['type'];
    if (!$width || !$height) {
        return "";
    }
    list($width, $height) = dimension_image($width, $height, $params['max_dim']);
    if ($params['unanimate_gif']) {
        $filename = get_unanimated_gif($login, $filename, dirname($path));
    }
    $image_path = WDCPREFIX . "/users/{$login}/{$dir}/{$filename}";
    $params['image'] = array('src' => $image_path, 'alt' => $params['alt'], 'width' => $width, 'height' => $height, 'id' => $params['id'], 'class' => $params['class']);
    array_walk($params['image'], 'array2params');
    $html = '<img ' . implode(" ", $params['image']) . '/>';
    return sprintf($params['template'], $html);
}
Esempio n. 5
0
 /**
  * Получить информацию о пользователе для вывода в результате поиска.
  *
  * @param $uid идентификатор пользователя
  *
  * @return array
  * */
 public static function getUserShortInfo($uid)
 {
     global $DB;
     $query = "SELECT u.uid, u.uname, u.usurname, u.login, u.photo, file.path, u.role\n                    FROM users AS u\n                    LEFT JOIN file \n                        ON file.fname = u.photo \n                    WHERE u.uid = {$uid}                                                            \n                 ";
     $data = $DB->row($query);
     $data['uname'] = iconv('WINDOWS-1251', 'UTF-8//IGNORE', $data['uname']);
     $data['usurname'] = iconv('WINDOWS-1251', 'UTF-8//IGNORE', $data['usurname']);
     $data['photo'] = get_unanimated_gif($data['login'], $data['photo']);
     if ($data['photo'] === null || $data['path'] === null) {
         $data['photo'] = '/images/temp/small-pic.gif';
     }
     $contacts = explode(',', self::getMsgContact($_SESSION['uid']));
     $data['isContacts'] = 0;
     foreach ($contacts as $c) {
         if ($uid == $c) {
             $data['isContacts'] = 1;
             break;
         }
     }
     $found = 0;
     if (count($data)) {
         $found = 1;
     }
     $data = array('record' => $data, 'found' => $found, 'dav' => WDCPREFIX);
     return $data;
 }
 /**
  * Поиск пользователей и компаний
  * @param $s     - поисковая строка
  * @param $limit - сколько записей запрашивать
  * @param $userType - фильтр результатов поиска  0: искать и фриленсеров и работодателей,   
  *                                               1: искать только фриленсеров,
  *                                               2: искать только работодателей,
  * @param $scope    - определяет, где искать     0:   в СБР/контактах и общем списке пользователей,
  *                                               1:   в СБР/контактах,
  *                                               2:   в общем списке пользователей
  * @param $is_delete - искать удаленных пользователей или нет
  * */
 private function getUsersAndCompany($s, $limit = " ALL ", $userType = 0, $scope = 0, $is_delete = true)
 {
     require_once $_SERVER["DOCUMENT_ROOT"] . "/classes/letters.php";
     $s = iconv("UTF-8", "WINDOWS-1251//IGNORE", $s);
     $s = substr($s, 0, 40);
     $rows = array();
     if ($scope != 1) {
         if ($s != "") {
             $rows = users::GetUsersBySubstringInFinInfo($s, $limit, $moreUsers);
             //$DB->cache(600)->rows($cmd);
             $map = array();
             foreach ($rows as $k => $i) {
                 $i["uname"] = str_replace(array("onerror", "onload", '<script'), array('', '', ''), $i["uname"]);
                 $i["uname"] = iconv("WINDOWS-1251", "UTF-8//IGNORE", htmlspecialchars_decode($i["uname"]));
                 $i["usurname"] = '';
                 $i["address"] = str_replace(array("onerror", "onload", '<script'), array('', '', ''), $i["address"]);
                 $i["address"] = iconv("WINDOWS-1251", "UTF-8//IGNORE", "{$i['country']}, {$i['city']}, {$i['index']}, {$i['address']}");
                 $i["photo"] = str_replace(array("onerror", "onload", '<script'), array('', '', ''), $i["photo"]);
                 $i['photo'] = get_unanimated_gif($i['login'], $i['photo']);
                 $i['path'] = "users/" . substr($i['login'], 0, 2) . "/" . $i['login'] . "/foto/";
                 $i["name"] = str_replace(array("onerror", "onload", '<script'), array('', '', ''), $i["name"]);
                 $i["name"] = iconv("WINDOWS-1251", "UTF-8//IGNORE", htmlspecialchars_decode($i["name"]));
                 $i["country"] = iconv("WINDOWS-1251", "UTF-8//IGNORE", htmlspecialchars_decode($i["country"]));
                 $i["city"] = iconv("WINDOWS-1251", "UTF-8//IGNORE", htmlspecialchars_decode($i["city"]));
                 $i["isContacts"] = 1;
                 if ($i["photo"] === null || $i["path"] === null) {
                     $i["photo"] = "/images/temp/small-pic.gif";
                 }
                 $rows[$k] = $i;
                 $map[$i["uid"]] = $k;
             }
             $moreUsers -= $limit;
             if ($moreUsers < 0) {
                 $moreUsers = 0;
             }
         }
     }
     //get company list
     $companies = letters::getCompanies($s, $limit);
     if ($companies['data']) {
         foreach ($companies['data'] as $company) {
             if ($company['frm_type']) {
                 $company['name'] = $company['frm_type'] . ' "' . $company['name'] . '"';
             }
             $i["uid"] = $company['id'];
             $company["name"] = str_replace(array("onerror", "onload", '<script'), array('', '', ''), $company["name"]);
             $i["uname"] = iconv("WINDOWS-1251", "UTF-8//IGNORE", htmlspecialchars_decode($company['name']));
             $company["address"] = str_replace(array("onerror", "onload", '<script'), array('', '', ''), $company["address"]);
             $company["index"] = str_replace(array("onerror", "onload", '<script'), array('', '', ''), $company["index"]);
             $company["city_title"] = str_replace(array("onerror", "onload", '<script'), array('', '', ''), $company["city_title"]);
             $i["address"] = iconv("WINDOWS-1251", "UTF-8//IGNORE", "{$company['country_title']}, {$company['city_title']}, {$company['index']}, {$company['address']}");
             $i["name"] = iconv("WINDOWS-1251", "UTF-8//IGNORE", htmlspecialchars_decode($i["name"]));
             $i["country"] = iconv("WINDOWS-1251", "UTF-8//IGNORE", htmlspecialchars_decode($i["country"]));
             $i["city"] = iconv("WINDOWS-1251", "UTF-8//IGNORE", htmlspecialchars_decode($i["city"]));
             $i["usurname"] = "";
             $i["login"] = "";
             $i['photo'] = "";
             $i["isContacts"] = 0;
             $i["isCompany"] = 1;
             $rows[] = $i;
         }
     }
     $moreCompany = intval($companies['count']) - intval(count($companies['data']));
     //сюда запишем N из фразы "Показаны первые M из N компаний"
     $result = $rows;
     $data = array("list" => $result, "counters" => array("moreContacts" => $moreUsers, "moreUsers" => $moreCompany), "dav" => WDCPREFIX);
     return json_encode($data);
 }
Esempio n. 7
0
/**
 *
 * Аналог view_preview(...) без обращения к CFile за размерами и типом
 * генерируется тег картинки без размеров а тип определяется по расширению файла
 *
 * @param type $ulogin
 * @param type $filename
 * @param type $dir
 * @param type $align
 * @param type $show_blank_preview
 * @param type $unanimate_gif
 * @param type $alt
 * @param type $max_dim
 * @return string HTML-код
 */
function view_preview2($ulogin, $filename, $dir, $align = 'center', $show_blank_preview = false, $unanimate_gif = false, $alt = '', $max_dim = 0)
{
    $l_dir = substr($ulogin, 0, 2) . "/" . $ulogin;
    if ($filename == '') {
        return $show_blank_preview ? view_blank_preview($align) : "";
    } else {
        $width = $height = $max_dim;
        $path = "users/{$l_dir}/{$dir}/" . $filename;
        if (pathinfo($filename, PATHINFO_EXTENSION) == 'swf') {
            return "<div class=\"b-page__desktop b-page__ipad\"  style=\"text-align:{$align}\"><div id=\"viewattachswf\"></div></div>\n                    <script type=\"text/javascript\">\n                    \tvar flashvars = {};\n                    \tvar params = {allowscriptaccess: \"never\", wmode: \"opaque\"};\n                    \tvar attributes = {};\n                    \tswfobject.embedSWF(\"" . WDCPREFIX . "/users/{$ulogin}/{$dir}/{$filename}\", \"viewattachswf\", \"{$width}\", \"{$height}\", \"9.0.16\", \"/scripts/expressInstall.swf\", flashvars, params, attributes);\n                    </script>";
        }
        if ($unanimate_gif) {
            $filename = get_unanimated_gif($ulogin, $filename, dirname($path));
        }
        return "<span style=\"text-align:{$align}\"><img class=\"b-pic b-pic_max_{$max_dim}\" src=\"" . WDCPREFIX . "/users/{$ulogin}/{$dir}/{$filename}\" alt=\"{$alt}\" itemprop=\"contentUrl\" /></span>";
    }
}