function update041() { $this->mLog->addReport(_AD_LEGACY_MESSAGE_UPDATE_STARTED); //Add Table $sqlfileInfo = $this->_mTargetXoopsModule->getInfo('sqlfile'); $dirname = $this->_mTargetXoopsModule->getVar('dirname'); $sqlfile = $sqlfileInfo[XOOPS_DB_TYPE]; $sqlfilepath = XOOPS_MODULE_PATH . '/' . $dirname . '/' . $sqlfile; require_once XOOPS_MODULE_PATH . '/legacy/admin/class/Legacy_SQLScanner.class.php'; $scanner = new Legacy_SQLScanner(); $scanner->setDB_PREFIX(XOOPS_DB_PREFIX); $scanner->setDirname($this->_mTargetXoopsModule->get('dirname')); if (!$scanner->loadFile($sqlfilepath)) { $this->mLog->addError(XCube_Utils::formatMessage(_AD_LEGACY_ERROR_SQL_FILE_NOT_FOUND, $sqlfile)); return false; } $scanner->parse(); $sqls = $scanner->getSQL(); $root = XCube_Root::getSingleton(); $db = $root->mController->getDB(); foreach ($sqls as $sql) { if (strpos($sql, '_message_users') !== false) { if (!$db->query($sql)) { $this->mLog->addError($db->error()); return false; } } } $this->mLog->addReport(_AD_LEGACY_MESSAGE_DATABASE_SETUP_FINISHED); //add table $this->updatemain(); return true; }
function executeViewIndex(&$controller, &$xoopsUser, &$render) { // // Because this action's template uses USER message catalog, load it. // $root =& $controller->mRoot; $config_handler =& xoops_gethandler('config'); $moduleConfigUser =& $config_handler->getConfigsByDirname('user'); if ($moduleConfigUser['use_ssl'] == 1 && !empty($_POST[$moduleConfigUser['sslpost_name']])) { session_id($_POST[$moduleConfigUser['sslpost_name']]); } $render->setTemplateName("legacy_misc_ssllogin.html"); $render->setAttribute("message", XCube_Utils::formatMessage(_MD_LEGACY_MESSAGE_LOGIN_SUCCESS, $xoopsUser->get('uname'))); }
function preBlockFilter() { if (LEGACY_INSTALLERCHECKER_ACTIVE == true && is_dir(XOOPS_ROOT_PATH . "/install")) { $root =& XCube_Root::getSingleton(); $root->mLanguageManager->loadModuleMessageCatalog('legacy'); $xoopsConfig = $root->mContext->mXoopsConfig; require_once XOOPS_ROOT_PATH . '/class/template.php'; $xoopsTpl = new XoopsTpl(); $xoopsTpl->assign(array('xoops_sitename' => htmlspecialchars($xoopsConfig['sitename']), 'xoops_themecss' => xoops_getcss(), 'xoops_imageurl' => XOOPS_THEME_URL . '/' . $xoopsConfig['theme_set'] . '/', 'lang_message_confirm' => XCube_Utils::formatMessage(_MD_LEGACY_MESSAGE_INSTALL_COMPLETE_CONFIRM, XOOPS_ROOT_PATH . "/install"), 'lang_message_warning' => XCube_Utils::formatMessage(_MD_LEGACY_MESSAGE_INSTALL_COMPLETE_WARNING, XOOPS_ROOT_PATH . "/install"))); $xoopsTpl->compile_check = true; // @todo filebase template with absolute file path $xoopsTpl->display(XOOPS_ROOT_PATH . '/modules/legacy/templates/legacy_install_completed.html'); exit; } }
function validateBmodule() { $bmodule = $this->get('bmodule'); if (!count($bmodule)) { $this->addErrorMessage(_AD_LEGACY_ERROR_BMODULE); } else { $handler =& xoops_gethandler('module'); foreach ($this->get('bmodule') as $mid) { $module =& $handler->get($mid); if ($mid != -1 && $mid != 0 && !is_object($module)) { $this->addErrorMessage(XCube_Utils::formatMessage(_AD_LEGACY_ERROR_OBJECTEXIST, _AD_LEGACY_LANG_BMODULE)); } } } }
function validate() { parent::validate(); // // If htmlbanner is clicked, htmlbanner is requreid. // if ($this->get('htmlbanner')) { if (strlen($this->get('htmlcode')) == 0) { $this->addErrorMessage(XCube_Utils::formatMessage(_AD_LEGACYRENDER_ERROR_REQUIRED, _AD_LEGACYRENDER_LANG_HTMLCODE)); } } else { if (strlen($this->get('imageurl')) == 0) { $this->addErrorMessage(XCube_Utils::formatMessage(_AD_LEGACYRENDER_ERROR_REQUIRED, _AD_LEGACYRENDER_LANG_IMAGEURL)); } if (strlen($this->get('clickurl')) == 0) { $this->addErrorMessage(XCube_Utils::formatMessage(_AD_LEGACYRENDER_ERROR_REQUIRED, _AD_LEGACYRENDER_LANG_CLICKURL)); } } }
function validateSmile_url() { if ($this->_mIsNew && $this->get('smile_url') == null) { $this->addErrorMessage(XCube_Utils::formatMessage(_MD_LEGACY_ERROR_REQUIRED, _AD_LEGACY_LANG_SMILE_URL)); } }
function _processReport() { if (!$this->mLog->hasError()) { $this->mLog->add(XCube_Utils::formatMessage(_AD_LEGACY_MESSAGE_UPDATING_MODULE_SUCCESSFUL, $this->_mCurrentXoopsModule->get('name'))); } else { $this->mLog->addError(XCube_Utils::formatMessage(_AD_LEGACY_ERROR_UPDATING_MODULE_FAILURE, $this->_mCurrentXoopsModule->get('name'))); } }
function _saveTargetImages(&$targetimages, $t_imgcat_id) { if (count($targetimages) == 0) { return true; } $imgcathandler =& xoops_getmodulehandler('imagecategory', 'legacy'); $t_category =& $imgcathandler->get($t_imgcat_id); $t_category_type = $t_category->get('imgcat_storetype'); $imagehandler =& xoops_getmodulehandler('image'); if (strtolower($t_category_type) == "file") { for ($i = 0; $i < count($targetimages); $i++) { $ext_pos = strrpos($targetimages[$i]['name'], '.'); if ($ext_pos === false) { continue; } $ext = strtolower(substr($targetimages[$i]['name'], $ext_pos + 1)); if (empty($this->mAllowedExts[$ext])) { continue; } $file_name = substr($targetimages[$i]['name'], 0, $ext_pos); $save_file_name = uniqid('img') . '.' . $ext; $filehandle = fopen(XOOPS_UPLOAD_PATH . '/' . $save_file_name, "w"); if (!$filehandle) { $this->_addErrorMessage(XCube_Utils::formatMessage(_AD_LEGACY_ERROR_COULD_NOT_SAVE_IMAGE_FILE, $file_name)); continue; } if (!@fwrite($filehandle, $targetimages[$i]['content'])) { $this->_addErrorMessage(XCube_Utils::formatMessage(_AD_LEGACY_ERROR_COULD_NOT_SAVE_IMAGE_FILE, $file_name)); @fclose($filehandle); continue; } @fclose($filehandle); $image =& $imagehandler->create(); $image->set('image_nicename', $file_name); $image->set('image_name', $save_file_name); $image->set('image_mimetype', $this->mAllowedExts[$ext]); $image->set('image_display', 1); $image->set('imgcat_id', $t_imgcat_id); if (!$imagehandler->insert($image)) { $this->_addErrorMessage(XCube_Utils::formatMessage(_AD_LEGACY_ERROR_COULD_NOT_SAVE_IMAGE_FILE, $file_name)); } unset($image); } //end of for } elseif (strtolower($t_category_type) == "db") { for ($i = 0; $i < count($targetimages); $i++) { $ext_pos = strrpos($targetimages[$i]['name'], '.'); if ($ext_pos === false) { continue; } $ext = strtolower(substr($targetimages[$i]['name'], $ext_pos + 1)); if (empty($this->mAllowedExts[$ext])) { continue; } $file_name = substr($targetimages[$i]['name'], 0, $ext_pos); $save_file_name = uniqid('img') . '.' . $ext; // $image =& $imagehandler->create(); $image->set('image_nicename', $file_name); $image->set('image_name', $save_file_name); $image->set('image_mimetype', $this->mAllowedExts[$ext]); $image->set('image_display', 1); $image->set('imgcat_id', $t_imgcat_id); $image->loadImageBody(); if (!is_object($image->mImageBody)) { $image->mImageBody =& $image->createImageBody(); } $image->mImageBody->set('image_body', $targetimages[$i]['content']); if (!$imagehandler->insert($image)) { $this->_addErrorMessage(XCube_Utils::formatMessage(_AD_LEGACY_ERROR_COULD_NOT_SAVE_IMAGE_FILE, $file_name)); } unset($image); } //end of for } //end of elseif return true; }
function uninstallPreferenceByOrder($order, &$module, &$log) { $handler =& xoops_gethandler('config'); $criteria = new CriteriaCompo(); $criteria->add(new Criteria('conf_modid', $module->get('mid'))); $criteria->add(new Criteria('conf_catid', 0)); $criteria->add(new Criteria('conf_order', $order)); $configArr =& $handler->getConfigs($criteria); foreach (array_keys($configArr) as $idx) { if ($handler->deleteConfig($configArr[$idx])) { $log->addReport(XCube_Utils::formatMessage("Delete preference '{0}'.", $configArr[$idx]->get('conf_name'))); } else { $log->addError(XCube_Utils::formatMessage("Could not delete preference '{0}'.", $configArr[$idx]->get('conf_name'))); } } }
function _saveSmilesImages(&$smilesimages) { if (count($smilesimages) == 0) { return true; } $smileshandler =& xoops_getmodulehandler('smiles'); for ($i = 0; $i < count($smilesimages); $i++) { $ext_pos = strrpos($smilesimages[$i]['name'], '.'); if ($ext_pos === false) { continue; } $ext = strtolower(substr($smilesimages[$i]['name'], $ext_pos + 1)); if (empty($this->mAllowedExts[$ext])) { continue; } $file_name = substr($smilesimages[$i]['name'], 0, $ext_pos); $save_file_name = uniqid('smil') . '.' . $ext; $filehandle = fopen(XOOPS_UPLOAD_PATH . '/' . $save_file_name, "w"); if (!$filehandle) { $this->_addErrorMessage(XCube_Utils::formatMessage(_AD_LEGACY_ERROR_COULD_NOT_SAVE_SMILES_FILE, $file_name)); continue; } if (!@fwrite($filehandle, $smilesimages[$i]['content'])) { $this->_addErrorMessage(XCube_Utils::formatMessage(_AD_LEGACY_ERROR_COULD_NOT_SAVE_SMILES_FILE, $file_name)); @fclose($filehandle); continue; } @fclose($filehandle); $smiles =& $smileshandler->create(); $smiles->set('code', $file_name); $smiles->set('emotion', $file_name); $smiles->set('smile_url', $save_file_name); $smiles->set('display', 1); if (!$smileshandler->insert($smiles)) { $this->_addErrorMessage(XCube_Utils::formatMessage(_AD_LEGACY_ERROR_COULD_NOT_SAVE_SMILES_FILE, $file_name)); } unset($smiles); } return true; }
/** * Check the login request through delegates, and set XoopsObject to member * property if the login is success. * * @access public */ function checkLogin() { if (!is_object($this->mRoot->mContext->mXoopsUser)) { $this->mCheckLogin->call(new XCube_Ref($this->mRoot->mContext->mXoopsUser)); $this->mRoot->mLanguageManager->loadModuleMessageCatalog('legacy'); if (is_object($this->mRoot->mContext->mXoopsUser)) { // If the current user doesn't bring to any groups, kick out him for XCL's security. $t_groups =& $this->mRoot->mContext->mXoopsUser->getGroups(); if (!is_array($t_groups)) { // exception $this->logout(); return; } else { if (count($t_groups) == 0) { // exception, too $this->logout(); return; } } // RMV-NOTIFY // Perform some maintenance of notification records $notification_handler =& xoops_gethandler('notification'); $notification_handler->doLoginMaintenance($this->mRoot->mContext->mXoopsUser->get('uid')); XCube_DelegateUtils::call("Site.CheckLogin.Success", new XCube_Ref($this->mRoot->mContext->mXoopsUser)); // // Fall back process for login success. // $url = XOOPS_URL; if (!empty($_POST['xoops_redirect']) && !strpos(xoops_getrequest('xoops_redirect'), 'register')) { $parsed = parse_url(XOOPS_URL); $url = isset($parsed['scheme']) ? $parsed['scheme'] . '://' : 'http://'; if (isset($parsed['host'])) { $url .= isset($parsed['port']) ? $parsed['host'] . ':' . $parsed['port'] . trim(xoops_getrequest('xoops_redirect')) : $parsed['host'] . trim(xoops_getrequest('xoops_redirect')); } else { $url .= xoops_getenv('HTTP_HOST') . trim(xoops_getrequest('xoops_redirect')); } } $this->executeRedirect($url, 1, XCube_Utils::formatMessage(_MD_LEGACY_MESSAGE_LOGIN_SUCCESS, $this->mRoot->mContext->mXoopsUser->get('uname'))); } else { XCube_DelegateUtils::call("Site.CheckLogin.Fail", new XCube_Ref($this->mRoot->mContext->mXoopsUser)); // // Fall back process for login fail. // $this->executeRedirect(XOOPS_URL . "/user.php", 1, _MD_LEGACY_ERROR_INCORRECTLOGIN); } } else { $this->executeForward(XOOPS_URL . '/'); } }
function _saveAvatarImages(&$avatarimages) { if (count($avatarimages) == 0) { return true; } $avatarhandler =& xoops_getmodulehandler('avatar'); for ($i = 0; $i < count($avatarimages); $i++) { $ext_pos = strrpos( $avatarimages[$i]['name'] , '.' ) ; if( $ext_pos === false ) continue ; $ext = strtolower( substr( $avatarimages[$i]['name'] , $ext_pos + 1 ) ) ; if( empty( $this->mAllowedExts[$ext] ) ) continue ; $file_name = substr( $avatarimages[$i]['name'] , 0 , $ext_pos ) ; $save_file_name = uniqid( 'savt' ) . '.' . $ext ; $filehandle = fopen( XOOPS_UPLOAD_PATH.'/'.$save_file_name , "w" ) ; if( ! $filehandle ) { $this->_addErrorMessage(XCube_Utils::formatMessage(_AD_USER_ERROR_COULD_NOT_SAVE_AVATAR_FILE, $file_name)); continue ; } if ( !@fwrite($filehandle, $avatarimages[$i]['content']) ) { $this->_addErrorMessage(XCube_Utils::formatMessage(_AD_USER_ERROR_COULD_NOT_SAVE_AVATAR_FILE, $file_name)); @fclose( $filehandle ) ; continue; }; @fclose( $filehandle ) ; $avatar =& $avatarhandler->create(); $avatar->set('avatar_name', $file_name); $avatar->set('avatar_file', $save_file_name); $avatar->set('avatar_display', 1); $avatar->set('avatar_weight', 0); $avatar->set('avatar_type', 'S'); $avatar->set('avatar_mimetype', $this->mAllowedExts[$ext]); if (!$avatarhandler->insert($avatar)) { $this->_addErrorMessage(XCube_Utils::formatMessage(_AD_USER_ERROR_COULD_NOT_SAVE_AVATAR_FILE, $file_name)); } unset($avatar); } return true; }
function validatePass() { // precondition check if (strlen($this->get('pass')) > 0 && !preg_match('/^[\x21-\x7e]+$/', $this->get('pass'))) { $this->addErrorMessage(XCube_Utils::formatMessage(_MD_USER_ERROR_INJURY, _MD_USER_LANG_PASSWORD)); $this->set('pass',null); // reset $this->set('vpass',null); } if (strlen($this->get('pass'))>0||strlen($this->get('vpass'))>0) { if($this->get('pass')!=$this->get('vpass')) { $this->addErrorMessage(_MD_USER_ERROR_PASSWORD); $this->set('pass',null); // reset $this->set('vpass',null); } } }
function validatePasswd() { if (strlen($this->get('login')) > 0 && strlen($this->get('passwd')) == 0) { $this->addErrorMessage(XCube_Utils::formatMessage(_AD_LEGACYRENDER_ERROR_REQUIRED, _AD_LEGACYRENDER_LANG_PASSWD)); } }
function validateRank() { $t_rank = $this->get('rank'); if ($t_rank > 0) { $handler =& xoops_getmodulehandler('ranks', 'user'); $rank =& $handler->get($t_rank); if (!is_object($rank)) { $this->addErrorMessage(XCube_Utils::formatMessage(_MD_USER_ERROR_INJURY, _AD_USER_LANG_RANK)); } elseif ($rank->get('rank_special') != 1) { $this->addErrorMessage(XCube_Utils::formatMessage(_MD_USER_ERROR_INJURY, _AD_USER_LANG_RANK)); } } }
/** * リダイレクトする * @param XoopsUser $xoopsUser */ public function redirect(XoopsUser $xoopsUser) { $url = $this->_getRedirectURL(); $message = XCube_Utils::formatMessage(_MD_LEGACY_MESSAGE_LOGIN_SUCCESS, $xoopsUser->get('uname')); $this->mRoot->mController->executeRedirect($url, 1, $message); }
function validate() { parent::validate(); $handler =& xoops_getmodulehandler('imagecategory', 'legacy'); $category =& $handler->get($this->get('imgcat_id')); $formFile = $this->get('image_name'); if ($formFile != null && is_object($category)) { // // Imagefile width & height check. // if ($formFile->getWidth() > $category->get('imgcat_maxwidth') || $formFile->getHeight() > $category->get('imgcat_maxheight')) { $this->addErrorMessage(XCube_Utils::formatMessage(_AD_LEGACY_ERROR_IMG_SIZE, $category->get('imgcat_maxwidth'), $category->get('imgcat_maxheight'))); } // // Check file size // if ($formFile->getFilesize() > $category->get('imgcat_maxsize')) { $this->addErrorMessage(XCube_Utils::formatMessage(_AD_LEGACY_ERROR_IMG_FILESIZE, $category->get('imgcat_maxsize'))); } } }
function _fetchImageset(&$tar, &$tplset, &$themeimages) { if (count($themeimages) == 0) { return true; } $handler =& xoops_gethandler('imageset'); $imgset =& $handler->create(); $imgset->set('imgset_name', $tplset->get('tplset_name')); $imgset->set('imgset_refid', 0); if (!$handler->insert($imgset)) { $this->_addErrorMessage(XCube_Utils::formatMessage(_AD_LEGACYRENDER_ERROR_COULD_NOT_SAVE_IMAGESET, $tplset->get('tplset_name'))); return false; } if (!$handler->linktplset($imgset->get('imgset_id'), $tplset->get('tplset_name'))) { $this->_addErrorMessage(_AD_LEGACYRENDER_ERROR_COULD_NOT_SAVE_LINKTPLSET); return false; } $handler =& xoops_gethandler('imagesetimg'); for ($i = 0; $i < count($themeimages); $i++) { if (isset($themeimages[$i]['name']) && $themeimages[$i]['name'] != '') { $image =& $handler->create(); $image->set('imgsetimg_file', $themeimages[$i]['name']); $image->set('imgsetimg_imgset', $imgset->get('imgset_id')); $image->set('imgsetimg_body', $themeimages[$i]['content'], true); if (!$handler->insert($image)) { $this->_addErrorMessage(XCube_Utils::formatMessage(_AD_LEGACYRENDER_ERROR_COULD_NOT_SAVE_IMAGE_FILE, $image->get('imgsetimg_file'))); } unset($image); } } return true; }
function _adjustModules() { $handler =& xoops_gethandler('module'); $criteria =& new CriteriaCompo(); $criteria->add(new Criteria('isactive', 0)); $criteria->add(new Criteria('hasmain', 0)); $modules =& $handler->getObjects($criteria); foreach ($modules as $module) { $module->set('isactive', 1); $handler->insert($module); $log->add(XCube_Utils::formatMessage(_MI_XUPGRADE_MESSAGE_ADJUST_MODULE_ISACTIVE, $module->get('dirname'))); } }
function validateFrom_email() { if ($this->get('is_mail') && strlen($this->get('from_email')) == 0) { $this->addErrorMessage(XCube_Utils::formatMessage(_MD_USER_ERROR_REQUIRED, _AD_USER_LANG_FROM_EMAIL)); } }