5 require_once(
'base/functions.php');
37 private $_param = array();
38 private $_metaUrlIsCached =
false;
39 private $_metaUrl = array();
42 private $_classes = array();
53 public $importFlag =
false;
55 public $conf = array();
57 private $virtualHosts = array();
59 private static $confs = array();
68 public function __call($function, $params) {
69 if (strpos($function,
'__') !== 0) {
70 $magic_file = $GLOBALS[
'egotec_conf'][
'lib_dir'].
'base/'.get_class($this).
'.'.$function.
'.php';
71 if (file_exists($magic_file)) {
72 require_once($magic_file);
73 return call_user_func($function, $this, $params);
75 throw new Exception(
"Method 'Site.$function' not found");
85 private function _loadConfig() {
86 if ($this->pageTable && isset(self::$confs[$this->pageTable])) {
87 $this->conf = self::$confs[$this->pageTable];
90 $this->globalAllowed() ? $GLOBALS[
'egotec_conf'][
'site_dir'] .
'_global/admin/conf.json' :
'',
91 $GLOBALS[
'egotec_conf'][
'site_dir'] . $this->name .
'/admin/conf.json' 93 $this->conf = array();
94 foreach ($confs as $conf) {
96 $this->conf =
Ego_System::getJSON($conf, $this->conf,
true, [
'plugins',
'toolbar',
'menubar']);
100 if (empty($this->conf[
'site'])) {
103 $this->conf[
'site'] = parse_ini_file($GLOBALS[
'egotec_conf'][
'site_dir'] . $this->name .
'/conf.ini',
true);
109 if (empty($this->conf[
'admin'])) {
112 $this->conf[
'admin'] = parse_ini_file($GLOBALS[
'egotec_conf'][
'site_dir'] . $this->name .
'/admin/conf.ini',
true);
119 if (!empty($this->conf[
'site'][
'theme'])) {
120 $theme_paths = array(
121 $GLOBALS[
'egotec_conf'][
'pub_dir'] .
'theme/' . $this->conf[
'site'][
'theme'] .
'/site/admin/conf.json',
122 $this->globalAllowed() ? $GLOBALS[
'egotec_conf'][
'site_dir'] .
'_global/admin/' . $this->conf[
'site'][
'theme'] .
'.json' :
'' 124 foreach ($theme_paths as $theme_path) {
127 foreach (array(
'panel',
'navigation',
'layouts',
'page') as $key) {
128 if (!empty($theme_conf[$key])) {
129 if (empty($this->conf[$key])) {
130 $this->conf[$key] = array();
132 $this->conf[$key] = array_replace_recursive($theme_conf[$key], $this->conf[$key]);
140 if (!$this->language) {
141 $this->language = $this->conf[
'site'][
'default_language'];
142 $this->pageTable = $this->name.
'_'.$this->language;
146 $this->conf[
'site'][
'robots'] = $this->conf[
'site'][
'robots_' . $this->language] ?
147 $this->conf[
'site'][
'robots_' . $this->language] : ($this->conf[
'site'][
'robots_' . $this->conf[
'site'][
'default_language']] ?
148 $this->conf[
'site'][
'robots_' . $this->conf[
'site'][
'default_language']] :
149 $this->conf[
'site'][
'robots']);
150 $this->conf[
'site'][
'keywords'] = $this->conf[
'site'][
'keywords_' . $this->language] ?
151 $this->conf[
'site'][
'keywords_' . $this->language] : ($this->conf[
'site'][
'keywords_' . $this->conf[
'site'][
'default_language']] ?
152 $this->conf[
'site'][
'keywords_' . $this->conf[
'site'][
'default_language']] :
153 $this->conf[
'site'][
'keywords']);
154 $this->conf[
'site'][
'description'] = $this->conf[
'site'][
'description_' . $this->language] ?
155 $this->conf[
'site'][
'description_' . $this->language] : ($this->conf[
'site'][
'description_' . $this->conf[
'site'][
'default_language']] ?
156 $this->conf[
'site'][
'description_' . $this->conf[
'site'][
'default_language']] :
157 $this->conf[
'site'][
'description']);
160 if ($this->conf[
'site'][
'type'] ==
'media') {
161 $this->conf[
'admin'][
'enabled_types'][
'multimedia'] = 1;
162 $this->conf[
'admin'][
'enabled_types'][
'multimedia/image'] = 1;
163 $this->conf[
'admin'][
'enabled_types'][
'multimedia/file'] = 1;
164 $this->conf[
'admin'][
'enabled_types'][
'multimedia/category'] = 1;
168 if (!empty($this->conf[
'site'][
'title_' . $this->language])) {
169 $this->conf[
'site'][
'title'] = $this->conf[
'site'][
'title_' . $this->language];
170 } elseif (!empty($this->conf[
'site'][
'title_' . $this->conf[
'site'][
'default_language']])) {
171 $this->conf[
'site'][
'title'] = $this->conf[
'site'][
'title_' . $this->conf[
'site'][
'default_language']];
172 } elseif (empty($this->conf[
'site'][
'title'])) {
174 $this->conf[
'site'][
'title'] = $this->name;
180 self::$confs[$this->pageTable] = &$this->conf;
184 $this->site = &$this->conf[
'site'];
185 $this->admin = &$this->conf[
'admin'];
197 if ($new_site[
'type']==
'media')
199 Ego_System::mkdir($GLOBALS[
'egotec_conf'][
'var_dir'].
'media/'.$new_site[
'name']);
201 if (!empty($new_site[
'default_skin'])) {
202 $skin_dir = $GLOBALS[
'egotec_conf'][
'skin_dir'].$new_site[
'default_skin'];
209 copy($GLOBALS[
'egotec_conf'][
'lib_dir'].
'template/site/conf.ini', $GLOBALS[
'egotec_conf'][
'site_dir'].$new_site[
'name'].
'/conf.ini');
210 Ego_System::mkdir($GLOBALS[
'egotec_conf'][
'site_dir'].$new_site[
'name'].
'/admin');
211 copy($GLOBALS[
'egotec_conf'][
'lib_dir'].
'template/site/admin/conf.ini', $GLOBALS[
'egotec_conf'][
'site_dir'].$new_site[
'name'].
'/admin/conf.ini');
213 $newSite =
new Site($new_site[
'name']);
215 if ($new_site[
'lang'])
217 $new_site[
'default_language'] = $new_site[
'lang'];
218 $new_site[
'languages'] = $new_site[
'lang'];
222 if ($new_site[
'title'] && $new_site[
'default_language']) {
223 $new_site[
'title_' . $new_site[
'default_language']] = $new_site[
'title'];
224 unset($new_site[
'title']);
227 $rights = $new_site[
'rights'];
228 unset($new_site[
'name'], $new_site[
'lang'], $new_site[
'rights']);
229 $newSite->save($new_site);
230 $newSite->createTables();
231 require_once(
'base/Ego_Search_Factory.php');
234 $date = date(
'Y-m-d H:i:s');
237 'name' =>
'Homepage',
238 'title' =>
'Homepage',
241 'content' =>
'This is the Homepage of a new site.',
242 'extra' => serialize(array()),
245 'a_user' => $GLOBALS[
'auth']->getId(),
246 'c_user' => $GLOBALS[
'auth']->getId(),
247 'type' => $new_site[
'type']==
'media'?
'multimedia/category':
'page',
248 'children_order' =>
'type',
253 'release_from' =>
'0000-00-00 00:00:00',
254 'release_until' =>
'0000-00-00 00:00:00',
256 'workflow_state' => 0,
259 $db = new_db_connection();
261 $no_null_rights = explode(
',', $no_null_rights);
262 $insert_rights = array(
269 foreach ($newSite->getLanguages() as $lang)
271 $db->insert(array(
'table' => $newSite->name.
'_'.$lang,
'set' => $field));
272 $insert_rights[
'table'] = $newSite->name.
'_'.$lang.
'_rights';
273 foreach ($no_null_rights as $no_null_right)
275 if ($no_null_right !=
'live') {
276 $insert_rights[
'set'][
'perm'] = $no_null_right;
277 $db->insert($insert_rights);
283 if($newSite->site[
'type'] ==
"media")
285 $newSite->save_admin(array(
286 'enabled_types' => array(
288 'multimedia/image' => 1,
289 'multimedia/file' => 1,
290 'multimedia/category' => 1
293 } elseif ($newSite->site[
'type'] ==
"external") {
294 $newSite->save_admin(array(
295 'enabled_types' => array(
300 $newSite->save_admin(array(
301 'enabled_types' => array(
308 $default_group = is_array($rights) && $rights[
'group'] ? $rights[
'group'] : $GLOBALS[
'egotec_conf'][
'superuser'][
'group'];
309 $default_role = is_array($rights) && $rights[
'role'] ? $rights[
'role'] : $GLOBALS[
'egotec_conf'][
'superuser'][
'role'];
311 $right = $newSite->site[
'right'];
312 $right[
'admin_group_0'] = $default_group;
313 $right[
'admin_role_0'] = $default_role;
315 $right[
'translate_group_0'] = $default_group;
316 $right[
'translate_role_0'] = $default_role;
318 $right[
'view_group_0'] = $default_group;
319 $right[
'view_role_0'] = $default_role;
321 $right[
'linkto_group_0'] = $default_group;
322 $right[
'linkto_role_0'] = $default_role;
324 $right[
'addclone_group_0'] = $default_group;
325 $right[
'addclone_role_0'] = $default_role;
327 $right[
'newclone_group_0'] = $default_group;
328 $right[
'newclone_role_0'] = $default_role;
330 $right[
'trashcan_group_0'] = $default_group;
331 $right[
'trashcan_role_0'] = $default_role;
333 $right[
'stats_group_0'] = $default_group;
334 $right[
'stats_role_0'] = $default_role;
336 $right[
'liveserver_group_0'] = $default_group;
337 $right[
'liveserver_role_0'] = $default_role;
339 $right[
'site_group_0'] = $default_group;
340 $right[
'site_role_0'] = $default_role;
342 $right[
'skin_group_0'] = $default_group;
343 $right[
'skin_role_0'] = $default_role;
345 $right[
'change_type_group_0'] = $default_group;
346 $right[
'change_type_role_0'] = $default_role;
348 $right[
'linkchecker_group_0'] = $default_group;
349 $right[
'linkchecker_role_0'] = $default_role;
351 $right[
'nousechecker_group_0'] = $default_group;
352 $right[
'nousechecker_role_0'] = $default_role;
354 $right[
'barriercheck_group_0'] = $default_group;
355 $right[
'barriercheck_role_0'] = $default_role;
357 $newSite->save_admin(array(
362 self::$confs[$newSite->pageTable];
363 $newSite =
new Site($newSite->name);
366 if ($newSite->getSkinFile(
'layout.tpl') || $newSite->getSkinFile(
'layout.html')) {
367 $newSite->save_admin(array(
368 'frontend_admin' => 1
413 function __construct($site_name=
'', $language=
'', $skin=
'', $only_active=
true, $time=
'')
415 $this->_onlyActive = $only_active;
416 if ($_REQUEST[
'preview'] && $GLOBALS[
'auth'] && !$GLOBALS[
'auth']->isNobody()) {
417 $this->_onlyActive =
false;
420 $site_name = str_replace(
'/',
'', $site_name);
421 if (!file_exists($GLOBALS[
'egotec_conf'][
'site_dir'].$site_name))
427 $this->_isDefault =
true;
429 $site_name = $GLOBALS[
'egotec_conf'][
'default_site'];
431 $this->name = $site_name;
432 $this->_loadConfig();
433 if ($skin && in_array($skin, $this->getSkins()))
437 $this->skin = $this->site[
'default_skin'];
439 $this->theme = (string) $this->site[
'theme'];
440 $this->setLanguage($language);
441 if ($GLOBALS[
'virtual_host_site'] && $GLOBALS[
'virtual_host_lang'] && $GLOBALS[
'virtual_host_site']==$this->name)
443 $this->site[
'default_language'] = $GLOBALS[
'virtual_host_lang'];
445 $this->setTime($time);
451 !$this->hasMediaSite()
452 && !$this->admin[
'mediapool'][
'active']
454 $this->save_admin(array(
455 'mediapool' => array(
469 $this->_onlyActive = $b;
486 $this->_time = $time;
488 $expire_time = $this->_cache->getExpire();
489 $this->_time = date(
'Y-m-d H:i:s', (
int)($expire_time ? $expire_time : time()));
502 $this->virtualHosts = array();
506 $language = $this->site[
'default_language'];
508 if (in_array($language, $this->getLanguages()))
510 $new_page_table = $this->name.
'_'.$language;
511 if ($this->_param[
'auth_or'])
513 $this->_param[
'auth_or'] = str_replace($this->pageTable, $new_page_table, $this->_param[
'auth_or']);
515 if ($this->_param[
'deleted_or'])
517 $this->_param[
'deleted_or'] = str_replace($this->pageTable, $new_page_table, $this->_param[
'deleted_or']);
519 $this->language = $language;
520 $this->pageTable = $new_page_table;
522 $this->language = $this->site[
'default_language'];
523 $this->pageTable = $this->name.
'_'.$this->site[
'default_language'];
528 $path = $this->name.
'/'.$this->language.
'/';
531 $this->_cache->setPath($this->name.
'/'.$this->language.
'/');
534 if (empty($GLOBALS[
"egotec_conf"][
"cachemedia_dir"])) {
535 $GLOBALS[
"egotec_conf"][
"cachemedia_dir"] = $GLOBALS[
"egotec_conf"][
"var_dir"].
"cachemedia/";
538 switch ($GLOBALS[
'egotec_conf'][
'site_cache_type'])
541 require_once(
'base/Ego_Cache_apc.php');
542 $this->_cache =
new Ego_Cache_apc($path);
545 require_once(
'base/Ego_Cache_apcu.php');
546 $this->_cache =
new Ego_Cache_apcu($path);
549 require_once(
'base/Ego_Cache_shm.php');
550 $this->_cache =
new Ego_Cache_shm($path);
553 require_once(
'base/Ego_Cache_file.php');
554 $this->_cache =
new Ego_Cache_file($path);
557 if ($this->_cache->isExpired()) {
560 $this->_loadConfig();
570 $this->_rights = array_unique($rights);
571 $this->setParam(array(
'rights' => $this->_rights));
583 $this->_param = array_merge($this->_param, $param);
585 $this->_param = $param;
596 $this->_param = $param;
604 return md5(serialize($this->_param));
614 if (!$this->_languages) {
615 $this->_languages = explode(
',', $this->site[
'languages']);
617 return $this->_languages;
627 $skins = explode(
',', $this->site[
'skins']);
630 if (!in_array($this->site[
'default_skin'], $skins)) {
631 $skins[] = $this->site[
'default_skin'];
635 if ($theme && !empty($this->theme)) {
636 $skins[] = $this->theme;
639 return array_filter($skins);
651 $name = addslashes($name);
653 $id_file = $GLOBALS[
'egotec_conf'][
'cache_dir'].$this->name.
'/_id/'.$name;
654 if (file_exists($id_file))
656 $page_id = file_get_contents($id_file);
659 $db = new_db_connection(array(
661 'table' => $this->pageTable,
662 'where' =>
'url like :name',
663 'bind' => array(
'name' => $name)
665 if ($db->nextRecord())
667 $page_id = $db->Record[
'id'];
672 'table' => $this->pageTable,
673 'where' =>
'name like :name',
674 'bind' => array(
'name' => $name),
678 if ($db->nextRecord())
680 $page_id = $db->Record[
'id'];
685 if (isset($param[
'internal']))
695 'table' => $this->pageTable,
696 'where' =>
"type='search' or type='search_plus'",
697 'order' =>
'type,id asc',
700 if ($db->nextRecord())
702 $page_id = $db->Record[
'id'];
703 $_REQUEST[
'search_string'] = $name;
704 $_REQUEST[
'to_search'] =
'name,title,short,content,data';
705 $_REQUEST[
'search'] = 1;
710 $page_id = $this->rootId;
721 return $this->_onlyActive;
766 function getPages($query=array(), $param = array())
768 if (is_array($param))
770 $param = array_merge($this->_param, $param);
772 $param = $this->_param;
776 $param[
'lang'] = $this->language;
781 $site->setLanguage($param[
'lang']);
788 $page_table = $site->name.
'_'.$param[
'lang'];
790 if (is_string($query)||is_bool($query))
792 egotec_error_log(
'$query wurde als String übergeben Query: '.$query);
793 eval (
"\$query = $query;");
795 if (trim($query[
'where']))
797 $query[
'where'] =
'('.$query[
'where'].
')';
800 $query[
'where'] =
'1=1';
802 if (($site->getOnlyActive() && !$param[
'inactive']) || $param[
'only_active'])
804 $query[
'where'] = $query[
'where'].
" 807 $query[
'where'] = $query[
'where'].
" 808 and (release_until='0000-00-00 00:00:00' or release_until >= '".$site->getTime().
"') 809 and (release_from='0000-00-00 00:00:00' or release_from < '".$site->getTime().
"') 811 } elseif (($_REQUEST[
'preview'] || $GLOBALS[
'frontend_admin']) && empty($param[
'expired'])) {
813 $query[
'where'] = $query[
'where'].
" 814 and (release_until='0000-00-00 00:00:00' or release_until >= '".$site->getTime().
"') 819 $bitand_query = $this->getBitandQuery($param);
820 $query[
'bitand'] = $bitand_query;
822 if ((integer)$param[
'deleted']>=0)
824 $query[
'where'] = $query[
'where'].
' AND (deleted='.
825 (integer)$param[
'deleted'].($param[
'deleted_or']?
' OR '.$param[
'deleted_or']:
'').
')';
827 $query[
'table'] = ($query[
'table']?$query[
'table'].
',':
'').$page_table;
828 if (!isset($param[
'rights']))
830 $param[
'rights'] = array(
'view');
832 if (!isset($query[
'fields']))
834 $query[
'fields'] = $page_table.
'.*';
838 $query[
'where'] = ($query[
'where']?$query[
'where'].
' AND ':
'').
'('.$param[
'where'].
')';
840 if ($param[
'auth_or']!=
'1=1')
842 $query = $GLOBALS[
'auth']->getPageTableQuery($page_table, $param[
'rights'], $query, $param);
844 if ($param[
'fulltext'] || $param[
'extra'] || $param[
'filter'])
846 require_once(
'base/Ego_Search_Factory.php');
849 if ($param[
'extra']) {
851 if (isset($param[
'extra_bind'])) {
853 $param[
'extra-bind'] = $param[
'extra_bind'];
855 $search->setExtraQuery($param[
'extra'], (array) $param[
'extra-bind']);
858 if ($query[
'where'] && preg_match(
'/\W'.$this->pageTable.
'\.id in \(([0-9, ]+)\)/i', $query[
'where'], $matches)) {
859 $query[
'id_list'] = array_map(
'trim', explode(
',', $matches[1]));
862 if ($GLOBALS[
'egotec_conf'][
'search_engine'] ==
'sql') {
863 $query = $search->search((
string) $param[
'fulltext'], $site->pageTable.
'.id', $query,
true);
864 } elseif ($GLOBALS[
'egotec_conf'][
'search_engine'] ==
'lucene' || $GLOBALS[
'egotec_conf'][
'search_engine'] ==
'elastic') {
865 $query = $search->search((
string) $param[
'fulltext'], $site->pageTable.
'.id', $query, $param[
'filter'], (
bool) $param[
'fuzzy']);
867 $query = $search->search((
string) $param[
'fulltext'], $site->pageTable.
'.id', $query);
869 $query[
'distinct'] =
true;
871 if ($param[
'without_types'])
873 $query[
'where'].=
' AND type NOT IN (\''.str_replace(
",",
"','",$param[
'without_types']).
'\')
'; 875 if ($param['search_keywords
']) 877 if ($site->admin['keywords
']['site
']) 879 $keywords_tbl = $site->admin['keywords
']['site
'].'_
'.$site->language; 882 $keywords_tbl = $site->pageTable; 885 $search = new Ego_Search_Sql($keywords_tbl, '_keywords
'); 886 $query = $search->search( 887 $param['search_keywords
'], 888 $site->pageTable.'.id
', 894 $site->name.'_keywords_rel.page_id
', 895 ',
'.$site->name.'_keywords_rel
', 896 $site->name.'_keywords_rel.keyword_id=
'.$keywords_tbl.'_keywords.id
', 897 'SELECT SUM(page_id/page_id) FROM
'.$keywords_tbl.'_keywords,
'.$site->name.'_keywords_rel WHERE
'. 898 $site->name.'_keywords_rel.keyword_id=
'.$keywords_tbl.'_keywords.id
', 901 $query['distinct
'] = true; 906 foreach ($query['andor
'] as $ors) 908 $and[] = '(
'.join(') OR (
', $ors).')
'; 910 $query['where
'].= "\n AND (".join(") AND (", $and).')
'; 911 unset($query['andor
']); 915 $query['where
'].= "\n AND ".join(' AND
', $query['and
']); 916 unset($query['and
']); 920 $query['where
'].= "\n AND ( (".join(")\n OR (", $query['or
']).') )
'; 925 $query['fields2
'] = '(LN((
'.join(') + (
', $query['score
']).'))+1) AS score
'; 926 unset($query['score
']); 928 if ($param['has_children
']) 930 $has_children_where = $param['has_children_where
'] ? ' AND (
'.$param['has_children_where
'].')
' : ''; 931 if ((integer)$param['deleted
']>=0) 932 { // Gelöschte Seiten ausblenden. 933 $has_children_where.= ' AND (has_table.deleted=
'. 934 (integer)$param['deleted
'].($param['deleted_or
']?' OR
'.$param['deleted_or
']:'').')
'; 936 if (($site->getOnlyActive() && !$param['inactive
']) || $param['only_active
']) 937 { // Die ursprüngliche Zeile $query.=... gab beim Aufruf über Smarty eine Fehlermeldung 938 $has_children_where.= ' AND has_table.inactive=0
'. 939 ' AND (has_table.release_until=\
'0000-00-00 00:00:00\' or has_table.release_until>=\''.$site->getTime().
'\')
'. 940 ' AND (has_table.release_from=\
'0000-00-00 00:00:00\' or has_table.release_from<\''.$site->getTime().
'\')
'; 941 } elseif (($_REQUEST['preview
'] || $GLOBALS['frontend_admin
']) && empty($param['expired
'])) { 942 // In der Vorschau/Frontend Administration werden inaktive Seiten durch das Freigabe bis Datum nicht angezeigt 943 $has_children_where.= ' AND (has_table.release_until=\
'0000-00-00 00:00:00\' or has_table.release_until>=\''.$site->getTime().
'\')
'; 946 /* Bitand für has_children ermitteln 947 * (die pageTable muss mit "has_table" ersetzt werden, damit die bitand Anweisungen auch auf den Sub-Select angewendet werden) 949 $query['field_as_bitand
']['has_children
'] = array_map(function($value) { 950 $value[0] = str_replace($this->pageTable . '.
', 'has_table.
', $value[0]); 955 'page_table
' => 'has_table
', 956 'where
' => ''.$page_table.'.id=
'.$page_table.'_children.page_id
'. 957 ' AND
'.$page_table.'_children.child=has_table.id
'. 960 $query['distinct
'] = true; 962 if ($param['auth_or
']!='1=1
') 964 $children_query = $GLOBALS['auth
']->getPageTableQuery($page_table, $param['rights
'], $children_query, $param); 966 $query['field_as
']['has_children
'] = 'SELECT count(DISTINCT child)
'. 967 ' FROM
'.$page_table.'_children,
'.$page_table.' has_table
'. 968 ($children_query['join
']?' LEFT JOIN
'.(is_array($children_query['join
'])? 969 implode(' LEFT JOIN
', $children_query['join
']):$children_query['join
']):''). 970 ' WHERE
'.$children_query['where
']; 972 if ($param['multi_parents
']) 975 if ((integer)$param['deleted
']>=0) 976 { // Gelöschte Seiten ausblenden. 977 $multi_where.= ' AND (multi_table.deleted=
'. 978 (integer)$param['deleted
'].($param['deleted_or
']?' OR
'.$param['deleted_or
']:'').')
'; 980 if (($site->getOnlyActive() && !$param['inactive
']) || $param['only_active
']) 981 { // Die ursprüngliche Zeile $query.=... gab beim Aufruf über Smarty eine Fehlermeldung 982 $multi_where.= ' AND multi_table.inactive=0
'. 983 ' AND (multi_table.release_until=\
'0000-00-00 00:00:00\' or multi_table.release_until>=\''.$site->getTime().
'\')
'. 984 ' AND (multi_table.release_from=\
'0000-00-00 00:00:00\' or multi_table.release_from<\''.$site->getTime().
'\')
'; 985 } elseif (($_REQUEST['preview
'] || $GLOBALS['frontend_admin
']) && empty($param['expired
'])) { 986 // In der Vorschau/Frontend Administration werden inaktive Seiten durch das Freigabe bis Datum nicht angezeigt 987 $multi_where.= ' AND (multi_table.release_until=\
'0000-00-00 00:00:00\' or multi_table.release_until>=\''.$site->getTime().
'\')
'; 990 // Bitand für multi_parents ermitteln 991 $query['field_as_bitand
']['multi_parents
'] = $bitand_query; 993 $query['field_as
']['multi_parents
'] = 'SELECT count(page_id)-1
'. 994 ' FROM
'.$page_table.'_children,
'.$page_table.' multi_table
'. 995 ' WHERE
'.$page_table.'.id=child
'. 996 ' AND
'.$page_table.'_children.page_id=multi_table.id
'. 998 $query['distinct
'] = true; 1001 if ($GLOBALS['egotec_conf
']['pages_cache
'] && !$param['no_cache
']) 1003 return new Page_Iterator($site, new_db_connection($query, $site->getCache())); 1005 return new Page_Iterator($site, new_db_connection($query)); 1016 private function getBitandQuery($param) { 1019 if ($param['no_nav_hide
']) 1020 { // Nur Seiten, die in der Navigation angezeigt werden (nav_hide&1=0) 1021 $query[] = array('nav_hide
', 1, 0); 1022 $param['sitemap
'] = true; // Außerdem nur Seiten, die in der Sitemap angezeigt werden 1024 if ($param['no_intranet
']) 1025 { // Nur Seiten, die auf den Liveserver übertragen werden (nav_hide&2=0) 1026 $query[] = array('nav_hide
', 2, 0); 1028 if ($param['intranet
']) 1029 { // Nur Seiten, die nur im Intranet angezeigt werden (nav_hide&2=2) 1030 $query[] = array('nav_hide
', 2, 2); 1032 if ($param['search
']) 1033 { // Nur Seiten, die nicht von der Suche ausgeschlossen werden (nav_hide&4=0) 1034 $query[] = array('nav_hide
', 4, 0); 1036 if ($param['sitemap
'] && (!$GLOBALS['egotec_conf
']['show_hidden_sitemap
'] || !$GLOBALS['admin_area
'])) 1037 { // Nur Seiten, die in der Sitemap angezeigt werden (nav_hide&8=0) 1038 $query[] = array('nav_hide
', 8, 0); 1040 if ($param['nouse
']) 1041 { // Nur Seiten, die im Verwendungsnachweis berücksichtigt werden sollen (nav_hide&16=0) 1042 $query[] = array('nav_hide
', 16, 0); 1044 if (isset($param['flag0
'])) 1045 { // Weitere Flag für offene Anwendungsfälle (nav_hide&32=0) 1046 $query[] = array('nav_hide
', 32, $param['flag0
']?32:0); 1048 if (isset($param['flag1
'])) 1049 { // Weitere Flag für offene Anwendungsfälle (nav_hide&64=0) 1050 $query[] = array('nav_hide
', 64, $param['flag1
']?64:0); 1052 if (isset($param['flag2
'])) 1053 { // Weitere Flag für offene Anwendungsfälle (nav_hide&128=0) 1054 $query[] = array('nav_hide
', 128, $param['flag2
']?128:0); 1056 if (isset($param['flag3
'])) 1057 { // Weitere Flag für offene Anwendungsfälle (nav_hide&256=0) 1058 $query[] = array('nav_hide
', 256, $param['flag3
']?256:0); 1060 if (isset($param['flag4
'])) 1061 { // Weitere Flag für offene Anwendungsfälle (nav_hide&512=0) 1062 $query[] = array('nav_hide
', 512, $param['flag4
']?512:0); 1064 if (isset($param['flag5
'])) 1065 { // Weitere Flag für offene Anwendungsfälle (nav_hide&1024=0) 1066 $query[] = array('nav_hide
', 1024, $param['flag5
']?1024:0); 1068 if (isset($param['flag6
'])) 1069 { // Weitere Flag für offene Anwendungsfälle (nav_hide&2048=0) 1070 $query[] = array('nav_hide
', 2048, $param['flag6
']?2048:0); 1072 if (isset($param['flag7
'])) 1073 { // Weitere Flag für offene Anwendungsfälle (nav_hide&4096=0) 1074 $query[] = array('nav_hide
', 4096, $param['flag7
']?4096:0); 1086 function getLostPages($deleted = -1) 1088 /* Verlorene Seiten sind: 1089 * 1. Seiten ohne Elternseite 1090 * 2. Seiten die als Elternseite nur Schlagwörter haben (aber selbst kein Schlagwort sind) */ 1091 return $this->getPages( 1093 'join
' => array($this->pageTable.'_children ON child =
id'), 1094 'where
' => "id != {$this->rootId} AND (child IS NULL OR (type != '_keywords/entry
' AND id IN (SELECT child FROM {$this->pageTable}_children INNER JOIN {$this->pageTable} ON page_id = id WHERE type = '_keywords/entry
') AND id NOT IN (SELECT child FROM {$this->pageTable}_children INNER JOIN {$this->pageTable} ON page_id = id WHERE type != '_keywords/entry
')))" 1097 'deleted
' => $deleted, 1113 function getPage($id, $param=array()) 1119 if (!is_numeric($id)) 1121 $id = $this->getPageId($id, $param); 1123 $cache_key = md5(serialize([$this->language, $param])); 1124 if ($id == $this->rootId && $page=$this->_root[$cache_key]) { 1127 if (is_numeric($id) && is_numeric($_REQUEST['id']) && $id == $_REQUEST['id']) { 1128 // Falls möglich, die aktuelle abgelaufene Seite anzeigen 1129 $param['expired
'] = true; 1131 $pages = $this->getPages( 1133 'fields
' => $param['fields
'], 1134 'where
' => 'id=:
id', 1135 'bind
' => array('id' => (int)$id) 1140 $page = $pages->nextPage(); 1141 if ($id == $this->rootId) { // Die root Seite cachen, da auf diese oft zugefriffen wird. 1142 $this->_root[$cache_key] = $page; 1158 function getRoot($param = array()) 1160 return $this->getPage($this->rootId, $param); 1171 function getErrorPage() 1173 $GLOBALS['_SERVER
']['REDIRECT_STATUS
'] = '404
'; 1174 if (!($page = $this->getPage($this->site['error_id
'] ? $this->site['error_id
'] : $this->rootId))) { 1175 // Falls die eingestellte Fehlerseite nicht erreichbar ist, wird die Startseite verwendet 1176 $page = $this->getRoot(); 1187 function getUrl($param, $page = null) 1189 if (!$this->_onlyActive && !isset($param['nonactive
'])) 1190 { // Auch inaktive Seiten anzeigen. 1191 $param['nonactive
'] = true; 1193 if (isset($param['nonactive
']) && !$param['nonactive
']) 1195 unset($param['nonactive
']); 1197 if (!isset($param['lang
'])) 1199 $param['lang
'] = $this->language; 1201 if (!isset($param['skin
']) && $this->skin!=$this->site['default_skin
']) 1203 $param['skin
'] = $this->skin; 1205 if (!isset($param['site
'])) 1207 $param['site
'] = $this->name; 1210 // Alphabetische Reihenfolge der URL Parameter 1213 if ($param['get_frontend_url
']) { 1214 // Im Adminbereich eine sprechende URL ermitteln 1215 unset($param['get_frontend_url
']); 1216 if ($GLOBALS['is_admin
']) { 1217 require_once('soap/Ego_SOAP.php
'); 1218 $soap = new Ego_SOAP(); 1219 return $soap->soapCall('pageGetUrl
', array( 1220 'site
' => $this->name, 1221 'lang
' => $this->language, 1222 'id' => $param['id'], 1223 'param
' => soap_var($param) 1227 return get_url('index.php
', $param, $page); 1237 function getPageUrl($page_id, $params = array(), $page = null) 1239 return $page_id?$this->getUrl(array_merge(array('id' => $page_id), $params), $page):$this->getErrorPage(); 1252 function getMediaSite($lang = '') 1254 if ($this->site['type
'] != 'media
' && empty($this->site['media
'])) { 1266 $lang = $this->language; 1269 if ($this->site['type
'] == 'media
') 1271 $media_site = $this; 1274 $media_site = new Site($this->site['media
'], '', '', $this->_onlyActive); 1275 $media_site->setParam($this->_param); 1278 // Prüfen ob die aktuelle Sprache auch im Multimedia Mandanten existiert 1280 in_array($lang, $media_site->getLanguages()) 1281 && $lang != $media_site->language 1284 $media_site->setLanguage($lang); 1295 public function hasMediaSite() { 1296 return ($this->site['type
'] == 'media
' || !empty($this->site['media
'])); 1306 function getMediaUrl($id, $param = array(), $url_param = array()) 1308 if ($param['no_suffix
']) 1310 $url_param['no_suffix
'] = $param['no_suffix
']; 1311 unset($param['no_suffix
']); 1313 return $this->getMediaSite()->getPage($id, $param)->getUrl($url_param); 1322 function clearCache($id=0, $all_languages = false) 1324 if ($all_languages) { 1325 // Cache für alle Sprachen ungültig setzen 1326 $site = clone $this; 1327 foreach ($site->getLanguages() as $lang) { 1328 $site->setLanguage($lang); 1329 $site->clearCache($id); 1334 $language = $this->language; 1335 $pageTable = $this->name.'_
'.$language; 1336 if (!file_exists($GLOBALS['egotec_conf
']['log_dir
'].$this->name.'_
'.$language)) 1338 Ego_System::mkdir($GLOBALS['egotec_conf
']['log_dir
'].$this->name.'_
'.$language, 0777, true); 1342 { // Bei Bildern wird nicht der komplette Cache, sondern nur das aktuelle Bild gelöscht 1343 $cache_path = $GLOBALS['egotec_conf
']['cachemedia_dir
'].$this->name.'/
'.$language.'/
'; 1344 Ego_System::deldir($cache_path.$id, true); 1352 // Cache, Lebensdauer einstellen nun immer 24h 1353 $new_cache_lifetime = 86400; 1355 $cache_expire = date('Y-m-d H:i:s
', time()+$new_cache_lifetime); 1356 $time = date('Y-m-d H:i:s
'); 1357 $db = new_db_connection(array( // Datum der nächsten Änderung durch Ablauf von Freigabefenstern bestimmen. 1359 'table
' => $pageTable, 1360 'where
' => 'release_from>:time
', 1361 'bind
' => array('time
' => $time), 1362 'order
' => 'release_from asc
', 1365 if ($db->nextRecord()) 1367 if ($db->Record['release_from
']<$cache_expire) 1369 $cache_expire = $db->Record['release_from
']; 1374 'table
' => $pageTable, 1375 'where
' => 'release_until>:time
', 1376 'bind
' => array('time
' => $time), 1377 'order
' => 'release_until asc
', 1380 if ($db->nextRecord()) 1382 if ($db->Record['release_until
']<$cache_expire) 1384 $cache_expire = $db->Record['release_until
']; 1387 $d = preg_split('/[-, ,:]/
', $cache_expire); 1388 $this->_cache->reset(); 1390 $this->_cache->setExpire(mktime($d[3], $d[4], $d[5], $d[1], $d[2], $d[0])); 1391 $this->setTime(); // Der Zeitstempel für die Freigabeabfrage muss neu gesetzt werden. 1393 // types.cache und classes.cache löschen 1394 Ego_System::clearTypeCache($this->name); 1396 // Allgemeine Cache löschen (nicht für APC, da hier die allgemeine Cache die selbe ist wie die Site Cache) 1397 if ($GLOBALS['egotec_conf
']['site_cache_type
'] != 'apc
') { 1398 $cache = Ego_System::getCache(); 1401 Ego_System::clearNginxCache(); 1409 function save($site) 1412 $this->site = array_merge($this->site, $site); 1414 // Diese Keys gibt es nicht mehr und sind mittlerweile unterteilt in Sprachen 1415 unset($this->site['title
']); 1416 unset($this->site['robots
']); 1417 unset($this->site['keywords
']); 1418 unset($this->site['description
']); 1419 unset($this->_languages); 1421 Ego_System::write_ini_file($GLOBALS['egotec_conf
']['site_dir
'].$this->name.'/conf.ini
', $this->site); 1429 function save_admin($admin=array()) 1432 $original_admin = $this->admin; 1433 $this->admin = array_merge($this->admin, $admin); 1438 $enabled_types = array(); 1439 if(is_array($this->admin['enabled_types
'])) 1441 foreach ($this->admin['enabled_types
'] as $key => $value) 1445 $enabled_types[$key] = $value; 1449 $this->admin['enabled_types
'] = $enabled_types; 1451 // Schlagwortregister anlegen 1452 if ($this->admin['keyword_register_own_site
']) { 1453 if (!isset($this->admin['keywords
']['site
'])) { 1454 $this->admin['keywords
']['site
'] = $this->name; 1456 $reset = $this->admin['keywords
']['site
'] != $original_admin['keywords
']['site
']; 1457 if ($this->name !== $this->admin['keywords
']['site
']) { 1458 $origin_site = new Site($this->admin['keywords
']['site
']); 1459 $this->keywordRegister($origin_site, $reset); 1461 $this->keywordRegister(null, $reset); 1465 Ego_System::write_ini_file($GLOBALS['egotec_conf
']['site_dir
'].$this->name.DIRECTORY_SEPARATOR.'admin
'.DIRECTORY_SEPARATOR.'conf.ini
', $this->admin); 1466 Ego_System::clearTypeCache($this->name); 1476 private function keywordRegister($origin_site = null, $reset = false) { 1477 $root_page = $this->getRoot(); 1478 // Überprüfen ob es bereits ein Schlagwortregister existiert. 1479 $keyword_register_page = $this->getPages(array( 1480 'where
' => "type='_keywords/list
'" 1484 if ($keyword_register_page) { 1486 // Wenn das Schlagwortregister gewechselt wird, muss es neu angelegt werden 1487 $keyword_register_page->delete(false, false, true, array( 1488 'where
' => "type = '_keywords/entry
'" 1490 $this->clearTrashcan(array( 1491 'where
' => "type = '_keywords/list
' OR type = '_keywords/entry
'" 1494 // Wenn ein Schlagwortregister existiert, dann nicht machen. 1500 // Schlagwortregisterstartseite klonen. 1501 $origin_page = $origin_site->getPages(array( 1502 'where
' => "type='_keywords/list
'" 1506 if (!$origin_page) { // Wenn beim Originalmandant kein Schlagwortregister existiert, 1507 $keyword_register_field = array( 1508 'name
' => "Schlagwortregister", 1509 'title
' => "Schlagwortregister", 1510 'type
' => "_keywords/list", 1512 'nav_hide
' => 1+4+8 // Aus Navigation, Sitemap und Suche ausschließen. 1514 $origin_page = $origin_site->getRoot()->newChild($keyword_register_field); // dann dieses erstellen. 1515 } elseif ($origin_page->isClone()) { // Wenn der ausgewählte Mandant ebenfalls Klone nutzt, 1516 $origin_page = $origin_page->getCloneOriginal(); // so wird das Original geklont. 1518 $clone_page = $root_page->createClone($origin_page); 1519 $keyword_recursive = function($origin_page, $clone_page) use (&$keyword_recursive) { 1520 $orgin_children = $origin_page->getChildren(array( 1521 'where
' => "type='_keywords/entry
'" 1525 foreach ($orgin_children as $orgin_child) { 1526 $clone_child = $clone_page->createClone($orgin_child); 1527 $keyword_recursive($orgin_child, $clone_child); 1530 $keyword_recursive($origin_page, $clone_page); 1532 $keyword_register_field = array( 1533 'name
' => "Schlagwortregister", 1534 'title
' => "Schlagwortregister", 1535 'type
' => "_keywords/list", 1537 'nav_hide
' => 1+4+8 // Aus Navigation, Sitemap und Suche ausschließen. 1539 $root_page->newChild($keyword_register_field); 1555 private function _getTypesOfDirectory($root_dir, $site_name, $type='', $fullname='', $depth=-1, $site_type='') 1557 if (file_exists($root_dir.($type?$type.'/
':'').'/type.ini
')) 1559 $entry = parse_ini_file($root_dir.($type?$type.'/
':'').'/type.ini
', true); 1560 $fullname = ($fullname?$fullname.'/
':'').$entry['title
']; 1563 $root_dir == $GLOBALS['egotec_conf
']['lib_dir
'].'type/site/
' 1564 || $root_dir == $GLOBALS['egotec_conf
']['site_dir
'].'_global/
' 1572 case '_keywords/abbreviations
': 1573 if ($this->admin['keyword_register_own_site
']) { 1581 'name
' => $entry['title
'], 1582 'fullname
' => $fullname, 1583 'active
' => !$entry['inactive
'], 1584 'hidden
' => (bool) $entry['hidden
'], 1585 'global
' => $global, 1586 'system
' => $system, 1587 'blacklist
' => $entry['blacklist
'], 1588 'whitelist
' => $entry['whitelist
'] 1591 // Blacklist - Wenn der Seitentyp vom Mandanten ausgeschlossen ist. 1592 $excluded_sites = explode(',
', $types['blacklist
']); 1594 if ($types['whitelist
']) { 1595 // Whitelist - Wenn der Seitentyp nur auf bestimmten Mandanten verfügbar ist. 1596 $included_sites = explode(',
', $types['whitelist
']); 1598 // Wenn sich der Seitentyp auf der Blacklist befindet, nicht anzeigen. 1599 if (is_array($excluded_sites) && in_array($site_name, $excluded_sites)) { 1603 // Wenn eine Whitelist vorhanden ist und der Seitentyp nicht auf dieser ist, nicht anzeigen. 1604 if (is_array($included_sites) && !empty($included_sites) && !in_array($site_name, $included_sites) ) { 1608 foreach (array("icon","jquery") as $k) 1612 $types[$k] = $entry[$k]; 1617 if (is_dir($root_dir.($type?$type.'/
':''))) 1619 $dir = dir($root_dir.($type?$type.'/
':'')); 1620 while ($file = $dir->read()) 1622 if ($file[0]!='.
' && is_dir($dir->path.$file) && ($file!='multimedia
' || $site_type=='media
')) 1624 $type_array = $this->_getTypesOfDirectory($root_dir, $site_name, ($type?$type.'/
':'').$file, $fullname, $depth+1, $site_type); 1627 $types['children
'][$type_array['type
']] = $type_array; 1632 if ($types['children
']) 1646 private static function _getFlatTypes($tree) 1648 $types_array = array(); 1651 foreach ($tree as $item) 1653 $types_array[] = $item; 1654 if ($item['children
']) 1656 $types_array = array_merge($types_array, Site::_getFlatTypes($item['children
'])); 1660 return $types_array; 1677 function getTypes($flat=true,$params=array()) 1679 $cache_file = $GLOBALS['egotec_conf
']['cache_dir
'].$this->name.'/types
'.($flat ? 'Flat
' : '').md5(serialize(array($params))); 1681 Ego_System::file_exists($cache_file) 1682 && ($types = @unserialize(Ego_System::file_get_contents($cache_file))) 1687 if ($params['only_system
']) 1688 {//Systemseitentypen die NICHT durch Mandantenspezifische Seitentypen überschrieben werden 1689 $types = $this->_getTypesOfDirectory($GLOBALS['egotec_conf
']['site_dir
'].$this->name.'/
', $this->name); 1690 $types1 = $this->_getTypesOfDirectory($GLOBALS['egotec_conf
']['pub_dir
'].'type/site/
', $this->name); 1691 $types2 = $this->theme ? $this->_getTypesOfDirectory($GLOBALS['egotec_conf
']['pub_dir
']."theme/{$this->theme}/site/", $this->name) : null; 1692 $types3 = $this->globalAllowed() ? $this->_getTypesOfDirectory($GLOBALS['egotec_conf
']['site_dir
'].'_global/
', $this->name) : null; 1693 $types4 = $this->_getTypesOfDirectory($GLOBALS['egotec_conf
']['lib_dir
'].'type/site/
', $this->name, '', '', -1, $this->site['type
']); 1695 if (is_array($types)) { 1696 $result_types['children
'] = array_diff_key($types4['children
'],$types['children
']); 1698 $result_types = $types4; 1700 if (is_array($types3)) { 1701 $result_types['children
'] = array_diff_key($result_types['children
'],$types3['children
']); 1703 if (is_array($types2)) { 1704 $result_types['children
'] = array_diff_key($result_types['children
'], $types2['children
']); 1706 if (is_array($types1)) { 1707 $result_types['children
'] = array_merge($result_types['children
'],$types1['children
']); 1709 $this->_types = $result_types['children
']?$result_types['children
']:array(); 1710 if ($params['include_theme
']) { 1711 $theme_types = $types2['children
']?$types2['children
']:array(); 1712 $this->_types = array_merge($this->_types, $theme_types); 1714 if ($params['include_global
']) { 1715 $global_types = $types3['children
']?$types3['children
']:array(); 1716 $this->_types = array_merge($this->_types, $global_types); 1718 } elseif ($params['only_global
']) 1720 if ($this->globalAllowed()) { 1721 $types = $this->_getTypesOfDirectory($GLOBALS['egotec_conf
']['site_dir
'].'_global/
', $this->name); 1722 $this->_types = $types['children
']?$types['children
']:array(); 1724 $this->_types = array(); 1726 } elseif ($params['only_site
']) 1728 $types = $this->_getTypesOfDirectory($GLOBALS['egotec_conf
']['site_dir
'].$this->name.'/
', $this->name); 1729 $this->_types = $types['children
']?$types['children
']:array(); 1730 } elseif ($params['only_theme
']) 1732 $types = $this->_getTypesOfDirectory($GLOBALS['egotec_conf
']['pub_dir
'].'theme/
'.$this->theme.'/site/
', $this->name); 1733 $this->_types = $types['children
']?$types['children
']:array(); 1738 $types_filename=$GLOBALS['egotec_conf
']['cache_dir
'].$this->name.'/types.cache
'; 1739 if (Ego_System::file_exists($types_filename)) 1741 $this->_types = @unserialize(Ego_System::file_get_contents($types_filename)); 1744 $types = $this->_getTypesOfDirectory($GLOBALS['egotec_conf
']['site_dir
'].$this->name.'/
', $this->name); 1745 $types1 = $this->_getTypesOfDirectory($GLOBALS['egotec_conf
']['pub_dir
'].'type/site/
', $this->name); 1746 $types2 = $this->theme ? $this->_getTypesOfDirectory($GLOBALS['egotec_conf
']['pub_dir
']."theme/{$this->theme}/site/", $this->name) : null; 1747 $types3 = $this->globalAllowed() ? $this->_getTypesOfDirectory($GLOBALS['egotec_conf
']['site_dir
'].'_global/
', $this->name) : null; 1748 $types4 = $this->_getTypesOfDirectory($GLOBALS['egotec_conf
']['lib_dir
'].'type/site/
', $this->name, '', '', -1, $this->site['type
']); 1750 $this->_types = array_merge( 1751 $types4['children
']?$types4['children
']:array(), 1752 $types3['children
']?$types3['children
']:array(), 1753 $types2['children
']?$types2['children
']:array(), 1754 $types1['children
']?$types1['children
']:array(), 1755 $types['children
']?$types['children
']:array() 1757 Ego_System::file_put_contents($types_filename, serialize($this->_types)); 1764 $md5 = md5(serialize($params)); 1765 if (!$this->_typesFlat[$md5]) 1767 $this->_typesFlat[$md5] = Site::_getFlatTypes($this->_types); 1770 Ego_System::file_put_contents($cache_file, serialize($this->_typesFlat[$md5])); 1771 return $this->_typesFlat[$md5]; 1775 Ego_System::file_put_contents($cache_file, serialize($this->_types)); 1776 return $this->_types; 1786 function getTypeInfo($name) { 1787 if (!empty($this->_types)) { 1788 $parts = explode('/
', $name); 1789 $type = $this->_types[$parts[0]]; 1791 foreach ($parts as $index => $part) { 1792 if ($type['type
'] == $name) { 1795 if (empty($child)) { 1798 $child .= '/
'.$part; 1800 if (!empty($type['children
']) && !empty($type['children
'][$child])) { 1801 $type = $type['children
'][$child]; 1802 if ($type['type
'] == $name) { 1809 $types = $this->getTypes(); 1810 foreach ($types as $type) { 1811 if ($type['type
'] == $name) { 1826 function getTypeFiles($type) 1829 $dirs_to_read = array( 1830 'site »
' => array( 1831 $GLOBALS['egotec_conf
']['lib_dir
'].'type/site/
'.$type, 1832 $this->globalAllowed() ? $GLOBALS['egotec_conf
']['site_dir
'].'_global/
'.$type : '', 1833 $GLOBALS['egotec_conf
']['site_dir
'].$this->name.'/
'.$type, 1835 'site/admin »
' => array( 1836 $GLOBALS['egotec_conf
']['lib_dir
'].'type/site/
'.$type.'/admin
', 1837 $this->globalAllowed() ? $GLOBALS['egotec_conf
']['site_dir
'].'_global/
'.$type.'/admin
' : '', 1838 $GLOBALS['egotec_conf
']['site_dir
'].$this->name.'/
'.$type.'/admin
', 1840 'skin »
' => array( 1841 $GLOBALS['egotec_conf
']['bin_dir
'].'type/skin/
'.$type, 1842 $GLOBALS['egotec_conf
']['lib_dir
'].'type/skin/
'.$type, 1843 $this->globalAllowed() ? $GLOBALS['egotec_conf
']['skin_dir
'].'_global/
'.$type : '', 1844 $GLOBALS['egotec_conf
']['skin_dir
'].$this->skin.'/
'.$type 1847 if (!empty($this->theme)) { 1848 $dirs_to_read[$this->theme.' »
'] = array( 1849 $GLOBALS['egotec_conf
']['pub_dir
'].'theme/
'.$this->theme.'/site/
'.$type, 1850 $GLOBALS['egotec_conf
']['pub_dir
'].'theme/
'.$this->theme.'/skin/
'.$type, 1852 $dirs_to_read[$this->theme.'/admin »
'] = array( 1853 $GLOBALS['egotec_conf
']['pub_dir
'].'theme/
'.$this->theme.'/site/
'.$type.'/admin
' 1857 foreach ($dirs_to_read as $key => $dirs) 1859 foreach ($dirs as $d) 1865 while ($dir && false !== ($f = $dir->read())) 1867 if ($f[0]=='.
' || is_dir($dir->path.'/
'.$f)) continue; 1869 $files[$key.'/
'.$f] = $dir->path.'/
'.$f; 1887 function getBlocks() 1891 // Verzeichnis in dem die Blöcke liegen 1892 $dir = $GLOBALS['egotec_conf
']['skin_dir
'].$this->skin.'/blocks/
'; 1898 while(false !== ($entry = $d->read())) 1900 if (preg_match('/^(.*?)\.html$/i
', $entry, $matches)) 1902 $name = $matches[1]; 1905 $blocks[$name] = array( 1906 'html
' => file_get_contents($dir.$entry) 1910 $desc = $dir.$name.'_desc.php
'; 1911 if (file_exists($desc)) 1913 $blocks[$name]['desc
'] = file_get_contents($desc); 1917 $img = $dir.$name.'.gif
'; 1918 if (file_exists($img)) 1920 $blocks[$name]['img
'] = $img; 1943 function getSitemapRootIdArray($param = array(), $recalc = false, $user = true, $query = array()) 1945 $key = md5($this->pageTable.json_encode($this->_param)); 1947 // Aus dem User Objekt holen 1951 && is_array($GLOBALS['auth
']->user->extra['rootIdArray
']) 1952 && is_array($GLOBALS['auth
']->user->extra['rootIdArray
'][$key]) 1954 return $GLOBALS['auth
']->user->extra['rootIdArray
'][$key]; 1957 $where = $query['where
']; 1958 unset($query['where
']); 1959 $query = array_merge(array( 1960 'fields
' => $this->pageTable.'.id,
'. $this->pageTable.'_children.page_id
', 1961 'inner
' => array($this->pageTable.'_children ON
'.$this->pageTable.'_children.child=
'.$this->pageTable.'.id
'), 1965 $query['where
'] = $where; 1967 $all_parents = $this->getPages($query, $param); 1970 $parent_string = ''; 1971 foreach ($all_parents as $page) 1973 $parent_string = $parent_string.',
'.$page->field['page_id
']; 1974 $id_string = $id_string.',
'.$page->field['id']; 1976 $parent_string = trim($parent_string,',
'); 1977 $id_string = trim($id_string,',
'); 1981 $parents = empty($parent_string) ? array() : explode(',
', $parent_string); 1982 $all_ids = empty($id_string) ? array() : explode(',
', $id_string); 1983 $parents = array_unique($parents); 1984 $all_ids = array_unique($all_ids); 1986 if ($param['deleted
'] == 1) 1987 { // Die Eltern aller gelöschten Seiten zurückgeben. 1989 } elseif (empty($parents)) 1990 { // es gibt keine Eltern 1993 $with_permission = $all_ids; // Alle Eltern bestimmen, auf die der Benutzer eine Berechtigung besitzt. 1994 $ids = array(); // Alle Vorfahren zu den Eltern bestimmen, für die der Benutzer keine Berechtigung besitzt. 1995 $page = $this->getRoot(array('auth_or
' => '1=1
', 'deleted_or
' => '1=1
')); 1997 foreach ($parents as $id) 1999 if (!in_array($id, $with_permission)) 2001 $ids = array_merge($ids,$page->_getAncestorsIds( 2002 $this->getPage($id, array('auth_or
' => '1=1
')), 2003 array('limit
' => 1, 'order
' => 'id'), 2004 array('auth_or
' => '1=1
', 'deleted
' => -1) 2010 $ids = array_unique($ids); 2012 // Im User Objekt speichern 2013 if (!isset($param['deleted
']) && $user) { 2014 if (!is_array($GLOBALS['auth
']->user->extra['rootIdArray
'])) { 2015 $GLOBALS['auth
']->user->extra['rootIdArray
'] = array(); 2017 $GLOBALS['auth
']->user->extra['rootIdArray
'][$key] = $ids; 2018 $GLOBALS['auth
']->user->update(); 2033 function hasRight($right, $flag=false, $user_id = false, $rights = array()) 2035 $rights = !empty($rights) ? $rights : $this->admin['right
']; 2036 if ($right == "desktop") 2043 $group = $rights[$right.'_group_
'.$i]; 2048 $role = $rights[$right.'_role_
'.$i]; 2049 if ($GLOBALS['auth
']->hasPermission($group, $role, $flag, $user_id)) 2054 } while ($group!=''); 2064 function hasPermission($right) 2066 $rights = $this->admin['right
']; 2068 if (is_array($rights)) 2070 foreach ($rights as $r => $value) 2072 if (preg_match('/^
'.$right.'_group_(\d+)/i
', $r, $g)) 2076 if (isset($rights[$right.'_role_
'.$group]) && !$this->isPermission($value, $rights[$right.'_role_
'.$group])) 2090 function isPermission($group, $role) 2092 if (empty($group) && empty($role)) 2097 $db = new_db_connection( 2099 'fields
' => 'group_id
', 2100 'table
' => 'egotec_group
', 2101 'where
' => 'group_id =:group
', 2107 if($db->nextRecord()) 2109 $db = new_db_connection( 2111 'fields
' => 'role_id
', 2112 'table
' => 'egotec_role
', 2113 'where
' => 'role_id =:role
', 2120 return $db->nextRecord(); 2134 function checkRight($right, $flag=false) 2136 if ($this->hasRight($right, $flag)) 2140 throw new Auth_Exception(Auth_Exception::PERMISSION_DENIED_TEXT, Auth_Exception::PERMISSION_DENIED); 2150 public function getRights($right) { 2154 $group = $this->admin['right
'][$right.'_group_
'.$i]; 2158 $role = $this->admin['right
'][$right.'_role_
'.$i]; 2159 $rights[] = array('group
' => $group, 'role
' => $role); 2161 } while ($group != ''); 2171 public function setRight($right, $rights) { 2172 // Zunächst alle bisherigen Einträge löschen. 2175 $group = $this->admin['right
'][$right.'_group_
'.$i]; 2179 unset($this->admin['right
'][$right.'_group_
'.$i]); 2180 unset($this->admin['right
'][$right.'_role_
'.$i]); 2182 } while ($group != ''); 2184 // Jetzt die Rechte setzen. 2186 foreach ($rights as $one_right) { 2187 $this->admin['right
'][$right.'_group_
'.$i] = $one_right['group
']; 2188 $this->admin['right
'][$right.'_role_
'.$i] = $one_right['role
']; 2196 function destroyIDs($ids) 2198 $languages = $this->getLanguages(); 2199 $name = $this->name; 2200 foreach($languages as $language) 2202 foreach($ids as $id) 2204 $_dbErase = new_db_connection(); 2205 $_dbErase->delete(array('from
' => $name.'_
'.$language, 'where
' => 'id = \
''.$id.
'\''));
2206 $_dbErase->delete(array(
'from' => $name.
'_'.$language.
'_fulltext',
'where' =>
'id = \''.$id.
'\''));
2207 $_dbErase->delete(array(
'from' => $name.
'_'.$language.
'_rights',
'where' =>
'page_id = \''.$id.
'\''));
2208 $_dbErase->delete(array(
'from' => $name.
'_'.$language.
'_users',
'where' =>
'page_id = \''.$id.
'\''));
2209 $_dbErase->delete(array(
'from' => $name.
'_'.$language.
'_v',
'where' =>
'id = \''.$id.
'\''));
2225 'from' => $this->pageTable,
2226 'where' =>
'id='.$id
2228 $db = new_db_connection(
2229 $GLOBALS[
'auth']->getPageTableQuery(
2234 'user_id' => $user_id
2240 return (
boolean)$db->nextRecord();
2242 return $db->nextRecord() || $GLOBALS[
'auth']->hasSuperuserPermission();
2257 if (!$this->_metaUrlIsCached)
2259 $this->_metaUrl = array();
2262 foreach ($this->getLanguages() as $lang)
2264 $urls = $this->getPages(
2266 'fields' =>
'url,type',
2275 while ($url = $urls->nextPage())
2277 $this->_metaUrl[] = $url->field[
'url'];
2280 $this->_metaUrlIsCached =
true;
2282 return in_array($path, $this->_metaUrl);
2291 return $this->site[
'type'] ==
'content' && $GLOBALS[
'egotec_conf'][
'save_method'] ==
'public';
2301 return 'Site('.$this->name.
'.'.$this->language.
')';
2311 if ($this->_cache) {
2314 $this->_cache = clone $this->_cache;
2328 $need_space = 2*1024*1024*1024;
2329 $dir_name = $GLOBALS[
'egotec_conf'][
'backup_dir'].
'site/'.$this->name;
2334 $dir = dir($GLOBALS[
'egotec_conf'][
'backup_dir'].
'site/'.$this->name);
2335 while (
false !== ($f = $dir->read()))
2337 if (strrpos($f,
'.tar.gz')===strlen($f)-7)
2339 $time = filemtime($dir_name.
'/'.$f);
2340 $times[$time] = filesize($dir_name.
'/'.$f);
2341 $newest = $time > $newest ? $time : $newest;
2346 if (
sizeof($times)>0)
2348 $need_space = intval($times[$newest]) *3;
2356 $dir_name = $GLOBALS[
'egotec_conf'][
'backup_dir'];
2364 if ($need_space < disk_free_space($dir_name))
2380 return $this->_cache;
2390 $expire = (int) $this->admin[
'cache_expire_time'];
2404 if ($_REQUEST[
'preview']) {
2407 return $this->_cache->get($key);
2419 if ($_REQUEST[
'preview']) {
2422 $this->_cache->set($key, $value);
2430 return $this->_cache->getLastChanged();
2442 $auth = clone $GLOBALS[
'auth'];
2443 $smarty = clone $GLOBALS[
'smarty'];
2444 $active_cells = explode(
',', $GLOBALS[
'auth']->user->extra[$this->name.
'_desktop_cells']);
2447 $desklet_default_content =
'<p class="refresh"><a href="javascript:void(0)" onclick="egoDesktop.refresh()">' 2448 .$GLOBALS[
'auth']->translate(
'Laden Sie den Desktop neu, um den Inhalt dieses Desklets anzuzeigen.')
2450 $smarty->assign(
'desklet_default_content', $desklet_default_content);
2452 $desktop_dir = dir($GLOBALS[
'egotec_conf'][
'lib_dir'].
'desktop/'.($trashcan ?
'trashcan/' :
''));
2453 while ($desktop_file = $desktop_dir->read()) {
2455 is_file($desktop_dir->path.$desktop_file)
2456 && substr($desktop_file, strlen($desktop_file)-4) ==
'.php' 2457 && file_exists($desktop_dir->path.$desktop_file)
2459 require($desktop_dir->path.$desktop_file);
2462 $desktop_dir->close();
2464 if ($this->globalAllowed() && file_exists($GLOBALS[
'egotec_conf'][
'site_dir'].
'_global/admin/desktop/')) {
2465 $desktop_dir = dir($GLOBALS[
'egotec_conf'][
'site_dir'].
'_global/admin/desktop/');
2466 while ($desktop_file = $desktop_dir->read()) {
2468 is_file($desktop_dir->path.$desktop_file)
2469 && substr($desktop_file, strlen($desktop_file)-4) ==
'.php' 2470 && file_exists($desktop_dir->path.$desktop_file)
2472 require($desktop_dir->path.$desktop_file);
2475 $desktop_dir->close();
2477 if (file_exists($GLOBALS[
'egotec_conf'][
'site_dir'].$this->name.
'/admin/desktop/')) {
2478 $desktop_dir = dir($GLOBALS[
'egotec_conf'][
'site_dir'].$this->name.
'/admin/desktop/');
2479 while ($desktop_file = $desktop_dir->read()) {
2481 is_file($desktop_dir->path.$desktop_file)
2482 && substr($desktop_file, strlen($desktop_file)-4) ==
'.php' 2483 && file_exists($desktop_dir->path.$desktop_file)
2485 require($desktop_dir->path.$desktop_file);
2488 $desktop_dir->close();
2490 foreach ($this->getTypes() as $type) {
2491 $desktop_file = $GLOBALS[
'egotec_conf'][
'site_dir'].$this->name.
'/'.$type[
'type'].
'/admin/desktop.php';
2492 if ($this->globalAllowed() && !file_exists($desktop_file)) {
2493 $desktop_file = $GLOBALS[
'egotec_conf'][
'site_dir'].
'_global/'.$type[
'type'].
'/admin/desktop.php';
2495 if (!file_exists($desktop_file)) {
2496 $desktop_file = $GLOBALS[
'egotec_conf'][
'lib_dir'].
'type/site/'.$type[
'type'].
'/admin/desktop.php';
2498 if (file_exists($desktop_file)) {
2499 require($desktop_file);
2503 foreach ($GLOBALS[
'cells'] as $index => &$cell_item) {
2504 if (is_array($cell_item)) {
2505 foreach ($cell_item as &$cell) {
2506 if ($rights && isset($site->admin[
'desklets'][$cell[
'id']])) {
2507 $rights = explode(
';', $site->admin[
'desklets'][$cell[
'id']]);
2508 if (
sizeof($rights) > 0) {
2510 foreach ($rights as $right) {
2511 $group_role = explode(
',', $right);
2513 empty($group_role[0])
2514 || empty($group_role[1])
2515 ||$GLOBALS[
'auth']->hasPermission($group_role[0], $group_role[1])
2521 unset($GLOBALS[
'cells'][$index]);
2526 $cell[
'visible'] = ($cell[
'permanent'] || in_array($this->name.
'_'.$cell[
'id'], $active_cells));
2527 $cell[
'permanent'] = !empty($cell[
'permanent']);
2530 if (trim($cell[
'body']) ==
'') {
2531 $cell[
'body'] = $desklet_default_content;
2537 return $GLOBALS[
'cells'] = array_values($GLOBALS[
'cells']);
2547 if ($file = $this->getSiteFile(
'admin/uploader.php')) {
2548 require_once($file);
2549 if (function_exists(
'getUploaderPage')) {
2550 if (!$page && $GLOBALS[
'page']) {
2551 $page = $GLOBALS[
'page'];
2553 return getUploaderPage($this, $page);
2555 } elseif ($this->hasMediaSite()) {
2556 $media_site = $this->getMediaSite();
2557 $media_site->addParam(array(
2560 $_users_page = $media_site->getPages(
2561 array(
'where' =>
'name=\'_users\''),
2565 'only_active' =>
false 2570 $media_root_page = $media_site->getRoot(array(
'auth_or' =>
'1=1'));
2571 if (!$media_root_page) {
2574 $_users_page = $media_root_page->newChild(array(
2576 'title' =>
'_users',
2577 'type' =>
'multimedia/category',
2582 $user_page = $_users_page->getChildren(
2584 'where' =>
'name=:name',
2586 'name' => $GLOBALS[
'auth']->user->field[
'username']
2592 'only_active' =>
false 2595 if (!$user_page && !empty($GLOBALS[
'auth']->user->field[
'username']))
2597 $user_page = $_users_page->newChild(array(
2598 'name' => $GLOBALS[
'auth']->user->field[
'username'],
2599 'title' => $GLOBALS[
'auth']->user->field[
'username'],
2600 'type' =>
'multimedia/category',
2603 $user_page->setUsersArray(array(
2604 'edit' => array(array(
'user_id' => $GLOBALS[
'auth']->getId())),
2605 'child' => array(array(
'user_id' => $GLOBALS[
'auth']->getId())),
2606 'remove' => array(array(
'user_id' => $GLOBALS[
'auth']->getId()))
2610 $rights = $user_page->getRightsArray();
2611 foreach (array(
'edit',
'child',
'remove') as $perm) {
2613 empty($rights[$perm])
2614 || in_array(
'*', array($rights[$perm][0][
'group_id'], $rights[$perm][0][
'role_id']))
2616 $rights[$perm] = array(
2618 'group_id' => $GLOBALS[
'egotec_conf'][
'superuser'][
'group'],
2619 'role_id' => $GLOBALS[
'egotec_conf'][
'superuser'][
'role']
2624 $user_page->setRightsArray($rights);
2637 $deleted = $this->getPages(array(), array(
2641 return (
bool) $deleted->nextPage();
2652 if (empty($query[
'where'])) {
2653 $query[
'where'] =
'1=1';
2655 if (count($cluster_list) > 0) {
2657 foreach ($cluster_list as $cluster) {
2658 $log_filename = $GLOBALS[
'egotec_conf'][
'log_dir'].$this->name.
'/live.'.$this->name.
'_'.$this->language.
'.'.$cluster[
'id'].
'.up.date';
2659 if (file_exists($log_filename)) {
2660 $time[] = file_get_contents($log_filename);
2664 if (count($time) > 0) {
2665 $query[
'where'].=
" AND ".$this->pageTable.
".c_date<'{$time[0]}'";
2668 $log_filename = $GLOBALS[
'egotec_conf'][
'log_dir'].$this->name.
'/live.'.$this->name.
'_'.$this->language.
'.date';
2669 if (!file_exists($log_filename)) {
2670 $log_filename = $GLOBALS[
'egotec_conf'][
'log_dir'].$this->name.
'/live.date';
2672 if (file_exists($log_filename)) {
2673 $live_date = file_get_contents($log_filename);
2674 $query[
'where'].=
" AND ".$this->pageTable.
".c_date<'$live_date'";
2678 $del_array = array();
2679 $del_pages = $this->getPages($query, array(
2682 'only_active' =>
false,
2684 'rights' => array(
'delete')
2686 while ($page = $del_pages->nextPage()) {
2687 $del_array[] = $page;
2689 foreach ($del_array as $page) {
2693 $rest = $this->getPages($query, array(
2696 'only_active' =>
false,
2699 $msg = $GLOBALS[
'auth']->translate(
"Der Papierkorb wurde geleert.");
2700 $z = $rest->numRecords();
2702 $msg.=
"<br />".$GLOBALS[
'auth']->translate(
"%z Seiten können wegen mangelnder Berechtigung nicht gelöscht werden oder werden beim nächsten Liveabgleich gelöscht.");
2703 $msg = str_replace(
'%z', $z, $msg);
2705 $msg = str_replace(
'%z', $z, $msg);
2716 $cache_key =
'pageClasses';
2717 if (empty($this->_classes)) {
2718 $this->_classes = $this->getCacheEntry($cache_key);
2720 if ($this->_classes === null || !isset($this->_classes[$type])) {
2721 if (!is_array($this->_classes)) {
2722 $this->_classes = array();
2724 $this->_classes[$type] = $this->_getPageClass($type);
2725 $this->setCacheEntry($cache_key, $this->_classes);
2728 if (!class_exists($this->_classes[$type][
'class'],
false) && !empty($this->_classes[$type][
'file'])) {
2729 $file = $GLOBALS[
'egotec_conf'][
'egotec_dir'].ltrim($this->_classes[$type][
'file'], DIRECTORY_SEPARATOR);
2730 require_once($file);
2732 return $this->_classes[$type][
'class'];
2742 private function _getPageClass($type) {
2743 $prefix =
'Page' . ($this->conf[
'page'][
'prefix'] ??
'');
2747 foreach (explode(
'/', $type) as $part) {
2748 $class .= ucfirst($part);
2752 if ($file = $this->getSiteFile($type.
'/page.php', array(
'module'),
true,
true)) {
2753 return array(
'file' => $file,
'class' => $class);
2757 $class =
'Page' . ucfirst($this->name);
2758 if ($file = $this->getSiteFile(
'page.php', array(
'module',
'global',
'parent_theme'),
true,
true)) {
2759 return array(
'file' => $file,
'class' => $class);
2764 $class =
'Page' . ucfirst($this->theme);
2765 if ($file = $this->getSiteFile(
'page.php', array(
'custom',
'global',
'system',
'module',
'parent_custom'),
true,
true)) {
2766 return array(
'file' => $file,
'class' => $class);
2771 $class =
'PageGlobal';
2772 if ($file = $this->getSiteFile(
'page.php', array(
'custom',
'system',
'module'),
true,
true)) {
2773 return array(
'file' => $file,
'class' => $class);
2777 return array(
'file' =>
'',
'class' =>
'Page');
2789 $this->removeLinks($language);
2790 if (empty($language)) {
2791 $languages = $this->getLanguages();
2793 $languages = array($language);
2797 'only_active' =>
false,
2801 foreach ($this->getPages(array(), $params) as $page) {
2802 foreach ($languages as $lang) {
2803 if ($lang_page = $page->getLanguagePage($lang, $params)) {
2807 $lang_page->updateLinks(
false);
2824 if($this->site[
'type'] !=
'media') {
2825 echo
"Is not a media site\n";
2829 if ($GLOBALS[
'egotec_conf'][
'openoffice'][
'active'] != 1) {
2830 echo
"index is not active\n";
2834 require_once(
'openoffice/openoffice.php');
2837 $old_file = $GLOBALS[
'egotec_conf'][
'log_dir'].$this->name;
2838 $new_file = $GLOBALS[
'egotec_conf'][
'log_dir'].$this->name.
"_".$this->language;
2853 $addFile =
function($path, $entry) use (&$files) {
2854 if($entry[0] ===
'.') {
2858 if(preg_match(
'/_/', $entry)) {
2861 $files[$entry] = filemtime($path.
'/'.$entry).
' '.$entry;
2864 $path = $GLOBALS[
'egotec_conf'][
'var_dir'] .
'media/' . $this->name;
2873 while (
false !== ($entry = $d->read())) {
2874 if (!is_dir($d->path.
'/'.$entry)) {
2875 $addFile($d->path, $entry);
2882 $d = dir($d->path.
'/'.$this->language);
2883 while (
false !== ($_entry = $d->read())) {
2884 $files[$this->language.
'/'.$_entry] = filemtime($d->path.
'/'.$_entry).
' '.$this->language.
'/'.$_entry;
2890 $startTime = time();
2893 foreach($files as $entry => $fileTime) {
2894 if($resume && $fileTime <= $position) {
2898 $timeRound = strtok($fileTime,
' ');
2902 echo
"[Fs ] $entry ".date(
"Y-m-d H:i:s", $timeRound).
"\n";
2906 $id = preg_replace(
'/^[^\d]+/',
'', $entry);
2907 if (!is_numeric($id)) {
2911 $page = $this->getPage($id, array(
'inactive' => 1,
'auth_or' =>
'1=1'));
2913 echo
"[F] $id not found in DB\n";
2917 echo
"[DS ] ".$entry.
" ".date(
"Y-m-d H:i:s", $timeRound).
"\n";
2919 $extra = $page->extra;
2920 $mime_type = $extra[
'mime_type'];
2921 $file_ext = $extra[
'image_type'];
2923 if (!empty($mime_type)) {
2924 if (!empty($file_ext)) {
2931 # nur Dateien vom Type ^application oder text... versuchen zu importieren 2932 if (!preg_match(
'/^application|text/', $mime_type)) {
2936 if (empty($file_ext)) {
2937 if (!$GLOBALS[
'mime2ext']) {
2941 $file_ext = $GLOBALS[
'mime2ext'][$mime_type];
2944 $content = convert_content($path .
'/' . $entry, $file_ext, $mime_type);
2945 if(!empty($content)) {
2949 $page->update(array(
2954 }
catch(Exception $e) {
2955 echo
"f] " . $e->getMessage() .
"\n";
2956 Ego_System::file_put_contents($new_file.
"/index_error.log", date(
"Y-m-d H:i:s").
" Datei: $entry (".$page->field[
"name"].
"), Datenbankupdate fehlgeschlagen\n", FILE_APPEND);
2959 Ego_System::file_put_contents($new_file.
"/index.log", date(
"Y-m-d H:i:s").
" $entry (".$page->field[
"name"].
".".$extra[
'image_type'].
") [".strlen($content).
"]\n", FILE_APPEND);
2964 echo
"[FCf] $entry (mime_type: $mime_type)\n";
2965 Ego_System::file_put_contents($new_file.
"/index_error.log", date(
"Y-m-d H:i:s").
" Datei: $entry (".$page->field[
"name"].
".".$extra[
'image_type'].
"), konnte nicht konvertiert werden\n", FILE_APPEND);
2972 if ($timeout && time() - $startTime > $timeout) {
2977 $this->clearCache();
2978 echo $this->name.
"_".$this->language.
" Cache cleared.\n";
2988 $db = new_db_connection();
2992 'table' =>
'egotec_links',
2993 'where' =>
'src_site = :site AND src_lang = :lang',
2995 'site' => $this->name,
3001 'table' =>
'egotec_links',
3002 'where' =>
'src_site = :site',
3004 'site' => $this->name
3018 $db = new_db_connection();
3022 'table' =>
'egotec_url',
3023 'where' =>
'site = :site AND lang = :lang',
3025 'site' => $this->name,
3031 'table' =>
'egotec_url',
3032 'where' =>
'site = :site',
3034 'site' => $this->name
3051 $this->removeUrls($this->language);
3053 if ($root = $this->getRoot(array(
3056 'only_active' =>
false 3058 $root->updateUrls($verbose,
true);
3059 $this->clearCache();
3069 if ($this->site[
'type'] ==
'media') {
3070 return $this->getPages(array(
3071 'join' => array(
'egotec_links ON (' 3072 .
' egotec_links.dest_site = :site' 3073 .
' AND egotec_links.dest_lang = :lang' 3074 .
' AND id = egotec_links.dest_id)'),
3075 'where' =>
"egotec_links.src_id IS NULL" 3077 .
" AND type IN ('multimedia/file', 'multimedia/image')",
3079 'site' => $this->name,
3080 'lang' => $this->language
3085 'only_active' =>
false,
3088 } elseif ($media = $this->getMediaSite()) {
3089 return $media->getUnusedPages();
3116 if ($media = $this->getMediaSite()) {
3117 $pages = $media->getPages([
3118 'fields' => $media->pageTable.
'.*, egotec_links.src_id',
3120 'egotec_links ON ' . $media->pageTable .
'.id = egotec_links.dest_id' 3122 'where' =>
'src_site = :src_site AND src_lang = :src_lang AND dest_site = :dest_site',
3124 'src_site' => $this->name,
3125 'src_lang' => $this->language,
3126 'dest_site' => $media->name
3129 foreach ($pages as $page) {
3130 if ($page->extra[
'copyright'] !== null) {
3131 $key = md5(mb_strtolower($page->extra[
'copyright']));
3133 if (!isset($copyrights[$key])) {
3134 $copyrights[$key] = [
3135 'title' => $page->extra[
'copyright'],
3140 $identity = $page->getIdentity();
3141 if (!isset($copyrights[$key][
'pages'][$identity])) {
3142 $copyrights[$key][
'pages'][$identity] = [
3149 if ($link = $this->getPage($page->field[
'src_id'])) {
3150 $copyrights[$key][
'pages'][$identity][
'linked'][] = $link;
3157 if ($this->admin[
'mediapool'][
'active']) {
3158 $pages = $this->getPages();
3159 foreach ($pages as $page) {
3160 foreach ($page->getMediapool()->list() as $item) {
3161 if ($item[
'copyright']) {
3162 $key = md5(mb_strtolower($item[
'copyright']));
3164 if (!isset($copyrights[$key])) {
3165 $copyrights[$key] = [
3166 'title' => $item[
'copyright'],
3171 $identity = $item[
'name'];
3172 if (!isset($copyrights[$key][
'pages'][$identity])) {
3173 $copyrights[$key][
'pages'][$identity] = [
3180 $copyrights[$key][
'pages'][$identity][
'linked'][] = $page;
3186 usort($copyrights,
function($a, $b) {
3187 return strcmp($a[
'title'], $b[
'title']);
3189 return array_values($copyrights);
3204 public function getTemplate($mobile =
false, $name =
'index', $dir =
'', $variant =
'', $suffix =
'', $fallback =
true) {
3205 if (empty($suffix)) {
3206 $suffix = $_SERVER[
'REQUEST_SUFFIX'];
3208 $key =
'template'.md5(serialize(array($this->skin, $mobile, $name, $dir, $variant, $suffix, $fallback)));
3209 $template = $this->getCacheEntry($key);
3210 if ($template === null) {
3213 if (!empty($variant)) {
3214 $variant =
".{$variant}";
3216 if ($suffix ==
'.htm') {
3220 $suffix = !in_array($suffix, array(
'.html',
'.php')) ? $suffix :
'';
3221 if ($suffix && $variant == $suffix) {
3224 $base_dir = $dir ? explode(
'/', $dir)[0] :
'';
3225 foreach (array(
'.tpl',
'.html') as $file_suffix) {
3226 if (!empty($template)) {
3229 $file = $mobile ? $name . $variant .
'.mobile' . $suffix . $file_suffix : $name . $variant . $suffix . $file_suffix;
3235 && ($template_file = $this->getSkinFile($base_dir .
'/' . $name . $variant . $file_suffix))
3237 $template = $template_file;
3239 ($dir && ($template_file = $this->getSkinFile($dir .
'/' . $file)))
3240 || ($template_file = $this->getSkinFile($file))
3242 $template = $template_file;
3243 } elseif ($suffix !=
'') {
3244 $file = $mobile ? $name . $variant .
'.mobile' . $suffix . $file_suffix : $name . $variant . $suffix . $file_suffix;
3246 ($dir && ($template_file = $this->getSkinFile($dir .
'/' . $file)))
3247 || ($template_file = $this->getSkinFile($file))
3249 $template = $template_file;
3254 if (empty($template)) {
3257 $template = $this->getTemplate(
false, $name, $dir, $variant, $suffix, $fallback);
3258 } elseif ($variant !=
'' && $suffix !=
'') {
3260 $template = $this->getTemplate(
false, $name, $dir,
'', $suffix, $fallback);
3261 } elseif ($fallback) {
3263 if ($suffix !=
'') {
3265 return $this->getTemplate($mobile, $name, $dir, $variant,
'.html');
3266 } elseif ($variant !=
'') {
3268 return $this->getTemplate($mobile, $name, $dir,
'',
'.html');
3269 } elseif ($name ==
'body') {
3270 $template_file = $GLOBALS[
'egotec_conf'][
'lib_dir'] .
'type/skin/page/body.html';
3272 $template = $template_file;
3277 if (empty($template) && $fallback) {
3280 $this->setCacheEntry($key, $template);
3295 public function getSkinFile($path, $skip = array(
'module'), $url =
false, $relative =
false) {
3296 if (!$this->globalAllowed() && !in_array(
'global', $skip)) {
3313 public function getSiteFile($path, $skip = array(
'module'), $url =
false, $relative =
false) {
3315 !$this->globalAllowed() && !in_array(
'global', $skip)
3334 return $this->getSkinFile($path, array(
'module'),
true);
3336 return $this->getSiteFile($path, array(
'module'),
true);
3349 $key =
'variant'.md5(serialize(array($path, $skip)));
3350 $variants = $this->getCacheEntry($key);
3351 if ($variants === null) {
3353 $this->setCacheEntry($key, $variants);
3367 $key =
'layout'.md5(serialize(array($path, $skip)));
3368 $layouts = $this->getCacheEntry($key);
3369 if ($layouts === null) {
3370 $layouts = array_merge(
3372 $path !=
'' ?
Ego_System::getFiles(
'skin', $this->skin, $path.
'/layouts/*.tpl', $skip, $this->theme,
false,
false) : array()
3374 $layouts = array(
'default' => $layouts[
'_empty']) + $layouts;
3376 $conf = $this->conf[
'layouts'];
3378 if (!empty($conf)) {
3379 foreach ($layouts as $layout => $title) {
3380 if (!empty($conf[$layout][
'title'])) {
3381 $layouts[$layout] = $GLOBALS[
'auth']->translate($conf[$layout][
'title']);
3385 unset($layouts[
'_empty']);
3386 $this->setCacheEntry($key, $layouts);
3399 $key =
'block'.md5(serialize(array($path, $skip)));
3400 $blocks = $this->getCacheEntry($key);
3401 if ($blocks === null) {
3402 $blocks = array_merge(
3404 $path !=
'' ?
Ego_System::getFiles(
'skin', $this->skin, $path.
'/blocks/*.tpl', $skip, $this->theme,
false,
false) : array()
3406 $this->setCacheEntry($key, $blocks);
3417 $templates = array();
3418 $template_dirs = array(
3419 array($GLOBALS[
'egotec_conf'][
'skin_dir'].$this->skin.
'/blocks/', $GLOBALS[
'egotec_conf'][
'url_dir'].
'skin/'.$this->skin.
'/blocks/'),
3420 $this->globalAllowed() ? array($GLOBALS[
'egotec_conf'][
'skin_dir'].
'_global/blocks/', $GLOBALS[
'egotec_conf'][
'url_dir'].
'skin/_global/blocks/') : array()
3423 $template_dirs[] = array($GLOBALS[
'egotec_conf'][
'pub_dir'].
"theme/{$this->theme}/skin/blocks/", $GLOBALS[
'egotec_conf'][
'url_dir'].
"pub/theme/{$this->theme}/skin/blocks/");
3425 foreach ($template_dirs as $template_dir) {
3428 $dir = dir($template_dir[0]);
3429 while (($file = $dir->read()) !==
false) {
3431 !in_array($file, array(
'.',
'..'))
3432 && preg_match(
'/^(.*?)\.html$/i', $file, $match)
3438 $url = $template_dir[1].$file;
3445 $description = preg_replace(
'/(\r\n|\r|\n|\t)/msi',
'', strip_tags($description));
3446 $description = str_replace(
"'",
"\'", $description);
3449 $templates[] = array(
3452 'description' => $description
3470 !$GLOBALS[
'egotec_conf'][
'liveserver']
3471 && $this->admin[
'live'][
'login']
3472 && $this->admin[
'live'][
'password']
3484 if (!is_numeric($weight)) {
3489 $default_counts = array(
3498 foreach ($default_counts as $key => $default_value) {
3499 $value = (!empty($this->admin[
'count'][$key]) ? (int)$this->admin[
'count'][$key] : $default_value) + $weight;
3500 $counts[$key] = $value > 0 ? $value : 1;
3512 $virtualhost = array();
3514 $virtualhosts_ini = parse_ini_file($GLOBALS[
'egotec_conf'][
'var_dir'].
'conf/virtual_hosts.ini',
true);
3515 foreach ($virtualhosts_ini as $vhost => $vdata) {
3516 if ($vdata[
'site'] == $this->name && $vdata[
'lang'] == $this->language && !array_key_exists($vhost, $virtualhost)) {
3517 $virtualhost[md5($vhost)] = array(
3518 'site' => $vdata[
'site'],
3519 'lang' => $vdata[
'lang'],
3525 if (empty($virtualhost)) {
3526 $virtualhost[md5($_SERVER[
'HTTP_HOST'].
'/')] = array(
3527 'site' => $this->site,
3528 'lang' => $this->language,
3529 'domain' => $_SERVER[
'HTTP_HOST'].
'/' 3532 return $virtualhost;
3543 require_once
'stats/Ego_Piwik.php';
3544 $piwik =
new Ego_Piwik();
3545 $piwiksites = $this->getPages(array(
3546 'where' =>
"extra LIKE '%s:5:\"piwik\"%'" 3548 $hosts = $this->getVHosts();
3550 if ($piwiksites->numRecords()) {
3551 foreach ($piwiksites as $psite) {
3552 if ($psite->extra[
'piwik']) {
3553 if ($psite->extra[
'piwik'][
'auth_token'] ==
'undefined' && $psite->extra[
'piwik'][
'red_id'] ==
'undefined') {
3554 $piwikdata = $psite->addPiwikSite();
3555 $extra = $psite->extra;
3556 $extra[
'piwik'] = $piwikdata;
3557 $psite->updateExtra($extra);
3559 if (!$psite->extra[
'piwik'][
'live_id'] && $this->hasLiveserver()) {
3560 $piwikdata = $piwik->createWebsite($psite,
true);
3561 $extra = $psite->extra;
3562 $extra[
'piwik'] = $piwikdata;
3563 $psite->updateExtra($extra);
3565 $piwik->updateSiteURLs($psite->extra[
'piwik'][
'red_id'], $hosts, $psite->extra[
'piwik'][
'live_id'], $this);
3570 $new_psite = $this->getRoot();
3571 if ($new_psite && !$new_psite->extra[
'do_not_track']) {
3572 $piwikdata = $new_psite->addPiwikSite();
3573 $extra = $new_psite->extra;
3574 $extra[
'piwik'] = $piwikdata;
3575 $new_psite->updateExtra($extra);
3588 if ($fallback && !$suffix && $GLOBALS[
'egotec_conf'][
'liveserver']) {
3589 $admin_text = $this->getAdminText(
'_live',
false);
3590 return $admin_text ? $admin_text : $this->getAdminText(
'',
false);
3592 if (!empty($this->admin[
'administration'][
'admin_text'.$suffix])) {
3594 'text' => $GLOBALS[
'auth']->translate($this->admin[
'administration'][
'admin_text'.$suffix]),
3595 'url' => (
string) $this->admin[
'administration'][
'admin_url'.$suffix]
3597 } elseif (!empty($GLOBALS[
'egotec_conf'][
'admin_text'.$suffix])) {
3599 'text' => $GLOBALS[
'auth']->translate($GLOBALS[
'egotec_conf'][
'admin_text'.$suffix]),
3600 'url' => (
string) $GLOBALS[
'egotec_conf'][
'admin_url'.$suffix]
3613 return $this->site[
'type'] ==
'content' 3614 && $this->admin[
'frontend_admin']
3619 && !$GLOBALS[
'auth']->isNobody()
3630 $db = new_db_connection();
3631 if ( in_array(get_class($db), [
"Ego_Sql_mssql",
"Ego_Sql_oci"]) ) {
3636 foreach ($this->getLanguages() as $lang) {
3637 $pageTable = $this->name.
'_'.$lang;
3639 array(
'_v',
'id', $pageTable,
'id'),
3640 array(
'_children',
'page_id', $pageTable,
'id'),
3641 array(
'_rights',
'page_id', $pageTable,
'id'),
3642 array(
'_users',
'page_id', $pageTable,
'id'),
3643 array(
'_rights',
'group_id',
'egotec_group',
'group_id'),
3644 array(
'_rights',
'role_id',
'egotec_role',
'role_id'),
3645 array(
'_users',
'user_id',
'egotec_user',
'user_id')
3648 'table' =>
"{$pageTable}{$v[0]} AS t",
3650 'join' => array(
"{$v[2]} ON t.{$v[1]} = {$v[2]}.{$v[3]}"),
3651 'where' =>
"t.{$v[1]} != '*' AND {$v[2]}.{$v[3]} IS NULL" 3667 empty($GLOBALS[
'egotec_conf'][
'liveserver'])
3669 || (($page->field[
'nav_hide']&2) == 0
3670 && $page->isPublic()))
3676 foreach ($clusters as $cluster) {
3677 $cluster_date_file = $GLOBALS[
'egotec_conf'][
'log_dir'].$this->name.
'/live.'.$this->name.
'_'.$this->language.
'.'.$cluster[
'id'].
'.date';
3680 if (!$live_date || $cluster_date > $live_date) {
3681 $live_date = $cluster_date;
3687 $live_date_file = $GLOBALS[
'egotec_conf'][
'log_dir'] . $this->name .
'/live.' . $this->name .
'_' . $this->language .
'.date';
3689 $live_date_file = $GLOBALS[
'egotec_conf'][
'log_dir'] . $this->name .
'/live.date';
3697 if (!empty($live_date) && (!$page || $page->field[
'c_date'] > $live_date)) {
3700 foreach ($this->conf[
'admin'] as $key => $values) {
3702 strpos($key,
'cron_') === 0
3703 && !empty($GLOBALS[
'egotec_conf'][$key][
'aktiv'])
3704 && !empty($GLOBALS[
'egotec_conf'][$key][
'interval'])
3705 && (!empty($values[
'live_incr'])
3706 || !empty($values[
'cluster_incr']))
3710 date(
'Y-m-d', strtotime(
'+1 day'))
3713 strpos($GLOBALS[
'egotec_conf'][$key][
'interval'],
'*') === 0
3714 && strlen($GLOBALS[
'egotec_conf'][$key][
'interval']) >= 2
3717 $n_date = substr($GLOBALS[
'egotec_conf'][$key][
'interval'], 1);
3718 list($h, $is) = explode(
':', $n_date, 2);
3719 $intervals = array();
3720 foreach (range(0, 24, $h) as $h_range) {
3721 $intervals[] = $h_range.($is ?
":{$is}" :
'');
3724 $intervals = explode(
',', $GLOBALS[
'egotec_conf'][$key][
'interval']);
3726 foreach ($intervals as $date) {
3727 list($h, $i, $s) = explode(
':', $date, 3);
3728 $time = sprintf(
'%02d:%02d:%02d', (
string) $h, (
string) $i, (
string) $s);
3729 foreach ($dates as $date) {
3730 $date =
"$date $time";
3732 $date > (!$page ? $live_date : date(
'Y-m-d H:i:s', strtotime($page->field[
'c_date'])))
3733 && $date > date(
'Y-m-d H:i:s')
3734 && (empty($next_date) || $date < $next_date)
3755 $conf = $GLOBALS[
'egotec_conf'][
'rewrite'];
3756 if ($this->conf[
'admin'][
'rewrite'][
'overwrite']) {
3757 $conf = $this->conf[
'admin'][
'rewrite'];
3758 unset($conf[
'overwrite']);
3769 $networks = array();
3772 if (!empty($this->admin[
'social'][
'facebook_page_id']) && !empty($this->admin[
'social'][
'facebook_access_token'])) {
3773 $networks[] =
'facebook';
3777 if (!empty($this->admin[
'social'][
'twitter_access_token'])) {
3778 $networks[] =
'twitter';
3790 if (empty($this->virtualHosts)) {
3793 $identity[
'site'] == $this->name
3794 && $identity[
'lang'] == $this->language
3796 $this->virtualHosts[] = (string) $virtual_host;
3800 if (empty($this->virtualHosts)) {
3802 $host = $_SERVER[
'HTTP_HOST'];
3803 if (!empty($GLOBALS[
'egotec_conf'][
'rewrite'][
'host'])) {
3804 $host = $GLOBALS[
'egotec_conf'][
'rewrite'][
'host'];
3806 $default_host = rtrim($host,
'/');
3807 if ($GLOBALS[
'egotec_conf'][
'default_site'] != $this->name) {
3808 $default_host .=
'/' . $this->name;
3810 if (
sizeof($this->getLanguages()) > 1) {
3811 if ($this->language == $this->site[
'default_language']) {
3813 $this->virtualHosts[] = $default_host;
3815 $default_host .= (strpos($default_host,
'/') ===
false ?
'/' :
'-') . $this->language;
3817 $this->virtualHosts[] = $default_host;
3820 return $this->virtualHosts;
3829 return !$GLOBALS[
'egotec_conf'][
'non_global_sites']
3830 || !in_array($this->name, explode(
',', $GLOBALS[
'egotec_conf'][
'non_global_sites']));
3840 $f = create_function(
'$c',
'return preg_replace("/[- ]/", "_", $c);');
3842 return strcasecmp($f($a[
'fullname']), $f($b[
'fullname']));
__construct($site_name='', $language='', $skin='', $only_active=true, $time='')
getAdminText($suffix='', $fallback=true)
static getVariantFiles($type, $name, $path, $skip=array(), $parent='')
getSiteFile($path, $skip=array('module'), $url=false, $relative=false)
static file_put_contents($filename, $data, $flags=0, $context=null)
static start($table='', $param=[])
getPageClass($type='page')
updateMediaIndex($resume, $c_date, $skipFirst, $dryRun, $timeout)
getLayoutFiles($path='', $skip=array(), $conf=array())
static createSite($new_site)
getSkinFile($path, $skip=array('module'), $url=false, $relative=false)
getNextReplicationDate($page=null)
isFrontendAdmin($check_rights=true)
getUploaderPage($page=null)
getFile($path, $type='skin')
static getJSON($path, $values=array(), $combine=false, $ignore=[])
updateLinks($language='', $output=false)
static file_exists($file)
getDesklets($rights=false, $trashcan=false)
getPages($query=array(), $param=array())
__call($function, $params)
getTemplate($mobile=false, $name='index', $dir='', $variant='', $suffix='', $fallback=true)
removeLinks($language='')
static getMimeTypes($ext='')
static mkdir($dir, $mode=0755, $recursive=true)
static getCluster($site=null)
getPageId($name, $param=array())
getBlockFiles($path='', $skip=array())
clearTrashcan($query=array())
static file_get_contents($filename, $utf8=true, $context=null)
setRights($rights=array())
static getFallbackFile($type, $name, $path, $skip=array('module'), $url=false, $relative=false, $parent='')
getSearchCount($weight=0)
getVariantFiles($path, $skip=array())
updateUrls($reset=false, $verbose=false)
setLanguage($language='')
static filterNonUtf8($s, $substitute="", $strict=false)
static header($header, $replace=true)
hasRightsOnId($id, $rights, $user_id=false)
setCacheEntry($key, $value)
static getFiles($type, $name, $path, $skip=array(), $parent='', $return_path=false, $get_variants=true)