📄 langbanners.php
字号:
<?php/** * class langBanners * * A template to get you started building templates. Rename all langBanners * with the name of your plugin * * Call with {osdplugin name="langBanners" method="getSomething"} in a template * */include_once(MODOSDATE_DIR . 'modPlugin.php');class langBanners extends modPlugin { /** * The html to be displayed * * @access private */ var $html; /** * Holds the language phrases * * @access private */ var $lang; /** * Holds the configuration settings * * @access public */ var $config; /** * The name name of the plugin class. * * @access private */ var $plugin_class_name = "langBanners"; /** * The text that appears in the admin plugin list * * @access private */ var $display_name ; /** * The link text that appears on the user's menu * * @access private */ var $user_menu_text = ""; /** * Appear on users menu (true or false) * * @access private */ var $user_menu_appear = false; /** * The link text that appears on the admin's menu * * @access private */ var $admin_menu_text ; /** * Table that holds the banners * * @access private */ var $lang_banners_table = 'banners'; /** * Appear on admin's menu (true or false) * * @access private */ var $admin_menu_appear = true; /** * Constructor * * @return * @access public */ function langBanners( ) { $this->modPlugin(); $pluginDir = dirname(__FILE__).'/../'; $this->lang = $this->modLoadLang($pluginDir); $this->display_name = $this->admin_menu_text=$this->modGetLang('admin_title'); } // end of member method pluginClass /** * Does the processing to display a user page. Called from plugin.php * * @return array * @access public */ function displayPluginPage() { $this->modSmartyAssign('lang', $this->modGetLang() ); // This is what makes the template display on the page // return $this->modSmartyFetch('helloworld.tpl'); } /** * WARNING: USER IS NOT VALIDATED HERE. BE CAREFUL * Does the processing to display 100% plugin content. Called from pluginraw.php * * @return array * @access public */ function displayPluginContent() { $id = $_GET['id']; // Get the clicks // $search['id'] = $id; $row = $this->modGetRow($this->lang_banners_table, $search); $clicks = $row['clicks'] + 1; $linkurl = $row['linkurl']; // Update the clicks // $data['clicks'] = $clicks; $key['id'] = $id; $this->modEditRec($this->lang_banners_table, $data, $key); // Go to the site // header( 'location: ' . $linkurl ); } /** * Does the processing to display a admin page. Called from plugin.php * * @return array * @access public */ function displayPluginAdminPage() { $this->modSmartyAssign('lang', $this->modGetLang() ); $this->html = ''; if ( isset($_REQUEST['action']) && $_REQUEST['action'] == 'addbanner') { $this->displayAddBanner(); } elseif ( isset($_REQUEST['action']) && $_REQUEST['action'] == 'savebanner') { $this->saveBanner(); } elseif ( isset($_REQUEST['action']) && $_REQUEST['action'] == 'managebanner') { $this->manageBanner(); } elseif ( isset($_REQUEST['action']) && $_REQUEST['action'] == 'modifybanner') { $this->modifyBanner(); } else { $this->displayManageBanner(); } return $this->html; } /** * Returns the content that will appear in the left column of a page. Designed to be overridden by plugins * * @return array * @access public */ function displayLeftCol() { } /** * Returns the content that will appear in the main content area of the page. This content will appear after the existing main content. Designed to be overridden by plugins * * @return array * @access public */ function displayMain() { $banner = array(); $html = ''; $time = time(); $index = 0; $search['enabled'] = 'Y'; $search['language'] = $this->modGetLoadedLanguage(); $temp = $this->modGetAll($this->lang_banners_table, $search); if ( $temp ) { $j = 1; foreach( $temp as $index => $row ) { if ( $row['startdate'] <= $time && $row['expdate'] >= $time) { $banner[$j++] = $row[id]; } } $my_banner = $banner[ rand( 1, --$j ) ]; $bsearch['id'] = $my_banner; $bdata = $this->modGetRow($this->lang_banners_table, $bsearch); $bdata['bannerurl'] = stripslashes( $bdata['bannerurl'] ); $this->modSmartyAssign('data', $bdata ); $this->modSmartyAssign('bannerdir', $this->modSiteUrl() . 'banners/' ); $html .= $this->modSmartyFetch('banner.tpl'); } return $html; } function modifyBanner() { $err = false; if( $_POST['txtlinkurl'] == '' ) { $err = $this->lang['link_blank']; } if ( ! $err ) { /// Start Date $sdd = $_POST['txtstartDay']; $smm = $_POST['txtstartMonth']; $syy = $_POST['txtstartYear']; $startdate = mktime(0,0,0,$smm,$sdd,$syy,0); /// Expity Date $edd = $_POST['txtendDay']; $emm = $_POST['txtendMonth']; $eyy = $_POST['txtendYear']; $expirydate = mktime(0,0,0,$emm,$edd,$eyy,0); $linkurl = $_POST['txtlinkurl']; $tooltip = addslashes( $_POST['txttooltip'] ); $bannerlink = ''; $imgsize = ''; $fname = ''; if ( $_FILES['txtbanner'] ) { if( is_uploaded_file( $_FILES['txtbanner']['tmp_name'] ) ) { $imgw = 0; $imgh = 0; $ext = split( "/", $_FILES['txtbanner']['type'] ); $size = getimagesize( $_FILES['txtbanner']['tmp_name'] ); if($ext[1] == 'pjpeg' || $ext[1]=='jpeg'){ $imgw = $size[0]; $imgh = $size[1]; $ext[1] = 'jpg'; $imgsize = $imgw . ' x ' . $imgh; } elseif( $ext[1] == 'x-shockwave-flash' ){ $ext[1] = 'swf'; } elseif( $ext[1] == 'gif' ){ $imgw = $size[0]; $imgh = $size[1]; $ext[1] = 'gif'; $imgsize = $imgw . ' x ' . $imgh; } else { $err = $this->lang['banner_wrong_type']; } if ( ! $err ) { $fname = 'langBanner'.$_POST['txtid'] . '.' . $ext[1]; $real_path = BANNER_DIR; if( $HTTP_ENV_VARS["OS"] == 'Windows_NT'){ $real_path= str_replace("\\","\\\\",$real_path); $file = $real_path."\\".$fname; } else { $file = $real_path."/".$fname; } copy( $_FILES['txtbanner']['tmp_name'], $file); } }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -