ignore v1.4, it's quite buggy compared to 1.9.
include_once XOOPS_ROOT_PATH.'/include/functions.php';
global $xoopsConfig;
$db =& Database::getInstance();
$bannerobject = '';
$bresult = $db->query("SELECT COUNT(*) FROM ".$db->prefix("banner"));
list ($numrows) = $db->fetchRow($bresult);
if ( $numrows > 1 ) {
$numrows = $numrows-1;
mt_srand((double)microtime()*1000000);
$bannum = mt_rand(0, $numrows);
} else {
$bannum = 0;
}
if ( $numrows > 0 ) {
$bresult = $db->query("SELECT * FROM ".$db->prefix("banner"), 1, $bannum);
list ($bid, $cid, $imptotal, $impmade, $clicks, $imageurl, $clickurl, $date, $htmlbanner, $htmlcode) = $db->fetchRow($bresult);
if ($xoopsConfig['my_ip'] == xoops_getenv('REMOTE_ADDR')) {
// EMPTY
} else {
$db->queryF(sprintf("UPDATE %s SET impmade = impmade+1 WHERE bid = %u", $db->prefix("banner"), $bid));
}
/* Check if this impression is the last one and print the banner */
if ( $imptotal == $impmade ) {
$newid = $db->genId($db->prefix("bannerfinish")."_bid_seq");
$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());
$db->queryF($sql);
$db->queryF(sprintf("DELETE FROM %s WHERE bid = %u", $db->prefix("banner"), $bid));
}
if ($htmlbanner){
$bannerobject = $htmlcode;
}else{
$bannerobject = '.XOOPS_URL.'/banners.php?op=click&bid='.$bid.'" target="_blank">';
if (stristr($imageurl, '.swf')) {
$bannerobject = $bannerobject
.'.'.$imageurl.'">'
.''
.''
.'';
} else {
$bannerobject = $bannerobject.'.$imageurl.'" alt="" />';
}
$bannerobject = $bannerobject.' ';
}
echo $bannerobject;
}
DROP TABLE IF EXISTS `csmapce_dev.ithq2_users`;
CREATE TABLE `csmapce_dev.ithq2_users` (
`uid` mediumint(8) unsigned NOT NULL auto_increment,
`name` varchar(60) NOT NULL default '',
`uname` varchar(25) NOT NULL default '',
`email` varchar(60) NOT NULL default '',
`url` varchar(100) NOT NULL default '',
`user_avatar` varchar(30) NOT NULL default 'blank.gif',
`user_regdate` int(10) unsigned NOT NULL default '0',
`user_icq` varchar(15) NOT NULL default '',
`user_from` varchar(100) NOT NULL default '',
`user_sig` tinytext NOT NULL,
`user_viewemail` tinyint(1) unsigned NOT NULL default '0',
`actkey` varchar(8) NOT NULL default '',
`user_aim` varchar(18) NOT NULL default '',
`user_yim` varchar(25) NOT NULL default '',
`user_msnm` varchar(100) NOT NULL default '',
`pass` varchar(32) NOT NULL default '',
`posts` mediumint(8) unsigned NOT NULL default '0',
`attachsig` tinyint(1) unsigned NOT NULL default '0',
`rank` smallint(5) unsigned NOT NULL default '0',
`level` tinyint(3) unsigned NOT NULL default '1',
`theme` varchar(100) NOT NULL default '',
`timezone_offset` float(3,1) NOT NULL default '0.0',
`last_login` int(10) unsigned NOT NULL default '0',
`umode` varchar(10) NOT NULL default '',
`uorder` tinyint(1) unsigned NOT NULL default '0',
`notify_method` tinyint(1) NOT NULL default '1',
`notify_mode` tinyint(1) NOT NULL default '0',
`user_occ` varchar(100) NOT NULL default '',
`bio` tinytext NOT NULL,
`user_intrest` varchar(150) NOT NULL default '',
`user_mailok` tinyint(1) unsigned NOT NULL default '1',
PRIMARY KEY (`uid`),
KEY `uname` (`uname`),
KEY `email` (`email`),
KEY `uiduname` (`uid`,`uname`),
KEY `unamepass` (`uname`,`pass`)
) TYPE=MyISAM;
ALTER TABLE `ithq2_users` ADD UNIQUE (`uname`);
ALTER TABLE `ithq2_users` ADD UNIQUE (`email`);
INSERT IGNORE INTO csmapce_dev.ithq2_users( name,
uname,
email,
url,
user_avatar,
user_regdate,
user_icq,
user_from,
user_sig,
user_viewemail,
actkey,
user_aim,
user_yim,
user_msnm,
pass,
posts,
attachsig,
rank,
LEVEL ,
theme,
timezone_offset,
last_login,
umode,
uorder,
notify_method,
notify_mode,
user_occ,
bio,
user_intrest,
user_mailok )
SELECT name, uname, email, url, user_avatar, user_regdate, user_icq, user_from, user_sig, user_viewemail, actkey, user_aim, user_yim, user_msnm, pass, posts, attachsig, rank,
LEVEL , theme, timezone_offset, last_login, umode, uorder, notify_method, notify_mode, user_occ, bio, user_intrest, user_mailok
FROM csmapce_dev.ithq_users
UNION (
SELECT name, uname, email, url, user_avatar, user_regdate, user_icq, user_from, user_sig, user_viewemail, actkey, user_aim, user_yim, user_msnm, pass, posts, attachsig, rank,
LEVEL , theme, timezone_offset, last_login, umode, uorder, notify_method, notify_mode, user_occ, bio, user_intrest, user_mailok
FROM csmapce_dev.demo_users
);
CREATE TABLE `csmapce_dev.ithqFinal_users` (
`uid` mediumint(8) unsigned NOT NULL auto_increment,
`name` varchar(60) NOT NULL default '',
`uname` varchar(25) NOT NULL default '',
`email` varchar(60) NOT NULL default '',
`url` varchar(100) NOT NULL default '',
`user_avatar` varchar(30) NOT NULL default 'blank.gif',
`user_regdate` int(10) unsigned NOT NULL default '0',
`user_icq` varchar(15) NOT NULL default '',
`user_from` varchar(100) NOT NULL default '',
`user_sig` tinytext NOT NULL,
`user_viewemail` tinyint(1) unsigned NOT NULL default '0',
`actkey` varchar(8) NOT NULL default '',
`user_aim` varchar(18) NOT NULL default '',
`user_yim` varchar(25) NOT NULL default '',
`user_msnm` varchar(100) NOT NULL default '',
`pass` varchar(32) NOT NULL default '',
`posts` mediumint(8) unsigned NOT NULL default '0',
`attachsig` tinyint(1) unsigned NOT NULL default '0',
`rank` smallint(5) unsigned NOT NULL default '0',
`level` tinyint(3) unsigned NOT NULL default '1',
`theme` varchar(100) NOT NULL default '',
`timezone_offset` float(3,1) NOT NULL default '0.0',
`last_login` int(10) unsigned NOT NULL default '0',
`umode` varchar(10) NOT NULL default '',
`uorder` tinyint(1) unsigned NOT NULL default '0',
`notify_method` tinyint(1) NOT NULL default '1',
`notify_mode` tinyint(1) NOT NULL default '0',
`user_occ` varchar(100) NOT NULL default '',
`bio` tinytext NOT NULL,
`user_intrest` varchar(150) NOT NULL default '',
`user_mailok` tinyint(1) unsigned NOT NULL default '1',
PRIMARY KEY (`uid`),
KEY `uname` (`uname`),
KEY `email` (`email`),
KEY `uiduname` (`uid`,`uname`),
KEY `unamepass` (`uname`,`pass`)
) TYPE=MyISAM;
INSERT IGNORE INTO csmapce_dev.ithqFinal_users( name,
uname,
email,
url,
user_avatar,
user_regdate,
user_icq,
user_from,
user_sig,
user_viewemail,
actkey,
user_aim,
user_yim,
user_msnm,
pass,
posts,
attachsig,
rank,
LEVEL ,
theme,
timezone_offset,
last_login,
umode,
uorder,
notify_method,
notify_mode,
user_occ,
bio,
user_intrest,
user_mailok )
SELECT name, uname, email, url, user_avatar, user_regdate, user_icq, user_from, user_sig, user_viewemail, actkey, user_aim, user_yim, user_msnm, pass, posts, attachsig, rank,
LEVEL , theme, timezone_offset, last_login, umode, uorder, notify_method, notify_mode, user_occ, bio, user_intrest, user_mailok
FROM csmapce_dev.ithq2_users;
DROP TABLE IF EXISTS `csmapce_dev.ithq2_users`;