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("
", $user['email']); printf("", $user['id']); printf(""); printf("
Email address:
Please give a valid email address.
You will be contacted on it to
finalize the advertising campaign:


Please name your advertising campaign.
Please select the package you would like:
Please select the maximum number of
user views you would like:
This is the maximum amount a single user
will be able to view the advertisement
on a single day.
I agree with the stated rules.
"); break; case 'track': $ad = $DSADresults->getAd($_GET['id']); if(!$user['admin'] && $user['id'] != $ad['contactid']) { die(); } $clicks = $DSADresults->collectClicks($ad['id']); $views = $DSADresults->checkViews($ad['id']); if($ad['enddate'] == '0000-00-00 00:00:00') { $dateLeft = 'Start Date:'; $dateRight = $ad['startdate']; } else{ $dateLeft = 'End Date:'; $dateRight = $ad['enddate']; } printf(" ", $ad['name'], $ad['target'], $dateLeft, $dateRight, $ad['max_views'], $views['cnt'], $ad['max_views_day'], $clicks['cnt']); if($user['admin']) { printf("", $ad['contactemail'], $ad['contactname']); } echo '
Name%s
Target:%s
%s%s
Max views:%d
Views to date:%d
Max views
user:
%d
Clicks:%d
Contact:%s
Daily Statistics'; $dailyStats = $DSADresults->getDailyStats($ad['id']); foreach($dailyStats as $dailyStat) { printf("", $dailyStat['year'], $dailyStat['month'], $dailyStat['day'], $dailyStat['views'], $dailyStat['clicks']); } echo '
Date Views Clicks
%d-%d-%d%d%d
'; break; case 'step2': printf("Please finish your advertisement below.
You are supposed to designate the target of your advertisement,
And upload 3 images, one in 768x90, one in 120x600 and one in 125x125.
These images can be in JPG or PNG. Other formats are not accepted.
Notice that the advertisement still needs to be approved.
If the images are found to be in violation to our rules,
the advertisement may be rejected, and no refund will be issued. %s
Please designate the target
of the advertisements:
768 x 90
120 x 600
125 x 125
Startdate advertisement campaign "; printf("
I agree with the stated rules.
"); break; case 'rules': printf("Advertisement Conditions
  1. These conditions are between the person ordering the advertisement, hereafter referred to as "Advertiser", and Derelict Studios LLC, here after referred to as "Derelict Studios".
  2. Upon agreeing to these conditions, an advertisement campaign will be prepared, to run on the Derelict Studios websites. These advertisements will link to an internal counter, which will lead to the site of the Advertiser.
  3. After the payment has been finalised, the final approval of the advertising campaign may be denied, or the running advertisement may be terminated, if any of the other rules are violated. In case of termination for violation of underlying clauses, no refund will be issued.
  4. The advertisements, nor the Advertiser's website, may contain no pornographic, hate-related, violent, or illegal content. It is up to Derelict Studios to decide on the precise definitions of "pornographic", "hate-related" or "violent". The definition of "illegal" will be determined by the laws of the United States of America, and the laws of the State of Ohio.
  5. The payment from the Advertiser to Derelict Studios will be done by Paypal, in US Dollars.
  6. Daily statistics will be gathered, and handed out to the Advertiser on request. In no case will the details of individual viewers be handed out, and the details of the individual viewers will be destroyed once the advertisement campaign has ended.
"); break; case 'approve': $ad = $DSADresults->getNewAd($_GET['id']); printf("Here are non-counting preview examples of your advertisement.
These will be reviewed to be working, and to be confirm our rules.

768 x 90


120 x 600


125 x 125


", $ad['target'], $ad['name_ad'], $ad['id'], $ad['imagetype'], $ad['target'], $ad['name_ad'], $ad['id'], $ad['imagetype'], $ad['target'], $ad['name_ad'], $ad['id'], $ad['imagetype']); if($user['admin']) { printf("
", $ad['id'], $ad['id'], $user['id']); } break; default: printf("

Start new advertisement
"); foreach($newAds as $newAd) { if($user['admin']) { if($newAd['paid']) { if($newAd['approved'] == 1) { $status = sprintf("Starts %s", $newAd['startdate']); } else if($newAd['approved'] == -1) { $status = sprintf("Marked for deletion! Preview", $newAd['id']); } else if(!empty($newAd['target'])) { $status = sprintf("Awaiting approval: Preview", $newAd['id']); } else{ $status = 'Paid, awaiting images'; } } else{ $status = sprintf("Awaiting payment - ", $newAd['id'], $newAd['id'], $user['id'], $newAd['id']); } printf("", $newAd['email'], $newAd['name_contact'], $newAd['name_ad'], $newAd['max_views'], $newAd['max_views_day'], $status); } else{ if($newAd['paid']) { if($newAd['approved']) { $status = sprintf("Starts %s", $newAd['startdate']); } else if(!empty($newAd['target'])) { $status = sprintf("Awaiting approval: Preview", $newAd['id']); } else{ $status = sprintf("Paid, please proceed here", $newAd['id']); } } else{ $option = $DSADresults->getOption($newAd['optionPackage']); $status = sprintf("Awaiting payment: $%d", $option['price']); } printf("", $newAd['name_ad'], $newAd['max_views'], $newAd['max_views_day'], $status); } } echo '
NameMinimum number
of views
Max number
views/day/user
Status
%s ordered '%s'%d%d%s
%s%d%d%s
'; if(!empty($ads)) { $runningAds = array(); $finishedAds = array(); foreach($ads as $ad) { if($ad['enddate'] == '0000-00-00 00:00:00') { $runningAds[] = $ad; } else{ $finishedAds[] = $ad; } } echo 'Running advertisements'; if($user['admin']) { echo ''; } echo ''; foreach($runningAds as $runningAd) { $clicks = $DSADresults->collectClicks($runningAd['id']); $views = $DSADresults->checkViews($runningAd['id']); if($user['admin']) { printf("", $runningAd['name'], $views['cnt'], $runningAd['max_views'], $runningAd['max_views_day'], $clicks['cnt'], $runningAd['id'], $runningAd['startdate'], $runningAd['contactemail'], $runningAd['contactname']); } else{ printf("", $runningAd['name'], $runningAd['max_views'], $runningAd['max_views_day'], $views['cnt'], $clicks['cnt'], $runningAd['id'], $runningAd['startdate']); } } echo '
NameViewsMax viewsMax views/
user
ClicksTracked dataStarting dateContact
%s%d%d%d%dStatistics%s%s
%s%d%d%d%dStatistics%s

Finished advertisements'; if($user['admin']) { echo ''; } echo ''; foreach($finishedAds as $finishedAd) { $clicks = $DSADresults->collectClicks($finishedAd['id']); if($user['admin']) { printf("", $finishedAd['name'], $finishedAd['max_views'], $clicks['cnt'], $finishedAd['id'], $finishedAd['enddate'], $finishedAd['contactemail'], $finishedAd['contactname']); } else{ printf("", $finishedAd['name'], $finishedAd['max_views'], $clicks['cnt'], $finishedAd['id'], $finishedAd['enddate']); } } } break; } } echo ''; ?>
NameViewsClicksTracked dataEnding dateContact
%s%d%dStatistics%s%s
%s%d%dStatistics%s