/** * 모듈 설정을 불러오는 메소드. */ public function getConfig() { $config = getModel('module')->getModuleConfig('member_expire'); if (!is_object($config)) { $config = new stdClass(); } if (!$config->expire_threshold) { $config->expire_threshold = 365; } if (!$config->expire_method) { $config->expire_method = 'delete'; } if (!$config->auto_expire) { $config->auto_expire = 'N'; } if (!$config->auto_restore) { $config->auto_restore = 'N'; } if (!$config->auto_start) { $config->auto_start = '2015-08-18'; } if (!$config->email_threshold) { $config->email_threshold = 0; } if (!$config->email_subject) { $config->email_subject = strval(Context::getSiteTitle()); if ($config->email_subject !== '') { $config->email_subject = '[' . $config->email_subject . ']'; } $config->email_subject .= ' 휴면계정 전환 안내'; } if (!$config->email_content) { $config->email_content = file_get_contents($this->module_path . 'tpl/email_default.html'); } return $config; }
</a></p> <header class="header"> <h1> <a href="<?php echo geturl(''); ?> " id="siteTitle"> <?php if (!Context::getSiteTitle() && !$__Context->layout_info->LOGO_IMG && !$__Context->layout_info->LOGO_TEXT) { ?> <img src="/layouts/default/siteTitle.png" alt="XpressEngine"><?php } ?> <?php if (Context::getSiteTitle() && !$__Context->layout_info->LOGO_IMG && !$__Context->layout_info->LOGO_TEXT) { echo Context::getSiteTitle(); } ?> <?php if ($__Context->layout_info->LOGO_IMG) { ?> <img src="<?php echo $__Context->layout_info->LOGO_IMG; ?> " alt="<?php echo $__Context->layout_info->LOGO_TEXT; ?> "><?php } ?> <?php
/** * Add OpenGraph metadata tags. * * @param string $output * @return void */ function _addOpenGraphMetadata() { // Get information about the current request. $page_type = 'website'; $current_module_info = Context::get('current_module_info'); $site_module_info = Context::get('site_module_info'); $document_srl = Context::get('document_srl'); if ($document_srl) { $oDocument = Context::get('oDocument') ?: getModel('document')->getDocument($document_srl, false, false); if ($oDocument instanceof documentItem && $oDocument->document_srl == $document_srl && !$oDocument->isSecret()) { $page_type = 'article'; } } // Add basic metadata. Context::addOpenGraphData('og:title', Context::getBrowserTitle()); Context::addOpenGraphData('og:site_name', Context::getSiteTitle()); if ($page_type === 'article' && config('seo.og_extract_description')) { $description = trim(utf8_normalize_spaces($oDocument->getContentText(200))); } else { $description = Context::getMetaTag('description'); } Context::addOpenGraphData('og:description', $description); Context::addMetaTag('description', $description); // Add metadata about this page. Context::addOpenGraphData('og:type', $page_type); if ($page_type === 'article') { $canonical_url = getFullUrl('', 'mid', $current_module_info->mid, 'document_srl', $document_srl); } elseif (($page = Context::get('page')) > 1) { $canonical_url = getFullUrl('', 'mid', $current_module_info->mid, 'page', $page); } elseif ($current_module_info->module_srl == $site_module_info->module_srl) { $canonical_url = getFullUrl(''); } else { $canonical_url = getFullUrl('', 'mid', $current_module_info->mid); } Context::addOpenGraphData('og:url', $canonical_url); Context::setCanonicalURL($canonical_url); // Add metadata about the locale. $lang_type = Context::getLangType(); $locales = (include \RX_BASEDIR . 'common/defaults/locales.php'); if (isset($locales[$lang_type])) { Context::addOpenGraphData('og:locale', $locales[$lang_type]['locale']); } if ($page_type === 'article' && $oDocument->getLangCode() !== $lang_type && isset($locales[$oDocument->getLangCode()])) { Context::addOpenGraphData('og:locale:alternate', $locales[$oDocument->getLangCode()]); } // Add image. if ($page_type === 'article' && config('seo.og_extract_images')) { if (($document_images = Rhymix\Framework\Cache::get("seo:document_images:{$document_srl}")) === null) { $document_images = array(); if ($oDocument->hasUploadedFiles()) { foreach ($oDocument->getUploadedFiles() as $file) { if ($file->isvalid !== 'Y' || !preg_match('/\\.(?:bmp|gif|jpe?g|png)$/i', $file->uploaded_filename)) { continue; } list($width, $height) = @getimagesize($file->uploaded_filename); if ($width < 100 && $height < 100) { continue; } $image = array('filepath' => $file->uploaded_filename, 'width' => $width, 'height' => $height); if ($file->cover_image === 'Y') { array_unshift($document_images, $image); } else { $document_images[] = $image; } if (count($document_images) >= 1) { break; } } } Rhymix\Framework\Cache::set("seo:document_images:{$document_srl}", $document_images, 0, true); } } else { $document_images = null; } if ($document_images) { $first_image = reset($document_images); $first_image['filepath'] = preg_replace('/^.\\/files\\//', \RX_BASEURL . 'files/', $first_image['filepath']); Context::addOpenGraphData('og:image', Rhymix\Framework\URL::getCurrentDomainURL($first_image['filepath'])); Context::addOpenGraphData('og:image:width', $first_image['width']); Context::addOpenGraphData('og:image:height', $first_image['height']); } elseif ($default_image = getAdminModel('admin')->getSiteDefaultImageUrl($width, $height)) { Context::addOpenGraphData('og:image', Rhymix\Framework\URL::getCurrentDomainURL($default_image)); if ($width && $height) { Context::addOpenGraphData('og:image:width', $width); Context::addOpenGraphData('og:image:height', $height); } } // Add datetime for articles. if ($page_type === 'article' && config('seo.og_use_timestamps')) { Context::addOpenGraphData('article:published_time', $oDocument->getRegdate('c')); Context::addOpenGraphData('article:modified_time', $oDocument->getUpdate('c')); } }
/** * @brief display the board conent view **/ function dispBoardContentView() { // get the variable value $document_srl = Context::get('document_srl'); $page = Context::get('page'); // generate document model object $oDocumentModel = getModel('document'); /** * if the document exists, then get the document information **/ if ($document_srl) { $oDocument = $oDocumentModel->getDocument($document_srl, false, true); // if the document is existed if ($oDocument->isExists()) { // if the module srl is not consistent if ($oDocument->get('module_srl') != $this->module_info->module_srl) { return $this->stop('msg_invalid_request'); } // check the manage grant if ($this->grant->manager) { $oDocument->setGrant(); } // if the consultation function is enabled, and the document is not a notice if ($this->consultation && !$oDocument->isNotice()) { $logged_info = Context::get('logged_info'); if ($oDocument->get('member_srl') != $logged_info->member_srl) { $oDocument = $oDocumentModel->getDocument(0); } } // if the document is TEMP saved, check Grant if ($oDocument->getStatus() == 'TEMP') { if (!$oDocument->isGranted()) { $oDocument = $oDocumentModel->getDocument(0); } } } else { // if the document is not existed, then alert a warning message Context::set('document_srl', '', true); $this->alertMessage('msg_not_founded'); } /** * if the document is not existed, get an empty document **/ } else { $oDocument = $oDocumentModel->getDocument(0); } /** *check the document view grant **/ if ($oDocument->isExists()) { if (!$this->grant->view && !$oDocument->isGranted()) { $oDocument = $oDocumentModel->getDocument(0); Context::set('document_srl', '', true); $this->alertMessage('msg_not_permitted'); } else { // add the document title to the browser Context::setCanonicalURL($oDocument->getPermanentUrl()); $seo_title = config('seo.document_title') ?: '$SITE_TITLE - $DOCUMENT_TITLE'; getController('module')->replaceDefinedLangCode($seo_title); Context::setBrowserTitle($seo_title, array('site_title' => Context::getSiteTitle(), 'site_subtitle' => Context::getSiteSubtitle(), 'subpage_title' => $this->module_info->browser_title, 'document_title' => $oDocument->getTitleText(), 'page' => Context::get('page') ?: 1)); // update the document view count (if the document is not secret) if (!$oDocument->isSecret() || $oDocument->isGranted()) { $oDocument->updateReadedCount(); } // disappear the document if it is secret if ($oDocument->isSecret() && !$oDocument->isGranted()) { $oDocument->add('content', lang('thisissecret')); } } } Context::set('update_view', $this->grant->update_view); // setup the document oject on context $oDocument->add('module_srl', $this->module_srl); Context::set('oDocument', $oDocument); /** * add javascript filters **/ Context::addJsFilter($this->module_path . 'tpl/filter', 'insert_comment.xml'); // return new Object(); }
/** * 휴면 안내메일을 발송하는 메소드. */ public function sendEmail($member_srl, $config = null, $resend = true, $use_transaction = true) { // 회원 오브젝트를 통째로 받은 경우 member_srl을 추출한다. if (is_object($member_srl) && isset($member_srl->member_srl)) { $member = $member_srl; $member_srl = $member_srl->member_srl; } else { $args = new stdClass(); $args->member_srl = $member_srl; $member_query = executeQuery('member.getMemberInfoByMemberSrl', $args); if (!$member_query->toBool() || !$member_query->data) { return -41; } $member = is_object($member_query->data) ? $member_query->data : reset($member_query->data); if (!$member) { return -42; } $member_srl = $member->member_srl; } // 모듈 설정이 로딩되지 않은 경우 지금 로딩한다. if (!$config) { $config = $this->getConfig(); } // 이미 발송한 경우, $resend = true가 아니라면 재발송하지 않는다. $args = new stdClass(); $args->member_srl = $member_srl; $output = executeQuery('member_expire.getNotifiedDates', $args); if (!$output->toBool()) { return -43; } if (count($output->data) && !$resend) { return 2; } // 정리 예정일을 계산한다. $start_date = strtotime($config->auto_start) + zgap(); $base_date = $member->last_login ? $member->last_login : $member->regdate; $base_date = $base_date ? ztime($base_date) : 0; $expire_date = $base_date + 86400 * $config->expire_threshold; if ($expire_date < $start_date) { $expire_date = $start_date; } $member->expire_date = date('YmdHis', $expire_date); // 매크로를 변환한다. $site_title = Context::getSiteTitle(); $macros = array('{SITE_NAME}' => htmlspecialchars($site_title, ENT_QUOTES, 'UTF-8', false), '{USER_ID}' => htmlspecialchars($member->user_id, ENT_QUOTES, 'UTF-8', false), '{USER_NAME}' => htmlspecialchars($member->user_name, ENT_QUOTES, 'UTF-8', false), '{NICK_NAME}' => htmlspecialchars($member->nick_name, ENT_QUOTES, 'UTF-8', false), '{EMAIL}' => htmlspecialchars($member->email_address, ENT_QUOTES, 'UTF-8', false), '{LOGIN_DATE}' => $base_date ? date('Y년 n월 j일', $base_date) : '(로그인 기록 없음)', '{EXPIRE_DATE}' => date('Y년 n월 j일', $expire_date), '{TIME_LIMIT}' => $this->translateThreshold($config->expire_threshold), '{CLEAN_METHOD}' => $config->expire_method === 'delete' ? '삭제' : '별도의 저장공간으로 이동'); // 메일을 작성하여 발송한다. $subject = htmlspecialchars_decode(str_replace(array_keys($macros), array_values($macros), $config->email_subject)); $content = str_replace(array_keys($macros), array_values($macros), $config->email_content); $recipient_name = $member->user_name ? $member->user_name : ($member->nick_name ? $member->nick_name : 'member'); static $sender_name = null; static $sender_email = null; if ($sender_name === null) { $member_config = getModel('module')->getModuleConfig('member'); $sender_name = $member_config->webmaster_name ? $member_config->webmaster_name : ($site_title ? $site_title : 'webmaster'); $sender_email = $member_config->webmaster_email; } $oMail = new Mail(); $oMail->setTitle($subject); $oMail->setContent($content); $oMail->setSender($sender_name, $sender_email); $oMail->setReceiptor($recipient_name, $member->email_address); $oMail->send(); // 트랜잭션을 시작한다. if ($use_transaction) { $this->oDB->begin(); } // 발송한 메일을 기록한다. $output = executeQuery('member_expire.deleteNotifiedDate', $member); if (!$output->toBool()) { if ($use_transaction) { $this->oDB->rollback(); } return -44; } $output = executeQuery('member_expire.insertNotifiedDate', $member); if (!$output->toBool()) { if ($use_transaction) { $this->oDB->rollback(); } return -45; } // 트랜잭션을 커밋한다. if ($use_transaction) { $this->oDB->commit(); } return 1; }
/** * Initialization. It finds the target module based on module, mid, document_srl, and prepares to execute an action * @return boolean true: OK, false: redirected * */ public function init() { $oModuleModel = getModel('module'); $site_module_info = Context::get('site_module_info'); // if success_return_url and error_return_url is incorrect $urls = array(Context::get('success_return_url'), Context::get('error_return_url')); foreach ($urls as $url) { if (empty($url)) { continue; } if ($host = parse_url($url, PHP_URL_HOST)) { $defaultHost = parse_url(Context::getDefaultUrl(), PHP_URL_HOST); if ($host !== $defaultHost) { $siteModuleHost = $site_module_info->domain; if (strpos($siteModuleHost, '/') !== false) { $siteModuleHost = parse_url($siteModuleHost, PHP_URL_HOST); } if ($host !== $siteModuleHost) { Context::set('success_return_url', null); Context::set('error_return_url', null); } } } } if (!$this->document_srl && $this->mid && $this->entry) { $oDocumentModel = getModel('document'); $this->document_srl = $oDocumentModel->getDocumentSrlByAlias($this->mid, $this->entry); if ($this->document_srl) { Context::set('document_srl', $this->document_srl); } } // Get module's information based on document_srl, if it's specified if ($this->document_srl) { $module_info = $oModuleModel->getModuleInfoByDocumentSrl($this->document_srl); // If the document does not exist, remove document_srl if (!$module_info) { if (Context::getRequestMethod() == 'GET') { $this->error = 'The document does not exist'; $this->httpStatusCode = '404'; return true; } else { unset($this->document_srl); } } else { // If it exists, compare mid based on the module information // if mids are not matching, set it as the document's mid if (!$this->mid || $this->mid != $module_info->mid) { if (Context::getRequestMethod() == 'GET') { Context::setCacheControl(0); header('location: ' . getNotEncodedSiteUrl($site_module_info->domain, 'mid', $module_info->mid, 'document_srl', $this->document_srl), true, 301); return false; } else { $this->mid = $module_info->mid; Context::set('mid', $this->mid); } } // if requested module is different from one of the document, remove the module information retrieved based on the document number if ($this->module && $module_info->module != $this->module) { unset($module_info); } // if the secret document permission does not have, specify HTTP 403 if (Context::getRequestMethod() == 'GET') { $oDocumentModel = getModel('document'); $oDocument = $oDocumentModel->getDocument($this->document_srl); if ($oDocument->isSecret() || $oDocument->get('status') === $oDocumentModel->getConfigStatus('temp')) { if (!$oDocument->isGranted() && !$oDocument->isAccessible()) { $this->httpStatusCode = '403'; } } } } } // If module_info is not set yet, and there exists mid information, get module information based on the mid if (!$module_info && $this->mid) { $module_info = $oModuleModel->getModuleInfoByMid($this->mid, $site_module_info->site_srl); //if($this->module && $module_info->module != $this->module) unset($module_info); } // redirect, if module_site_srl and site_srl are different if (!$this->module && !$module_info && $site_module_info->site_srl == 0 && $site_module_info->module_site_srl > 0) { Context::setCacheControl(0); $site_info = $oModuleModel->getSiteInfo($site_module_info->module_site_srl); header('location: ' . getNotEncodedSiteUrl($site_info->domain, 'mid', $site_module_info->mid), true, 301); return false; } // If module_info is not set still, and $module does not exist, find the default module if (!$module_info && !$this->module && !$this->mid) { $module_info = $site_module_info; } if (!$module_info && !$this->module && $site_module_info->module_site_srl) { $module_info = $site_module_info; } // redirect, if site_srl of module_info is different from one of site's module_info if ($module_info && $module_info->site_srl != $site_module_info->site_srl && !Rhymix\Framework\UA::isRobot()) { // If the module is of virtual site if ($module_info->site_srl) { $site_info = $oModuleModel->getSiteInfo($module_info->site_srl); $redirect_url = getNotEncodedSiteUrl($site_info->domain, 'mid', Context::get('mid'), 'document_srl', Context::get('document_srl'), 'module_srl', Context::get('module_srl'), 'entry', Context::get('entry')); // If it's called from a virtual site, though it's not a module of the virtual site } else { $redirect_url = getNotEncodedSiteUrl(Context::getDefaultUrl(), 'mid', Context::get('mid'), 'document_srl', Context::get('document_srl'), 'module_srl', Context::get('module_srl'), 'entry', Context::get('entry')); } Context::setCacheControl(0); header("Location: {$redirect_url}", true, 301); return false; } // redirect, if site start module if (Context::getRequestMethod() === 'GET' && isset($_GET['mid']) && $_GET['mid'] === $site_module_info->mid && count($_GET) === 1) { Context::setCacheControl(0); header('location: ' . getNotEncodedSiteUrl($site_module_info->domain), true, 301); return false; } // If module info was set, retrieve variables from the module information if ($module_info) { $this->module = $module_info->module; $this->mid = $module_info->mid; $this->module_info = $module_info; if ($module_info->mid == $site_module_info->mid) { $seo_title = config('seo.main_title') ?: '$SITE_TITLE - $SITE_SUBTITLE'; } else { $seo_title = config('seo.subpage_title') ?: '$SITE_TITLE - $SUBPAGE_TITLE'; } getController('module')->replaceDefinedLangCode($seo_title); Context::setBrowserTitle($seo_title, array('site_title' => Context::getSiteTitle(), 'site_subtitle' => Context::getSiteSubtitle(), 'subpage_title' => $module_info->browser_title, 'page' => Context::get('page') ?: 1)); $module_config = $oModuleModel->getModuleConfig('module'); if ($module_info->meta_keywords) { Context::addMetaTag('keywords', $module_info->meta_keywords); } elseif ($module_config->meta_keywords) { Context::addMetaTag('keywords', $module_config->meta_keywords); } if ($module_info->meta_description) { Context::addMetaTag('description', $module_info->meta_description); } elseif ($module_config->meta_description) { Context::addMetaTag('description', $module_config->meta_description); } $viewType = Mobile::isFromMobilePhone() ? 'M' : 'P'; $targetSrl = Mobile::isFromMobilePhone() ? 'mlayout_srl' : 'layout_srl'; // use the site default layout. if ($module_info->{$targetSrl} == -1) { $oLayoutAdminModel = getAdminModel('layout'); $layoutSrl = $oLayoutAdminModel->getSiteDefaultLayout($viewType, $module_info->site_srl); } else { $layoutSrl = $module_info->{$targetSrl}; } // reset a layout_srl in module_info. $module_info->{$targetSrl} = $layoutSrl; $part_config = $oModuleModel->getModulePartConfig('layout', $layoutSrl); Context::addHtmlHeader($part_config->header_script); } // Set module and mid into module_info if (!isset($this->module_info)) { $this->module_info = new stdClass(); } $this->module_info->module = $this->module; $this->module_info->mid = $this->mid; // Set site_srl add 2011 08 09 $this->module_info->site_srl = $site_module_info->site_srl; // Still no module? it's an error if (!$this->module) { $this->error = 'msg_module_is_not_exists'; $this->httpStatusCode = '404'; return true; } // If mid exists, set mid into context if ($this->mid) { Context::set('mid', $this->mid, TRUE); } // Call a trigger after moduleHandler init $output = self::triggerCall('moduleHandler.init', 'after', $this->module_info); if (!$output->toBool()) { $this->error = $output->getMessage(); return true; } // Set current module info into context Context::set('current_module_info', $this->module_info); return true; }