/** * set_reg_attribs() * * @param mixed $attribs * @return */ function set_reg_attribs($attribs) { global $crypt, $db, $db_config, $global_config, $module_upload; $reg_attribs = array(); $reg_attribs['server'] = $attribs['server']; $reg_attribs['username'] = ''; $reg_attribs['email'] = $attribs['contact/email']; $reg_attribs['first_name'] = ''; $reg_attribs['last_name'] = ''; $reg_attribs['gender'] = ''; $reg_attribs['yim'] = ''; $reg_attribs['photo'] = ''; $reg_attribs['openid'] = $attribs['id']; $reg_attribs['opid'] = $crypt->hash($attribs['id']); $username = explode('@', $attribs['contact/email']); $username = array_shift($username); if ($attribs['server'] == 'yahoo') { $reg_attribs['yim'] = $username; } $username = str_pad($username, NV_UNICKMIN, '0', STR_PAD_RIGHT); $username = substr($username, 0, NV_UNICKMAX - 2); $username2 = $username; for ($i = 0; $i < 100; ++$i) { if ($i > 0) { $username2 = $username . str_pad($i, 2, '0', STR_PAD_LEFT); } $query = "SELECT userid FROM " . NV_USERS_GLOBALTABLE . " WHERE md5username='******'"; $userid = $db->query($query)->fetchColumn(); if (!$userid) { $query = "SELECT userid FROM " . NV_USERS_GLOBALTABLE . "_reg WHERE md5username='******'"; $userid = $db->query($query)->fetchColumn(); if (!$userid) { $reg_attribs['username'] = $username2; break; } } } if (isset($attribs['namePerson/first']) and !empty($attribs['namePerson/first'])) { $reg_attribs['first_name'] = $attribs['namePerson/first']; } elseif (isset($attribs['namePerson/friendly']) and !empty($attribs['namePerson/friendly'])) { $reg_attribs['first_name'] = $attribs['namePerson/friendly']; } elseif (isset($attribs['namePerson']) and !empty($attribs['namePerson'])) { $reg_attribs['first_name'] = $attribs['namePerson']; } if (isset($attribs['namePerson/last']) and !empty($attribs['namePerson/last'])) { $reg_attribs['last_name'] = $attribs['namePerson/last']; } if (isset($attribs['person/gender']) and !empty($attribs['person/gender'])) { $reg_attribs['gender'] = $attribs['person/gender']; } if ($global_config['allowuserreg'] == 1 or $global_config['allowuserreg'] == 2) { if (!empty($attribs['picture_url']) and empty($attribs['picture_mode'])) { $upload = new NukeViet\Files\Upload(array('images'), $global_config['forbid_extensions'], $global_config['forbid_mimes'], NV_UPLOAD_MAX_FILESIZE, NV_MAX_WIDTH, NV_MAX_HEIGHT); $upload_info = $upload->save_urlfile($attribs['picture_url'], NV_UPLOADS_REAL_DIR . '/' . $module_upload, false); if (empty($upload_info['error'])) { $basename = change_alias($reg_attribs['username']) . '.' . nv_getextension($upload_info['basename']); $newname = $basename; $fullname = $upload_info['name']; $i = 1; while (file_exists(NV_UPLOADS_REAL_DIR . '/' . $module_upload . '/' . $newname)) { $newname = preg_replace('/(.*)(\\.[a-zA-Z0-9]+)$/', '\\1_' . $i . '\\2', $basename); ++$i; } $check = nv_renamefile($fullname, NV_UPLOADS_REAL_DIR . '/' . $module_upload . '/' . $newname); if ($check[0] == 1) { $reg_attribs['photo'] = NV_UPLOADS_DIR . '/' . $module_upload . '/' . $newname; } } } } return $reg_attribs; }
$result->closeCursor(); if (isset($_FILES['image_file']) and is_uploaded_file($_FILES['image_file']['tmp_name']) and !empty($array['u'])) { // Get post data $array['x1'] = $nv_Request->get_int('x1', 'post', 0); $array['y1'] = $nv_Request->get_int('y1', 'post', 0); $array['x2'] = $nv_Request->get_int('x2', 'post', 0); $array['y2'] = $nv_Request->get_int('y2', 'post', 0); $array['w'] = $nv_Request->get_int('w', 'post', 0); $array['h'] = $nv_Request->get_int('h', 'post', 0); // Caculate crop size $array['avatar_width'] = intval($array['x2'] - $array['x1']); $array['avatar_height'] = intval($array['y2'] - $array['y1']); if (sizeof(array_filter(array($array['x1'], $array['y1'], $array['x2'], $array['y2'], $array['w'], $array['h']))) < 4 or $array['avatar_width'] < $global_config['avatar_width'] or $array['avatar_height'] < $global_config['avatar_height']) { $array['error'] = $lang_module['avatar_error_data']; } else { $upload = new NukeViet\Files\Upload(array('images'), $global_config['forbid_extensions'], $global_config['forbid_mimes'], NV_UPLOAD_MAX_FILESIZE, NV_MAX_WIDTH, NV_MAX_HEIGHT); // Storage in temp dir $upload_info = $upload->save_file($_FILES['image_file'], NV_ROOTDIR . '/' . NV_TEMP_DIR, false); // Delete upload tmp @unlink($_FILES['image_file']['tmp_name']); if (empty($upload_info['error'])) { $basename = $upload_info['basename']; $basename = preg_replace('/(.*)(\\.[a-zA-Z]+)$/', '\\1_' . nv_genpass(8) . "_" . $user_info['userid'] . '\\2', $basename); $image = new NukeViet\Files\Image($upload_info['name'], NV_MAX_WIDTH, NV_MAX_HEIGHT); // Resize image, crop image $image->resizeXY($array['w'], $array['h']); $image->cropFromLeft($array['x1'], $array['y1'], $array['avatar_width'], $array['avatar_height']); $image->resizeXY($global_config['avatar_width'], $global_config['avatar_height']); // Save new image $image->save(NV_ROOTDIR . '/' . NV_TEMP_DIR, $basename); $image->close();
} elseif (!isset($_FILES, $_FILES['upload'], $_FILES['upload']['tmp_name']) and !$nv_Request->isset_request('fileurl', 'post')) { $error = $lang_module['uploadError1']; } elseif (!isset($_FILES) and !nv_is_url($nv_Request->get_string('fileurl', 'post,get'))) { $error = $lang_module['uploadError2']; } else { $type = $nv_Request->get_string('type', 'post,get'); if ($type == 'image' and in_array('images', $admin_info['allow_files_type'])) { $allow_files_type = array('images'); } elseif ($type == 'flash' and in_array('flash', $admin_info['allow_files_type'])) { $allow_files_type = array('flash'); } elseif (empty($type)) { $allow_files_type = $admin_info['allow_files_type']; } else { $allow_files_type = array(); } $upload = new NukeViet\Files\Upload($allow_files_type, $global_config['forbid_extensions'], $global_config['forbid_mimes'], NV_UPLOAD_MAX_FILESIZE, NV_MAX_WIDTH, NV_MAX_HEIGHT); if (isset($_FILES['upload']['tmp_name']) and is_uploaded_file($_FILES['upload']['tmp_name'])) { $upload_info = $upload->save_file($_FILES['upload'], NV_ROOTDIR . '/' . $path, false, $global_config['nv_auto_resize']); } else { $urlfile = rawurldecode(trim($nv_Request->get_string('fileurl', 'post'))); $upload_info = $upload->save_urlfile($urlfile, NV_ROOTDIR . '/' . $path, false, $global_config['nv_auto_resize']); } if (!empty($upload_info['error'])) { $error = $upload_info['error']; } elseif (preg_match('#image\\/[x\\-]*([a-z]+)#', $upload_info['mime'])) { if (isset($array_thumb_config[$path])) { $thumb_config = $array_thumb_config[$path]; } else { $thumb_config = $array_thumb_config['']; $_arr_path = explode('/', $path); while (sizeof($_arr_path) > 1) {
$error = $upload_info['error']; } else { @chmod($upload_info['name'], 0644); if (!empty($file_name) and is_file(NV_ROOTDIR . '/' . $file_name)) { @nv_deletefile(NV_UPLOADS_REAL_DIR . '/' . NV_BANNER_DIR . '/' . $file_name); } $file_name = $upload_info['basename']; $file_ext = $upload_info['ext']; $file_mime = $upload_info['mime']; $width = $upload_info['img_info'][0]; $height = $upload_info['img_info'][1]; } } if ($file_ext == 'swf') { if (isset($_FILES['imageforswf']) and is_uploaded_file($_FILES['imageforswf']['tmp_name'])) { $upload = new NukeViet\Files\Upload($contents['file_allowed_ext'], $global_config['forbid_extensions'], $global_config['forbid_mimes'], NV_UPLOAD_MAX_FILESIZE, NV_MAX_WIDTH, NV_MAX_HEIGHT); $upload_info = $upload->save_file($_FILES['imageforswf'], NV_UPLOADS_REAL_DIR . '/' . NV_BANNER_DIR, false); @unlink($_FILES['imageforswf']['tmp_name']); if (!empty($upload_info['error'])) { $error = $upload_info['error']; } else { @chmod($upload_info['name'], 0644); if (!empty($imageforswf) and is_file(NV_ROOTDIR . '/' . $imageforswf)) { @nv_deletefile(NV_UPLOADS_REAL_DIR . '/' . NV_BANNER_DIR . '/' . $imageforswf); } $imageforswf = $upload_info['basename']; } } } else { if (!empty($imageforswf) and is_file(NV_ROOTDIR . '/' . $imageforswf)) { @nv_deletefile(NV_UPLOADS_REAL_DIR . '/' . NV_BANNER_DIR . '/' . $imageforswf);
$array['filesize'] = $upload_info['size']; } else { $is_error = true; $error = $upload_info['error']; } unset($upload, $upload_info); } } if (!$is_error) { if (empty($fileupload) and empty($array['linkdirect'])) { $is_error = true; $error = $lang_module['file_error_fileupload']; } else { $fileimage = ''; if (isset($_FILES['upload_fileimage']) and is_uploaded_file($_FILES['upload_fileimage']['tmp_name'])) { $upload = new NukeViet\Files\Upload(array('images'), $global_config['forbid_extensions'], $global_config['forbid_mimes'], NV_UPLOAD_MAX_FILESIZE, NV_MAX_WIDTH, NV_MAX_HEIGHT); $upload_info = $upload->save_file($_FILES['upload_fileimage'], NV_UPLOADS_REAL_DIR . '/' . $module_upload . '/temp', false); @unlink($_FILES['upload_fileimage']['tmp_name']); if (empty($upload_info['error'])) { mt_srand((double) microtime() * 1000000); $maxran = 1000000; $random_num = mt_rand(0, $maxran); $random_num = md5($random_num); $nv_pathinfo_filename = nv_pathinfo_filename($upload_info['name']); $new_name = NV_UPLOADS_REAL_DIR . '/' . $module_upload . '/temp/' . $nv_pathinfo_filename . '.' . $random_num . '.' . $upload_info['ext']; $rename = nv_renamefile($upload_info['name'], $new_name); if ($rename[0] == 1) { $fileimage = $new_name; } else { $fileimage = $upload_info['name']; }
if (!empty($clid) and !isset($clients[$clid])) { $clid = 0; } if ($click_url == 'http://') { $click_url = ''; } if (empty($title)) { $error = $lang_module['title_empty']; } elseif (empty($pid) or !isset($plans[$pid])) { $error = $lang_module['plan_not_selected']; } elseif (!empty($click_url) and !nv_is_url($click_url)) { $error = $lang_module['click_url_invalid']; } elseif (!is_uploaded_file($_FILES['banner']['tmp_name'])) { $error = $lang_module['file_upload_empty']; } else { $upload = new NukeViet\Files\Upload($contents['file_allowed_ext'], $global_config['forbid_extensions'], $global_config['forbid_mimes'], NV_UPLOAD_MAX_FILESIZE, NV_MAX_WIDTH, NV_MAX_HEIGHT); $upload_info = $upload->save_file($_FILES['banner'], NV_UPLOADS_REAL_DIR . '/' . NV_BANNER_DIR, false); @unlink($_FILES['banner']['tmp_name']); if (!empty($upload_info['error'])) { $error = $upload_info['error']; } else { @chmod($upload_info['name'], 0644); $file_name = $upload_info['basename']; $file_ext = $upload_info['ext']; $file_mime = $upload_info['mime']; $width = $upload_info['img_info'][0]; $height = $upload_info['img_info'][1]; if (empty($publ_date)) { $publtime = NV_CURRENTTIME; } else { unset($m);