/admin/setup/install.php
PHP | 231 lines | 157 code | 33 blank | 41 comment | 21 complexity | 5361e489e8a62e22593fe565b60ba65e MD5 | raw file
Possible License(s): GPL-2.0
- <?php
- define('SW_',true);
- define('SW_PAGE_SETUP',true);
- require_once('../../framework/init.php');
- //?????????
- if(SW::$preAction!='install') die('Access Error');
- //??????
- $objInstall=new SWInstall();
- $arrErr=array();
- $succeed=false;
- //????config??????
- if(!is_writable(SW::dirPath(''))) $arrErr[]='???????, ??????????';
- $formpost=SW::request('formpost','post');
- //???????
- if(!empty($formpost) && !$arrErr){
-
- //??????
- $objInstall->title=SWFunc::closeHtml(SW::request('title','post'));
- if(!$objInstall->title) $arrErr[]='?????';
-
- //??????
- $objInstall->url=SWFunc::checkUrl(SW::request('url','post'),true);
- if(!$objInstall->url) $arrErr[]='??????';
- $objInstall->description=SWFunc::closeHtml(SW::request('description','post'));
- $objInstall->author=SWFunc::closeHtml(SW::request('author','post'));
- if(!$objInstall->author) $arrErr[]='????????';
-
- $objInstall->email=SWFunc::checkString(SW::request('email','post'));
- if(!SWFunc::checkEmail($objInstall->email)) $arrErr[]='???????????';
-
- $objInstall->account=SWFunc::checkString(SW::request('account','post'));
- if(!SWFunc::checkCharacter($objInstall->account,3)) $arrErr[]='???????';
- //?????????????????
- $objInstall->password=SWFunc::checkString(SW::request('password','post'));
- if(!$objInstall->password || $objInstall->password!=SW::request('repassword','post') || !SWFunc::checkCharacter($objInstall->password,2,4,16)) $arrErr[]='?????????????';
-
- $objInstall->language=SWFunc::checkString(SW::request('language','post'));
- if(!$objInstall->language) $arrErr[]='?????/??';
-
- $objInstall->timezone=SWFunc::checkString(SW::request('timezone','post'));
- if(!$objInstall->timezone) $arrErr[]='?????';
- $objInstall->dbprefix=SWFunc::checkString(SW::request('dbprefix','post'));
- if($objInstall->dbprefix && !SWFunc::checkCharacter($objInstall->dbprefix,3)) $arrErr[]='???????';
-
- //?????????????????
- if(!$arrErr){
- $objInstall->dbhost=SWFunc::checkString(SW::request('dbhost','post'));
- $objInstall->dbname=SWFunc::checkString(SW::request('dbname','post'));
- $objInstall->dbuser=SWFunc::checkString(SW::request('dbuser','post'));
- $objInstall->dbpass=SWFunc::checkString(SW::request('dbpass','post'));
- if(!$objInstall->checkDatabase()) $arrErr[]='MySQL?????????';
- }
- //?????????
- if(!$arrErr){
- //??config??
- $objInstall->createConfig();
- //?????????????
- $objInstall->importData();
- /*
- //??????
- $objPost=new SWPost();
- $objPost->id=0;
- $objPost->title='????Swan';
- $objPost->content='<p>?????????????????????????????????Swan?????????<br />???????<a href="http://www.svoo.org/" target="_blank">Swan????</a>???????</p>';
- $objPost->state=1;
- $objPost->allowcomment=1;
- $objPost->posttime=time();
- $objPost->edittime=time();
- $objPost->alias='';
- $objPost->flag=1;
- $objPost->save();
- //??????
- if($objPost->id>0){
- $objComm=new SWComment();
- $objComm->id=0;
- $objComm->postid=$objPost->id;
- $objComm->content='?????Swan????';
- $objComm->author='VAL';
- $objComm->email='jizhaoyi@gmail.com';
- $objComm->url='http://www.svoo.org/';
- $objComm->ip=SWFunc::getIp();
- $objComm->posttime=time();
- $objComm->state=1;
- $objComm->type=1;
- $objComm->save();
- }
- */
- $succeed=true;
- }
- }
- ?>
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
- <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
- <head>
- <title>Install Swan <?php __(SW_VERSION);?></title>
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
- <link type="text/css" href="../css/setup.css" rel="stylesheet" />
- </head>
- <body>
- <?php if(!$succeed){?>
- <div class="title">Swan <?php __(SW_VERSION);?></div>
- <?php if($arrErr){?>
- <div class="error">
- <ul><?php foreach($arrErr as $err){__('<li>'.$err.'</li>');}?></ul>
- </div>
- <?php }else{?>
- <div class="info">
- <ul><li>????????????????</li></ul>
- </div>
- <?php }?>
- <div class="window">
- <form name="form1" method="post" action="">
- <h1>????</h1>
- <p>
- <label>????</label>
- <input type="text" value="<?php __($objInstall->title);?>" name="title" />
- </p>
- <p>
- <label>????</label>
- <input type="text" value="<?php __($objInstall->getRootUrl());?>" name="url" />
- </p>
- <p>
- <label>????</label>
- <textarea cols="40" rows="2" name="description"><?php __($objInstall->description);?></textarea>
- </p>
- <p>
- <label>??/??</label>
- <select name="language">
- <?php
- foreach(SWLanguage::getAllLanguages() as $value){
- __('<option value="'.$value.'" '.($objInstall->language==$value?'selected="selected"':'').'>'.$value.'</option>');
- }
- ?>
- </select>
- </p>
- <p>
- <label>????</label>
- <select name="timezone">
- <?php
- foreach(SWFunc::timezoneList() as $value){
- __('<option value="'.$value.'" '.($objInstall->timezone==$value?'selected="selected"':'').'>'.$value.'</option>');
- }
- ?>
- </select>
- </p>
- <h1>????</h1>
- <p>
- <label>????</label>
- <input type="text" value="<?php __($objInstall->author);?>" name="author" />
- </p>
- <p>
- <label>????</label>
- <input type="text" value="<?php __($objInstall->email);?>" name="email" />
- </p>
- <p>
- <label>?? <span class="sub">(??????)</span></label>
- <input type="text" value="<?php __($objInstall->account);?>" name="account" />
- </p>
- <p>
- <label>?? <span class="sub">(??????)</span></label>
- <input type="password" value="" name="password" />
- </p>
- <p>
- <label>???? <span class="sub">(????????)</span></label>
- <input type="password" value="" name="repassword" />
- </p>
- <h1>?????</h1>
- <p>
- <label>???</label>
- <input type="text" value="<?php __($objInstall->dbhost);?>" name="dbhost" />
- </p>
- <p>
- <label>???</label>
- <input type="text" value="<?php __($objInstall->dbname);?>" name="dbname" />
- </p>
- <p>
- <label>?????</label>
- <input type="text" value="<?php __($objInstall->dbuser);?>" name="dbuser" />
- </p>
- <p>
- <label>?????</label>
- <input type="password" value="<?php __($objInstall->dbpass);?>" name="dbpass" />
- </p>
- <p>
- <label>???</label>
- <input type="text" value="<?php __($objInstall->dbprefix);?>" name="dbprefix" />
- </p>
- <input type="hidden" value="1" name="formpost" />
- <button type="submit">?? »</button>
- </form>
- <div style="clear:both;"></div>
- </div>
- <?php }else{?>
- <div class="title">Complete</div>
- <div class="window">
- <h2>?????</h2>
- <p><a href="<?php __(SW::urlPath('admin.login'));?>">??????</a></p>
- <p><a href="<?php __(SW::urlPath('',true));?>">??????</a></p>
- <p><a href="http://www.svoo.org" target="_blank">??????????</p>
- <div style="clear:both;"></div>
- </div>
- <?php }?>
- </body>
- </html>