include("../cuip/cuip.php");
include("php/config.php");
//include("php/dsadDB.php");
$cuip = new Cuip();
include("php/adresults.php");
//$dsadDB = new dsadDB(MySQLServer, MySQLUser, MySQLPass, MySQLDB);
$DSADresults = new DSADResults();
//$action = 'newAd';
$user = $cuip->checkCookies();
switch($_GET['do']) {
case 'login':
if(empty($_POST['userid'])) {
$userID = $cuip->checkUserName($_POST['username']);
} else{
$userID = $_POST['userid'];
}
$userWithCookie = $cuip->checkLogin($userID, $_POST['password']);
$user['cuip_hash'] = $userWithCookie['cuip_hash'];
$userID = $userWithCookie['userID'];
$action = 'hmm';
break;
case 'step1':
if($user['id'] != $_POST['id']) {
break;
}
if($_POST['agree'] != 'agree') {
break;
}
$orderer = $cuip->getForumData($_POST['id']);
$option = $DSADresults->getOption($_POST['options']);
$request = $_POST;
$request['contactName'] = $orderer['name'];
$request['max_views'] = $option['max_views'];
$DSADresults->newAd($request);
$DSADresults->emailStep1($orderer, $_POST, $option);
$action = 'hmm';
break;
case 'paid':
if($user['id'] != $_POST['adminid'] || $_POST['adid'] != $_GET['id']) {
die("No.");
}
$DSADresults->setAdAsPaid($_POST['adid']);
break;
case 'step2':
$ad = $DSADresults->getNewAd($_GET['id']);
if($ad['contactid'] == $user['id']) {
$action = 'step2';
}
break;
case 'rules':
$action='rules';
break;
case 'approve':
$action = 'approve';
break;
case 'track':
$action = 'track';
break;
case 'ja':
if($user['id'] != $_POST['adminid']) {
die("No");
}
if($_POST['approve'] == 'Delete') {
$DSADresults->setForDeletion($_POST['id']);
$status = '
Marked for Deletion!
';
} else if($_POST['approve'] == 'Approve') {
$DSADresults->setForRun($_POST['id']);
$status = '
Marked for Approval!
';
}
break;
case 'step3':
$ad = $DSADresults->getNewAd($_GET['id']);
if($user['id'] != $_POST['user'] || $ad['contactid'] != $user['id']) {
break;
}
if($_POST['agree'] != 'agree') {
break;
}
$whoops = array();
$target = str_ireplace('http://', '', $_POST['target']);
$startDate = sprintf("%d-%d-%d 00:00:00", $_POST['year'], $_POST['month'], $_POST['day']);
if($_FILES['768x90']['type'] == 'image/jpeg') {
$firstImage = $DSADresults->handleJpg($_FILES['768x90'], '768x90', $ad);
$secondImage = $DSADresults->handleJpg($_FILES['120x600'], '120x600', $ad);
$thirdImage = $DSADresults->handleJpg($_FILES['125x125'], '125x125', $ad);
$type = 'jpg';
} else if($_FILES['768x90']['type'] == 'image/png') {
$firstImage = $DSADresults->handlePng($_FILES['768x90'], '768x90', $ad);
$secondImage = $DSADresults->handlePng($_FILES['120x600'], '120x600', $ad);
$thirdImage = $DSADresults->handlePng($_FILES['125x125'], '125x125', $ad);
$type = 'png';
} else{
$action = 'step2';
$whoops = '
Image should be a JPG or PNG file!
';
break;
}
if(!($firstImage && $secondImage && $thirdImage)) {
$action = 'step2';
if(!$firstImage) {
$whoops = '
The first image size is not correct!';
}
if(!$secondImage) {
$whoops .= '
The second image size is not correct!';
}
if(!$thirdImage) {
$whoops .= '
The third image size is not correct!';
}
$whoops .= '
';
break;
}
$DSADresults->addImages($ad, $target, $type, $startDate);
break;
case 'newAd':
$action = 'newAd';
break;
default:
break;
}
$user = $cuip->secondUserCheck($user);
echo "";
if($user['id'] == -1) {
$cuip->printWholeLoginScreen(-1, 'index', "Derelict Studios Advertising Login", "Be sure to be logged in with your forum account.
");
die();
}
$cuip->printCuipHeader("Derelict Studios Advertising", '');
echo $status;
if($user['admin']) {
$newAds = $DSADresults->getAllNewAds();
$ads = $DSADresults->getAllAds();
} else{
$newAds = $DSADresults->checkNewAds($user['id']);
$ads = $DSADresults->checkAds($user['id']);
}
//$user['admin'] = FALSE;
echo "";
if((empty($newAds) || $_GET['do'] == 'newAd') && empty($ads) && empty($action)) {
$action = 'newAd';
} else{
switch($action) {
case 'newAd':
printf("Welcome at the Derelict Studios Advertisement page.
You can rent advertising space at Derelict Studios through the form below.
");
printf("
Start new advertisement
| Name | Minimum number of views | Max number views/day/user | Status |
| %s ordered '%s' | %d | %d | %s |
| %s | %d | %d | %s |
| Name | Views | Max views | Max views/ user | Clicks | Tracked data | Starting date | '; if($user['admin']) { echo 'Contact | '; } echo '
| %s | %d | %d | %d | %d | Statistics | %s | %s |
| %s | %d | %d | %d | %d | Statistics | %s |
| Name | Views | Clicks | Tracked data | Ending date | '; if($user['admin']) { echo 'Contact | '; } echo '
| %s | %d | %d | Statistics | %s | %s |
| %s | %d | %d | Statistics | %s |