Example #1
0
 function display()
 {
     current_page('files');
     page_title(lang('fl_mylist'), URL . '/files/');
     if (!user('logged')) {
         return login_req();
     }
     $data = ldb_select('upload', '*', '`uid`=' . user('id') . ' ORDER BY `tms_upload` DESC');
     $u_list = '';
     for ($x = 0; $x < count($data); $x++) {
         $f_title = '';
         if ($data[$x]['comment']) {
             $f_title = htmlspecialchars($data[$x]['comment']);
         } else {
             # Get files
             $f_list = ldb_select('file', array('file_name'), '`upid`=' . $data[$x]['id'] . ' ORDER BY `id`');
             $f_list_len = 0;
             $f_list_d = array();
             for ($a = 0; $a < count($f_list); $a++) {
                 $f_list_d[] = '<i>' . htmlspecialchars($f_list[$a]['file_name']) . '</i>';
                 $f_list_len += mb_strlen($f_list[$a]['file_name'], 'UTF-8');
                 if ($f_list_len > 50) {
                     break;
                 }
             }
             if (count($f_list_d) < count($f_list)) {
                 $f_list_d[] = '<b>...</b>';
             }
             $f_title = implode(', ', $f_list_d);
         }
         $f_title = trim($f_title);
         if (!$f_title) {
             $f_title = sprintf(lang('fld_title_n'), $data[$x]['id']);
         }
         $u_list .= '<tr>';
         $u_list .= '<td align="center">' . $data[$x]['id'] . '</td>';
         $u_list .= '<td align="left" class="mf-table-flink"><a href="' . URL . '/f/' . $data[$x]['code'] . '/">' . $f_title . '</a></td>';
         $u_list .= '<td align="center">' . date('d.m.Y H:i', $data[$x]['tms_upload']) . '</td>';
         $u_list .= '<td align="center">' . time_delete($data[$x]['tms_upload'], $data[$x]['tms_delete']) . '</td>';
         $u_list .= '<td align="center">' . format_size($data[$x]['file_size']) . '</td>';
         $u_list .= '</tr>';
     }
     $tpl = new ltpl('myfiles');
     $tpl->v('u_list', $u_list);
     return $tpl->get();
 }
Example #2
0
 function display()
 {
     $index_tpl = 'index';
     $tpl = new ltpl($index_tpl);
     // fatal errors?
     if ($this->global_msg) {
         // Show global message (login error?)
         $this->mainhref = $this->global_msg;
     }
     // Errors & warnings
     if ($this->error) {
         // Add fatal errors
         $out = '';
         $out .= '<div class="error_div">';
         $out .= '<h3>' . lang('e_title') . '</h3>';
         if (count($this->error) > 1) {
             $out .= '<ul>';
             foreach ($this->error as $k => $e) {
                 $out .= '<li>' . $e . '</li>';
             }
             $out .= '</ul>';
         } else {
             $out .= '<p>' . $this->error[0] . '</p>';
         }
         $out .= '</div>';
         $this->mainhref = $out . $this->mainhref;
     }
     $tpl->v('main', $this->mainhref);
     // Site title
     if (!$this->site_title) {
         $this->site_title = $GLOBALS['siteconfig']['site_title'];
     } else {
         $this->site_title = $GLOBALS['siteconfig']['site_title'] . ' : ' . $this->site_title;
     }
     if ($this->page_title) {
         $this->page_title[count($this->page_title) - 1] = '<b>' . $this->page_title[count($this->page_title) - 1] . '</b>';
         $this->page_title = implode(' / ', $this->page_title);
     }
     if (!$this->meta_kw && !$this->meta_desc) {
         //$metad = db_select_one ('site_pages', array('meta_kw','meta_desc'),'index','name');
         $this->meta_kw = @$metad['meta_kw'];
         $this->meta_desc = @$metad['meta_desc'];
     }
     $tpl->v('main', $this->mainhref);
     $tpl->v('meta_kw', $this->meta_kw);
     $tpl->v('meta_desc', $this->meta_desc);
     $tpl->v('site_title', $this->site_title);
     $tpl->v('page_title', $this->page_title);
     $tpl->v('public_wdg', $this->public_wdg);
     $tpl->v('cookie_domain', COOKIE_DOMAIN);
     $tpl->v('code_bottom', @$GLOBALS['siteconfig']['code_bottom']);
     if (@cfg('debug') || is_debug()) {
         $tpl->v('debug', ldb_log_html());
     }
     echo $tpl->get();
 }
Example #3
0
 function display()
 {
     current_page('upload');
     if (!user('logged')) {
         # Login req
         return login_req();
     }
     if (!@$_COOKIE['usid']) {
         setcookie('usid', md5(microtime(true) . mt_rand() . md5(sha1(time()) . microtime(true)) . mt_rand()), time() + 86400, '/', COOKIE_DOMAIN);
     } else {
         setcookie('usid', $_COOKIE['usid'], time() + 86400, '/', COOKIE_DOMAIN);
     }
     if (!$this->check_sid()) {
         // Generate new SID
         return $this->new_sid();
     }
     if (input(1, 'complete')) {
         return $this->complete();
     }
     if (input(1, 'final')) {
         return $this->get_final();
     }
     # Form - reset status
     if (ldb_select_one('upload', array('id'), $this->sid, 'code')) {
         return $this->new_sid();
     }
     # Default - show form
     $tpl = new ltpl('upload');
     # Get ext table
     $ext_t = '';
     $ext_js = array();
     if (cfg('ext_control')) {
         foreach ($GLOBALS['ext'] as $eg) {
             $ext_t .= '<div class="ext_t"><h3>' . $eg['t'] . ':</h3><ul>';
             foreach ($eg['d'] as $ed) {
                 $ext_t .= '<li><b>' . $ed[0] . '</b> (' . implode(', ', $ed[1]) . ')</li>';
                 $ext_js = array_merge($ext_js, $ed[1]);
             }
             $ext_t .= '</ul></div>';
         }
     }
     include_once CORE_PATH . '/ttl.php';
     $ttl_s = '';
     foreach ($GLOBALS['ttl'] as $tm => $tt) {
         $ttl_s .= '<option value="' . $tm . '"' . ($tm == $GLOBALS['ttl_def'] ? ' selected="selected"' : '') . '>' . $tt . '</option>';
     }
     $tpl->v('sid', $this->sid);
     $tpl->v('ext_t', $ext_t);
     $tpl->v('ext_js', '\'' . implode('\',\'', $ext_js) . '\'');
     $tpl->v('max_size', user_max_size());
     $tpl->v('ttl_sel', $ttl_s);
     return $tpl->get();
 }
Example #4
0
 static function file($name)
 {
     $tpl = new ltpl($name);
     return $tpl->get();
 }
Example #5
0
 function display()
 {
     current_page('f');
     page_title(lang('fl_mylist'), URL . '/files/');
     $out = '';
     $public = false;
     if (input(2)) {
         $public = true;
     }
     $sid = input(1);
     $u_data = ldb_select_one('upload', '*', $sid, 'code');
     if (!$u_data) {
         return core_error_404();
     }
     $GLOBALS['core']->public_wdg = !$public;
     if ($u_data['uid'] != user('id')) {
         if (!input(2, $u_data['ph'])) {
             return core_error_404();
         } else {
             # Public page view...
         }
     }
     $own = $u_data['uid'] == user('id');
     if ($own && @$_POST['sub_edit'] && @($_GET['k'] = md5(user('lk')))) {
         return $this->edit($u_data);
     }
     if ($own && @$_GET['del'] && @($_GET['k'] = md5(user('lk')))) {
         return $this->del($u_data);
     }
     page_title(sprintf(lang('fld_title_n'), $u_data['id']));
     $f_data = ldb_select('file', '*', '`upid`=' . $u_data['id']);
     $u_data['time_added'] = date('d.m.Y H:i', $u_data['tms_upload']);
     $u_data['time_del'] = time_delete($u_data['tms_upload'], $u_data['tms_delete']);
     $u_data['user'] = user_link($u_data['uid']);
     $u_data['descr'] = htmlspecialchars($u_data['comment']);
     $f_list = '';
     for ($x = 0; $x < count($f_data); $x++) {
         $f_link = URL . '/c/d/' . $u_data['code'] . '/' . $f_data[$x]['upn'] . '/' . $f_data[$x]['dh'] . '/' . htmlspecialchars($f_data[$x]['file_name']);
         $f_flink = URL . '/c/f/' . $u_data['code'] . '/' . $f_data[$x]['upn'] . '/' . $f_data[$x]['dh'] . '/' . htmlspecialchars($f_data[$x]['file_name']);
         $fd = $f_data[$x];
         $fd['size'] = format_size($fd['file_size']);
         $fd['name'] = htmlspecialchars($fd['file_name']);
         $tpl = new ltpl('download-file-item');
         $tpl->v('f', $fd);
         $tpl->v('f_link', $f_link);
         $tpl->v('f_link_f', $f_flink);
         # Get file icon
         $f_icon = get_icon($fd['file_ext']);
         $tpl->v('f_icon', $f_icon);
         $f_list .= $tpl->get();
     }
     include_once CORE_PATH . '/ttl.php';
     $ttl_s = '';
     foreach ($GLOBALS['ttl'] as $tm => $tt) {
         $ttl_s .= '<option value="' . $tm . '"' . ($tm == $u_data['ttl'] ? ' selected="selected"' : '') . '>' . $tt . '</option>';
     }
     $u_data['publink'] = URL . '/f/' . $u_data['code'] . '/' . $u_data['ph'] . '/';
     $tpl = new ltpl('download-file');
     $tpl->v('u_data', $u_data);
     $tpl->v('f_list', $f_list);
     $tpl->v('ttl_sel', $ttl_s);
     $tpl->v('own', $u_data['uid'] == user('id'));
     $out .= $tpl->get();
     return $out;
 }
Example #6
0
function show_vote($id)
{
    $id = intval($id);
    $data = db_select_one('site_votes', '*', $id);
    if (!$data) {
        return 'Опрос не найден';
    }
    $ans = @unserialize($data['data']);
    # Voting?
    if ($data['is_active'] == 'Y' && user('logged') && isset($_POST['sub_vote']) && !db_select('site_votes_voters', array('id'), '`id`=' . $id . ' AND `uid`=' . user('id'))) {
        # Voting!
        if ($data['type'] == 'S') {
            if (isset($ans[@$_POST['vote_ans']])) {
                $ans[@$_POST['vote_ans']]['a']++;
            }
        } else {
            for ($x = 0; $x < count($ans); $x++) {
                if (in_array($x, @$_POST['vote_ans'])) {
                    $ans[$x]['a']++;
                }
            }
        }
        db_update_by_id('site_votes', $id, array('data' => serialize($ans)));
        db_insert('site_votes_voters', array('id' => $id, 'uid' => user('id'), 'tms' => time()));
        redirect_msg(URL . '/votes/' . $id . '/', 'Спасибо, ваш голос принят!');
        exit;
    }
    # Check - resuilts?
    $out = '';
    $bot = '';
    $is_res = false;
    if ($data['is_active'] != 'Y' || !user('logged') || isset($_GET['vote_resuilts']) || db_select('site_votes_voters', array('id'), '`id`=' . $id . ' AND `uid`=' . user('id'))) {
        $is_res = true;
    }
    $tpl = new ltpl('vote_area');
    $tpl->v('title', $data['title']);
    if ($is_res) {
        $GLOBALS['vote_color'] = 0;
        $all = 0;
        for ($x = 0; $x < count($ans); $x++) {
            $all += $ans[$x]['a'];
        }
        # Show resuilts
        for ($x = 0; $x < count($ans); $x++) {
            $pers = @round($ans[$x]['a'] / $all * 100);
            $out .= '<tr>';
            $out .= '<td width="30" align="center">' . ($x + 1) . '.</td>';
            $out .= '<td align="left">' . htmlspecialchars($ans[$x]['t']) . '</td>';
            #$out .= '<td width="30" align="left">'.intval($ans[$x]['a']).'</td>';
            $out .= '<td width="30" align="left">' . $pers . '%</td>';
            $out .= '</tr>';
            $pers = @round($ans[$x]['a'] / $all * 100);
            if (!$pers) {
                $pers = 1;
            }
            $out .= '<tr>';
            $out .= '<td>&nbsp;</td>';
            $out .= '<td align="left" colspan="2"><table width="100%"><tr><td width="' . $pers . '%" style="background-color:' . vote_color() . ';padding:5px;"><img src="' . URL . '/tpl/images/spacer.gif" alt=""/></td><td><img src="' . URL . '/tpl/images/spacer.gif" alt=""/></td></tr></table></td>';
            $out .= '</tr>';
        }
        if ($data['is_active'] != 'Y') {
            $bot = 'Опрос уже завершен';
        } elseif (!user('logged')) {
            $bot = 'Гости не могут голосовать';
        } elseif (db_select('site_votes_voters', array('id'), '`id`=' . $id . ' AND `uid`=' . user('id'))) {
            $bot = 'Вы уже отдали свой голос';
        } else {
            $bot = '<input type="submit" value="Голосовать"/>';
        }
        #$bot .= '<input type="submit" value="Голосовать"/>';
    } else {
        # Show form
        $idt = mt_rand();
        for ($x = 0; $x < count($ans); $x++) {
            if ($data['type'] == 'S') {
                $ch = '<input type="radio" name="vote_ans" value="' . $x . '" id="vote_' . $idt . '_' . $x . '"/>';
            } else {
                $ch = '<input type="checkbox" name="vote_ans[]" value="' . $x . '" id="vote_' . $idt . '_' . $x . '"/>';
            }
            $out .= '<tr>';
            $out .= '<td width="15" align="center">' . $ch . '</td>';
            $out .= '<td align="left"><label for="vote_' . $idt . '_' . $x . '">' . htmlspecialchars($ans[$x]['t']) . '</label></td>';
            $out .= '</tr>';
        }
        $bot .= '<input type="submit" name="sub_vote" value="Голосовать"/> <input type="button" value="Результаты" onclick="document.location.href=\'' . URL . '/votes/' . $id . '/?vote_resuilts=1\';"/>';
    }
    $tpl->v('id', $id);
    $tpl->v('data', $out);
    $tpl->v('is_res', $is_res);
    $tpl->v('bot', $bot);
    return $tpl->get();
}
Example #7
0
 function post_attach($text)
 {
     $data = ldb_select('site_attach_files', '*', '`id` IN (SELECT `file_id` FROM `site_attach_post` WHERE `id_1`=\'' . $this->id_1 . '\' AND `id_2`=' . $this->id_2 . ')');
     if (!$data) {
         return '';
     }
     $data = array_id2key($data);
     # Get list of attaches inline in post
     $match = array();
     if (preg_match_all('"file/([0-9]+)/"Uuims', $text, $m)) {
         for ($x = 0; $x < count($m[1]); $x++) {
             if (isset($data[$m[1][$x]])) {
                 $match[$m[1][$x]] = 1;
             }
         }
     }
     $types = array();
     foreach ($data as $id => $at) {
         if (isset($match[$id])) {
             continue;
         }
         $type = $this->get_type($at['file_name']);
         if ($type == 'IMAGE') {
             $types['image'][] = $at;
             continue;
         }
         if ($type == 'FVIDEO') {
             $types['fvideo'][] = $at;
             continue;
         }
         $types['other'][] = $at;
     }
     if (!$types) {
         return '';
     }
     // No files
     $out = '';
     # Images
     if (@$types['image']) {
         $out .= '<div class="attaches_list">';
         $out .= '<a name="attach_img"></a>';
         $out .= '<h3>Фотографии</h3>';
         foreach ($types['image'] as $att) {
             $out .= '<a href="' . $this->file_link($att) . '" rel="lightbox[roadtrip]"><img src="' . $this->file_link($att) . '?size=600x120" alt="" style="margin:3px;vertical-align:middle;" class="attach_img_gal"/></a> ';
         }
         $out .= '</div>';
     }
     # Flash video
     if (@$types['fvideo']) {
         $out .= '<div class="attaches_list">';
         $out .= '<a name="attach_video"></a>';
         $out .= '<h3>Видео</h3>';
         $tpl = new ltpl('attach_video');
         $list = '';
         $init = array();
         foreach ($types['fvideo'] as $att) {
             if (!$init) {
                 $init = $att;
             }
             $list .= '<table width="100%" cellpadding="0" cellspacing="0"><tr>';
             $list .= '<td width="80" align="center"><img src="' . URL . '/tpl/img/play_sd.png" id="att_video_btn_' . $att['id'] . '" style="cursor:pointer;" onclick="play_video(' . $att['id'] . ',\'' . $att['key'] . '\');" alt="Посмотреть" title="Посмотреть"/></td>';
             $list .= '<td align="left" valign="top">';
             #$list .= '<div class="attach_video_name">'.$att['file_name'].'</div>';
             #$list .= '<div class="attach_video_size">'.format_size($att['file_size']).'</div>';
             $list .= '</td>';
             $list .= '</tr></table>';
         }
         $init['url'] = attach::file_link($init);
         $tpl->v('list', $list);
         $tpl->v('init', $init);
         $out .= $tpl->get();
         $out .= '</div>';
     }
     # Other
     if (@$types['other']) {
         $out .= '<div class="attaches_list">';
         $out .= '<h3>Прочие файлы</h3>';
         foreach ($types['other'] as $att) {
             $out .= '<table width="100%" cellpadding="1" cellspacing="0"><tr>';
             $out .= '<td width="80" align="center"><a href="' . $this->file_link($att) . '" target="_blank">' . $this->list_prev($att) . '</a></td>';
             $out .= '<td valign="top" align="left">';
             $out .= '<div><a href="' . $this->file_link($att) . '" target="_blank">' . $att['file_name'] . '</a></div>';
             $out .= 'Размер: ' . format_size($att['file_size']);
             #$out .= ' <img src="'.URL.'/file/'.$att['id'].'/'.$att['file_name'].'?size=120x120" alt=""/></a> ';
             $out .= '<td></tr></table>';
         }
         $out .= '</div>';
     }
     # dbg ($types);
     return $out;
 }
Example #8
0
function login_form()
{
    if (user('logged')) {
        $tpl = new ltpl('login_form_inline');
        if (is_admin()) {
        }
        return $tpl->get();
    } else {
        $tpl = new ltpl('login_form_inline');
        # Current URL
        # dbg ($_SERVER);
        $red = $_SERVER['REQUEST_URI'];
        if (@$_POST['red']) {
            $red = $_POST['red'];
        }
        $tpl->v('current_url', $red);
        return $tpl->get();
    }
}