@@ 1762-1817 (lines=56) @@ | ||
1759 | * |
|
1760 | * @return null|string |
|
1761 | */ |
|
1762 | public static function getBannerFromIdBanner($banner_id) |
|
1763 | { |
|
1764 | ###### Hack by www.stefanosilvestrini.com ###### |
|
1765 | global $xoopsConfig; |
|
1766 | $db = XoopsDatabaseFactory::getDatabaseConnection(); |
|
1767 | $bresult = $db->query('SELECT COUNT(*) FROM ' . $db->prefix('banner') . ' WHERE bid=' . $banner_id); |
|
1768 | list($numrows) = $db->fetchRow($bresult); |
|
1769 | if ($numrows > 1) { |
|
1770 | --$numrows; |
|
1771 | mt_srand((double)microtime() * 1000000); |
|
1772 | $bannum = mt_rand(0, $numrows); |
|
1773 | } else { |
|
1774 | $bannum = 0; |
|
1775 | } |
|
1776 | if ($numrows > 0) { |
|
1777 | $bresult = $db->query('SELECT * FROM ' . $db->prefix('banner') . ' WHERE bid=' . $banner_id, 1, $bannum); |
|
1778 | list($bid, $cid, $imptotal, $impmade, $clicks, $imageurl, $clickurl, $date, $htmlbanner, $htmlcode) = $db->fetchRow($bresult); |
|
1779 | if ($xoopsConfig['my_ip'] == xoops_getenv('REMOTE_ADDR')) { |
|
1780 | // EMPTY |
|
1781 | } else { |
|
1782 | $db->queryF(sprintf('UPDATE %s SET impmade = impmade+1 WHERE bid = %u', $db->prefix('banner'), $bid)); |
|
1783 | } |
|
1784 | /* Check if this impression is the last one and print the banner */ |
|
1785 | if ($imptotal == $impmade) { |
|
1786 | $newid = $db->genId($db->prefix('bannerfinish') . '_bid_seq'); |
|
1787 | $sql = sprintf('INSERT INTO %s (bid, cid, impressions, clicks, datestart, dateend) VALUES (%u, %u, %u, %u, %u, %u)', $db->prefix('bannerfinish'), $newid, $cid, $impmade, $clicks, $date, time()); |
|
1788 | $db->queryF($sql); |
|
1789 | $db->queryF(sprintf('DELETE FROM %s WHERE bid = %u', $db->prefix('banner'), $bid)); |
|
1790 | } |
|
1791 | if ($htmlbanner) { |
|
1792 | $bannerobject = $htmlcode; |
|
1793 | } else { |
|
1794 | $bannerobject = '<div align="center"><a href="' . XOOPS_URL . '/banners.php?op=click&bid=' . $bid . '" target="_blank">'; |
|
1795 | if (stristr($imageurl, '.swf')) { |
|
1796 | $bannerobject = $bannerobject |
|
1797 | . '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0" width="468" height="60">' |
|
1798 | . '<param name="movie" value="' |
|
1799 | . $imageurl |
|
1800 | . '"></param>' |
|
1801 | . '<param name="quality" value="high"></param>' |
|
1802 | . '<embed src="' |
|
1803 | . $imageurl |
|
1804 | . '" quality="high" pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="468" height="60">' |
|
1805 | . '</embed>' |
|
1806 | . '</object>'; |
|
1807 | } else { |
|
1808 | $bannerobject = $bannerobject . '<img src="' . $imageurl . '" alt="">'; |
|
1809 | } |
|
1810 | $bannerobject .= '</a></div>'; |
|
1811 | } |
|
1812 | ||
1813 | return $bannerobject; |
|
1814 | } |
|
1815 | ||
1816 | return null; |
|
1817 | } |
|
1818 | ||
1819 | /** |
|
1820 | * @param $client_id |
|
@@ 1824-1879 (lines=56) @@ | ||
1821 | * |
|
1822 | * @return string |
|
1823 | */ |
|
1824 | public static function getBannerFromIdClient($client_id) |
|
1825 | { |
|
1826 | ###### Hack by www.stefanosilvestrini.com ###### |
|
1827 | global $xoopsConfig; |
|
1828 | $db = XoopsDatabaseFactory::getDatabaseConnection(); |
|
1829 | $bresult = $db->query('SELECT COUNT(*) FROM ' . $db->prefix('banner') . ' WHERE cid=' . $client_id); |
|
1830 | list($numrows) = $db->fetchRow($bresult); |
|
1831 | if ($numrows > 1) { |
|
1832 | --$numrows; |
|
1833 | mt_srand((double)microtime() * 1000000); |
|
1834 | $bannum = mt_rand(0, $numrows); |
|
1835 | } else { |
|
1836 | $bannum = 0; |
|
1837 | } |
|
1838 | if ($numrows > 0) { |
|
1839 | $bresult = $db->query('SELECT * FROM ' . $db->prefix('banner') . ' WHERE cid=' . $client_id . ' ORDER BY rand()', 1, $bannum); |
|
1840 | list($bid, $cid, $imptotal, $impmade, $clicks, $imageurl, $clickurl, $date, $htmlbanner, $htmlcode) = $db->fetchRow($bresult); |
|
1841 | if ($xoopsConfig['my_ip'] == xoops_getenv('REMOTE_ADDR')) { |
|
1842 | // EMPTY |
|
1843 | } else { |
|
1844 | $db->queryF(sprintf('UPDATE %s SET impmade = impmade+1 WHERE bid = %u', $db->prefix('banner'), $bid)); |
|
1845 | } |
|
1846 | /* Check if this impression is the last one and print the banner */ |
|
1847 | if ($imptotal == $impmade) { |
|
1848 | $newid = $db->genId($db->prefix('bannerfinish') . '_bid_seq'); |
|
1849 | $sql = sprintf('INSERT INTO %s (bid, cid, impressions, clicks, datestart, dateend) VALUES (%u, %u, %u, %u, %u, %u)', $db->prefix('bannerfinish'), $newid, $cid, $impmade, $clicks, $date, time()); |
|
1850 | $db->queryF($sql); |
|
1851 | $db->queryF(sprintf('DELETE FROM %s WHERE bid = %u', $db->prefix('banner'), $bid)); |
|
1852 | } |
|
1853 | if ($htmlbanner) { |
|
1854 | $bannerobject = $htmlcode; |
|
1855 | } else { |
|
1856 | $bannerobject = '<div align="center"><a href="' . XOOPS_URL . '/banners.php?op=click&bid=' . $bid . '" target="_blank">'; |
|
1857 | if (stristr($imageurl, '.swf')) { |
|
1858 | $bannerobject = $bannerobject |
|
1859 | . '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0" width="468" height="60">' |
|
1860 | . '<param name="movie" value="' |
|
1861 | . $imageurl |
|
1862 | . '"></param>' |
|
1863 | . '<param name="quality" value="high"></param>' |
|
1864 | . '<embed src="' |
|
1865 | . $imageurl |
|
1866 | . '" quality="high" pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="468" height="60">' |
|
1867 | . '</embed>' |
|
1868 | . '</object>'; |
|
1869 | } else { |
|
1870 | $bannerobject = $bannerobject . '<img src="' . $imageurl . '" alt="">'; |
|
1871 | } |
|
1872 | $bannerobject .= '</a></div>'; |
|
1873 | } |
|
1874 | ||
1875 | return $bannerobject; |
|
1876 | } |
|
1877 | ||
1878 | return null; |
|
1879 | } |
|
1880 | ||
1881 | /** |
|
1882 | * @param $email |