PageRenderTime 41ms CodeModel.GetById 30ms RepoModel.GetById 1ms app.codeStats 0ms

/admin/setup/install.php

http://swan.googlecode.com/
PHP | 231 lines | 157 code | 33 blank | 41 comment | 21 complexity | 5361e489e8a62e22593fe565b60ba65e MD5 | raw file
Possible License(s): GPL-2.0
  1. <?php
  2. define('SW_',true);
  3. define('SW_PAGE_SETUP',true);
  4. require_once('../../framework/init.php');
  5. //?????????
  6. if(SW::$preAction!='install') die('Access Error');
  7. //??????
  8. $objInstall=new SWInstall();
  9. $arrErr=array();
  10. $succeed=false;
  11. //????config??????
  12. if(!is_writable(SW::dirPath(''))) $arrErr[]='???????, ??????????';
  13. $formpost=SW::request('formpost','post');
  14. //???????
  15. if(!empty($formpost) && !$arrErr){
  16. //??????
  17. $objInstall->title=SWFunc::closeHtml(SW::request('title','post'));
  18. if(!$objInstall->title) $arrErr[]='?????';
  19. //??????
  20. $objInstall->url=SWFunc::checkUrl(SW::request('url','post'),true);
  21. if(!$objInstall->url) $arrErr[]='??????';
  22. $objInstall->description=SWFunc::closeHtml(SW::request('description','post'));
  23. $objInstall->author=SWFunc::closeHtml(SW::request('author','post'));
  24. if(!$objInstall->author) $arrErr[]='????????';
  25. $objInstall->email=SWFunc::checkString(SW::request('email','post'));
  26. if(!SWFunc::checkEmail($objInstall->email)) $arrErr[]='???????????';
  27. $objInstall->account=SWFunc::checkString(SW::request('account','post'));
  28. if(!SWFunc::checkCharacter($objInstall->account,3)) $arrErr[]='???????';
  29. //?????????????????
  30. $objInstall->password=SWFunc::checkString(SW::request('password','post'));
  31. if(!$objInstall->password || $objInstall->password!=SW::request('repassword','post') || !SWFunc::checkCharacter($objInstall->password,2,4,16)) $arrErr[]='?????????????';
  32. $objInstall->language=SWFunc::checkString(SW::request('language','post'));
  33. if(!$objInstall->language) $arrErr[]='?????/??';
  34. $objInstall->timezone=SWFunc::checkString(SW::request('timezone','post'));
  35. if(!$objInstall->timezone) $arrErr[]='?????';
  36. $objInstall->dbprefix=SWFunc::checkString(SW::request('dbprefix','post'));
  37. if($objInstall->dbprefix && !SWFunc::checkCharacter($objInstall->dbprefix,3)) $arrErr[]='???????';
  38. //?????????????????
  39. if(!$arrErr){
  40. $objInstall->dbhost=SWFunc::checkString(SW::request('dbhost','post'));
  41. $objInstall->dbname=SWFunc::checkString(SW::request('dbname','post'));
  42. $objInstall->dbuser=SWFunc::checkString(SW::request('dbuser','post'));
  43. $objInstall->dbpass=SWFunc::checkString(SW::request('dbpass','post'));
  44. if(!$objInstall->checkDatabase()) $arrErr[]='MySQL?????????';
  45. }
  46. //?????????
  47. if(!$arrErr){
  48. //??config??
  49. $objInstall->createConfig();
  50. //?????????????
  51. $objInstall->importData();
  52. /*
  53. //??????
  54. $objPost=new SWPost();
  55. $objPost->id=0;
  56. $objPost->title='????Swan';
  57. $objPost->content='<p>?????????????????????????????????Swan?????????<br />???????<a href="http://www.svoo.org/" target="_blank">Swan????</a>???????</p>';
  58. $objPost->state=1;
  59. $objPost->allowcomment=1;
  60. $objPost->posttime=time();
  61. $objPost->edittime=time();
  62. $objPost->alias='';
  63. $objPost->flag=1;
  64. $objPost->save();
  65. //??????
  66. if($objPost->id>0){
  67. $objComm=new SWComment();
  68. $objComm->id=0;
  69. $objComm->postid=$objPost->id;
  70. $objComm->content='?????Swan????';
  71. $objComm->author='VAL';
  72. $objComm->email='jizhaoyi@gmail.com';
  73. $objComm->url='http://www.svoo.org/';
  74. $objComm->ip=SWFunc::getIp();
  75. $objComm->posttime=time();
  76. $objComm->state=1;
  77. $objComm->type=1;
  78. $objComm->save();
  79. }
  80. */
  81. $succeed=true;
  82. }
  83. }
  84. ?>
  85. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
  86. <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
  87. <head>
  88. <title>Install Swan <?php __(SW_VERSION);?></title>
  89. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  90. <link type="text/css" href="../css/setup.css" rel="stylesheet" />
  91. </head>
  92. <body>
  93. <?php if(!$succeed){?>
  94. <div class="title">Swan <?php __(SW_VERSION);?></div>
  95. <?php if($arrErr){?>
  96. <div class="error">
  97. <ul><?php foreach($arrErr as $err){__('<li>'.$err.'</li>');}?></ul>
  98. </div>
  99. <?php }else{?>
  100. <div class="info">
  101. <ul><li>????????????????</li></ul>
  102. </div>
  103. <?php }?>
  104. <div class="window">
  105. <form name="form1" method="post" action="">
  106. <h1>????</h1>
  107. <p>
  108. <label>????</label>
  109. <input type="text" value="<?php __($objInstall->title);?>" name="title" />
  110. </p>
  111. <p>
  112. <label>????</label>
  113. <input type="text" value="<?php __($objInstall->getRootUrl());?>" name="url" />
  114. </p>
  115. <p>
  116. <label>????</label>
  117. <textarea cols="40" rows="2" name="description"><?php __($objInstall->description);?></textarea>
  118. </p>
  119. <p>
  120. <label>??/??</label>
  121. <select name="language">
  122. <?php
  123. foreach(SWLanguage::getAllLanguages() as $value){
  124. __('<option value="'.$value.'" '.($objInstall->language==$value?'selected="selected"':'').'>'.$value.'</option>');
  125. }
  126. ?>
  127. </select>
  128. </p>
  129. <p>
  130. <label>????</label>
  131. <select name="timezone">
  132. <?php
  133. foreach(SWFunc::timezoneList() as $value){
  134. __('<option value="'.$value.'" '.($objInstall->timezone==$value?'selected="selected"':'').'>'.$value.'</option>');
  135. }
  136. ?>
  137. </select>
  138. </p>
  139. <h1>????</h1>
  140. <p>
  141. <label>????</label>
  142. <input type="text" value="<?php __($objInstall->author);?>" name="author" />
  143. </p>
  144. <p>
  145. <label>????</label>
  146. <input type="text" value="<?php __($objInstall->email);?>" name="email" />
  147. </p>
  148. <p>
  149. <label>?? <span class="sub">(??????)</span></label>
  150. <input type="text" value="<?php __($objInstall->account);?>" name="account" />
  151. </p>
  152. <p>
  153. <label>?? <span class="sub">(??????)</span></label>
  154. <input type="password" value="" name="password" />
  155. </p>
  156. <p>
  157. <label>???? <span class="sub">(????????)</span></label>
  158. <input type="password" value="" name="repassword" />
  159. </p>
  160. <h1>?????</h1>
  161. <p>
  162. <label>???</label>
  163. <input type="text" value="<?php __($objInstall->dbhost);?>" name="dbhost" />
  164. </p>
  165. <p>
  166. <label>???</label>
  167. <input type="text" value="<?php __($objInstall->dbname);?>" name="dbname" />
  168. </p>
  169. <p>
  170. <label>?????</label>
  171. <input type="text" value="<?php __($objInstall->dbuser);?>" name="dbuser" />
  172. </p>
  173. <p>
  174. <label>?????</label>
  175. <input type="password" value="<?php __($objInstall->dbpass);?>" name="dbpass" />
  176. </p>
  177. <p>
  178. <label>???</label>
  179. <input type="text" value="<?php __($objInstall->dbprefix);?>" name="dbprefix" />
  180. </p>
  181. <input type="hidden" value="1" name="formpost" />
  182. <button type="submit">?? &raquo;</button>
  183. </form>
  184. <div style="clear:both;"></div>
  185. </div>
  186. <?php }else{?>
  187. <div class="title">Complete</div>
  188. <div class="window">
  189. <h2>?????</h2>
  190. <p><a href="<?php __(SW::urlPath('admin.login'));?>">??????</a></p>
  191. <p><a href="<?php __(SW::urlPath('',true));?>">??????</a></p>
  192. <p><a href="http://www.svoo.org" target="_blank">??????????</p>
  193. <div style="clear:both;"></div>
  194. </div>
  195. <?php }?>
  196. </body>
  197. </html>