Exemplo n.º 1
0
/**
 * 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;
}
Exemplo n.º 2
0
 $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) {
             array_pop($_arr_path);
             $_path = implode('/', $_arr_path);
             if (isset($array_thumb_config[$_path])) {
                 $thumb_config = $array_thumb_config[$_path];
                 break;