install.php 41 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035
  1. <?php
  2. /**
  3. * [WeEngine System] Copyright (c) 2014 WE7.CC
  4. * WeEngine is NOT a free software, it under the license terms, visited http://www.we7.cc/ for more details.
  5. */
  6. ini_set('display_errors', '1');
  7. error_reporting(E_ALL ^ E_NOTICE);
  8. set_time_limit(0);
  9. ob_start();
  10. define('IA_ROOT', str_replace("\\",'/', dirname(__FILE__)));
  11. define('APP_URL', 'http://v2.addons.we7.cc/web/');
  12. define('APP_STORE_URL', 'http://v2.addons.we7.cc/web');
  13. define('APP_STORE_API', 'http://v2.addons.we7.cc/api.php');
  14. if($_GET['res']) {
  15. $res = $_GET['res'];
  16. $reses = tpl_resources();
  17. if(array_key_exists($res, $reses)) {
  18. if($res == 'css') {
  19. header('content-type:text/css');
  20. } else {
  21. header('content-type:image/png');
  22. }
  23. echo base64_decode($reses[$res]);
  24. exit();
  25. }
  26. }
  27. $actions = array('license', 'env', 'db', 'finish');
  28. $action = !empty($_GET['step']) ? $_GET['step'] : $_COOKIE['action'];
  29. $action = in_array($action, $actions) ? $action : 'license';
  30. $ispost = strtolower($_SERVER['REQUEST_METHOD']) == 'post';
  31. if(file_exists(IA_ROOT . '/data/install.lock') && $action != 'finish') {
  32. header('location: ./index.php');
  33. exit;
  34. }
  35. header('content-type: text/html; charset=utf-8');
  36. if($action == 'license') {
  37. if($ispost) {
  38. setcookie('action', 'env');
  39. header('location: ?refresh');
  40. exit;
  41. }
  42. tpl_install_license();
  43. }
  44. if($action == 'env') {
  45. if($ispost) {
  46. setcookie('action', $_POST['do'] == 'continue' ? 'db' : 'license');
  47. header('location: ?refresh');
  48. exit;
  49. }
  50. $ret = array();
  51. $ret['server']['os']['value'] = php_uname();
  52. if(PHP_SHLIB_SUFFIX == 'dll') {
  53. $ret['server']['os']['remark'] = '建议使用 Linux 系统以提升程序性能';
  54. $ret['server']['os']['class'] = 'warning';
  55. }
  56. $ret['server']['sapi']['value'] = $_SERVER['SERVER_SOFTWARE'];
  57. if(PHP_SAPI == 'isapi') {
  58. $ret['server']['sapi']['remark'] = '建议使用 Apache 或 Nginx 以提升程序性能';
  59. $ret['server']['sapi']['class'] = 'warning';
  60. }
  61. $ret['server']['php']['value'] = PHP_VERSION;
  62. $ret['server']['dir']['value'] = IA_ROOT;
  63. if(function_exists('disk_free_space')) {
  64. $ret['server']['disk']['value'] = floor(disk_free_space(IA_ROOT) / (1024*1024)).'M';
  65. } else {
  66. $ret['server']['disk']['value'] = 'unknow';
  67. }
  68. $ret['server']['upload']['value'] = @ini_get('file_uploads') ? ini_get('upload_max_filesize') : 'unknow';
  69. $ret['php']['version']['value'] = PHP_VERSION;
  70. $ret['php']['version']['class'] = 'success';
  71. if(version_compare(PHP_VERSION, '5.3.0') == -1) {
  72. $ret['php']['version']['class'] = 'danger';
  73. $ret['php']['version']['failed'] = true;
  74. $ret['php']['version']['remark'] = 'PHP版本必须为 5.3.0 以上. <a href="http://bbs.we7.cc/forum.php?mod=redirect&goto=findpost&ptid=3564&pid=58062">详情</a>';
  75. }
  76. $ret['php']['pdo']['ok'] = extension_loaded('pdo') && extension_loaded('pdo_mysql');
  77. if($ret['php']['pdo']['ok']) {
  78. $ret['php']['pdo']['value'] = '<span class="glyphicon glyphicon-ok text-success"></span>';
  79. $ret['php']['pdo']['class'] = 'success';
  80. } else {
  81. $ret['php']['pdo']['failed'] = true;
  82. $ret['php']['pdo']['value'] = '<span class="glyphicon glyphicon-remove text-warning"></span>';
  83. $ret['php']['pdo']['class'] = 'warning';
  84. $ret['php']['pdo']['remark'] = '您的PHP环境不支持PDO, 请开启此扩展. <a target="_blank" href="http://bbs.we7.cc/forum.php?mod=redirect&goto=findpost&ptid=3564&pid=58074">详情</a>';
  85. }
  86. $ret['php']['fopen']['ok'] = @ini_get('allow_url_fopen') && function_exists('fsockopen');
  87. if($ret['php']['fopen']['ok']) {
  88. $ret['php']['fopen']['value'] = '<span class="glyphicon glyphicon-ok text-success"></span>';
  89. } else {
  90. $ret['php']['fopen']['value'] = '<span class="glyphicon glyphicon-remove text-danger"></span>';
  91. }
  92. $ret['php']['curl']['ok'] = extension_loaded('curl') && function_exists('curl_init');
  93. if($ret['php']['curl']['ok']) {
  94. $ret['php']['curl']['value'] = '<span class="glyphicon glyphicon-ok text-success"></span>';
  95. $ret['php']['curl']['class'] = 'success';
  96. } else {
  97. $ret['php']['curl']['value'] = '<span class="glyphicon glyphicon-remove text-danger"></span>';
  98. $ret['php']['curl']['class'] = 'danger';
  99. $ret['php']['curl']['remark'] = '您的PHP环境不支持cURL, 也不支持 allow_url_fopen, 系统无法正常运行. <a target="_blank" href="http://bbs.we7.cc/thread-26119-1-1.html">详情</a>';
  100. $ret['php']['curl']['failed'] = true;
  101. }
  102. $ret['php']['ssl']['ok'] = extension_loaded('openssl');
  103. if($ret['php']['ssl']['ok']) {
  104. $ret['php']['ssl']['value'] = '<span class="glyphicon glyphicon-ok text-success"></span>';
  105. $ret['php']['ssl']['class'] = 'success';
  106. } else {
  107. $ret['php']['ssl']['value'] = '<span class="glyphicon glyphicon-remove text-danger"></span>';
  108. $ret['php']['ssl']['class'] = 'danger';
  109. $ret['php']['ssl']['failed'] = true;
  110. $ret['php']['ssl']['remark'] = '没有启用OpenSSL, 将无法访问公众平台的接口, 系统无法正常运行. <a target="_blank" href="http://bbs.we7.cc/forum.php?mod=redirect&goto=findpost&ptid=3564&pid=58109">详情</a>';
  111. }
  112. $ret['php']['gd']['ok'] = extension_loaded('gd');
  113. if($ret['php']['gd']['ok']) {
  114. $ret['php']['gd']['value'] = '<span class="glyphicon glyphicon-ok text-success"></span>';
  115. $ret['php']['gd']['class'] = 'success';
  116. } else {
  117. $ret['php']['gd']['value'] = '<span class="glyphicon glyphicon-remove text-danger"></span>';
  118. $ret['php']['gd']['class'] = 'danger';
  119. $ret['php']['gd']['failed'] = true;
  120. $ret['php']['gd']['remark'] = '没有启用GD, 将无法正常上传和压缩图片, 系统无法正常运行. <a target="_blank" href="http://bbs.we7.cc/forum.php?mod=redirect&goto=findpost&ptid=3564&pid=58110">详情</a>';
  121. }
  122. $ret['php']['dom']['ok'] = class_exists('DOMDocument');
  123. if($ret['php']['dom']['ok']) {
  124. $ret['php']['dom']['value'] = '<span class="glyphicon glyphicon-ok text-success"></span>';
  125. $ret['php']['dom']['class'] = 'success';
  126. } else {
  127. $ret['php']['dom']['value'] = '<span class="glyphicon glyphicon-remove text-danger"></span>';
  128. $ret['php']['dom']['class'] = 'danger';
  129. $ret['php']['dom']['failed'] = true;
  130. $ret['php']['dom']['remark'] = '没有启用DOMDocument, 将无法正常安装使用模块, 系统无法正常运行. <a target="_blank" href="http://bbs.we7.cc/forum.php?mod=redirect&goto=findpost&ptid=3564&pid=58111">详情</a>';
  131. }
  132. $ret['php']['session']['ok'] = ini_get('session.auto_start');
  133. if($ret['php']['session']['ok'] == 0 || strtolower($ret['php']['session']['ok']) == 'off') {
  134. $ret['php']['session']['value'] = '<span class="glyphicon glyphicon-ok text-success"></span>';
  135. $ret['php']['session']['class'] = 'success';
  136. } else {
  137. $ret['php']['session']['value'] = '<span class="glyphicon glyphicon-remove text-danger"></span>';
  138. $ret['php']['session']['class'] = 'danger';
  139. $ret['php']['session']['failed'] = true;
  140. $ret['php']['session']['remark'] = '系统session.auto_start开启, 将无法正常注册会员, 系统无法正常运行. <a target="_blank" href="http://bbs.we7.cc/forum.php?mod=redirect&goto=findpost&ptid=3564&pid=58111">详情</a>';
  141. }
  142. $ret['php']['asp_tags']['ok'] = ini_get('asp_tags');
  143. if(empty($ret['php']['asp_tags']['ok']) || strtolower($ret['php']['asp_tags']['ok']) == 'off') {
  144. $ret['php']['asp_tags']['value'] = '<span class="glyphicon glyphicon-ok text-success"></span>';
  145. $ret['php']['asp_tags']['class'] = 'success';
  146. } else {
  147. $ret['php']['asp_tags']['value'] = '<span class="glyphicon glyphicon-remove text-danger"></span>';
  148. $ret['php']['asp_tags']['class'] = 'danger';
  149. $ret['php']['asp_tags']['failed'] = true;
  150. $ret['php']['asp_tags']['remark'] = '请禁用可以使用ASP 风格的标志,配置php.ini中asp_tags = Off';
  151. }
  152. $ret['write']['root']['ok'] = local_writeable(IA_ROOT . '/');
  153. if($ret['write']['root']['ok']) {
  154. $ret['write']['root']['value'] = '<span class="glyphicon glyphicon-ok text-success"></span>';
  155. $ret['write']['root']['class'] = 'success';
  156. } else {
  157. $ret['write']['root']['value'] = '<span class="glyphicon glyphicon-remove text-danger"></span>';
  158. $ret['write']['root']['class'] = 'danger';
  159. $ret['write']['root']['failed'] = true;
  160. $ret['write']['root']['remark'] = '本地目录无法写入, 将无法使用自动更新功能, 系统无法正常运行. <a href="http://bbs.we7.cc/">详情</a>';
  161. }
  162. $ret['write']['data']['ok'] = local_writeable(IA_ROOT . '/data');
  163. if($ret['write']['data']['ok']) {
  164. $ret['write']['data']['value'] = '<span class="glyphicon glyphicon-ok text-success"></span>';
  165. $ret['write']['data']['class'] = 'success';
  166. } else {
  167. $ret['write']['data']['value'] = '<span class="glyphicon glyphicon-remove text-danger"></span>';
  168. $ret['write']['data']['class'] = 'danger';
  169. $ret['write']['data']['failed'] = true;
  170. $ret['write']['data']['remark'] = 'data目录无法写入, 将无法写入配置文件, 系统无法正常安装. ';
  171. }
  172. $ret['continue'] = true;
  173. foreach($ret['php'] as $opt) {
  174. if($opt['failed']) {
  175. $ret['continue'] = false;
  176. break;
  177. }
  178. }
  179. if($ret['write']['failed']) {
  180. $ret['continue'] = false;
  181. }
  182. tpl_install_env($ret);
  183. }
  184. if($action == 'db') {
  185. if($ispost) {
  186. if($_POST['do'] != 'continue') {
  187. setcookie('action', 'env');
  188. header('location: ?refresh');
  189. exit();
  190. }
  191. $family = $_POST['family'] == 'x' ? 'x' : 'v';
  192. $db = $_POST['db'];
  193. $user = $_POST['user'];
  194. try {
  195. $pieces = explode(':', $db['server']);
  196. $db['server'] = $pieces[0];
  197. $db['port'] = !empty($pieces[1]) ? $pieces[1] : '3306';
  198. $link = new PDO("mysql:host={$db['server']};port={$db['port']}", $db['username'], $db['password']); // dns可以没有dbname
  199. $link->exec("SET character_set_connection=utf8, character_set_results=utf8, character_set_client=binary");
  200. $link->exec("SET sql_mode=''");
  201. if ($link->errorCode() != '00000') {
  202. $errorInfo = $link->errorInfo();
  203. $error = $errorInfo[2];
  204. } else {
  205. $statement = $link->query("SHOW DATABASES LIKE '{$db['name']}';");
  206. $fetch = $statement->fetch();
  207. if (empty($fetch)){
  208. if (substr($link->getAttribute(PDO::ATTR_SERVER_VERSION), 0, 3) > '4.1') {
  209. $link->query("CREATE DATABASE IF NOT EXISTS `{$db['name']}` DEFAULT CHARACTER SET utf8");
  210. } else {
  211. $link->query("CREATE DATABASE IF NOT EXISTS `{$db['name']}`");
  212. }
  213. }
  214. $statement = $link->query("SHOW DATABASES LIKE '{$db['name']}';");
  215. $fetch = $statement->fetch();
  216. if (empty($fetch)) {
  217. $error .= "数据库不存在且创建数据库失败. <br />";
  218. }
  219. if ($link->errorCode() != '00000') {
  220. $errorInfo = $link->errorInfo();
  221. $error .= $errorInfo[2];
  222. }
  223. }
  224. } catch (PDOException $e) {
  225. $error = $e->getMessage();
  226. if (strpos($error, 'Access denied for user') !== false) {
  227. $error = '您的数据库访问用户名或是密码错误. <br />';
  228. } else {
  229. $error = iconv('gbk', 'utf8', $error);
  230. }
  231. }
  232. if(empty($error)) {
  233. $link->exec("USE {$db['name']}");
  234. $statement = $link->query("SHOW TABLES LIKE '{$db['prefix']}%';");
  235. if ($statement->fetch()) {
  236. $error = '您的数据库不为空,请重新建立数据库或是清空该数据库或更改表前缀!';
  237. }
  238. }
  239. if(empty($error)) {
  240. $config = local_config();
  241. $cookiepre = local_salt(4) . '_';
  242. $authkey = local_salt(8);
  243. $config = str_replace(array(
  244. '{db-server}', '{db-username}', '{db-password}', '{db-port}', '{db-name}', '{db-tablepre}', '{cookiepre}', '{authkey}', '{attachdir}'
  245. ), array(
  246. $db['server'], $db['username'], $db['password'], $db['port'], $db['name'], $db['prefix'], $cookiepre, $authkey, 'attachment'
  247. ), $config);
  248. $verfile = IA_ROOT . '/framework/version.inc.php';
  249. $dbfile = IA_ROOT . '/data/db.php';
  250. if($_POST['type'] == 'remote') {
  251. $link = NULL;
  252. $ins = remote_install();
  253. if(empty($ins)) {
  254. die('<script type="text/javascript">alert("连接不到服务器, 请稍后重试!");history.back();</script>');
  255. }
  256. if($ins == 'error') {
  257. die('<script type="text/javascript">alert("版本错误,请确认是否为微擎最新版安装文件!");history.back();</script>');
  258. }
  259. $link = new PDO("mysql:dbname={$db['name']};host={$db['server']};port={$db['port']}", $db['username'], $db['password']);
  260. $link->exec("SET character_set_connection=utf8, character_set_results=utf8, character_set_client=binary");
  261. $link->exec("SET sql_mode=''");
  262. $tmpfile = IA_ROOT . '/we7source.tmp';
  263. file_put_contents($tmpfile, $ins);
  264. $zip = new ZipArchive;
  265. $res = $zip->open($tmpfile);
  266. if ($res === TRUE) {
  267. $zip->extractTo(IA_ROOT);
  268. $zip->close();
  269. } else {
  270. die('<script type="text/javascript">alert("安装失败,请确认当前目录是否有写入权限!");history.back();</script>');
  271. }
  272. unlink($tmpfile);
  273. }
  274. if(file_exists(IA_ROOT . '/index.php') && is_dir(IA_ROOT . '/web') && file_exists($verfile) && file_exists($dbfile)) {
  275. $dat = require $dbfile;
  276. if(empty($dat) || !is_array($dat)) {
  277. die('<script type="text/javascript">alert("安装包不正确, 数据安装脚本缺失.");history.back();</script>');
  278. }
  279. foreach($dat['schemas'] as $schema) {
  280. $sql = local_create_sql($schema);
  281. local_run($sql);
  282. }
  283. foreach($dat['datas'] as $data) {
  284. local_run($data);
  285. }
  286. } else {
  287. die('<script type="text/javascript">alert("你正在使用本地安装, 但未下载完整安装包, 请从微擎官网下载完整安装包后重试.");history.back();</script>');
  288. }
  289. $salt = local_salt(8);
  290. $password = sha1("{$user['password']}-{$salt}-{$authkey}");
  291. $link->exec("INSERT INTO {$db['prefix']}users (username, password, salt, joindate, groupid) VALUES('{$user['username']}', '{$password}', '{$salt}', '" . time() . "', 1)");
  292. local_mkdirs(IA_ROOT . '/data');
  293. file_put_contents(IA_ROOT . '/data/config.php', $config);
  294. touch(IA_ROOT . '/data/install.lock');
  295. setcookie('action', 'finish');
  296. header('location: ?refresh');
  297. exit();
  298. }
  299. }
  300. tpl_install_db($error);
  301. }
  302. if($action == 'finish') {
  303. setcookie('action', '', -10);
  304. $dbfile = IA_ROOT . '/data/db.php';
  305. @unlink($dbfile);
  306. define('IN_SYS', true);
  307. require IA_ROOT . '/framework/bootstrap.inc.php';
  308. require IA_ROOT . '/web/common/bootstrap.sys.inc.php';
  309. $_W['uid'] = $_W['isfounder'] = 1;
  310. load()->web('common');
  311. load()->web('template');
  312. load()->model('setting');
  313. load()->model('cache');
  314. cache_build_frame_menu();
  315. cache_build_setting();
  316. cache_build_users_struct();
  317. cache_build_module_subscribe_type();
  318. tpl_install_finish();
  319. }
  320. function local_writeable($dir) {
  321. $writeable = 0;
  322. if(!is_dir($dir)) {
  323. @mkdir($dir, 0777);
  324. }
  325. if(is_dir($dir)) {
  326. if($fp = fopen("$dir/test.txt", 'w')) {
  327. fclose($fp);
  328. unlink("$dir/test.txt");
  329. $writeable = 1;
  330. } else {
  331. $writeable = 0;
  332. }
  333. }
  334. return $writeable;
  335. }
  336. function local_salt($length = 8) {
  337. $result = '';
  338. while(strlen($result) < $length) {
  339. $result .= sha1(uniqid('', true));
  340. }
  341. return substr($result, 0, $length);
  342. }
  343. function local_config() {
  344. $cfg = <<<EOF
  345. <?php
  346. defined('IN_IA') or exit('Access Denied');
  347. \$config = array();
  348. \$config['db']['master']['host'] = '{db-server}';
  349. \$config['db']['master']['username'] = '{db-username}';
  350. \$config['db']['master']['password'] = '{db-password}';
  351. \$config['db']['master']['port'] = '{db-port}';
  352. \$config['db']['master']['database'] = '{db-name}';
  353. \$config['db']['master']['charset'] = 'utf8';
  354. \$config['db']['master']['pconnect'] = 0;
  355. \$config['db']['master']['tablepre'] = '{db-tablepre}';
  356. \$config['db']['slave_status'] = false;
  357. \$config['db']['slave']['1']['host'] = '';
  358. \$config['db']['slave']['1']['username'] = '';
  359. \$config['db']['slave']['1']['password'] = '';
  360. \$config['db']['slave']['1']['port'] = '3307';
  361. \$config['db']['slave']['1']['database'] = '';
  362. \$config['db']['slave']['1']['charset'] = 'utf8';
  363. \$config['db']['slave']['1']['pconnect'] = 0;
  364. \$config['db']['slave']['1']['tablepre'] = 'ims_';
  365. \$config['db']['slave']['1']['weight'] = 0;
  366. \$config['db']['common']['slave_except_table'] = array('core_sessions');
  367. // -------------------------- CONFIG COOKIE --------------------------- //
  368. \$config['cookie']['pre'] = '{cookiepre}';
  369. \$config['cookie']['domain'] = '';
  370. \$config['cookie']['path'] = '/';
  371. // -------------------------- CONFIG SETTING --------------------------- //
  372. \$config['setting']['charset'] = 'utf-8';
  373. \$config['setting']['cache'] = 'mysql';
  374. \$config['setting']['timezone'] = 'Asia/Shanghai';
  375. \$config['setting']['memory_limit'] = '256M';
  376. \$config['setting']['filemode'] = 0644;
  377. \$config['setting']['authkey'] = '{authkey}';
  378. \$config['setting']['founder'] = '1';
  379. \$config['setting']['development'] = 0;
  380. \$config['setting']['referrer'] = 0;
  381. // -------------------------- CONFIG UPLOAD --------------------------- //
  382. \$config['upload']['image']['extentions'] = array('gif', 'jpg', 'jpeg', 'png');
  383. \$config['upload']['image']['limit'] = 5000;
  384. \$config['upload']['attachdir'] = '{attachdir}';
  385. \$config['upload']['audio']['extentions'] = array('mp3');
  386. \$config['upload']['audio']['limit'] = 5000;
  387. // -------------------------- CONFIG MEMCACHE --------------------------- //
  388. \$config['setting']['memcache']['server'] = '';
  389. \$config['setting']['memcache']['port'] = 11211;
  390. \$config['setting']['memcache']['pconnect'] = 1;
  391. \$config['setting']['memcache']['timeout'] = 30;
  392. \$config['setting']['memcache']['session'] = 1;
  393. // -------------------------- CONFIG PROXY --------------------------- //
  394. \$config['setting']['proxy']['host'] = '';
  395. \$config['setting']['proxy']['auth'] = '';
  396. EOF;
  397. return trim($cfg);
  398. }
  399. function local_mkdirs($path) {
  400. if(!is_dir($path)) {
  401. local_mkdirs(dirname($path));
  402. mkdir($path);
  403. }
  404. return is_dir($path);
  405. }
  406. function local_run($sql) {
  407. global $link, $db;
  408. if(!isset($sql) || empty($sql)) return;
  409. $sql = str_replace("\r", "\n", str_replace(' ims_', ' '.$db['prefix'], $sql));
  410. $sql = str_replace("\r", "\n", str_replace(' `ims_', ' `'.$db['prefix'], $sql));
  411. $ret = array();
  412. $num = 0;
  413. foreach(explode(";\n", trim($sql)) as $query) {
  414. $ret[$num] = '';
  415. $queries = explode("\n", trim($query));
  416. foreach($queries as $query) {
  417. $ret[$num] .= (isset($query[0]) && $query[0] == '#') || (isset($query[1]) && isset($query[1]) && $query[0].$query[1] == '--') ? '' : $query;
  418. }
  419. $num++;
  420. }
  421. unset($sql);
  422. foreach($ret as $query) {
  423. $query = trim($query);
  424. if($query) {
  425. $link->exec($query);
  426. if($link->errorCode() != '00000') {
  427. $errorInfo = $link->errorInfo();
  428. echo $errorInfo[0] . ": " . $errorInfo[2] . "<br />";
  429. exit($query);
  430. }
  431. }
  432. }
  433. }
  434. function local_create_sql($schema) {
  435. $pieces = explode('_', $schema['charset']);
  436. $charset = $pieces[0];
  437. $engine = $schema['engine'];
  438. $sql = "CREATE TABLE IF NOT EXISTS `{$schema['tablename']}` (\n";
  439. foreach ($schema['fields'] as $value) {
  440. if(!empty($value['length'])) {
  441. $length = "({$value['length']})";
  442. } else {
  443. $length = '';
  444. }
  445. $signed = empty($value['signed']) ? ' unsigned' : '';
  446. if(empty($value['null'])) {
  447. $null = ' NOT NULL';
  448. } else {
  449. $null = '';
  450. }
  451. if(isset($value['default'])) {
  452. $default = " DEFAULT '" . $value['default'] . "'";
  453. } else {
  454. $default = '';
  455. }
  456. if($value['increment']) {
  457. $increment = ' AUTO_INCREMENT';
  458. } else {
  459. $increment = '';
  460. }
  461. $sql .= "`{$value['name']}` {$value['type']}{$length}{$signed}{$null}{$default}{$increment},\n";
  462. }
  463. foreach ($schema['indexes'] as $value) {
  464. $fields = implode('`,`', $value['fields']);
  465. if($value['type'] == 'index') {
  466. $sql .= "KEY `{$value['name']}` (`{$fields}`),\n";
  467. }
  468. if($value['type'] == 'unique') {
  469. $sql .= "UNIQUE KEY `{$value['name']}` (`{$fields}`),\n";
  470. }
  471. if($value['type'] == 'primary') {
  472. $sql .= "PRIMARY KEY (`{$fields}`),\n";
  473. }
  474. }
  475. $sql = rtrim($sql);
  476. $sql = rtrim($sql, ',');
  477. $sql .= "\n) ENGINE=$engine DEFAULT CHARSET=$charset;\n\n";
  478. return $sql;
  479. }
  480. function remote_install() {
  481. global $family;
  482. $token = '';
  483. $pars = array();
  484. $pars['host'] = $_SERVER['HTTP_HOST'];
  485. $pars['version'] = '1.0';
  486. $pars['type'] = 'install';
  487. $pars['method'] = 'application.install';
  488. $url = $_SERVER['HTTP_HOST'].'/gateway.php';
  489. $urlset = parse_url($url);
  490. $cloudip = gethostbyname($urlset['host']);
  491. $headers[] = "Host: {$urlset['host']}";
  492. $ch = curl_init();
  493. curl_setopt($ch, CURLOPT_URL, $urlset['scheme'] . '://' . $cloudip . $urlset['path']);
  494. curl_setopt($ch, CURLOPT_POST, 1);
  495. curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($pars, '', '&'));
  496. curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  497. curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
  498. $content = curl_exec($ch);
  499. curl_close($ch);
  500. if (empty($content)) {
  501. return showerror(-1, '获取安装信息失败,可能是由于网络不稳定,请重试。');
  502. }
  503. return $content;
  504. }
  505. function tpl_frame() {
  506. global $action, $actions;
  507. $action = $_COOKIE['action'];
  508. $step = array_search($action, $actions);
  509. $steps = array();
  510. for($i = 0; $i <= $step; $i++) {
  511. if($i == $step) {
  512. $steps[$i] = ' list-group-item-info';
  513. } else {
  514. $steps[$i] = ' list-group-item-success';
  515. }
  516. }
  517. $progress = $step * 25 + 25;
  518. $content = ob_get_contents();
  519. ob_clean();
  520. $tpl = <<<EOF
  521. <!DOCTYPE html>
  522. <html lang="zh-cn">
  523. <head>
  524. <meta charset="utf-8">
  525. <meta http-equiv="X-UA-Compatible" content="IE=edge">
  526. <meta name="viewport" content="width=device-width, initial-scale=1">
  527. <title>安装系统 - 微擎 - 公众平台自助开源引擎</title>
  528. <link rel="stylesheet" href="http://cdn.bootcss.com/bootstrap/3.2.0/css/bootstrap.min.css">
  529. <style>
  530. html,body{font-size:13px;font-family:"Microsoft YaHei UI", "微软雅黑", "宋体";}
  531. .pager li.previous a{margin-right:10px;}
  532. .header a{color:#FFF;}
  533. .header a:hover{color:#428bca;}
  534. .footer{padding:10px;}
  535. .footer a,.footer{color:#eee;font-size:14px;line-height:25px;}
  536. </style>
  537. <!--[if lt IE 9]>
  538. <script src="http://cdn.bootcss.com/html5shiv/3.7.2/html5shiv.min.js"></script>
  539. <script src="http://cdn.bootcss.com/respond.js/1.4.2/respond.min.js"></script>
  540. <![endif]-->
  541. </head>
  542. <body style="background-color:#28b0e4;">
  543. <div class="container" style="width:1200px;">
  544. <div class="header" style="margin:15px auto;">
  545. <ul class="nav nav-pills pull-right" role="tablist">
  546. <li role="presentation" class="active"><a href="javascript:;">安装微擎系统</a></li>
  547. <li role="presentation"><a href="http://www.we7.cc">微擎官网</a></li>
  548. <li role="presentation"><a href="http://bbs.we7.cc">访问论坛</a></li>
  549. </ul>
  550. <img src="?res=logo" />
  551. </div>
  552. <div class="row well" style="margin:auto 0;">
  553. <div class="col-xs-2" style="padding:0; width:14%;">
  554. <div class="progress" title="安装进度">
  555. <div class="progress-bar progress-bar-info progress-bar-striped active" role="progressbar" aria-valuenow="{$progress}" aria-valuemin="0" aria-valuemax="100" style="width: {$progress}%;">
  556. {$progress}%
  557. </div>
  558. </div>
  559. <div class="panel panel-default">
  560. <div class="panel-heading">
  561. 安装步骤
  562. </div>
  563. <ul class="list-group">
  564. <a href="javascript:;" class="list-group-item{$steps[0]}"><span class="glyphicon glyphicon-copyright-mark"></span> &nbsp; 许可协议</a>
  565. <a href="javascript:;" class="list-group-item{$steps[1]}"><span class="glyphicon glyphicon-eye-open"></span> &nbsp; 环境监测</a>
  566. <a href="javascript:;" class="list-group-item{$steps[2]}"><span class="glyphicon glyphicon-cog"></span> &nbsp; 参数配置</a>
  567. <a href="javascript:;" class="list-group-item{$steps[3]}"><span class="glyphicon glyphicon-ok"></span> &nbsp; 成功</a>
  568. </ul>
  569. </div>
  570. </div>
  571. <div class="col-xs-10">
  572. {$content}
  573. </div>
  574. </div>
  575. <div class="footer" style="margin:15px auto;">
  576. <div class="text-center">
  577. <a href="http://www.we7.cc">关于微擎</a> &nbsp; &nbsp; <a href="http://bbs.we7.cc">微擎帮助</a> &nbsp; &nbsp; <a href="http://www.we7.cc">购买授权</a>
  578. </div>
  579. <div class="text-center">
  580. Powered by <a href="http://www.we7.cc"><b>微擎</b></a> v1.x &copy; 2018 <a href="http://www.we7.cc">www.we7.cc</a>
  581. </div>
  582. </div>
  583. </div>
  584. <script src="http://cdn.bootcss.com/jquery/1.11.1/jquery.min.js"></script>
  585. <script src="http://cdn.bootcss.com/bootstrap/3.2.0/js/bootstrap.min.js"></script>
  586. </body>
  587. </html>
  588. EOF;
  589. echo trim($tpl);
  590. }
  591. function tpl_install_license() {
  592. echo <<<EOF
  593. <div class="panel panel-default">
  594. <div class="panel-heading">阅读许可协议</div>
  595. <div class="panel-body" style="overflow-y:scroll;max-height:400px;line-height:20px;">
  596. <h3>微擎1.70商业纯净版安装说明</h3>
  597. <p>
  598. <li>本微擎由微擎提供</li>
  599. </p>
  600. <p>
  601. <strong>0x2 版本介绍 </strong>
  602. <ol>
  603. <li>0xA 删除所有附件</li>
  604. <li>0xB 删除测试公众号</li>
  605. <li>0xC 删除授权和盗版检测</li>
  606. </ol>
  607. </p>
  608. <p>
  609. <strong>0x3 数据库优化说明 </strong>
  610. <ol>
  611. <li>0xA 删除所有数据后自增ID归1</li>
  612. <li>0xB 删除沉余数据</li>
  613. </ol>
  614. </p>
  615. <p>
  616. <strong>0x4 对应版本 </strong>
  617. <ol>
  618. <li>微擎1.7.0 20180202150514</li>
  619. </ol>
  620. </p>
  621. </div>
  622. </div>
  623. <form class="form-inline" role="form" method="post">
  624. <ul class="pager">
  625. <li class="pull-left" style="display:block;padding:5px 10px 5px 0;">
  626. <div class="checkbox">
  627. <label>
  628. <input type="checkbox"> 我已经阅读并同意此协议
  629. </label>
  630. </div>
  631. </li>
  632. <li class="previous"><a href="javascript:;" onclick="if(jQuery(':checkbox:checked').length == 1){jQuery('form')[0].submit();}else{alert('您必须同意软件许可协议才能安装!')};">继续 <span class="glyphicon glyphicon-chevron-right"></span></a></li>
  633. </ul>
  634. </form>
  635. EOF;
  636. tpl_frame();
  637. }
  638. function tpl_install_env($ret = array()) {
  639. if(empty($ret['continue'])) {
  640. $continue = '<li class="previous disabled"><a href="javascript:;">请先解决环境问题后继续</a></li>';
  641. } else {
  642. $continue = '<li class="previous"><a href="javascript:;" onclick="$(\'#do\').val(\'continue\');$(\'form\')[0].submit();">继续 <span class="glyphicon glyphicon-chevron-right"></span></a></li>';
  643. }
  644. echo <<<EOF
  645. <div class="panel panel-default">
  646. <div class="panel-heading">服务器信息</div>
  647. <table class="table table-striped">
  648. <tr>
  649. <th style="width:150px;">参数</th>
  650. <th>值</th>
  651. <th></th>
  652. </tr>
  653. <tr class="{$ret['server']['os']['class']}">
  654. <td>服务器操作系统</td>
  655. <td>{$ret['server']['os']['value']}</td>
  656. <td>{$ret['server']['os']['remark']}</td>
  657. </tr>
  658. <tr class="{$ret['server']['sapi']['class']}">
  659. <td>Web服务器环境</td>
  660. <td>{$ret['server']['sapi']['value']}</td>
  661. <td>{$ret['server']['sapi']['remark']}</td>
  662. </tr>
  663. <tr class="{$ret['server']['php']['class']}">
  664. <td>PHP版本</td>
  665. <td>{$ret['server']['php']['value']}</td>
  666. <td>{$ret['server']['php']['remark']}</td>
  667. </tr>
  668. <tr class="{$ret['server']['dir']['class']}">
  669. <td>程序安装目录</td>
  670. <td>{$ret['server']['dir']['value']}</td>
  671. <td>{$ret['server']['dir']['remark']}</td>
  672. </tr>
  673. <tr class="{$ret['server']['disk']['class']}">
  674. <td>磁盘空间</td>
  675. <td>{$ret['server']['disk']['value']}</td>
  676. <td>{$ret['server']['disk']['remark']}</td>
  677. </tr>
  678. <tr class="{$ret['server']['upload']['class']}">
  679. <td>上传限制</td>
  680. <td>{$ret['server']['upload']['value']}</td>
  681. <td>{$ret['server']['upload']['remark']}</td>
  682. </tr>
  683. </table>
  684. </div>
  685. <div class="alert alert-info">PHP环境要求必须满足下列所有条件,否则系统或系统部份功能将无法使用。</div>
  686. <div class="panel panel-default">
  687. <div class="panel-heading">PHP环境要求</div>
  688. <table class="table table-striped">
  689. <tr>
  690. <th style="width:150px;">选项</th>
  691. <th style="width:180px;">要求</th>
  692. <th style="width:50px;">状态</th>
  693. <th>说明及帮助</th>
  694. </tr>
  695. <tr class="{$ret['php']['version']['class']}">
  696. <td>PHP版本</td>
  697. <td>5.3或者5.3以上</td>
  698. <td>{$ret['php']['version']['value']}</td>
  699. <td>{$ret['php']['version']['remark']}</td>
  700. </tr>
  701. <tr class="{$ret['php']['curl']['class']}">
  702. <td>cURL</td>
  703. <td>支持</td>
  704. <td>{$ret['php']['curl']['value']}</td>
  705. <td>{$ret['php']['curl']['remark']}</td>
  706. </tr>
  707. <tr class="{$ret['php']['pdo']['class']}">
  708. <td>PDO</td>
  709. <td>支持</td>
  710. <td>{$ret['php']['pdo']['value']}</td>
  711. <td>{$ret['php']['pdo']['remark']}</td>
  712. </tr>
  713. <tr class="{$ret['php']['ssl']['class']}">
  714. <td>openSSL</td>
  715. <td>支持</td>
  716. <td>{$ret['php']['ssl']['value']}</td>
  717. <td>{$ret['php']['ssl']['remark']}</td>
  718. </tr>
  719. <tr class="{$ret['php']['gd']['class']}">
  720. <td>GD2</td>
  721. <td>支持</td>
  722. <td>{$ret['php']['gd']['value']}</td>
  723. <td>{$ret['php']['gd']['remark']}</td>
  724. </tr>
  725. <tr class="{$ret['php']['dom']['class']}">
  726. <td>DOM</td>
  727. <td>支持</td>
  728. <td>{$ret['php']['dom']['value']}</td>
  729. <td>{$ret['php']['dom']['remark']}</td>
  730. </tr>
  731. <tr class="{$ret['php']['session']['class']}">
  732. <td>session.auto_start</td>
  733. <td>关闭</td>
  734. <td>{$ret['php']['session']['value']}</td>
  735. <td>{$ret['php']['session']['remark']}</td>
  736. </tr>
  737. <tr class="{$ret['php']['asp_tags']['class']}">
  738. <td>asp_tags</td>
  739. <td>关闭</td>
  740. <td>{$ret['php']['asp_tags']['value']}</td>
  741. <td>{$ret['php']['asp_tags']['remark']}</td>
  742. </tr>
  743. </table>
  744. </div>
  745. <div class="alert alert-info">系统要求微擎整个安装目录必须可写, 才能使用微擎所有功能。</div>
  746. <div class="panel panel-default">
  747. <div class="panel-heading">目录权限监测</div>
  748. <table class="table table-striped">
  749. <tr>
  750. <th style="width:150px;">目录</th>
  751. <th style="width:180px;">要求</th>
  752. <th style="width:50px;">状态</th>
  753. <th>说明及帮助</th>
  754. </tr>
  755. <tr class="{$ret['write']['root']['class']}">
  756. <td>/</td>
  757. <td>整目录可写</td>
  758. <td>{$ret['write']['root']['value']}</td>
  759. <td>{$ret['write']['root']['remark']}</td>
  760. </tr>
  761. <tr class="{$ret['write']['data']['class']}">
  762. <td>/</td>
  763. <td>data目录可写</td>
  764. <td>{$ret['write']['data']['value']}</td>
  765. <td>{$ret['write']['data']['remark']}</td>
  766. </tr>
  767. </table>
  768. </div>
  769. <form class="form-inline" role="form" method="post">
  770. <input type="hidden" name="do" id="do" />
  771. <ul class="pager">
  772. <li class="previous"><a href="javascript:;" onclick="$('#do').val('back');$('form')[0].submit();"><span class="glyphicon glyphicon-chevron-left"></span> 返回</a></li>
  773. {$continue}
  774. </ul>
  775. </form>
  776. EOF;
  777. tpl_frame();
  778. }
  779. function tpl_install_db($error = '') {
  780. if(!empty($error)) {
  781. $message = '<div class="alert alert-danger">发生错误: ' . $error . '</div>';
  782. }
  783. $insTypes = array();
  784. if(file_exists(IA_ROOT . '/index.php') && is_dir(IA_ROOT . '/app') && is_dir(IA_ROOT . '/web')) {
  785. $insTypes['local'] = ' checked="checked"';
  786. } else {
  787. $insTypes['remote'] = ' checked="checked"';
  788. }
  789. if (!empty($_POST['type'])) {
  790. $insTypes = array();
  791. $insTypes[$_POST['type']] = ' checked="checked"';
  792. }
  793. $disabled = empty($insTypes['local']) ? ' disabled="disabled"' : '';
  794. echo <<<EOF
  795. {$message}
  796. <form class="form-horizontal" method="post" role="form">
  797. <div class="panel panel-default">
  798. <div class="panel-heading">安装选项</div>
  799. <div class="panel-body">
  800. <div class="form-group">
  801. <label class="col-sm-2 control-label">安装方式</label>
  802. <div class="col-sm-10">
  803. <label class="radio-inline">
  804. <input type="radio" name="type" value="local"{$insTypes['local']}{$disabled}> 离线安装
  805. </label>
  806. </div>
  807. </div>
  808. </div>
  809. </div>
  810. <div class="panel panel-default">
  811. <div class="panel-heading">数据库选项</div>
  812. <div class="panel-body">
  813. <div class="form-group">
  814. <label class="col-sm-2 control-label">数据库主机</label>
  815. <div class="col-sm-4">
  816. <input class="form-control" type="text" name="db[server]" value="127.0.0.1">
  817. </div>
  818. </div>
  819. <div class="form-group">
  820. <label class="col-sm-2 control-label">数据库用户</label>
  821. <div class="col-sm-4">
  822. <input class="form-control" type="text" name="db[username]" value="">
  823. </div>
  824. </div>
  825. <div class="form-group">
  826. <label class="col-sm-2 control-label">数据库密码</label>
  827. <div class="col-sm-4">
  828. <input class="form-control" type="text" name="db[password]">
  829. </div>
  830. </div>
  831. <div class="form-group">
  832. <label class="col-sm-2 control-label">表前缀</label>
  833. <div class="col-sm-4">
  834. <input class="form-control" type="text" name="db[prefix]" value="ims_">
  835. </div>
  836. </div>
  837. <div class="form-group">
  838. <label class="col-sm-2 control-label">数据库名称</label>
  839. <div class="col-sm-4">
  840. <input class="form-control" type="text" name="db[name]" value="">
  841. </div>
  842. </div>
  843. </div>
  844. </div>
  845. <div class="panel panel-default">
  846. <div class="panel-heading">管理选项</div>
  847. <div class="panel-body">
  848. <div class="form-group">
  849. <label class="col-sm-2 control-label">管理员账号</label>
  850. <div class="col-sm-4">
  851. <input class="form-control" type="username" name="user[username]">
  852. </div>
  853. </div>
  854. <div class="form-group">
  855. <label class="col-sm-2 control-label">管理员密码</label>
  856. <div class="col-sm-4">
  857. <input class="form-control" type="password" name="user[password]">
  858. </div>
  859. </div>
  860. <div class="form-group">
  861. <label class="col-sm-2 control-label">确认密码</label>
  862. <div class="col-sm-4">
  863. <input class="form-control" type="password"">
  864. </div>
  865. </div>
  866. </div>
  867. </div>
  868. <input type="hidden" name="do" id="do" />
  869. <ul class="pager">
  870. <li class="previous"><a href="javascript:;" onclick="$('#do').val('back');$('form')[0].submit();"><span class="glyphicon glyphicon-chevron-left"></span> 返回</a></li>
  871. <li class="previous"><a href="javascript:;" onclick="if(check(this)){jQuery('#do').val('continue');if($('input[name=type]:checked').val() == 'remote'){alert('在线安装时,安装程序会下载精简版快速完成安装,完成后请务必注册云服务更新到完整版。')}$('form')[0].submit();}">继续 <span class="glyphicon glyphicon-chevron-right"></span></a></li>
  872. </ul>
  873. </form>
  874. <script>
  875. var lock = false;
  876. function check(obj) {
  877. if(lock) {
  878. return;
  879. }
  880. $('.form-control').parent().parent().removeClass('has-error');
  881. var error = false;
  882. $('.form-control').each(function(){
  883. if($(this).val() == '') {
  884. $(this).parent().parent().addClass('has-error');
  885. this.focus();
  886. error = true;
  887. }
  888. });
  889. if(error) {
  890. alert('请检查未填项');
  891. return false;
  892. }
  893. if($(':password').eq(0).val() != $(':password').eq(1).val()) {
  894. $(':password').parent().parent().addClass('has-error');
  895. alert('确认密码不正确.');
  896. return false;
  897. }
  898. lock = true;
  899. $(obj).parent().addClass('disabled');
  900. $(obj).html('正在执行安装');
  901. return true;
  902. }
  903. </script>
  904. EOF;
  905. tpl_frame();
  906. }
  907. function tpl_install_finish() {
  908. $modules = get_store_module();
  909. $themes = get_store_theme();
  910. echo <<<EOF
  911. <div class="page-header"><h3>安装完成</h3></div>
  912. <div class="alert alert-danger"><i class="fa fa-exclamation-triangle"></i> 微擎为你提供优质的CMS!</div>
  913. <div class="alert alert-success">
  914. 恭喜您!已成功安装“微擎 - 公众平台自助开源引擎”系统,您现在可以: <a target="_blank" class="btn btn-success" href="./web/index.php">访问网站首页</a>
  915. </div>
  916. EOF;
  917. tpl_frame();
  918. }
  919. function tpl_resources() {
  920. static $res = array(
  921. 'logo' => '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',
  922. );
  923. return $res;
  924. }
  925. function showerror($errno, $message = '') {
  926. return array(
  927. 'errno' => $errno,
  928. 'error' => $message,
  929. );
  930. }
  931. function get_store_module() {
  932. load()->func('communication');
  933. $response = ihttp_request(APP_STORE_API, array('controller' => 'store', 'action' => 'api', 'do' => 'module'));
  934. $response = json_decode($response['content'], true);
  935. $modules = '';
  936. foreach ($response['message'] as $key => $module) {
  937. if ($key % 3 < 1) {
  938. $modules .= '</tr><tr>';
  939. }
  940. $module['detail_link'] = APP_STORE_URL . trim($module['detail_link'], '.');
  941. $modules .= '<td>';
  942. $modules .= '<div class="col-sm-4">';
  943. $modules .= '<a href="' . $module['detail_link'] . '" title="查看详情" target="_blank">';
  944. $modules .= '<img src="' . $module['logo']. '"' . ' width="50" height="50" ' . $module['title'] . '" /></a>';
  945. $modules .= '</div>';
  946. $modules .= '<div class="col-sm-8">';
  947. $modules .= '<p><a href="' . $module['detail_link'] .'" title="查看详情" target="_blank">' . $module['title'] . '</a></p>';
  948. $modules .= '<p>安装量:<span class="text-danger">' . $module['purchases'] . '</span></p>';
  949. $modules .= '</div>';
  950. $modules .= '</td>';
  951. }
  952. $modules = substr($modules, 5) . '</tr>';
  953. return $modules;
  954. }
  955. function get_store_theme() {
  956. load()->func('communication');
  957. $response = ihttp_request(APP_STORE_API, array('controller' => 'store', 'action' => 'api', 'do' => 'theme'));
  958. $response = json_decode($response['content'], true);
  959. $themes = '<tr><td colspan="' . count($response['message']) . '">';
  960. $themes .= '<div class="form-group">';
  961. foreach ($response['message'] as $key => $theme) {
  962. $theme['detail_link'] = APP_STORE_URL . trim($theme['detail_link'], '.');
  963. $themes .= '<div class="col-sm-2" style="padding-left: 7px;margin-right: 25px;">';
  964. $themes .= '<a href="' . $theme['detail_link'] .'" title="查看详情" target="_blank" /><img src="' . $theme['logo']. '" /></a>';
  965. $themes .= '<p></p><p class="text-right">';
  966. $themes .= '<a href="' . $theme['detail_link']. '" title="查看详情" target="_blank">' . $theme['title'] . '</a></p>';
  967. $themes .= '</div>';
  968. }
  969. $themes .= '</div>';
  970. return $themes;
  971. }