function UploadSave($FILE) { global $_G; $ext = strtolower(substr(strrchr($FILE['name'], '.'), 1)); $target = self::getPath($ext ? '.' . $ext : '', 'dzz'); if ($ext && in_array(strtolower($ext), $_G['setting']['unRunExts'])) { $unrun = 1; } else { $unrun = 0; } $filepath = $_G['setting']['attachdir'] . $target; if (!save_to_local($FILE['tmp_name'], $filepath)) { return false; } $md5 = md5_file($filepath); if ($md5 && ($attach = DB::fetch_first("select * from " . DB::table('attachment') . " where md5='{$md5}'"))) { $attach['filename'] = $FILE['name']; @unlink($filepath); return $attach; } else { $remote = 0; $attach = array('filesize' => $FILE['size'], 'attachment' => $target, 'filetype' => strtolower($ext), 'filename' => $FILE['name'], 'remote' => $remote, 'copys' => 0, 'md5' => $md5, 'unrun' => $unrun, 'dateline' => $_G['timestamp']); if ($attach['aid'] = DB::insert('attachment', $attach, 1)) { C::t('local_storage')->update_usesize_by_remoteid($attach['remote'], $attach['filesize']); dfsockopen($_G['siteurl'] . 'misc.php?mod=movetospace&aid=' . $attach['aid'] . '&remoteid=0', 0, '', '', FALSE, '', 1); return $attach; } else { return false; } } }
function upload_to_icon($upload, $target, $domain) { global $_G; $source = $upload['tmp_name']; if (!$target) { $imageext = array('jpg', 'jpeg', 'png', 'gif'); $ext = strtolower(substr(strrchr($upload['name'], '.'), 1, 10)); if (!in_array($ext, $imageext)) { $ext = 'jpg'; } $subdir = $subdir1 = $subdir2 = ''; $subdir1 = date('Ym'); $subdir2 = date('d'); $subdir = $subdir1 . '/' . $subdir2 . '/'; $target = 'icon/' . $subdir . '' . $domain . '_' . strtolower(random(8)) . '.' . $ext; $target_attach = $_G['setting']['attachdir'] . $target; } else { $target_attach = $_G['setting']['attachdir'] . $target; } if (save_to_local($source, $target_attach)) { return $target; } else { return false; } }