<commit_before><?php
    /**
     * @class  adminAdminView
     * @author NHN (<EMAIL>)
     * @brief  admin view class of admin module
     **/

    class adminAdminView extends admin {

		var $layout_list;

        /**
         * @brief Initilization
         * @return none
         **/
        function init() {

            // forbit access if the user is not an administrator
            $oMemberModel = &getModel('member');
            $logged_info = $oMemberModel->getLoggedInfo();
            if($logged_info->is_admin!='Y') return $this->stop("msg_is_not_administrator");

            // change into administration layout
            $this->setTemplatePath($this->module_path.'tpl');
            $this->setLayoutPath($this->getTemplatePath());
            $this->setLayoutFile('layout.html');

			$this->makeGnbUrl();

            // Retrieve the list of installed modules

            $db_info = Context::getDBInfo();

            Context::set('time_zone_list', $GLOBALS['time_zone']);
            Context::set('time_zone', $GLOBALS['_time_zone']);
            Context::set('use_rewrite', $db_info->use_rewrite=='Y'?'Y':'N');
            Context::set('use_sso', $db_info->use_sso=='Y'?'Y':'N');
            Context::set('use_html5', $db_info->use_html5=='Y'?'Y':'N');
            Context::set('use_spaceremover', $db_info->use_spaceremover?$db_info->use_spaceremover:'Y');//not use
            Context::set('qmail_compatibility', $db_info->qmail_compatibility=='Y'?'Y':'N');
            Context::set('use_db_session', $db_info->use_db_session=='N'?'N':'Y');
            Context::set('use_mobile_view', $db_info->use_mobile_view =='Y'?'Y':'N');
            Context::set('use_ssl', $db_info->use_ssl?$db_info->use_ssl:"none");
			Context::set('use_cdn', $db_info->use_cdn?$db_info->use_cdn:"none");
            if($db_info->http_port) Context::set('http_port', $db_info->http_port);
            if($db_info->https_port) Context::set('https_port', $db_info->https_port);

			$this->showSendEnv();
        }

		function makeGnbUrl($module = 'admin')
		{
			global $lang;
			$oAdminAdminModel = &getAdminModel('admin');
			$lang->menu_gnb_sub = $oAdminAdminModel->getAdminMenuLang();

			$oMenuAdminModel = &getAdminModel('menu');
			$menu_info = $oMenuAdminModel->getMenuByTitle('__XE_ADMIN__');

			if(is_readable($menu_info->php_file))
				include $menu_info->php_file;
			else {
				header('location:'.getNotEncodedUrl('', 'module', 'admin'));
				return;
			}

            $oModuleModel = &getModel('module');
			$moduleActionInfo = $oModuleModel->getModuleActionXml($module);
			if(is_object($moduleActionInfo->menu))
			{
				$subMenuTitle = '';
				foreach($moduleActionInfo->menu AS $key=>$value)
				{
					if($value->acts && in_array(Context::get('act'), $value->acts))
					{
						$subMenuTitle = $value->title;
						break;
					}
				}
			}

			$parentSrl = 0;
			if(is_array($menu->list))
			{
				foreach($menu->list AS $key=>$value)
				{
					$parentMenu = $value;
					if(is_array($parentMenu['list']) && count($parentMenu['list']) > 0)
					{
						foreach($parentMenu['list'] AS $key2=>$value2)
						{
							$childMenu = $value2;
							if($subMenuTitle == $childMenu['text'])
							{
								$parentSrl = $childMenu['parent_srl'];
								break;
							}
						}
					}
				}
			}

			// Admin logo, title setup
			$configObject = $oModuleModel->getModuleConfig('admin');
			$gnbTitleInfo->adminTitle = $configObject->adminTitle?$configObject->adminTitle:'XE Admin';
			$gnbTitleInfo->adminLogo = $configObject->adminLogo?$configObject->adminLogo:'modules/admin/tpl/img/xe.h1.png';

			$browserTitle = 'Dashboard';
			if($subMenuTitle) $browserTitle = $subMenuTitle;
			$browserTitle .= ' - '.$gnbTitleInfo->adminTitle;

			Context::set('subMenuTitle', $subMenuTitle);
			Context::set('gnbUrlList', $menu->list);
			Context::set('parentSrl', $parentSrl);
			Context::set('gnb_title_info', $gnbTitleInfo);
            Context::setBrowserTitle($browserTitle);
		}

		function loadSideBar()
		{
            $oModuleModel = &getModel('module');
            $installed_module_list = $oModuleModel->getModulesXmlInfo();

            $installed_modules = $package_modules = array();
            $package_idx = 0;
            foreach($installed_module_list as $key => $val) {
				if($val->category == 'migration') $val->category = 'system';
				if($val->category == 'interlock') $val->category = 'accessory';
				if($val->category == 'statistics') $val->category = 'accessory';

                if($val->module == 'admin' || !$val->admin_index_act) continue;
                // get action information
                $action_spec = $oModuleModel->getModuleActionXml($val->module);
                $actions = array();
                if($action_spec->default_index_act) $actions[] = $action_spec->default_index_act;
                if($action_spec->admin_index_act) $actions[] = $action_spec->admin_index_act;
                if($action_spec->action) foreach($action_spec->action as $k => $v) $actions[] = $k;

                $obj = null;
                $obj->category = $val->category;
                $obj->title = $val->title;
                $obj->description = $val->description;
                $obj->index_act = $val->admin_index_act;
                if(in_array(Context::get('act'), $actions)) $obj->selected = true;

                // Packages
                if($val->category == 'package') {
                    if($package_idx == 0) $obj->position = "first";
                    else $obj->position = "mid";
                    $package_modules[] = $obj;
                    $package_idx ++;
                    if($obj->selected) Context::set('package_selected',true);
                // Modules
                } else {
                    $installed_modules[] = $obj;
                }
                if($obj->selected) {
                    Context::set('selected_module_category', $val->category);
                    Context::set('selected_module_info', $val);
                }
            }
            if(count($package_modules)) $package_modules[count($package_modules)-1]->position = 'end';
            Context::set('package_modules', $package_modules);
            Context::set('installed_modules', $installed_modules);
            Context::setBrowserTitle("XE Admin Page");

			// add javascript tooltip plugin - gony
			Context::loadJavascriptPlugin('qtip');
			Context::loadJavascriptPlugin('watchinput');
		}

        /**
         * @brief Display Super Admin Dashboard
         * @return none
         **/
        function dispAdminIndex() {
            // Get statistics
            $args->date = date("Ymd000000", time()-60*60*24);
            $today = date("Ymd");

            // Member Status
			$oMemberAdminModel = &getAdminModel('member');
			$status->member->todayCount = $oMemberAdminModel->getMemberCountByDate($today);
			$status->member->totalCount = $oMemberAdminModel->getMemberCountByDate();

            // Document Status
			$oDocumentAdminModel = &getAdminModel('document');
			$status->document->todayCount = $oDocumentAdminModel->getDocumentCountByDate($today);
			$status->document->totalCount = $oDocumentAdminModel->getDocumentCountByDate();

            // Comment Status
			$oCommentModel = &getModel('comment');
			$status->comment->todayCount = $oCommentModel->getCommentCountByDate($today);
			$status->comment->totalCount = $oCommentModel->getCommentCountByDate();

            // Trackback Status
			$oTrackbackAdminModel = &getAdminModel('trackback');
			$status->trackback->todayCount = $oTrackbackAdminModel->getTrackbackCountByDate($today);
			$status->trackback->totalCount = $oTrackbackAdminModel->getTrackbackCountByDate();

            // Attached files Status
			$oFileAdminModel = &getAdminModel('file');
			$status->file->todayCount = $oFileAdminModel->getFilesCountByDate($today);
			$status->file->totalCount = $oFileAdminModel->getFilesCountByDate();

            Context::set('status', $status);

            // Latest Document
			$oDocumentModel = &getModel('document');
			$columnList = array('document_srl', 'module_srl', 'category_srl', 'title', 'nick_name', 'member_srl');
			$args->list_count = 5;;
			$output = $oDocumentModel->getDocumentList($args, false, false, $columnList);
            Context::set('latestDocumentList', $output->data);
			unset($args, $output, $columnList);

			// Latest Comment
			$oCommentModel = &getModel('comment');
			$columnList = array('comment_srl', 'module_srl', 'document_srl', 'content', 'nick_name', 'member_srl');
			$args->list_count = 5;
			$output = $oCommentModel->getNewestCommentList($args, $columnList);
			if(is_array($output))
			{
				foreach($output AS $key=>$value)
					$value->content = strip_tags($value->content);
			}
            Context::set('latestCommentList', $output);
			unset($args, $output, $columnList);

			//Latest Trackback
			$oTrackbackModel = &getModel('trackback');
			$columnList = array();
			$args->list_count = 5;
			$output =$oTrackbackModel->getNewestTrackbackList($args);
            Context::set('latestTrackbackList', $output->data);
			unset($args, $output, $columnList);

            //Retrieve recent news and set them into context
            $newest_news_url = sprintf("http://news.xpressengine.com/%s/news.php?version=%s&package=%s", _XE_LOCATION_, __ZBXE_VERSION__, _XE_PACKAGE_);
            $cache_file = sprintf("%sfiles/cache/newest_news.%s.cache.php", _XE_PATH_, _XE_LOCATION_);
            if(!file_exists($cache_file) || filemtime($cache_file)+ 60*60 < time()) {
                // Considering if data cannot be retrieved due to network problem, modify filemtime to prevent trying to reload again when refreshing administration page
                // Ensure to access the administration page even though news cannot be displayed
                FileHandler::writeFile($cache_file,'');
                FileHandler::getRemoteFile($newest_news_url, $cache_file, null, 1, 'GET', 'text/html', array('REQUESTURL'=>getFullUrl('')));
            }

            if(file_exists($cache_file)) {
                $oXml = new XmlParser();<commit_msg>issue 70 admin dashboard debug<commit_after><?php
    /**
     * @class  adminAdminView
     * @author NHN (<EMAIL>)
     * @brief  admin view class of admin module
     **/

    class adminAdminView extends admin {

		var $layout_list;

        /**
         * @brief Initilization
         * @return none
         **/
        function init() {

            // forbit access if the user is not an administrator
            $oMemberModel = &getModel('member');
            $logged_info = $oMemberModel->getLoggedInfo();
            if($logged_info->is_admin!='Y') return $this->stop("msg_is_not_administrator");

            // change into administration layout
            $this->setTemplatePath($this->module_path.'tpl');
            $this->setLayoutPath($this->getTemplatePath());
            $this->setLayoutFile('layout.html');

			$this->makeGnbUrl();

            // Retrieve the list of installed modules

            $db_info = Context::getDBInfo();

            Context::set('time_zone_list', $GLOBALS['time_zone']);
            Context::set('time_zone', $GLOBALS['_time_zone']);
            Context::set('use_rewrite', $db_info->use_rewrite=='Y'?'Y':'N');
            Context::set('use_sso', $db_info->use_sso=='Y'?'Y':'N');
            Context::set('use_html5', $db_info->use_html5=='Y'?'Y':'N');
            Context::set('use_spaceremover', $db_info->use_spaceremover?$db_info->use_spaceremover:'Y');//not use
            Context::set('qmail_compatibility', $db_info->qmail_compatibility=='Y'?'Y':'N');
            Context::set('use_db_session', $db_info->use_db_session=='N'?'N':'Y');
            Context::set('use_mobile_view', $db_info->use_mobile_view =='Y'?'Y':'N');
            Context::set('use_ssl', $db_info->use_ssl?$db_info->use_ssl:"none");
			Context::set('use_cdn', $db_info->use_cdn?$db_info->use_cdn:"none");
            if($db_info->http_port) Context::set('http_port', $db_info->http_port);
            if($db_info->https_port) Context::set('https_port', $db_info->https_port);

			$this->showSendEnv();
        }

		function makeGnbUrl($module = 'admin')
		{
			global $lang;
			$oAdminAdminModel = &getAdminModel('admin');
			$lang->menu_gnb_sub = $oAdminAdminModel->getAdminMenuLang();

			$oMenuAdminModel = &getAdminModel('menu');
			$menu_info = $oMenuAdminModel->getMenuByTitle('__XE_ADMIN__');

			if(is_readable($menu_info->php_file))
				include $menu_info->php_file;
			else {
				header('location:'.getNotEncodedUrl('', 'module', 'admin'));
				return;
			}

            $oModuleModel = &getModel('module');
			$moduleActionInfo = $oModuleModel->getModuleActionXml($module);
			if(is_object($moduleActionInfo->menu))
			{
				$subMenuTitle = '';
				foreach($moduleActionInfo->menu AS $key=>$value)
				{
					if($value->acts && in_array(Context::get('act'), $value->acts))
					{
						$subMenuTitle = $value->title;
						break;
					}
				}
			}

			$parentSrl = 0;
			if(is_array($menu->list))
			{
				foreach($menu->list AS $key=>$value)
				{
					$parentMenu = $value;
					if(is_array($parentMenu['list']) && count($parentMenu['list']) > 0)
					{
						foreach($parentMenu['list'] AS $key2=>$value2)
						{
							$childMenu = $value2;
							if($subMenuTitle == $childMenu['text'])
							{
								$parentSrl = $childMenu['parent_srl'];
								break;
							}
						}
					}
				}
			}

			// Admin logo, title setup
			$configObject = $oModuleModel->getModuleConfig('admin');
			$gnbTitleInfo->adminTitle = $configObject->adminTitle?$configObject->adminTitle:'XE Admin';
			$gnbTitleInfo->adminLogo = $configObject->adminLogo?$configObject->adminLogo:'modules/admin/tpl/img/xe.h1.png';

			$browserTitle = 'Dashboard';
			if($subMenuTitle) $browserTitle = $subMenuTitle;
			$browserTitle .= ' - '.$gnbTitleInfo->adminTitle;

			Context::set('subMenuTitle', $subMenuTitle);
			Context::set('gnbUrlList', $menu->list);
			Context::set('parentSrl', $parentSrl);
			Context::set('gnb_title_info', $gnbTitleInfo);
            Context::setBrowserTitle($browserTitle);
		}

		function loadSideBar()
		{
            $oModuleModel = &getModel('module');
            $installed_module_list = $oModuleModel->getModulesXmlInfo();

            $installed_modules = $package_modules = array();
            $package_idx = 0;
            foreach($installed_module_list as $key => $val) {
				if($val->category == 'migration') $val->category = 'system';
				if($val->category == 'interlock') $val->category = 'accessory';
				if($val->category == 'statistics') $val->category = 'accessory';

                if($val->module == 'admin' || !$val->admin_index_act) continue;
                // get action information
                $action_spec = $oModuleModel->getModuleActionXml($val->module);
                $actions = array();
                if($action_spec->default_index_act) $actions[] = $action_spec->default_index_act;
                if($action_spec->admin_index_act) $actions[] = $action_spec->admin_index_act;
                if($action_spec->action) foreach($action_spec->action as $k => $v) $actions[] = $k;

                $obj = null;
                $obj->category = $val->category;
                $obj->title = $val->title;
                $obj->description = $val->description;
                $obj->index_act = $val->admin_index_act;
                if(in_array(Context::get('act'), $actions)) $obj->selected = true;

                // Packages
                if($val->category == 'package') {
                    if($package_idx == 0) $obj->position = "first";
                    else $obj->position = "mid";
                    $package_modules[] = $obj;
                    $package_idx ++;
                    if($obj->selected) Context::set('package_selected',true);
                // Modules
                } else {
                    $installed_modules[] = $obj;
                }
                if($obj->selected) {
                    Context::set('selected_module_category', $val->category);
                    Context::set('selected_module_info', $val);
                }
            }
            if(count($package_modules)) $package_modules[count($package_modules)-1]->position = 'end';
            Context::set('package_modules', $package_modules);
            Context::set('installed_modules', $installed_modules);
            Context::setBrowserTitle("XE Admin Page");

			// add javascript tooltip plugin - gony
			Context::loadJavascriptPlugin('qtip');
			Context::loadJavascriptPlugin('watchinput');
		}

        /**
         * @brief Display Super Admin Dashboard
         * @return none
         **/
        function dispAdminIndex() {
            // Get statistics
            $args->date = date("Ymd000000", time()-60*60*24);
            $today = date("Ymd");

            // Member Status
			$oMemberAdminModel = &getAdminModel('member');
			$status->member->todayCount = $oMemberAdminModel->getMemberCountByDate($today);
			$status->member->totalCount = $oMemberAdminModel->getMemberCountByDate();

            // Document Status
			$oDocumentAdminModel = &getAdminModel('document');
			$status->document->todayCount = $oDocumentAdminModel->getDocumentCountByDate($today);
			$status->document->totalCount = $oDocumentAdminModel->getDocumentCountByDate();

            // Comment Status
			$oCommentModel = &getModel('comment');
			$status->comment->todayCount = $oCommentModel->getCommentCountByDate($today);
			$status->comment->totalCount = $oCommentModel->getCommentCountByDate();

            // Trackback Status
			$oTrackbackAdminModel = &getAdminModel('trackback');
			$status->trackback->todayCount = $oTrackbackAdminModel->getTrackbackCountByDate($today);
			$status->trackback->totalCount = $oTrackbackAdminModel->getTrackbackCountByDate();

            // Attached files Status
			$oFileAdminModel = &getAdminModel('file');
			$status->file->todayCount = $oFileAdminModel->getFilesCountByDate($today);
			$status->file->totalCount = $oFileAdminModel->getFilesCountByDate();

            Context::set('status', $status);

            // Latest Document
			$oDocumentModel = &getModel('document');
			$columnList = array('document_srl', 'module_srl', 'category_srl', 'title', 'nick_name', 'member_srl');
			$args->list_count = 5;;
			$output = $oDocumentModel->getDocumentList($args, false, false, $columnList);
            Context::set('latestDocumentList', $output->data);
			unset($args, $output, $columnList);

			// Latest Comment
			$oCommentModel = &getModel('comment');
			$columnList = array('comment_srl', 'module_srl', 'document_srl', 'content', 'nick_name', 'member_srl');
			$args->list_count = 5;
			$output = $oCommentModel->getNewestCommentList($args, $columnList);
			if(is_array($output))
			{
				foreach($output AS $key=>$value)
				{
					$value->content = strip_tags($value->content);
					if(!trim($value->content)) $value->content = '...';
				}
			}
            Context::set('latestCommentList', $output);
			unset($args, $output, $columnList);

			//Latest Trackback
			$oTrackbackModel = &getModel('trackback');
			$columnList = array();
			$args->list_count = 5;
			$output =$oTrackbackModel->getNewestTrackbackList($args);
            Context::set('latestTrackbackList', $output->data);
			unset($args, $output, $columnList);

            //Retrieve recent news and set them into context
            $newest_news_url = sprintf("http://news.xpressengine.com/%s/news.php?version=%s&package=%s", _XE_LOCATION_, __ZBXE_VERSION__, _XE_PACKAGE_);
            $cache_file = sprintf("%sfiles/cache/newest_news.%s.cache.php", _XE_PATH_, _XE_LOCATION_);
            if(!file_exists($cache_file) || filemtime($cache_file)+ 60*60 < time()) {
                // Considering if data cannot be retrieved due to network problem, modify filemtime to prevent trying to reload again when refreshing administration page
                // Ensure to access the administration page even though news cannot be displayed
                FileHandler::writeFile($cache_file,'');
                FileHandler::getRemoteFile($newest_news_url, $cache_file, null, 1, 'GET', 'text/html', array('REQUESTURL'=>getFullUrl('')));
            }

            if(file_exists($cache_file)) {
                $oXml = new XmlParser();
{'fraction_non_alphanumeric': 0.16105273495040753, 'fraction_numerical': 0.0031424923892762447, 'mean_word_length': 2.9280617164898746, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 267, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '801126', 'n_tokens_mistral': 6862, 'n_tokens_neox': 6028, 'n_words': 947}