Example #1
0
function check_attach($attid)
{
    global $DB;
    $thisattach = $DB->selectRow("SELECT * FROM f_attachs WHERE attach_id=?d", $attid);
    $ext = strtolower(substr(strrchr($thisattach['attach_file'], '.'), 1));
    if ($thisattach['attach_id']) {
        $res = '<a href="' . $config['site_href'] . 'index.php?n=forum&sub=attach&nobody=1&action=download&attid=' . $thisattach['attach_id'] . '">';
        $res .= '<img src="' . $config['site_href'] . 'images/mime/' . $ext . '.png" alt="" align="absmiddle">';
        $res .= ' Download: [ ' . $thisattach['attach_file'] . ' ] ' . return_good_size($thisattach['attach_filesize']) . ' </a>';
    }
    return $res;
}
Example #2
0
     mkdir($user_attach_dir);
 }
 $attachs = $DB->select("SELECT * FROM f_attachs WHERE attach_member_id=?d ORDER BY attach_date DESC", $user['id']);
 foreach ($attachs as $i => $attach) {
     $attachs[$i]['ext'] = strtolower(substr(strrchr($attach['attach_file'], '.'), 1));
     $attachs[$i]['goodsize'] = return_good_size($attach['attach_filesize']);
     $all_attachs_size += $attach['attach_filesize'];
     $all_attachs_count++;
 }
 if ($all_attachs_size <= $config['max_attachs_size']) {
     $this['allowupload'] = true;
 } else {
     $this['allowupload'] = false;
 }
 $this['goodsize'] = return_good_size($all_attachs_size);
 $this['maxfilesize'] = return_good_size($config['max_attachs_size'] - $all_attachs_size);
 if ($_GET['action'] == 'upload' && $this['allowupload'] === true) {
     $params = array();
     $tmpattach = $_FILES['attach'];
     $allowed_ext = explode('|', $config['allowed_attachs']);
     if (is_uploaded_file($tmpattach['tmp_name'])) {
         if ($tmpattach['size'] <= $config['max_attachs_size'] - $all_attachs_size) {
             $ext = strtolower(substr(strrchr($tmpattach['name'], '.'), 1));
             if (in_array($ext, $allowed_ext)) {
                 if (@move_uploaded_file($tmpattach['tmp_name'], $user_attach_dir . $tmpattach['name'])) {
                     $params['attach_file'] = $tmpattach['name'];
                     $params['attach_location'] = $user_attach_dir;
                     $params['attach_date'] = time();
                     if ($_GET['tid']) {
                         $params['attach_tid'] = $_GET['tid'];
                     }