18 require_once SQ_CORE_PACKAGE_PATH.
'/folder/folder.inc';
76 SQ_LINK_TYPE_1 => Array(
82 SQ_LINK_TYPE_2 => Array(
88 SQ_LINK_NOTICE => Array(
113 $result = parent::canCreateLink($minor, $link_type, $exclusive);
114 if ($result !== TRUE)
return $result;
116 if (($minor instanceof
Site) && ($link_type != SQ_LINK_NOTICE)) {
118 $network_link = $GLOBALS[
'SQ_SYSTEM']->am->getLinks($minor->id, SQ_SC_LINK_SIGNIFICANT,
'site_network', FALSE,
'minor');
119 if (!empty($network_link)) {
120 return translate(
'core_one_network_for_site');
144 if (($minor instanceof
Site) && ($old_major instanceof
Site_Network) && ($link_type != SQ_LINK_NOTICE)) {
147 $network_link = $GLOBALS[
'SQ_SYSTEM']->am->getLinks($minor->id, SQ_SC_LINK_SIGNIFICANT,
'site_network', FALSE,
'minor');
148 if (count($network_link) > 1) {
149 return translate(
'core_one_network_for_site');
153 return parent::canMoveLink($minor, $old_major, $link_type);
169 if (!isset($this->_tmp[
'primary_url'])) {
170 $site_link = $GLOBALS[
'SQ_SYSTEM']->am->getLink($this->
id, SQ_LINK_NOTICE,
'site', FALSE,
'primary_site');
171 if (empty($site_link))
return '';
174 $bind_vars = Array(
'assetid'=> $site_link[
'minorid']);
177 throw new Exception(
'Unable to get primary URL due to database error: '.$e->getMessage());
180 if (empty($primary_url_data))
return '';
181 $primary_url = $primary_url_data[0][
'url'];
183 if ($primary_url_data[0][
'https'] ==
'1') {
184 $primary_url =
'https://'.$primary_url;
186 $primary_url =
'http://'.$primary_url;
189 $primary_url = sq_root_url($primary_url);
190 $this->_tmp[
'primary_url'] = $primary_url;
193 return $this->_tmp[
'primary_url'];
211 $session_str = file_get_contents($session_file);
213 $parts = preg_split(
'/\w+\|/', $session_str, -1, PREG_SPLIT_OFFSET_CAPTURE);
214 $session_arr = Array();
216 for ($i = 0; $i < count($parts); $i++) {
217 if ($i == count($parts) - 1)
continue;
218 $offset = $parts[$i][1] + strlen($parts[$i][0]);
219 $len = $parts[$i + 1][1] - 1 - $offset;
221 $key = substr($session_str, $offset, $len);
222 $session_arr[$key] = unserialize($parts[$i + 1][0]);
240 require_once SQ_FUDGE_PATH.
'/general/file_system.inc';
242 if (!file_exists($session_file)) {
243 trigger_localised_error(
'CORE0072', E_USER_WARNING, $session_file);
247 if (!is_array($session_contents)) {
248 trigger_localised_error(
'CORE0004', E_USER_WARNING, gettype($session_contents));
253 foreach ($session_contents as $key => $val) {
254 $session_str .= $key.
'|'.serialize($val);
257 if (!string_to_file($session_str, $session_file)) {
258 trigger_localised_error(
'CORE0021', E_USER_WARNING, $session_file);
282 if (!is_array($pri_sess)) {
284 trigger_localised_error(
'CORE0071', E_USER_ERROR);
288 $pri_timestamp = array_get_index($pri_sess,
'SQ_SESSION_TIMESTAMP', -1);
289 $sec_timestamp = array_get_index($_SESSION,
'SQ_SESSION_TIMESTAMP', -1);
290 $pri_login_key = array_get_index($pri_sess,
'SQ_LOGIN_KEY', NULL);
291 $sec_login_key = array_get_index($_SESSION,
'SQ_LOGIN_KEY', NULL);
294 if ($pri_timestamp > $sec_timestamp || $pri_timestamp == -1) {
296 $_SESSION = $pri_sess;
299 $pri_sess = $_SESSION;
303 $pri_sess[
'SQ_SESSION_TIMESTAMP'] = $now;
304 $_SESSION[
'SQ_SESSION_TIMESTAMP'] = $now;
307 if (!is_null($pri_login_key)) {
308 $pri_sess[
'SQ_LOGIN_KEY'] = $pri_login_key;
310 if (!is_null($sec_login_key)) {
311 $_SESSION[
'SQ_LOGIN_KEY'] = $sec_login_key;
317 $_SESSION[
'PRIMARY_SESSIONID'] = $pri_sessionid;
318 $pri_sess[
'PRIMARY_SESSIONID'] = $pri_sessionid;
322 trigger_localised_error(
'CORE0020', E_USER_ERROR);