Integrated evaluation notice for apps
[GitHub/WoltLab/WCF.git] / wcfsetup / install / files / lib / acp / page / IndexPage.class.php
1 <?php
2 declare(strict_types=1);
3 namespace wcf\acp\page;
4 use wcf\page\AbstractPage;
5 use wcf\system\application\ApplicationHandler;
6 use wcf\system\cache\builder\OptionCacheBuilder;
7 use wcf\system\package\PackageInstallationDispatcher;
8 use wcf\system\request\LinkHandler;
9 use wcf\system\WCF;
10
11 /**
12 * Shows the welcome page in admin control panel.
13 *
14 * @author Marcel Werk
15 * @copyright 2001-2018 WoltLab GmbH
16 * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
17 * @package WoltLabSuite\Core\Acp\Page
18 */
19 class IndexPage extends AbstractPage {
20 /**
21 * server information
22 * @var string[]
23 */
24 public $server = [];
25
26 /**
27 * @inheritDoc
28 */
29 public function readData() {
30 parent::readData();
31
32 $this->server = [
33 'os' => PHP_OS,
34 'webserver' => isset($_SERVER['SERVER_SOFTWARE']) ? $_SERVER['SERVER_SOFTWARE'] : '',
35 'mySQLVersion' => WCF::getDB()->getVersion(),
36 'load' => ''
37 ];
38
39 // get load
40 if (function_exists('sys_getloadavg')) {
41 $load = sys_getloadavg();
42 if (is_array($load) && count($load) == 3) {
43 $this->server['load'] = implode(', ', $load);
44 }
45 }
46 }
47
48 /**
49 * @inheritDoc
50 */
51 public function assignVariables() {
52 parent::assignVariables();
53
54 $usersAwaitingApproval = 0;
55 if (REGISTER_ACTIVATION_METHOD == 2) {
56 $sql = "SELECT COUNT(*)
57 FROM wcf".WCF_N."_user
58 WHERE activationCode <> 0";
59 $statement = WCF::getDB()->prepareStatement($sql);
60 $statement->execute();
61 $usersAwaitingApproval = $statement->fetchSingleColumn();
62 }
63
64 $recaptchaWithoutKey = false;
65 $recaptchaKeyLink = '';
66 if (CAPTCHA_TYPE == 'com.woltlab.wcf.recaptcha' && (!RECAPTCHA_PUBLICKEY || !RECAPTCHA_PRIVATEKEY)) {
67 $recaptchaWithoutKey = true;
68
69 $optionCategories = OptionCacheBuilder::getInstance()->getData([], 'categories');
70 $categorySecurity = $optionCategories['security'];
71 $recaptchaKeyLink = LinkHandler::getInstance()->getLink(
72 'Option',
73 [
74 'id' => $categorySecurity->categoryID,
75 'optionName' => 'recaptcha_publickey'
76 ], '#category_security.antispam'
77 );
78 }
79
80 $evaluationExpired = $evaluationPending = [];
81 foreach (ApplicationHandler::getInstance()->getApplications() as $application) {
82 if ($application->getPackage()->package === 'com.woltlab.wcf') {
83 continue;
84 }
85
86 $app = WCF::getApplicationObject($application);
87 $endDate = $app->getEvaluationEndDate();
88 if ($endDate) {
89 if ($endDate < TIME_NOW) {
90 $pluginStoreFileID = $app->getEvaluationPluginStoreID();
91 $isWoltLab = false;
92 if ($pluginStoreFileID === 0 && strpos($application->getPackage()->package, 'com.woltlab.') === 0) {
93 $isWoltLab = true;
94 }
95
96 $evaluationExpired[] = [
97 'packageName' => $application->getPackage()->getName(),
98 'isWoltLab' => $isWoltLab,
99 'pluginStoreFileID' => $pluginStoreFileID
100 ];
101 }
102 else {
103 if (!isset($evaluationPending[$endDate])) {
104 $evaluationPending[$endDate] = [];
105 }
106
107 $evaluationPending[$endDate][] = $application->getPackage()->getName();
108 }
109 }
110 }
111
112 WCF::getTPL()->assign([
113 'recaptchaWithoutKey' => $recaptchaWithoutKey,
114 'recaptchaKeyLink' => $recaptchaKeyLink,
115 'server' => $this->server,
116 'usersAwaitingApproval' => $usersAwaitingApproval,
117 'evaluationExpired' => $evaluationExpired,
118 'evaluationPending' => $evaluationPending
119 ]);
120 }
121
122 /**
123 * @inheritDoc
124 */
125 public function show() {
126 // check package installation queue
127 if ($this->action == 'WCFSetup') {
128 $queueID = PackageInstallationDispatcher::checkPackageInstallationQueue();
129
130 if ($queueID) {
131 WCF::getTPL()->assign(['queueID' => $queueID]);
132 WCF::getTPL()->display('packageInstallationSetup');
133 exit;
134 }
135 }
136
137 // show page
138 parent::show();
139 }
140 }