1
0
mirror of https://github.com/e107inc/e107.git synced 2025-01-17 20:58:30 +01:00

Converted some sortcodes from .sc to .php

This commit is contained in:
mcfly 2009-01-08 19:28:11 +00:00
parent ddff8df497
commit 1d78c848b8
6 changed files with 240 additions and 227 deletions

View File

@ -0,0 +1,59 @@
<?php
// $Id: banner.php,v 1.1 2009-01-08 19:28:11 mcfly_e107 Exp $
function banner_shortcode($parm)
{
global $menu_pref;
$e107 = e107::getInstance();
$ret = '';
$text = '';
mt_srand ((double) microtime() * 1000000);
$seed = mt_rand(1,2000000000);
$time = time();
$query = " (banner_startdate=0 OR banner_startdate <= {$time}) AND (banner_enddate=0 OR banner_enddate > {$time}) AND (banner_impurchased=0 OR banner_impressions<=banner_impurchased)".($parm ? " AND banner_campaign='".$e107->tp->toDB($parm)."'" : '')."
AND banner_active IN (".USERCLASS_LIST.")
ORDER BY RAND($seed) LIMIT 1";
if($e107->sql->db_Select('banner', 'banner_id, banner_image, banner_clickurl', $query))
{
$row = $e107->sql->db_Fetch();
if(!$row['banner_image'])
{
return "<a href='".e_HTTP.'banner.php?'.$row['banner_id']."' rel='external'>no image assigned to this banner</a>";
}
$fileext1 = substr(strrchr($row['banner_image'], '.'), 1);
$e107->sql->db_Update('banner', 'banner_impressions=banner_impressions+1 WHERE banner_id='.(int)$row['banner_id']);
switch ($fileext1)
{
case 'swf':
return "
<object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0\" width=\"468\" height=\"60\">\n
<param name=\"movie\" value=\"".e_IMAGE_ABS."banners/".$row['banner_image']."\">\n
<param name=\"quality\" value=\"high\">\n
<param name=\"SCALE\" value=\"noborder\">\n
<embed src=\"".e_IMAGE_ABS."banners/".$row['banner_image']."\" width=\"468\" height=\"60\" scale=\"noborder\" quality=\"high\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\" type=\"application/x-shockwave-flash\"></embed>
</object>
";
break;
case 'html':
case 'js':
case 'php': // Code - may 'echo' text, or may return it as a value
$file_data = file_get_contents(e_IMAGE.'banners/'.$row['banner_image']);
return $file_data;
break;
default:
$ban_ret = "<img src='".e_IMAGE_ABS.'banners/'.$row['banner_image']."' alt='".$row['banner_clickurl']."' style='border:0' />";
break;
}
return "<a href='".e_HTTP.'banner.php?'.$row['banner_id']."' rel='external'>".$ban_ret.'</a>';
}
else
{
return '&nbsp;';
}
}
?>

View File

@ -1,48 +0,0 @@
// $Id: banner.sc,v 1.5 2007-10-08 20:10:40 e107steved Exp $
global $sql, $tp, $ns, $menu_pref;
$ret = "";
unset($text);
mt_srand ((double) microtime() * 1000000);
$seed = mt_rand(1,2000000000);
$query = " (banner_startdate=0 OR banner_startdate<=".time().") AND (banner_enddate=0 OR banner_enddate>".time().") AND (banner_impurchased=0 OR banner_impressions<=banner_impurchased)".($parm ? " AND banner_campaign='".$tp -> toDB($parm)."'" : "")."
AND banner_active IN (".USERCLASS_LIST.")
ORDER BY RAND($seed)";
if($sql -> db_Select("banner", "*", $query))
{
$row = $sql->db_Fetch();
if(!$row['banner_image'])
{
return "<a href='".e_HTTP."banner.php?".$row['banner_id']."' rel='external'>no image assigned to this banner</a>";
}
$fileext1 = substr(strrchr($row['banner_image'], "."), 1);
$sql->db_Update("banner", "banner_impressions=banner_impressions+1 WHERE banner_id='{$row['banner_id']}' ");
switch ($fileext1)
{
case 'swf' :
return "
<object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0\" width=\"468\" height=\"60\">\n
<param name=\"movie\" value=\"".e_IMAGE_ABS."banners/".$row['banner_image']."\">\n
<param name=\"quality\" value=\"high\">\n
<param name=\"SCALE\" value=\"noborder\">\n
<embed src=\"".e_IMAGE_ABS."banners/".$row['banner_image']."\" width=\"468\" height=\"60\" scale=\"noborder\" quality=\"high\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\" type=\"application/x-shockwave-flash\"></embed>
</object>
";
case 'html' :
case 'js' :
case 'php' : // Code - may 'echo' text, or may return it as a value
$file_data = file_get_contents(e_IMAGE."banners/".$row['banner_image']);
return $file_data;
default :
$ban_ret = "<img src='".e_IMAGE_ABS."banners/".$row['banner_image']."' alt='".$row['banner_clickurl']."' style='border:0' />";
}
return "<a href='".e_HTTP."banner.php?".$row['banner_id']."' rel='external'>".$ban_ret."</a>";
}
else
{
return "&nbsp;";
}

View File

@ -0,0 +1,99 @@
<?php
function custom_shortcode($parm)
{
global $pref;
$e107 = e107::getInstance();
$custom_query = explode('+', $parm);
switch($custom_query[0])
{
case 'login':
case 'login noprofile':
include_lan(e_PLUGIN.'login_menu/languages/'.e_LANGUAGE.'.php');
$ret = '';
$sep = (defined('LOGINC_SEP')) ? LOGINC_SEP : "<span class='loginc sep'>.:.</span>";
if (USER == true)
{
$ret .= "<span class='mediumtext'><span class='loginc welcome'>".LOGIN_MENU_L5." ".USERNAME."</span>&nbsp;&nbsp;&nbsp;".$sep." ";
if(ADMIN == true)
{
$ret .= "<a class='loginc admin' href='".e_ADMIN."admin.php'>".LOGIN_MENU_L11."</a> ".$sep.' ';
}
$ret .= ($custom_query[0] != 'login noprofile') ? "<a class='loginc profile' href='".e_BASE."user.php?id.".USERID."'>".LOGIN_MENU_L13."</a>\n".$sep." ":"";
$ret .= "<a class='loginc usersettings' href='" . e_BASE . "usersettings.php'>".LOGIN_MENU_L12."</a> ".$sep." <a class='loginc logout' href='".e_BASE."index.php?logout'>".LOGIN_MENU_L8."</a> ".$sep."</span>";
}
else
{
$ret .= "<form method='post' action='".e_SELF.(e_QUERY ? '?'.e_QUERY : '')."'>\n<div class='loginc_div'>\n".LOGIN_MENU_L1."<input class='tbox loginc user' type='text' name='username' size='15' value='$username' maxlength='20' />&nbsp;&nbsp;\n".LOGIN_MENU_L2."<input class='tbox loginc pass' type='password' name='userpass' size='15' value='' maxlength='20' />&nbsp;&nbsp;\n";
$ret .= ($pref['user_tracking'] == "cookie") ? "<input type='checkbox' name='autologin' value='1' />".LOGIN_MENU_L6."&nbsp;&nbsp;\n" : "";
$ret .= "<input class='button loginc' type='submit' name='userlogin' value='".LOGIN_MENU_L28."' />";
if($pref['user_reg'])
{
$ret .= "&nbsp;&nbsp;<a class='loginc signup' href='".e_SIGNUP."'>".LOGIN_MENU_L3."</a>";
}
$ret .= "</div>\n</form>";
}
return $ret;
break;
case 'search':
if(!check_class($pref['search_restrict']))
{
return '';
}
$searchflat = true;
include_once(e_PLUGIN.'search_menu/search_menu.php');
return '';
break;
case 'quote':
$qotd_file = e_BASE.'quote.txt';
if(!file_exists($qotd_file))
{
$quote = "Quote file not found ($qotd_file)";
}
else
{
$quotes = file($qotdf_file);
$quote = $e107->tp->toHTML($quotes[rand(0, count($quotes) -1 )], true);
}
return $quote;
break;
case 'language':
require_once(e_HANDLER.'file_class.php');
$fl = new e_file;
$reject = array('.','..','/','CVS','thumbs.db','*._$');
$lanlist = $fl->get_dirs(e_LANGUAGEDIR);
sort($lanlist);
$action = (e_QUERY && !$_GET['elan']) ? e_SELF.'?'.e_QUERY : e_SELF;
$lantext = "<form method='post' action='".$action."' id='langchange'>
<div><select name='sitelanguage' class='tbox' onchange=\"document.getElementById('langchange').submit()\">\n";
foreach($lanlist as $langval)
{
$langname = $langval;
$langval = ($langval == $pref['sitelanguage']) ? '' : $langval;
$selected = ($langval == USERLAN) ? "selected='selected'" : '';
$lantext .= "<option value='".$langval."' $selected>".$langname."</option>\n ";
}
$lantext .= "</select>
<input type='hidden' name='setlanguage' value='1' />
</div></form>
";
return $lantext;
break;
case 'clock':
$clock_flat = true;
include_once(e_PLUGIN.'clock_menu/clock_menu.php');
return '';
break;
case 'welcomemessage':
return $e107->tp->parseTemplate('{WMESSAGE}');
break;
}
}
?>

View File

@ -1,98 +0,0 @@
global $tp,$pref;
$ret = "";
$custom_query = explode('+', $parm);
switch($custom_query[0])
{
case "login":
case "login noprofile":
include_lan(e_PLUGIN."login_menu/languages/".e_LANGUAGE.".php");
$sep = (defined("LOGINC_SEP")) ? LOGINC_SEP : "<span class='loginc sep'>.:.</span>";
if (USER == TRUE)
{
$ret .= "<span class='mediumtext'><span class='loginc welcome'>".LOGIN_MENU_L5." ".USERNAME."</span>&nbsp;&nbsp;&nbsp;".$sep." ";
if(ADMIN == TRUE)
{
$ret .= "<a class='loginc admin' href='".e_ADMIN."admin.php'>".LOGIN_MENU_L11."</a> ".$sep." ";
}
$ret .= ($custom_query[0] != "login noprofile") ? "<a class='loginc profile' href='".e_BASE."user.php?id.".USERID."'>".LOGIN_MENU_L13."</a>\n".$sep." ":"";
$ret .= "<a class='loginc usersettings' href='" . e_BASE . "usersettings.php'>".LOGIN_MENU_L12."</a> ".$sep." <a class='loginc logout' href='".e_BASE."index.php?logout'>".LOGIN_MENU_L8."</a> ".$sep."</span>";
}
else
{
$ret .= "<form method='post' action='".e_SELF.(e_QUERY ? '?'.e_QUERY : '')."'>\n<div class='loginc_div'>\n".LOGIN_MENU_L1."<input class='tbox loginc user' type='text' name='username' size='15' value='$username' maxlength='20' />&nbsp;&nbsp;\n".LOGIN_MENU_L2."<input class='tbox loginc pass' type='password' name='userpass' size='15' value='' maxlength='20' />&nbsp;&nbsp;\n";
$ret .= ($pref['user_tracking'] == "cookie") ? "<input type='checkbox' name='autologin' value='1' />".LOGIN_MENU_L6."&nbsp;&nbsp;\n" : "";
$ret .= "<input class='button loginc' type='submit' name='userlogin' value='".LOGIN_MENU_L28."' />";
if($pref['user_reg'])
{
$ret .= "&nbsp;&nbsp;<a class='loginc signup' href='".e_SIGNUP."'>".LOGIN_MENU_L3."</a>";
}
$ret .= "</div>\n</form>";
}
return $ret;
break;
case "search":
if(!check_class($pref['search_restrict']))
{
return "";
}
$searchflat = TRUE;
include_once(e_PLUGIN."search_menu/search_menu.php");
return "";
break;
case "quote":
$qotd_file = e_BASE."quote.txt";
if(!file_exists($qotd_file))
{
$quote = "Quote file not found ($qotd_file)";
}
else
{
$quotes = file(e_BASE."quote.txt");
$quote = $tp->toHTML($quotes[rand(0, count($quotes) -1 )], TRUE);
}
return $quote;
break;
case "language":
require_once(e_HANDLER."file_class.php");
$fl = new e_file;
$reject = array('.','..','/','CVS','thumbs.db','*._$');
$lanlist = $fl->get_dirs(e_LANGUAGEDIR);
sort($lanlist);
$action = (e_QUERY && !$_GET['elan']) ? e_SELF."?".e_QUERY : e_SELF;
$lantext = "<form method='post' action='".$action."' id='langchange'>
<div><select name='sitelanguage' class='tbox' onchange=\"document.getElementById('langchange').submit()\">\n";
foreach($lanlist as $langval) {
$langname = $langval;
$langval = ($langval == $pref['sitelanguage']) ? "" : $langval;
$selected = ($langval == USERLAN) ? "selected='selected'" : "";
$lantext .= "<option value='".$langval."' $selected>".$langname."</option>\n ";
}
$lantext .= "</select>\n";
$lantext .= "<input type='hidden' name='setlanguage' value='1' />";
$lantext .= "</div></form>";
return $lantext;
break;
case "clock":
$clock_flat = TRUE;
include_once(e_PLUGIN."clock_menu/clock_menu.php");
return "";
break;
case "welcomemessage":
return $tp->parseTemplate("{WMESSAGE}");
break;
}

View File

@ -0,0 +1,82 @@
<?php
// $Id: wmessage.php,v 1.1 2009-01-08 19:28:11 mcfly_e107 Exp $
function wmessage_shortcode($parm)
{
global $e107, $e107cache, $pref;
$prefwmsc = varset($pref['wmessage_sc'], FALSE);
if (($prefwmsc && $parm == 'header') || (!$prefwmsc && ($parm !='header')) )
{ // Two places it might be invoked - allow one or the other
return;
}
if ($parm != 'force')
{
$full_url = 'news.php'; // Set a default in case
$front_qry = '';
$uc_array = explode(',', USERCLASS_LIST);
foreach ($pref['frontpage'] as $fk => $fp)
{
if (in_array($fk,$uc_array))
{
$full_url = $fp;
break;
}
}
list($front_url, $front_qry) = explode('?', $full_url.'?'); // extra '?' ensure the array is filled
}
if (strpos($front_url, 'http') === FALSE) $front_url = SITEURL.$front_url;
if (($parm == 'force') || ((e_SELF == $front_url) && (($parm == 'ignore_query') || (e_QUERY == $front_qry))))
{
// Actually want to display a welcome message here
global $ns;
if($cacheData = $e107cache->retrieve('wmessage'))
{
echo $cacheData;
return;
}
if (!defined('WMFLAG'))
{
$qry = "
SELECT * FROM #generic
WHERE gen_type ='wmessage' AND gen_intdata IN (".USERCLASS_LIST.')';
$wmessage = '';
$wmcaption = '';
if($e107->sql->db_Select_gen($qry))
{
while ($row = $e107->sql->db_Fetch())
{
$wmessage .= $e107->tp->toHTML($row['gen_chardata'], TRUE, 'BODY, defs', 'admin').'<br />';
if(!$wmcaption)
{
$wmcaption = $e107->tp->toHTML($row['gen_ip'], TRUE, 'TITLE');
}
}
}
if (isset($wmessage) && $wmessage)
{
ob_start();
if ($pref['wm_enclose'])
{
$ns->tablerender($wmcaption, $wmessage, 'wm');
}
else
{
echo ($wmcaption) ? $wmcaption.'<br />' : '';
echo $wmessage;
}
$cache_data = ob_get_flush();
$e107cache->set('wmessage', $cache_data);
}
}
}
}
?>

View File

@ -1,81 +0,0 @@
// $Id: wmessage.sc,v 1.6 2008-06-26 20:44:10 e107steved Exp $
$prefwmsc = varset($pref['wmessage_sc'], FALSE);
if (($prefwmsc && $parm == "header") || (!$prefwmsc && ($parm !='header')) )
{ // Two places it might be invoked - allow one or the other
return;
}
global $e107,$e107cache;
if ($parm != "force")
{
$full_url = 'news.php'; // Set a default in case
$front_qry = '';
$uc_array = explode(',', USERCLASS_LIST);
foreach ($pref['frontpage'] as $fk=>$fp)
{
if (in_array($fk,$uc_array))
{
$full_url = $fp;
break;
}
}
list($front_url,$front_qry) = explode("?",$full_url."?"); // extra '?' ensure the array is filled
}
if (strpos($front_url, 'http') === FALSE) $front_url = SITEURL.$front_url;
if (($parm == "force") || ((e_SELF == $front_url) && (($parm == "ignore_query") || (e_QUERY == $front_qry))))
{
// Actually want to display a welcome message here
global $sql, $pref, $tp, $ns;
if($cacheData = $e107cache->retrieve("wmessage"))
{
echo $cacheData;
return;
}
if (!defined("WMFLAG"))
{
$qry = "
SELECT * FROM #generic
WHERE gen_type ='wmessage' AND gen_intdata IN (".USERCLASS_LIST.")";
$wmessage = "";
$wmcaption = "";
if($sql->db_Select_gen($qry))
{
while ($row = $sql->db_Fetch())
{
$wmessage .= $tp->toHTML($row['gen_chardata'], TRUE, 'BODY, defs', 'admin')."<br />";
if(!$wmcaption){
$wmcaption = $tp->toHTML($row['gen_ip'], TRUE, 'TITLE');
}
}
}
if (isset($wmessage) && $wmessage)
{
ob_start();
if ($pref['wm_enclose'])
{
$ns->tablerender($wmcaption, $wmessage, "wm");
}
else
{
echo ($wmcaption) ? $wmcaption."<br />" : "";
echo $wmessage;
}
$cache_data = ob_get_flush();
$e107cache->set("wmessage", $cache_data);
}
}
}