18 require_once SQ_PACKAGES_PATH.
'/squiz_suite/systems/squiz_suite_system/squiz_suite_system.inc';
43 $this->_ser_attrs = TRUE;
44 parent::__construct($assetid);
61 $fb = $GLOBALS[
'SQ_SYSTEM']->am->getSystemAsset(
'funnelback_manager');
62 $suite = $GLOBALS[
'SQ_SYSTEM']->am->getSystemAsset(
'suite_manager');
63 $info = $suite->getCurrentProduct();
64 $systemid = array_get_index($info,
'systemid', NULL);
65 if ($systemid === NULL) {
70 $urls = array_unique($urls);
71 $excludes = array_unique($excludes);
73 foreach ($urls as $single_url) {
74 $protocol = parse_url($single_url, PHP_URL_SCHEME);
75 $real_url = str_replace($protocol.
'://',
'', $single_url);
77 $asset = $GLOBALS[
'SQ_SYSTEM']->am->getAssetFromURL($protocol, $real_url, TRUE, TRUE);
80 if (is_null($asset))
continue;
83 $collected_xmls = $fb->getXMLCache(Array($single_url), $asset->id, FALSE, $excludes);
85 foreach ($collected_xmls as $collect_xml) {
86 $content = array_get_index($collect_xml,
'xml',
'');
87 if (empty($content))
continue;
94 $xml = array_unique($xml);
97 foreach ($xml as $index => $piece) {
98 if ($systemid !== NULL) {
100 preg_match(
'/<fbmeta name="access_locks" content="(.*?)" \/>/i', $piece, $matches);
102 if (isset($matches[1])) {
103 preg_match_all(
'/\'(.*?)(\'\,|\'$)/i', $matches[1], $userid_matches);
104 if (isset($userid_matches[1])) {
105 $userids = $userid_matches[1];
106 $real_userids = array();
107 foreach ($userids as $userid) {
108 if ($userid ==
'public') {
109 $real_userids[] =
"'public'";
111 $real_userids[] =
"'".$systemid.
'://'.$userid.
"'";
115 $real_userids_string = implode(
',', $real_userids);
118 $pattern =
'/<fbmeta name="access_locks" content="(.*?)" \/>/i';
119 $replace =
'<fbmeta name="access_locks" content="'.$real_userids_string.
'" />';
120 $piece = preg_replace($pattern, $replace, $piece);
125 $xml[$index] = preg_replace(
'/<url>(.*?)<\/url>/i',
'<url>\\1<fbmeta name="SQUIZPRODUCTID" content="'.$systemid.
'" /></url>', $piece);
132 throw new Exception(
'Error: No urls found');
148 $protocol = parse_url($url, PHP_URL_SCHEME);
149 $base_url = str_replace($protocol.
'://',
'', $url);
150 $suite = $GLOBALS[
'SQ_SYSTEM']->am->getSystemAsset(
'suite_manager');
151 $asset = $GLOBALS[
'SQ_SYSTEM']->am->getAssetFromUrl($protocol, $base_url);
152 $root_url = $GLOBALS[
'SQ_SYSTEM']->am->getRootURL($base_url);
155 $context_changed = FALSE;
156 if (isset($root_url[
'base_contextid']) && $root_url[
'base_contextid'] !=
'0') {
157 $GLOBALS[
'SQ_SYSTEM']->changeContext($root_url[
'base_contextid']);
158 $context_changed = TRUE;
162 $old_server_host = $_SERVER[
'HTTP_HOST'];
163 $old_server_self = $_SERVER[
'PHP_SELF'];
164 $_SERVER[
'HTTP_HOST'] = parse_url($url, PHP_URL_HOST);
165 $_SERVER[
'PHP_SELF'] = parse_url($url, PHP_URL_PATH);
167 if ($asset->id !== $suite->id) {
168 if ($asset instanceof
File) {
170 $existing = $asset->getExistingFile();
171 $mime =
'text/plain';
172 $filename = $asset->attr(
'title');
173 if (!empty($existing)) {
174 require_once SQ_FUDGE_PATH.
'/standards_lists/mime_types.inc';
175 require_once SQ_FUDGE_PATH.
'/general/file_system.inc';
177 $ext = get_file_type($existing[
'filename']);
178 if (($asset->status & SQ_SC_STATUS_SAFE_EDITING) && ($GLOBALS[
'SQ_SYSTEM']->user instanceof
Public_User)) {
180 $ext = preg_replace(
'/,ffv\d+$/',
'', $ext);
181 $existing[
'filename'] = preg_replace(
'/,ffv\d+$/',
'', $existing[
'filename']);
183 $mime = (empty($standards_lists_mime_types[$ext])) ?
'text/plain' : $standards_lists_mime_types[$ext];
184 $filename = $existing[
'filename'];
185 readfile($existing[
'path']);
187 $contents = ob_get_contents();
190 if (!empty($contents)) {
192 '_base64' => chunk_split(base64_encode($contents)),
194 'filename' => $filename,
197 $response = $contents;
201 $asset->printFrontend();
202 $response = ob_get_contents();
207 if ($context_changed) $GLOBALS[
'SQ_SYSTEM']->restoreContext();
209 $_SERVER[
'HTTP_HOST'] = $old_server_host;
210 $_SERVER[
'PHP_SELF'] = $old_server_self;
214 throw new Exception(
'Error: No urls found');
230 foreach ($urls as $real_url) {
231 $am = $GLOBALS[
'SQ_SYSTEM']->am;
233 $url_parts = parse_url($real_url);
234 $protocol = array_get_index($url_parts,
'scheme',
'');
235 if (empty($protocol) === FALSE) {
236 $url = str_replace($protocol.
'://',
'', $real_url);
238 $asset = $am->getAssetFromUrl($protocol, $url, TRUE, TRUE);
239 if ($asset !== NULL) {
240 $type = $asset->type();
241 $iconPath = $am->getAssetIconURL($type);
243 $info[$real_url] = array(
244 'assetid' => $asset->id,
245 'name' => $asset->attr(
'name'),
248 $am->forgetAsset($asset, TRUE);
251 $info[$real_url] = NULL;
273 if (!is_array($urls)) $urls = Array($urls);
275 $am = $GLOBALS[
'SQ_SYSTEM']->am;
276 $mm = $GLOBALS[
'SQ_SYSTEM']->getMetadataManager();
277 $fm = $GLOBALS[
'SQ_SYSTEM']->am->getSystemAsset(
'funnelback_manager', TRUE);
279 foreach ($urls as $real_url) {
281 $url_parts = parse_url($real_url);
282 $protocol = array_get_index($url_parts,
'scheme',
'');
283 if (empty($protocol) === FALSE) {
284 $url = str_replace($protocol.
'://',
'', $real_url);
287 $asset = $am->getAssetFromUrl($protocol, $url, TRUE, TRUE);
288 if ($asset !== NULL && strpos($url,
'__data') !== FALSE) {
291 $metadata = $mm->getMetadata($asset->id);
292 foreach ($metadata as $meta) {
293 $name = $meta[0][
'name'];
295 $value = $meta[0][
'value'];
296 require_once SQ_FUDGE_PATH.
'/general/text.inc';
297 $keywords = retrieve_keywords_replacements($value);
298 $replacements = Array();
299 foreach ($keywords as $keyword) {
300 $replacements[$keyword] = $asset->getKeywordReplacement($keyword);
302 replace_keywords($value, $replacements);
303 $name = $fm->encodeText(htmlspecialchars($name, ENT_COMPAT, SQ_CONF_DEFAULT_CHARACTER_SET));
304 $value = $fm->encodeText(htmlspecialchars($value, ENT_COMPAT, SQ_CONF_DEFAULT_CHARACTER_SET));
305 $info[$real_url][
'metadata'][$name] = $value;
309 $info[$real_url][
'security_locks'] = $fm->getAccessLocks($asset);
311 $info[$real_url][
'SQUIZASSETYPE'] = $asset->type();
312 $info[$real_url][
'last_modified'] = date(
'Y-m-d', $asset->updated).
'T'.date(
'H:i:s', $asset->updated);
315 $info[$real_url][
'file_title'] = $asset->attr(
'title');
316 $info[$real_url][
'file_name'] = $asset->name;
317 if ($asset->created_userid != 0) {
318 $created_by = $GLOBALS[
'SQ_SYSTEM']->am->getAsset($asset->created_userid);
319 $info[$real_url][
'author_name'] = $created_by->name;
320 $info[$real_url][
'author_id'] = $created_by->id;
322 $info[$real_url][
'created'] = date(
'Y-m-d', $asset->created).
'T'.date(
'H:i:s', $asset->created);
325 $am->forgetAsset($asset, TRUE);
328 $info[$real_url] = NULL;
332 return json_encode($info);
348 $am = $GLOBALS[
'SQ_SYSTEM']->am;
350 $status = SQ_STATUS_UNDER_CONSTRUCTION;
351 if ($set_to !=
'activate' && $set_to !=
'deactivate') {
352 return Array(
'success' => FALSE);
354 if ($set_to ==
'activate') $status = SQ_STATUS_LIVE;
359 if (empty($userid))
return Array(
'success' => FALSE);
360 if (!$am->assetExists($userid))
return Array(
'success' => FALSE);
364 $fm = $GLOBALS[
'SQ_SYSTEM']->am->getSystemAsset(
'funnelback_manager', TRUE);
365 if ($fm->attr(
'user') != $userid)
return Array(
'success' => FALSE);
368 $fb_user = $am->getAsset($userid);
369 if ($fb_user->status === $status)
return Array(
'success' => TRUE);
373 require_once SQ_SYSTEM_ROOT.
'/core/hipo/jobs/hipo_job_edit_status.inc';
375 $running_vars = Array(
376 'assetid' => $fb_user->id,
377 'new_status' => $status,
378 'dependants_only' => 0,
381 $init_hipo->setRunningVars($running_vars);
382 $init_hipo->_steps = $init_hipo->getInitialStepData();
383 if (!$init_hipo->prepare()) {
384 error_log(
'Could not initialise HIPO job');
385 return Array(
'success' => FALSE);
387 $init_hipo->freestyle();
389 $errors = $init_hipo->getErrors();
390 if(!empty($errors)) {
392 return Array(
'success' => FALSE);
395 return Array(
'success' => TRUE);
413 if (empty($username))
return FALSE;
418 $auth_folder = $GLOBALS[
'SQ_SYSTEM']->am->getSystemAsset(
'authentication_folder');
419 if (is_null($auth_folder)) {
420 trigger_localised_error(
'SYS0249', E_USER_ERROR);
424 $auth_systems = $auth_folder->getAuthSystems();
425 foreach ($auth_systems as $systemid) {
426 $system = $GLOBALS[
'SQ_SYSTEM']->am->getAsset($systemid);
427 if (is_null($system))
continue;
429 if (empty($password)) {
430 $user = $system->locateUser($username);
433 $user = $system->authenticateUser($username, $password);
436 if (!is_null($user)) {
444 if ($return_keys && $res) {
445 $res = array_merge(Array($user->id), $user->getUserGroups());