Changeset 528 for trunk/banners.php
- Timestamp:
- Feb 23, 2013, 10:44:42 AM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/banners.php
r514 r528 3 3 include('includes/global.php'); 4 4 5 function ParentWebs($Selected)5 function SelectParentItem($Selected, $Self) 6 6 { 7 7 global $System; … … 14 14 $DbResult = $System->Database->select('Referrer', '`Id`, `Web`', 'Parent IS NULL'); 15 15 while($Language = $DbResult->fetch_assoc()) 16 if($Language['Id'] != $Self) 16 17 { 17 18 $Output .= '<option value="'.$Language['Id'].'"'; … … 24 25 } 25 26 26 $MonthAge = 3; 27 function PromotionShow() 28 { 29 global $System, $User; 30 31 $MonthAge = 3; 32 $YesNo = array('Ne', 'Ano'); 33 $Banner = '<a href="http://'.$System->Config['Web']['Host'].$System->Link('/').'"><img src="http://'.$System->Config['Web']['Host'].$System->Link('/banners/wowpreklad_big.jpg').'" '. 34 'alt="wowpreklad" title="Otevřený projekt překládání celé hry World of Warcraft" '. 35 'class="banner" height="60" width="468" /></a>'; 36 37 $BannerSmall = '<a href="http://'.$System->Config['Web']['Host'].$System->Link('/').'"><img src="http://'.$System->Config['Web']['Host'].$System->Link('/banners/wowpreklad_small.jpg').'" '. 38 'alt="wowpreklad" title="Otevřený projekt překládání celé hry World of Warcraft" '. 39 'class="banner" height="31" width="88" /></a>'; 27 40 28 $Banner = '<a href="http://'.$System->Config['Web']['Host'].$System->Link('/').'"><img src="http://'.$System->Config['Web']['Host'].$System->Link('/banners/wowpreklad_big.jpg').'" '. 29 'alt="wowpreklad" title="Otevřený projekt překládání celé hry World of Warcraft" '. 30 'class="banner" height="60" width="468" /></a>'; 31 32 $BannerSmall = '<a href="http://'.$System->Config['Web']['Host'].$System->Link('/').'"><img src="http://'.$System->Config['Web']['Host'].$System->Link('/banners/wowpreklad_small.jpg').'" '. 33 'alt="wowpreklad" title="Otevřený projekt překládání celé hry World of Warcraft" '. 34 'class="banner" height="31" width="88" /></a>'; 35 36 $Output = '<strong>Bannery:</strong><br />'; 41 $Output = '<strong>Bannery:</strong><br />'; 37 42 38 $Output .= $Banner.' <textarea rows="2" cols="30">'.htmlspecialchars($Banner).'</textarea><br />';39 $Output .= $BannerSmall.' <textarea rows="2" cols="30">'.htmlspecialchars($BannerSmall).'</textarea><br />';43 $Output .= $Banner.' <textarea rows="2" cols="30">'.htmlspecialchars($Banner).'</textarea><br />'; 44 $Output .= $BannerSmall.' <textarea rows="2" cols="30">'.htmlspecialchars($BannerSmall).'</textarea><br />'; 40 45 41 $Output .= '<br/><strong>Servery odkazující na nás:</strong> <br />42 <div style="font-size: 10px;">Seznam je automaticky aktualizován a zobrazeny jsou servery, ze kterých přišli uživatelé během posledních třech měsíců řazený sestupně dle nejnovějších.</div><br />';46 $Output .= '<br/><strong>Servery odkazující na nás:</strong> <br /> 47 <div style="font-size: 10px;">Seznam je automaticky aktualizován a zobrazeny jsou servery, ze kterých přišli uživatelé během posledních třech měsíců řazený sestupně dle nejnovějších.</div><br />'; 43 48 44 49 45 if(!$User->Licence(LICENCE_ADMIN)) $Where = ' WHERE (`Show`=1) AND (`Parent` IS NULL)'; 46 else $Where = ''; 47 $Query = 'SELECT * FROM (SELECT *, (`Hits` + COALESCE((SELECT SUM(`Hits`) FROM '. 48 '`Referrer` AS `T1` WHERE `T1`.`Parent` = `T2`.`Id`), 0)) AS `TotalHits`, '. 49 'GREATEST(`DateLast`, COALESCE((SELECT MAX(`DateLast`) FROM '. 50 '`Referrer` AS `T1` WHERE `T1`.`Parent` = `T2`.`Id`), 0)) AS `MaxDateLast` FROM '. 51 '`Referrer` AS `T2`'.$Where.') AS `T3` '. 52 'WHERE (`T3`.`MaxDateLast` > (NOW() - INTERVAL '.$MonthAge.' MONTH))'; 50 if(!$User->Licence(LICENCE_ADMIN)) $Where = ' WHERE (`Show`=1) AND (`Parent` IS NULL)'; 51 else $Where = ''; 52 $Query = 'SELECT *, (SELECT Web FROM `Referrer` AS T4 WHERE T4.Id = T3.Parent) AS ParentName '. 53 'FROM (SELECT *, '. 54 '(`Hits` + COALESCE((SELECT SUM(`Hits`) FROM '. 55 '`Referrer` AS `T1` WHERE `T1`.`Parent` = `T2`.`Id`), 0)) AS `TotalHits`, '. 56 'GREATEST(`DateLast`, COALESCE((SELECT MAX(`DateLast`) FROM '. 57 '`Referrer` AS `T1` WHERE `T1`.`Parent` = `T2`.`Id`), 0)) AS `MaxDateLast` FROM '. 58 '`Referrer` AS `T2` '.$Where.') AS `T3` '. 59 'WHERE (`T3`.`MaxDateLast` > (NOW() - INTERVAL '.$MonthAge.' MONTH))'; 53 60 54 61 55 $DbResult = $System->Database->query('SELECT COUNT(*) FROM ('.$Query.') AS T');56 $DbRow = $DbResult->fetch_row();57 $PageList = GetPageList($DbRow[0]);62 $DbResult = $System->Database->query('SELECT COUNT(*) FROM ('.$Query.') AS T'); 63 $DbRow = $DbResult->fetch_row(); 64 $PageList = GetPageList($DbRow[0]); 58 65 59 $Output .= $PageList['Output'].60 '<table class="BaseTable">';66 $Output .= $PageList['Output']. 67 '<table class="BaseTable">'; 61 68 62 $TableColumns = array(63 array('Name' => 'Web', 'Title' => 'Adresa'),64 array('Name' => 'MaxDateLast', 'Title' => 'Naposledy'),65 array('Name' => 'TotalHits', 'Title' => 'Příchodů'),66 );67 if($User->Licence(LICENCE_ADMIN))68 {69 $TableColumns[] = array('Name' => 'Show', 'Title' => 'Viditelné');70 $TableColumns[] = array('Name' => 'Parent', 'Title' => 'Rodič');71 $TableColumns[] = array('Name' => 'Description', 'Title' => 'Komentář');72 $TableColumns[] = array('Name' => 'Action', 'Title' => 'Akce');73 } 74 $Order = GetOrderTableHeader($TableColumns, 'MaxDateLast', 1);75 $Output .= $Order['Output'];69 $TableColumns = array( 70 array('Name' => 'Web', 'Title' => 'Adresa'), 71 array('Name' => 'MaxDateLast', 'Title' => 'Naposledy'), 72 array('Name' => 'TotalHits', 'Title' => 'Příchodů'), 73 ); 74 if($User->Licence(LICENCE_ADMIN)) 75 { 76 $TableColumns[] = array('Name' => 'Show', 'Title' => 'Viditelné'); 77 $TableColumns[] = array('Name' => 'Parent', 'Title' => 'Rodič'); 78 $TableColumns[] = array('Name' => 'Description', 'Title' => 'Komentář'); 79 $TableColumns[] = array('Name' => 'Action', 'Title' => 'Akce'); 80 } 81 $Order = GetOrderTableHeader($TableColumns, 'MaxDateLast', 1); 82 $Output .= $Order['Output']; 76 83 77 $Query .= $Order['SQL'].$PageList['SQLLimit'];84 $Query .= $Order['SQL'].$PageList['SQLLimit']; 78 85 79 $DbResult = $System->Database->query($Query);80 while($Line = $DbResult->fetch_assoc())81 {82 $Output .= '<tr><td><a href="'.$Line['LastURL'].'">'.$Line['Web'].'</a></td>'.86 $DbResult = $System->Database->query($Query); 87 while($Line = $DbResult->fetch_assoc()) 88 { 89 $Output .= '<tr><td><a href="'.$Line['LastURL'].'">'.$Line['Web'].'</a></td>'. 83 90 '<td>'.HumanDate($Line['MaxDateLast']).'</td>'. 84 91 '<td>'.$Line['TotalHits'].'</td>'; … … 86 93 { 87 94 $Output .= 88 '<td>'.$Line['Show'].'</td>'.89 '<td>'.$Line['Parent'].'</td>'.90 '<td>'.$Line['Description'].'</td>'.91 '<td><a href="?action=edit&id='.$Line['Id'].'">Upravit</a></td>';95 '<td>'.$YesNo[$Line['Show']].'</td>'. 96 '<td>'.$Line['ParentName'].'</td>'. 97 '<td>'.$Line['Description'].'</td>'. 98 '<td><a href="?action=edit&id='.$Line['Id'].'">Upravit</a></td>'; 92 99 } 93 100 $Output .= '</tr>'; 101 } 102 $Output .= '</table>'; 103 $Output .= $PageList['Output']; 104 105 while($Line = $DbResult->fetch_assoc()) 106 { 107 $Output .= '<a href="'.$Line['LastURL'].'">'.$Line['Web'].'</a> '.$Line['Description'].' <br />'; 108 } 109 $Output .= $PageList['Output']; 110 return($Output); 94 111 } 95 $Output .= '</table>';96 $Output .= $PageList['Output'];97 112 98 while($Line = $DbResult->fetch_assoc()) 113 function PromotionEdit() 99 114 { 100 $Output .= '<a href="'.$Line['LastURL'].'">'.$Line['Web'].'</a> '.$Line['Description'].' <br />'; 115 global $System, $User; 116 117 if($User->Licence(LICENCE_ADMIN)) 118 { 119 if(array_key_exists('id', $_GET)) 120 { 121 $DbResult = $System->Database->select('Referrer', '*', 'Id='.$_GET['id']); 122 if($DbResult->num_rows > 0) 123 { 124 $Item = $DbResult->fetch_assoc(); 125 if($Item['Show'] == 1) $Show = ' checked '; 126 else $Show = ''; 127 $Output = '<form action="?action=editsave&id='.$_GET['id'].'" method="post"><table>'. 128 '<tr><td>Web</td><td>'.$Item['Web'].'</td></tr>'. 129 '<tr><td>Viditelné</td><td><input type="checkbox" name="Show" '.$Show.'/></td></tr>'. 130 '<tr><td>Popis</td><td><input type="text" name="Description" value="'.$Item['Description'].'"/></td></tr>'. 131 '<tr><td>Nadřazená položka</td><td>'.SelectParentItem($Item['Parent'], $Item['Id']).'</td></tr>'. 132 '<tr><td colspan="2"><input type="submit" value="Uložit"/></td></tr></table></form>'; 133 } else $Output = ShowMessage('Položka nenalezena', MESSAGE_CRITICAL); 134 } else $Output = ShowMessage('Položka nezadána', MESSAGE_CRITICAL); 135 } else $Output = ShowMessage('Nemáte oprávnění', MESSAGE_CRITICAL); 136 return($Output); 101 137 } 102 138 139 function PromotionEditSave() 140 { 141 global $System, $User; 142 143 if($User->Licence(LICENCE_ADMIN)) 144 { 145 if($_POST['Parent'] == '') $_POST['Parent'] = null; 146 $_POST['Show'] = array_key_exists('Show', $_POST); 147 $DbResult = $System->Database->update('Referrer', 'Id='.$_GET['id'], array( 148 'Show' => $_POST['Show'], 149 'Parent' => $_POST['Parent'], 'Description' => $_POST['Description'])); 150 $Output = ShowMessage('Nastavení uloženo'); 151 $Output .= PromotionShow(); 152 } else $Output = ShowMessage('Nemáte oprávnění', MESSAGE_CRITICAL); 153 return($Output); 154 } 155 156 if(array_key_exists('action', $_GET)) 157 { 158 if($_GET['action'] == 'edit') $Output = PromotionEdit(); 159 else if($_GET['action'] == 'editsave') $Output = PromotionEditSave(); 160 else $Output = PromotionShow(); 161 } else $Output = PromotionShow(); 162 103 163 ShowPage($Output); 104 164
Note:
See TracChangeset
for help on using the changeset viewer.