Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class customDonations {
- private $db_connection = null;
- public $debugging = 1;
- public $auctionmessages = array();
- public function __construct(){
- $this->databaseConnection();
- }
- private function databaseConnection(){ //database connection
- if ($this->db_connection != null) {
- return true;
- } else {
- try {
- $this->db_connection = new PDO('mysql:host='. DB_HOST .';dbname='. DB_NAME . ';charset='.DB_CHARSET, DB_USER, DB_PASSWORD);
- if($this->debugging == 1){
- $this->db_connection->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
- $this->db_connection->setAttribute(PDO::ATTR_EMULATE_PREPARES, false); //debugging
- }
- return true;
- } catch (PDOException $e) {
- $this->auctionmessages[] = $e->getMessage();
- }
- }
- return false;
- }
- private function checkList(){ //check if there are any active auctions
- $check_list = $this->db_connection->prepare("SELECT * FROM crstube_posts
- INNER JOIN crstube_postmeta ON crstube_posts.ID = crstube_postmeta.post_id
- WHERE meta_key = 'wdm_listing_ends'
- AND meta_value < DATE_ADD(NOW(), INTERVAL 60 HOUR) AND meta_value > NOW()
- OR meta_key = 'wdm_listing_ends'
- AND NOW() < DATE_ADD(meta_value, INTERVAL 5 HOUR) AND meta_value < NOW()
- ORDER BY meta_value ASC");
- $check_list->execute();
- if($check_list->rowcount() != 0){
- return $check_list->fetchAll(PDO::FETCH_ASSOC);
- }
- return false;//there are activeauctions, return false
- }
- private function getData($id, $text){
- $check_list = $this->db_connection->prepare("SELECT * FROM crstube_postmeta WHERE post_id = :postid AND meta_key = :metavalue");
- $check_list->bindValue(':postid', $id, PDO::PARAM_INT);
- $check_list->bindValue(':metavalue', $text, PDO::PARAM_STR);
- $check_list->execute();
- if($check_list->rowcount() != 0){
- $data = $check_list->fetchAll(PDO::FETCH_ASSOC);
- return $data[0]['meta_value'];
- }
- return false;//there is no active auctions, return false
- }
- public function createDonationPage(){
- if($this->checkList() != false){
- $auction_list = $this->checkList();?>
- <?php
- $timercounter = 1;
- $returndata = array();
- foreach($auction_list as $single_auction):
- $image1 = $this->getData($single_auction['ID'], 'wdm-image-1');
- $description = $single_auction['post_excerpt']; // content <!-- <?php echo $description;
- $title = $single_auction['post_title'];
- $link = "http://creative-scape.net/crstube/auctions/?ult_auc_id=".$single_auction['ID'];
- $get_bids = $this->db_connection->prepare("SELECT * FROM crstube_wdm_bidders
- WHERE auction_id = :idvar ORDER BY bid DESC");
- $get_bids->bindValue(':idvar', $single_auction['ID'], PDO::PARAM_INT);
- $get_bids->execute();
- $get_bid = $get_bids->fetchAll(PDO::FETCH_ASSOC);
- if(count($get_bid) == 0){
- $price = $this->getData($single_auction['ID'], 'wdm_opening_bid');
- }else{
- $price = number_format($get_bid[0]['bid']);
- }
- ?>
- <a class="auctions" href='<?php echo $link; ?>'>
- <fieldset>
- <legend><b><?php echo $title; ?></b> <?php echo $price; ?>$</legend>
- <img src=<?php echo $image1; ?>> </br>
- <div id="padZeroes<?php echo $timercounter; ?>"></div>
- </fieldset></a>
- <script type="text/javascript">
- var t<?php echo $timercounter; ?> = "<?php echo $single_auction['meta_value']; ?>".split(/[- :]/);
- var liftoffTime<?php echo $timercounter; ?> = new Date(t<?php echo $timercounter; ?>[0], t<?php echo $timercounter; ?>[1]-1, t<?php echo $timercounter; ?>[2], t<?php echo $timercounter; ?>[3], t<?php echo $timercounter; ?>[4], t<?php echo $timercounter; ?>[5]);
- $(document).ready(function(){
- <?php echo "$('#padZeroes".$timercounter."').countdown({until: $.countdown.UTCDate(-5, liftoffTime". $timercounter."), padZeroes: true, compact: true});"; ?>
- });
- </script>
- <?php $timercounter++;
- endforeach;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement