php author Domovoy date Apr 2009 licence GPLv2 defined _VALID_MOS or d

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
<?php
/*
author: Domovoy
date: Apr 2009
licence: GPLv2
*/
defined( '_VALID_MOS' ) or die( 'Доступ запрещен' );
$par['total_empty'];
$par['layout'] ;
$par['empty_banner'];
function showBanners($par){
global $database, $toItemid, $toUrl;
echo '<div class="'.$par['class'].'">';
$nullDate = $database->getNullDate();
$now = _CURRENT_SERVER_TIME;
if($par['toSections']>-1){
$par['section_id'] = getsection_id();
if(is_array($par['section_id'])) $par['section_id'] = implode( ',', $par['section_id'] );
}
$where = " WHERE b.position=".$par['position'].
" AND (((m.menu_id=".$par['Itemid']." OR m.menu_id=0) AND (b.toItemid+".$par['toItemid'].">0))".
" OR (s.section_id IN (".$par['section_id'].") AND (b.toSections+".$par['toSections'].">0)))".
" AND b.published=1".
" AND (b.publish_up=".$database->Quote($nullDate)." OR b.publish_up<=".$database->Quote($now).")".
" AND (b.publish_down=".$database->Quote($nullDate)." OR b.publish_down>=".$database->Quote($now).")";
$query = "SELECT b.id, b.title, b.image, b.image2, b.link, b.company_id FROM (#__sidebanners AS b)".
" LEFT OUTER JOIN (#__sidebanners_menu AS m) ON b.id=m.banner_id".
" LEFT OUTER JOIN (#__sidebanners_sections AS s) ON b.id=s.banner_id".
$where.
" ORDER BY b.ordering".
" LIMIT ".$par['total'];
$database->setQuery($query);
$obj = $database->loadObjectList();
if ($database->getErrorNum()) {
echo 'error ';//.$database->stderr();
return;
}
//echo 'pos='.$par['position'].'<br />count='.count($obj).'<br />itemid='.$par['Itemid'].'<br />url='.$par['url'];
if(count($obj)) foreach($obj as $o){
echo showBanner($o, $par);
$query = "UPDATE #__sidebanners".
" SET shows=(shows+1)".
" WHERE id=".$o->id;
$database->setQuery($query);
$database->query();
if ($database->getErrorNum()) {
echo $database->stderr();
return;
}
}
echo '</div>';
}
function showBanner($obj, $par){
global $mosConfig_live_site;
$style = 'class="'.$par['banner_class'].'" style="width:'.$par['width'].'px;height:'.$par['height'].'px;"';
$html = '<div '.$style.'>';
$img_name = $obj->image;
$img_url = $mosConfig_live_site . $par['img_path'].'/'. $img_name;
if (eregi( "(\.bmp|\.gif|\.jpg|\.jpeg|\.png)$", $img_name )) {
if($obj->link !='') $link = sefRelToAbs( $obj->link );
if(isset($link)) $html.= '<a href="'.$link.'" target="_blank">';
if($obj->title !='') $alt = '" alt="'.$obj->title.'" title="'.$obj->title.'" ';
$html.= '<img src="'.$img_url . $alt . ' />';
if(isset($link)) $html.= '</a>';
} else if(eregi("\.swf$", $obj->image)){
$html.= '<embed '.$style.' src="'.$img_url.'" wmode="transparent" loop="true" type="application/x-shockwave-flash" sap="flash" sap-mode="checked" sap-type="flash" />';
}
$html .= '</div>';
return $html;
}
function getsection_id(){
global $database;
if($_REQUEST['option']=='com_content'){
if($_REQUEST['task']=='blogsection'){
return $_REQUEST['id'];
}else if($_REQUEST['task']=='blogcategory'){
$database->setQuery("SELECT section"
." FROM #__categories"
." WHERE id=".$_REQUEST['id']
." LIMIT 1"
);
return $database->loadResult();
}elseif($_REQUEST['task']=='view'){
$database->setQuery("SELECT sectionid"
." FROM #__content"
." WHERE id=".$_REQUEST['id']
." LIMIT 1"
);
return $database->loadResult();
}
}
else if($_REQUEST['option']=='com_company'){
if($_REQUEST['section']!=''){
return $_REQUEST['section'];
}else{
$database->setQuery("SELECT c.section".
" FROM (#__categories AS c)".
" INNER JOIN (#__company_categories AS cc) ON c.id=cc.category_id".
" WHERE cc.company_id=".$_REQUEST['id']
);
return $database->loadResultArray();
}
}
return 0;
}
?>