Exemple #1
0
 function clean_d()
 {
     $dh1 = opendir(ROOT_PATH . '/d/');
     if (!$dh1) {
         return;
     }
     # Error
     while (($file1 = readdir($dh1)) !== false) {
         if ($file1[0] == '.' || !is_dir(ROOT_PATH . '/d/' . $file1)) {
             continue;
         }
         # Hidden
         # Clean sub-d level 1
         $dh2 = opendir(ROOT_PATH . '/d/' . $file1);
         if (!$dh2) {
             continue;
         }
         # Error
         while (($file2 = readdir($dh2)) !== false) {
             if ($file2[0] == '.' || !is_dir(ROOT_PATH . '/d/' . $file1 . '/' . $file2)) {
                 continue;
             }
             # Hidden
             # Okay, we got key!
             $code = $file1 . $file2;
             $res = ldb_select_one('upload', array('id'), $code, 'code');
             if (!$res && !ldb_error()) {
                 # Delete this f**k'n file
                 echo 'Deleting: ' . ROOT_PATH . '/d/' . $file1 . '/' . $file2 . "\n";
                 recursive_remove_directory(ROOT_PATH . '/d/' . $file1 . '/' . $file2);
             }
         }
     }
 }
Exemple #2
0
function user_info($id = false)
{
    if (!$id) {
        $id = user('id');
    }
    $data = ldb_select_one('user', '*', $id);
    return $data;
}
 function file_link($data)
 {
     if (!is_array($data)) {
         $data = ldb_select_one('site_attach_files', '*', $data);
     }
     if (!$data) {
         return;
     }
     return URL . '/file/' . $data['id'] . '/' . $data['key'] . '/' . rawurlencode($data['file_name']);
 }
Exemple #4
0
 function display()
 {
     current_page('page');
     if (!user('logged')) {
         return login_req();
     }
     $data = ldb_select_one('page', '*', input(1), 'name');
     if (!$data) {
         return core_error_404();
     }
     page_title($data['title']);
     site_title($data['title']);
     $out = '';
     $out .= $data['text'];
     return $out;
 }
Exemple #5
0
 function delete()
 {
     $id = intval($_GET['id']);
     $data = ldb_select_one('upload', '*', $id);
     if (!$data || @$data['uid'] != $this->uid) {
         return $this->error('UPLOAD_NF', 'Upload is not found...');
     }
     ldb_query('DELETE FROM `upload` WHERE `id`=' . $id);
     echo '<delete status="ok"/>' . "\n";
 }
 function get_final()
 {
     # Okay, remove th SID
     @unlink(ROOT_PATH . '/tmp/sid/' . md5($this->sid));
     # Check upload data
     $u_data = ldb_select_one('upload', '*', $this->sid, 'code');
     if (!$u_data || $u_data['uid'] != user('id')) {
         return core_error_404();
     }
     include_once CORE_PATH . '/ttl.php';
     $ttl = @$_POST['files_ttl'];
     if (!isset($GLOBALS['ttl'][$ttl])) {
         $ttl = $GLOBALS['ttl_def'];
     }
     $tms_del = $u_data['tms_last'] + $ttl;
     $ttl_p = @$_POST['files_ttl_prol'] ? 'Y' : 'N';
     # Update TTL
     ldb_update_by_id('upload', $u_data['id'], array('tms_delete' => $tms_del, 'ttl' => $ttl, 'prolong' => $ttl_p, 'comment' => @$_POST['files_descr']));
     ldb_query('UPDATE `upload` SET `file_count`=(SELECT COUNT(*) FROM `file` WHERE `file`.`upid`=`upload`.`id`),`file_size`=(SELECT SUM(`file_size`) FROM `file` WHERE `file`.`upid`=`upload`.`id`) WHERE `id`=' . $u_data['id']);
     # Redirect to the file control...
     @header('Location: ' . URL . '/f/' . $this->sid . '/');
 }
Exemple #7
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;
 }
Exemple #8
0
function sr_menu_cascade_n($name)
{
    $data = ldb_select_one('page', '*', $name, 'name');
    if (!$data) {
        return '';
    }
    $out = '<li' . sr_menu_current('page-' . $name) . '><span class="s5_outer_active"><span class="s5_outer"><a class="active" id="tempID' . mt_rand() . '" href="' . URL . '/' . $data['name'] . '/">' . $data['title'] . '</a></span></span>' . "\n";
    $data_root = ldb_select('page', '*', '`root_id`=' . $data['id'] . ' ORDER BY `so`');
    if ($data_root) {
        $out .= '<ul onmouseover="check_id()">' . "\n";
        foreach ($data_root as $el) {
            $out .= sr_menu_cascade_s($el);
        }
        $out .= '</ul>' . "\n";
    }
    $out .= '</li>' . "\n";
    return $out;
}
Exemple #9
0
 function create_session($uid)
 {
     $data = ldb_select_one('user', '*', $uid);
     $lk = sha1(md5($_SERVER['HTTP_USER_AGENT']) . mt_rand() . md5($data['mail']) . time() . mt_rand(), true);
     $c_data = base64_encode($uid . ':' . base64_encode($lk));
     setcookie(cfg('auth_int_cookie_name'), $c_data, time() + intval(cfg('auth_int_session_time')), '/', COOKIE_DOMAIN);
     ldb_update_by_id('user', $uid, array('login_key' => md5($lk), 'last_login' => time(), 'last_ip' => $_SERVER['REMOTE_ADDR']));
 }