Chinaunix首页 | 论坛 | 博客
  • 博客访问: 5121878
  • 博文数量: 921
  • 博客积分: 16037
  • 博客等级: 上将
  • 技术积分: 8469
  • 用 户 组: 普通用户
  • 注册时间: 2006-04-05 02:08
文章分类

全部博文(921)

文章存档

2020年(1)

2019年(3)

2018年(3)

2017年(6)

2016年(47)

2015年(72)

2014年(25)

2013年(72)

2012年(125)

2011年(182)

2010年(42)

2009年(14)

2008年(85)

2007年(89)

2006年(155)

分类:

2007-11-21 16:51:40

<?php
    /**
     *虚拟注册帐户模和申请空间处理提取的数据格式
     * by yifei 2007-11-15
     */

    include_once('../space/include/main.inc.php');
    include_once('../space/include/common.inc.php');
    
    $sql = 'SELECT * FROM jiachen.infos WHERE state = \'0\' ORDER BY uid ASC LIMIT 0, 400';
    
    $querya = $_SGLOBAL['db']->query($sql);
    
    dbconnect(1);
    $i = 0;
    while($res = $_SGLOBAL['db']->fetch_array($querya)){    
    
        if($res['nickname'] == '' || $res['gender'] == '' || $res['headerphoto'] == '' || $res['blogurl'] == '' || $res['city'] == '') continue;
    
        $res['uid'] = intval($res['uid']);
        
        /**
         * 用户名验证是否已经存在
         */

        $username = $nickname = addslashes(trim(stripslashes($res['nickname'])));
        $sqla = "SELECT COUNT(uid) AS counts FROM popodoo.ppd_members WHERE username LIKE '%$username%'";
        
        $query = $_SGLOBAL['db']->query($sqla);
        $num = $_SGLOBAL['db']->fetch_array($query);
        
        $username = $num['counts'] == 0 ? $username : $username . ($num['counts'] + 1);
        
        //blogurl

        $blogUrl = $res['blogurl'];
        /**
         * 地区
         */

        $area = explode(' ', $res['city']);
            
        /**
         * 性别
         */

        $gender = $res['gender'] == '未知' ? 0 : $res['gender'];    
            
        /**
         * 出生时间格式化
         */

        $arr = array('年'=>'-','月'=>'-','日'=>'');        
        $bday = date('Y-m-d',strtotime(strtr($res['bday'], $arr)));

        /**
         * headerphoto中提取其头像图片名称
         * by yifei
         */

        preg_match("/[0-9]+((.jpg)|(.gif))/",$res['headerphoto'], $matches);
        
        $headerphoto = $matches[0];
        
    
        /**
         * 模拟注册和申请空间模块
         */

        $timestamp = time();
        $sql = "INSERT INTO ppd_members (username, password, secques, gender, adminid, groupid, regip, regdate, lastvisit, lastactivity, posts, credits, extcredits1, extcredits2, extcredits3, extcredits4, extcredits5, extcredits6, extcredits7, extcredits8, email, bday, sigstatus, tpp, ppp, styleid, dateformat, timeformat, pmsound, showemail, newsletter, invisible, timeoffset) VALUES ('$username', 'babd2925f9a5fe57586bd10374bdecc6', '', '$gender', '0', '10', '127.0.0.1', '$timestamp', '$timestamp', '$timestamp', '0', 0,0,0,0,0,0,0,0,0, '', '$bday', '0', '0', '0', '', '0', '0', '1', '1', '1', '0', '9999')";
        $_SGLOBAL['db']->query($sql);
        $uid = $_SGLOBAL['db']->insert_id();
        
        $sql = "INSERT INTO ppd_memberfields (uid, nickname, site, icq, qq, yahoo, msn, taobao, alipay, location, bio, sightml, customstatus, authstr, avatar, avatarwidth, avatarheight ) VALUES ('$uid', '$nickname', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '' )";
        $_SGLOBAL['db']->query($sql);
        
        /**
         * 成功注册后的数据条将状态字段改为1
         */

        $_SGLOBAL['db']->query('UPDATE jiachen.infos SET state = \'1\' WHERE uid = \''.$res['uid'].'\'');
        
        /**
         * 虚拟注册嘟嘟空间
         */

    
        $_POST['spacename'] = shtmlspecialchars($username).'的波波嘟空间';
        
        $tpl = array();
        $_POST['tplid'] = 'popodoo';
        $dir = S_ROOT.'./themes/'.$_POST['tplid'];
        if(is_dir($dir) && file_exists($dir.'/theme.php')) {
            @include_once($dir.'/theme.php');
            $tpl['css'] = cssimage_replace(sreadfile($dir.'/'.$themes['css']), 'themes/'.$_POST['tplid']);//�滻url

            $tpl['tplname'] = $themes['name'];
        }
        
        if(empty($tpl['css'])) {
            $tpl['css'] = 'body { margin: 0; padding: 0; background: #EEE; color: #000; font: 12px Arial, Helvetica, sans-serif; text-align: center; }
            input, textarea, select, button { font: 1em Arial, Helvetica, sans-serif; }
            #wrap { margin: 1em auto; text-align: left; width: 770px; w\idth: 760px; border: 5px solid #FFF; background: #FFF; overflow: hidden; }
            #header { background: #1C5B9E; margin-bottom: 5px; }
            #header * { color: #FFF; }
            #menu { line-height: 26px; }
            .xspace-blocktitle { margin: 0; font-size: 1.2em; line-height: 1.6em; border-bottom: 1px solid #CCC; }
            .sidearea { background: #EEE; padding: 5px; overflow: hidden; }
            #mainarea { padding: 5px; }
            a { color: #006; text-decoration: none; }
            a:hover { text-decoration: underline; }
            a:visited { color: #099; }'
;
        }
    
        if($_POST['spacemode'] != 'bbs') $_POST['spacemode'] = 'blog';
            $setsqlarr = array(
                'uid' => $uid,
                'dateline' => $_SGLOBAL['timestamp'],
                'username' => $username,
                'spacename' => $_POST['spacename'],
                'catid' => 70,
                'province' => shtmlspecialchars($area[0]),
                'city' => shtmlspecialchars($area[1]),
                'spacemode' => $_POST['spacemode']
        );
        inserttable('userspaces', $setsqlarr);
            $setsqlarr = array(
                'uid' => $uid,
                'blogmod' => 1,//blog模式

                'summarylen' => 300
            );    
        inserttable('userspacefields', $setsqlarr);
        updatetable('members', array('havespace'=>1), array('uid'=>$uid));
        
        $_SGLOBAL['db_bbs']->query('UPDATE '.tname('members', 1).' SET xspacestatus=\'1\', gender=\''.$gender.'\' ,bday=\''.$bday.'\' WHERE uid=\''.$uid.'\'');
        $_SGLOBAL['db_bbs']->query('UPDATE '.tname('memberfields', 1).' SET nickname=\''.$_POST['nickname'].'\' WHERE uid = \''.$uid.'\'');
        $thedir = getuserfile($uid, 'css', 'path', 1);
        writefile($thedir, $tpl['css']);
        
        //对应头像copy

        $file = 'image/'.$headerphoto;
        $file = file_exists($file) ? $file : 'image/'.$res['headerphoto'].'.gif';
        $fileOs = @copy($file, "../space/user"."/".$uid."/"."photo_".$uid.".gif");    
        if($fileOs){
             $sql = "UPDATE `supe_userspaces` SET `photo` = 'gif' WHERE uid = '".$uid."'";
             $_SGLOBAL['db']->query($sql);    
        }else
            @copy("../space/images/base/space_kid.gif", "../space/user"."/".$uid."/"."photo_".$uid.".gif");
            
        ++$i;        
     }
     
     $PHP_SELF = "http://".$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI'];
     messagebox('ok','恭喜您顺利插入'.$i.'条数据!', $PHP_SELF);     
?>

在x-space做虚拟注册和申请个人空间的程序。。

先抓取几万条数据《包括用户图片》。放到一个临时表。。

然后进行处理。。。。。。。

阅读(1773) | 评论(0) | 转发(0) |
0

上一篇:php连接access

下一篇:msqldump备份数据库

给主人留下些什么吧!~~