GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Push — master ( 423fe8...f48289 )
by gyeong-won
15:56 queued 08:14
created

autoinstall::checkUpdate()   D

Complexity

Conditions 9
Paths 7

Size

Total Lines 43
Code Lines 21

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 9
eloc 21
nc 7
nop 0
dl 0
loc 43
rs 4.909
c 0
b 0
f 0
1
<?php
2
/* Copyright (C) NAVER <http://www.navercorp.com> */
3
4
/**
5
 * XML Generater
6
 * @author NAVER ([email protected])
7
 */
8
class XmlGenerater
9
{
10
11
	/**
12
	 * Generate XML using given data
13
	 *
14
	 * @param array $params The data
15
	 * @return string Returns xml string
16
	 */
17
	function generate(&$params)
18
	{
19
		$xmlDoc = '<?xml version="1.0" encoding="utf-8" ?><methodCall><params>';
20
		if(!is_array($params))
21
		{
22
			return NULL;
23
		}
24
25
		$params["module"] = "resourceapi";
26
		foreach($params as $key => $val)
27
		{
28
			$xmlDoc .= sprintf("<%s><![CDATA[%s]]></%s>", $key, $val, $key);
29
		}
30
		$xmlDoc .= "</params></methodCall>";
31
		return $xmlDoc;
32
	}
33
34
	/**
35
	 * Request data to server and returns result
36
	 *
37
	 * @param array $params Request data
38
	 * @return object
39
	 */
40
	function getXmlDoc(&$params)
41
	{
42
		$body = XmlGenerater::generate($params);
43
		$buff = FileHandler::getRemoteResource(_XE_DOWNLOAD_SERVER_, $body, 3, "POST", "application/xml");
44
		if(!$buff)
45
		{
46
			return;
47
		}
48
49
		$xml = new XmlParser();
50
		$xmlDoc = $xml->parse($buff);
51
		return $xmlDoc;
52
	}
53
54
}
55
56
/**
57
 * High class of the autoinstall module
58
 * @author NAVER ([email protected])
59
 */
60
class autoinstall extends ModuleObject
61
{
62
63
	/**
64
	 * Temporary directory path
65
	 */
66
	var $tmp_dir = './files/cache/autoinstall/';
67
68
	/**
69
	 * Constructor
70
	 *
71
	 * @return void
72
	 */
73
	function autoinstall()
0 ignored issues
show
Coding Style Best Practice introduced by
Please use __construct() instead of a PHP4-style constructor that is named after the class.
Loading history...
74
	{
75
		$oModuleModel = getModel('module');
76
		$config = $oModuleModel->getModuleConfig('autoinstall');
77
		if($config->downloadServer != _XE_DOWNLOAD_SERVER_)
78
		{
79
			$this->stop('msg_not_match_server');
80
		}
81
	}
82
83
	/**
84
	 * For additional tasks required when installing
85
	 *
86
	 * @return Object
87
	 */
88
	function moduleInstall()
89
	{
90
		$oModuleController = getController('module');
91
92
		$config = new stdClass;
93
		$config->downloadServer = _XE_DOWNLOAD_SERVER_;
94
		$oModuleController->insertModuleConfig('autoinstall', $config);
95
	}
96
97
	/**
98
	 * Method to check if installation is succeeded
99
	 *
100
	 * @return bool
101
	 */
102
	function checkUpdate()
103
	{
104
		$oDB = DB::getInstance();
105
		$oModuleModel = getModel('module');
106
		$oModuleController = getController('module');
107
		$version_update_id = implode('.', array(__CLASS__, __XE_VERSION__, 'updated'));
108
		if($oModuleModel->needUpdate($version_update_id))
109
		{
110
			if(!FileHandler::exists('./modules/autoinstall/schemas/autoinstall_installed_packages.xml')
0 ignored issues
show
Bug Best Practice introduced by
The expression \FileHandler::exists('./...nstalled_packages.xml') of type string|false is loosely compared to false; this is ambiguous if the string can be empty. You might want to explicitly use === false instead.

In PHP, under loose comparison (like ==, or !=, or switch conditions), values of different types might be equal.

For string values, the empty string '' is a special case, in particular the following results might be unexpected:

''   == false // true
''   == null  // true
'ab' == false // false
'ab' == null  // false

// It is often better to use strict comparison
'' === false // false
'' === null  // false
Loading history...
111
				&& $oDB->isTableExists("autoinstall_installed_packages"))
112
			{
113
				return TRUE;
114
			}
115
			if(!FileHandler::exists('./modules/autoinstall/schemas/autoinstall_remote_categories.xml')
0 ignored issues
show
Bug Best Practice introduced by
The expression \FileHandler::exists('./...remote_categories.xml') of type string|false is loosely compared to false; this is ambiguous if the string can be empty. You might want to explicitly use === false instead.

In PHP, under loose comparison (like ==, or !=, or switch conditions), values of different types might be equal.

For string values, the empty string '' is a special case, in particular the following results might be unexpected:

''   == false // true
''   == null  // true
'ab' == false // false
'ab' == null  // false

// It is often better to use strict comparison
'' === false // false
'' === null  // false
Loading history...
116
				&& $oDB->isTableExists("autoinstall_remote_categories"))
117
			{
118
				return TRUE;
119
			}
120
121
			// 2011.08.08 add column 'list_order' in ai_remote_categories
122
			if(!$oDB->isColumnExists('ai_remote_categories', 'list_order'))
123
			{
124
				return TRUE;
125
			}
126
127
			// 2011.08.08 set _XE_DOWNLOAD_SERVER_ at module config
128
			$config = $oModuleModel->getModuleConfig('autoinstall');
129
			if(!isset($config->downloadServer))
130
			{
131
				return TRUE;
132
			}
133
134
			// 2012.11.12 add column 'have_instance' in autoinstall_packages
135
			if(!$oDB->isColumnExists('autoinstall_packages', 'have_instance'))
136
			{
137
				return TRUE;
138
			}
139
140
			$oModuleController->insertUpdatedLog($version_update_id);
141
		}
142
143
		return FALSE;
144
	}
145
146
	/**
147
	 * Execute update
148
	 *
149
	 * @return Object
150
	 */
151
	function moduleUpdate()
152
	{
153
		$oDB = DB::getInstance();
154
		$oModuleModel = getModel('module');
155
		$oModuleController = getController('module');
156
		$version_update_id = implode('.', array(__CLASS__, __XE_VERSION__, 'updated'));
157
		if($oModuleModel->needUpdate($version_update_id))
158
		{
159
			if(!FileHandler::exists('./modules/autoinstall/schemas/autoinstall_installed_packages.xml')
0 ignored issues
show
Bug Best Practice introduced by
The expression \FileHandler::exists('./...nstalled_packages.xml') of type string|false is loosely compared to false; this is ambiguous if the string can be empty. You might want to explicitly use === false instead.

In PHP, under loose comparison (like ==, or !=, or switch conditions), values of different types might be equal.

For string values, the empty string '' is a special case, in particular the following results might be unexpected:

''   == false // true
''   == null  // true
'ab' == false // false
'ab' == null  // false

// It is often better to use strict comparison
'' === false // false
'' === null  // false
Loading history...
160
				&& $oDB->isTableExists("autoinstall_installed_packages"))
161
			{
162
				$oDB->dropTable("autoinstall_installed_packages");
163
			}
164
			if(!FileHandler::exists('./modules/autoinstall/schemas/autoinstall_remote_categories.xml')
0 ignored issues
show
Bug Best Practice introduced by
The expression \FileHandler::exists('./...remote_categories.xml') of type string|false is loosely compared to false; this is ambiguous if the string can be empty. You might want to explicitly use === false instead.

In PHP, under loose comparison (like ==, or !=, or switch conditions), values of different types might be equal.

For string values, the empty string '' is a special case, in particular the following results might be unexpected:

''   == false // true
''   == null  // true
'ab' == false // false
'ab' == null  // false

// It is often better to use strict comparison
'' === false // false
'' === null  // false
Loading history...
165
				&& $oDB->isTableExists("autoinstall_remote_categories"))
166
			{
167
				$oDB->dropTable("autoinstall_remote_categories");
168
			}
169
170
			// 2011.08.08 add column 'list_order' in 'ai_remote_categories
171
			if(!$oDB->isColumnExists('ai_remote_categories', 'list_order'))
172
			{
173
				$oDB->addColumn('ai_remote_categories', 'list_order', 'number', 11, NULL, TRUE);
174
				$oDB->addIndex('ai_remote_categories', 'idx_list_order', array('list_order'));
175
			}
176
177
			// 2011. 08. 08 set _XE_DOWNLOAD_SERVER_ at module config
178
			$config = $oModuleModel->getModuleConfig('autoinstall');
179
			if(!isset($config->downloadServer))
180
			{
181
				$config->downloadServer = _XE_DOWNLOAD_SERVER_;
182
				$oModuleController->insertModuleConfig('autoinstall', $config);
183
			}
184
185
			// 2012.11.12 add column 'have_instance' in autoinstall_packages
186
			if(!$oDB->isColumnExists('autoinstall_packages', 'have_instance'))
187
			{
188
				$oDB->addColumn('autoinstall_packages', 'have_instance', 'char', '1', 'N', TRUE);
189
			}
190
191
			$oModuleController->insertUpdatedLog($version_update_id);
192
		}
193
194
		return new Object(0, 'success_updated');
195
	}
196
197
	/**
198
	 * Re-generate the cache file
199
	 * @return Object
200
	 */
201
	function recompileCache()
202
	{
203
		
204
	}
205
206
}
207
/* End of file autoinstall.class.php */
208
/* Location: ./modules/autoinstall/autoinstall.class.php */
209