Created
October 4, 2012 17:10
-
-
Save agustinhaller/3835018 to your computer and use it in GitHub Desktop.
draw
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| /*ini_set('display_errors', 1); | |
| ini_set('error_reporting', E_ALL); | |
| */ | |
| require_once("includes/all.inc.php"); | |
| require_once("includes/header.inc.php"); | |
| require_once("includes/footer.inc.php"); | |
| if(DEBUG) | |
| { | |
| ini_set('display_errors', 1); | |
| ini_set('error_reporting', E_ALL); | |
| } | |
| // Get company name and draw name | |
| $company_name = (isset($_REQUEST['company_name']) && $_REQUEST['company_name']!="") ? $_REQUEST['company_name'] : null; | |
| $draw_id = (isset($_REQUEST['draw_id']) && $_REQUEST['draw_id']!="") ? $_REQUEST['draw_id'] : null; | |
| $draw_id = str_replace("/", "", $draw_id); | |
| $logged_user = getUserByUsername($_SESSION['username']); | |
| if($company_name!=null && $draw_id!=null) | |
| { | |
| $current_draw = null; | |
| // Connect to db | |
| $conn = connect_db(); | |
| $db_error = false; | |
| if($conn!=false) | |
| { | |
| // Check if that company exists and if that draw is correct | |
| $q_cd = " SELECT d.*, o.tw_account | |
| FROM draws d, organizer_users o | |
| WHERE o.tw_account = '".$company_name."' | |
| AND d.organizer_id = o.id | |
| AND (d.is_active = 1 or d.is_active=2) | |
| AND d.id = ".$draw_id; | |
| // $q_cd = " SELECT d.*, c.tw_account | |
| // FROM draws d, company c | |
| // WHERE c.name = '".$company_name."' | |
| // AND d.company_id = c.id | |
| // AND d.is_active = 1 | |
| // AND d.id = ".$draw_id; | |
| // print_str($q_cd); | |
| $r_cd = mysql_query($q_cd); | |
| if($r_cd) | |
| { | |
| if(mysql_num_rows($r_cd) > 0) | |
| { | |
| // Single result | |
| $current_draw = mysql_fetch_array($r_cd); | |
| if($current_draw["is_active"]==2){ | |
| //IF IT's A DRAFT WE MUST CHECK THAT IF THE VISITOR IS THE ORGANIZER TO SHOW IT. | |
| $this_organizer_id = getOriganizerIdByUser($_SESSION['user_id']); | |
| if($this_organizer_id!= $current_draw["organizer_id"]){ | |
| if(!isset($_REQUEST["token"]) or $_REQUEST['token']!=md5($draw_id)){ | |
| $current_draw = null; | |
| $db_error = true; | |
| } | |
| }else{ | |
| //THE DRAW IS NOT ACTIVE AND THE ORGANIZER IS LOGGED | |
| //IF IT HAS CREDITS | |
| //SHOW MESSAGE SAYING IT'S A DRAW AND CLICK BELOW TO ACTIVATE | |
| //IF IT DOESN'T | |
| //SHOW MESSAGE SAYING TO BUY AND CLICK BELOW TO ACTIVATE | |
| $draw_id = (isset($_REQUEST['did']) && $_REQUEST['did']!="") ? $_REQUEST['did'] : null; | |
| $c = new Credits($_SESSION['user_id']); | |
| $draw_id = $_REQUEST['draw_id']; | |
| $current_balance = $c->getBalance(); | |
| $draw_credits_price = DRAW_CREDITS_PRICE; | |
| if($current_balance < $draw_credits_price){ | |
| $pbm = "NOT_ENOUGH_CREDIT"; | |
| setPostbackMsg($pbm, "draw_creation_response"); | |
| }else{ | |
| $pbm = "DRAFT_OK"; | |
| setPostbackMsg($pbm, "draw_creation_response"); | |
| } | |
| } | |
| } | |
| // print_str($current_draw); | |
| } | |
| else | |
| { | |
| // echo("pepe"); | |
| $db_error = true; | |
| } | |
| } | |
| else | |
| { | |
| // echo("pepe"); | |
| $db_error = true; | |
| } | |
| } | |
| else | |
| { | |
| // Error in mysql connection | |
| $db_error = true; | |
| } | |
| // Destroy db connection | |
| disconnect_db($conn); | |
| if($current_draw != null) | |
| { | |
| // Get logged user id | |
| $logged_user_id = $_SESSION['user_id']; | |
| $logged_user_tw_username = $_SESSION['username']; | |
| $cd_title = $current_draw['title']; | |
| $cd_organizer = "@".$current_draw['tw_account']; | |
| $days_en = array("Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"); | |
| $months_en = array("January","February","March","April","May","June","July","August","September","October","November","December"); | |
| $cd_start_date_aux = strtotime($current_draw['start_date']); | |
| $cd_start_date_00_aux = strtotime($current_draw['start_date_00']); | |
| $cd_start_date_aux2 = date("l d \d\e F \a\ \l\a\s H:i \h\s", $cd_start_date_aux); | |
| $find = array("{{DAY_NAME}}","{{DAY_NUMBER}}","{{MONTH_NAME}}","{{HOUR}}","{{MINUTES}}"); | |
| $replace = array(date("l",$cd_start_date_aux),date("d",$cd_start_date_aux),date("F",$cd_start_date_aux),date("H",$cd_start_date_aux),date("i",$cd_start_date_aux)); | |
| $cd_start_date_aux2 = translate("LONG_DATE_FORMAT",$find,$replace); | |
| $cd_start_date_aux3 = str_replace($days_en, $days, $cd_start_date_aux2); | |
| $cd_start_date = str_replace($months_en, $months, $cd_start_date_aux3); | |
| $cd_end_date_aux = strtotime($current_draw['end_date']); | |
| $cd_end_date_00_aux = strtotime($current_draw['end_date_00']); | |
| //$cd_end_date_aux2 = date("l d \d\e F \a\ \l\a\s H:i \h\s", $cd_end_date_aux); | |
| $find = array("{{DAY_NAME}}","{{DAY_NUMBER}}","{{MONTH_NAME}}","{{HOUR}}","{{MINUTES}}"); | |
| $replace = array(date("l",$cd_end_date_aux),date("d",$cd_end_date_aux),date("F",$cd_end_date_aux),date("H",$cd_end_date_aux),date("i",$cd_end_date_aux)); | |
| $cd_end_date_aux2 = translate("LONG_DATE_FORMAT",$find,$replace); | |
| $cd_end_date_aux3 = str_replace($days_en, $days, $cd_end_date_aux2); | |
| $cd_end_date = str_replace($months_en, $months, $cd_end_date_aux3); | |
| // $current_date = date("Y-m-d H:i:00", strtotime("+2 hour")); | |
| // $draw_start_date = date("Y-m-d H:i:00", $cd_start_date_aux); | |
| // $draw_end_date = date("Y-m-d H:i:00", $cd_end_date_aux); | |
| // $draw_has_started = ($current_date > $draw_start_date); | |
| // $draw_has_ended = ($current_date > $draw_end_date); | |
| $current_date = get00Time(); | |
| $draw_start_date = date("Y-m-d H:i:00", $cd_start_date_00_aux); | |
| $draw_end_date = date("Y-m-d H:i:00", $cd_end_date_00_aux); | |
| $draw_has_started = ($current_date >= $draw_start_date); | |
| $draw_has_ended = ($current_date >= $draw_end_date); | |
| // print_str($current_date, "current"); | |
| // print_str($draw_start_date, "draw_start_date"); | |
| // print_str($draw_end_date, "draw_end_date"); | |
| // print_str($draw_has_started, "draw_has_started"); | |
| // print_str($draw_has_ended, "draw_has_ended"); | |
| $cd_image = $current_draw['image']; | |
| $cd_terms_and_conditions = $current_draw['terms_and_conditions']; | |
| $cd_title_big = "Sorteo de ".$cd_organizer." - ".$cd_title; | |
| $cd_id = $current_draw['id']; | |
| $cd_participants_aux = getDrawParticipants($cd_id, 32); | |
| $cd_participants_aux2 = $cd_participants_aux['participants']; | |
| $cd_participants_count = $cd_participants_aux['participants_qty']; | |
| // Chop participants, get with at least 28 | |
| $cd_participants = array_slice($cd_participants_aux2, 0, 32); | |
| // Get owner data | |
| $cd_owner_aux = getUserByUsername($current_draw['tw_account']); | |
| // print_str($cd_owner_aux); | |
| $owner_tw_image = $cd_owner_aux['avatar_url']; | |
| $owner_tw_name = $cd_owner_aux['name']; | |
| $owner_tw_username = $cd_owner_aux['username']; | |
| $owner_tw_profile_url = "http://twitter.com/".$owner_tw_username; | |
| $draw_organizer_data = getOrganizerDrawData_byDrawId($cd_id); | |
| $draw_organizer_timezone = $draw_organizer_data['timezone']; | |
| // Show participants | |
| $participants_html = ""; | |
| $participants_html_items = array(); | |
| $participants_items_control = array(); | |
| foreach ($cd_participants as $participant) | |
| { | |
| $participant_twitter_username = $participant['tw_username']; | |
| $participant_twitter_name = $participant['tw_name']; | |
| $participant_twitter_url = $participant['tw_profile_url']; | |
| $participant_twitter_image = $participant['tw_image']; | |
| $participant_html = ' <li> | |
| <a class="participant-image" href="'.$participant_twitter_url.'" title="'.$participant_twitter_name.'" target="_blank"> | |
| <img src="'.$participant_twitter_image.'"/> | |
| </a> | |
| </li>'; | |
| // $participants_html .= $participant_html; | |
| $participants_html_items[] = $participant_html; | |
| $participants_items_control[] = $participant['tw_username']; | |
| } | |
| // Get all draw participation ways id's | |
| $draw_pw = getDrawParticipationWays($cd_id, true); | |
| // Get twitter user data from participant | |
| $participant_id = $logged_user_id; | |
| $participant = getParticipantTwitterData($participant_id); | |
| $participant_image = $participant['avatar_url']; | |
| $participant_username = $participant['username']; | |
| $participant_name = $participant['name']; | |
| $participant_profile_url = "http://twitter.com/".$participant_username; | |
| $organizer_username = $owner_tw_username; | |
| $draw_link = "http://".DOMAIN_BASE_URL."/".strtolower($company_name)."/".$draw_id; | |
| $draw_link = shortenURL($draw_link); | |
| // print_str($draw_pw, "draw_pw"); | |
| $draw_pw_html = ''; | |
| // This array reffers to the pw objects needed to build the participation popup markup | |
| // $draw_pws_actions = array(); | |
| // This array reffers to the pw objects needed to build the participation ways markup displayed on the draw page | |
| $draw_pws = array(); | |
| $draw_correct_pws = array(); | |
| foreach ($draw_pw as $pw) | |
| { | |
| // Get PW rules | |
| $pw_id = $pw['id']; | |
| $pw_description = $pw['description']; | |
| $pw_rules = getRules($pw); | |
| $pw_hidden_rules = getHiddenRules($pw); | |
| // print_str($pw_description, "pw_description"); | |
| // print_str($pw_rules, "pw_rules"); | |
| // print_str($pw_hidden_rules, "pw_hidden_rules"); | |
| // $pw_rules_actions = array(); | |
| if($pw_rules!=null || $pw_description=="retweet" || $pw_description=="follow_plus_retweet") | |
| { | |
| $pw_html = ''; | |
| switch ($pw_description) | |
| { | |
| case 'follow': | |
| // Get follow rules | |
| $pw_follow_rules = $pw_rules['rules']['follow'][0]['args']; | |
| // $follow_rules_str_2 = implode("</b>, <b>@", $pw_follow_rules); | |
| // $follow_rules_str = 'Seguir a <b>@'.$follow_rules_str_2.'</b>'; | |
| $follow_rules_str_2 = implode('</span>, <span class="mention">@', $pw_follow_rules); | |
| $follow_rules_str = '<div class="autolink-text">'.translate("FOLLOW_TO").'<span class="mention">@'.$follow_rules_str_2.'</span></div>'; | |
| // Create marckup for the PW | |
| $pw_html = '<li class="rule-item"> | |
| <ul class="rules-list"> | |
| <li>'.$follow_rules_str.'</li> | |
| </ul> | |
| </li>'; | |
| /*$pw_participate_html = '<li class="rule-item"> | |
| <ul class="rules-list"> | |
| <span style="font-size: 10px; color: #999;">Al clickear en PARTICIPAR! realizarás las siguientes acciones en tu cuenta de Twitter:</span> | |
| <li>'.$follow_rules_str.'</li> | |
| </ul> | |
| </li>';*/ | |
| $pw_participate_html = '<li class="rule-item"> | |
| <ul class="rules-list"> | |
| <span class="rules-span" >'.translate("MAKING_CLICK_ON").' <b class="hashtag colored" >'.translate("PARTICIPATE").'</b> '.translate("YOU_GIVE_US_AUTHORIZATION").':</span> | |
| <li>'.$follow_rules_str.'</li> | |
| </ul> | |
| </li>'; | |
| // Add rules actions to the array | |
| // $follow_actions = array(); | |
| // foreach ($pw_follow_rules as $follow_username) | |
| // { | |
| // $alreadyFollows = userFollowsBackUser($logged_user_tw_username, $follow_username); | |
| // $follow_actions[] = array( | |
| // 'username' => $follow_username, | |
| // 'already_follows' => $alreadyFollows | |
| // ); | |
| // } | |
| // $pw_rules_actions['follow'] = array( | |
| // 'values' => $follow_actions | |
| // //'rule_id' => '??', | |
| // //'already_participate' => '??' | |
| // ); | |
| break; | |
| case 'hashtag': | |
| // Get hashtag filters | |
| $pw_hashtag_filters = $pw_rules['filters']['hashtag'][0]['args']; | |
| $pw_hashtag_suggested_message = utf8_encode($pw_rules['filters']['hashtag'][0]['extra']); | |
| // $hashtag_filters_str_2 = implode("</b>, <b>#", $pw_hashtag_filters); | |
| // $hashtag_filters_str = 'Enviar tweet con hashtag <b>#'.$hashtag_filters_str_2.'</b>'; | |
| $hashtag_filters_str_2 = implode('</span>, <span class="hashtag">#', $pw_hashtag_filters); | |
| $hashtag_filters_str = '<div class="autolink-text">Enviar tweet con hashtag <span class="hashtag">#'.$hashtag_filters_str_2.'</span></div>'; | |
| //$tweet_text_2 = "Quiero participar del sorteo de @".$organizer_username."! #".$hashtag_filters_str_2." ".$draw_link; | |
| // $tweet_text_2 = translate("I_WANT_TO_PARTICIPATE")." #".$hashtag_filters_str_2." ".$draw_link; | |
| $tweet_text_2 = $pw_hashtag_suggested_message." (".$draw_link.")"; | |
| $hashtag_filters_participate_str = '<div class="autolink-text">'.translate("SEND_TWEET_WITH_HASHTAG").'<span class="hashtag">#'.$hashtag_filters_str_2.'</span></div> | |
| <ul class="retweets-list"> | |
| <li class="retweet-item"> | |
| <!-- | |
| <a class="retweet-creator-image" href="'.$participant_profile_url.'" title="'.$participant_name.'" target="_blank"> | |
| <img src="'.$participant_image.'"> | |
| </a> | |
| --> | |
| <div class="retweet-data-wrapper"> | |
| <!-- | |
| <h3> | |
| <a target="_blank" href="'.$participant_profile_url.'">@'.$participant_username.'</a> | |
| </h3> | |
| --> | |
| <div class="retweet-text participate-flow"> | |
| <!-- <span class="prize-desc autolink-text">'.$tweet_text_2.'</span> --> | |
| <div class="noMarginBottom"> | |
| <textarea class="tweet-text-input scheduled-tweet-textarea decorated" data-maxlength="140">'.str_replace("http://", "", $tweet_text_2).'</textarea> | |
| </div> | |
| <div class="tweet-btns-container"> | |
| <!-- <div style="font-size: 10px;" class="draw-link-be-tweeted">'.translate("A_LINK_TO_THE_DRAW_WILL_BE_INCLUDED").'</div> --> | |
| <div class="chars-left-dynamic" id="chars-left">'.(140 - strlen($tweet_text_2)).'</div> | |
| <div class="clear"></div> | |
| </div> | |
| </div> | |
| </div> | |
| </li> | |
| </ul> | |
| <div class="clear"></div>'; | |
| // Create marckup for the PW | |
| $pw_html = '<li class="rule-item"> | |
| <ul class="rules-list"> | |
| <li>'.$hashtag_filters_str.'</li> | |
| </ul> | |
| </li>'; | |
| $pw_participate_html = '<li class="rule-item"> | |
| <ul class="rules-list participate-flow"> | |
| <span class="rules-span" >'.translate("MAKING_CLICK_ON").' <b class="hashtag colored" >'.translate("PARTICIPATE").'</b> '.translate("YOU_GIVE_US_AUTHORIZATION").':</span> | |
| <li>'.$hashtag_filters_participate_str.'</li> | |
| </ul> | |
| </li>'; | |
| $pw_tweet_placeholder = $tweet_text_2; | |
| $pw_tweet_validation_args = $pw_hashtag_filters; | |
| // Add hashtag filters to the array | |
| // $hashtag_filters = array(); | |
| // foreach ($pw_hashtag_filters as $hashtag) | |
| // { | |
| // $hashtag_filters[] = array( | |
| // 'hashtag' => $hashtag | |
| // ); | |
| // } | |
| // $pw_rules_actions['hashtag'] = array( | |
| // 'values' => $hashtag_filters | |
| // //'rule_id' => '??', | |
| // //'already_participate' => '??' | |
| // ); | |
| break; | |
| case 'mention': | |
| // Get mention filters | |
| $pw_mention_filters = $pw_rules['filters']['mention'][0]['args']; | |
| $pw_mention_suggested_message = utf8_encode($pw_rules['filters']['mention'][0]['extra']); | |
| // $mention_filters_str_2 = implode("</b>, <b>@", $pw_mention_filters); | |
| // $mention_filters_str = 'Enviar tweet mencionando al usuario <b>@'.$mention_filters_str_2.'</b>'; | |
| $mention_filters_str_2 = implode('</span>, <span class="mention">@', $pw_mention_filters); | |
| $mention_filters_str = '<div class="autolink-text">'.translate("SEND_TWEET_MENTIONING_USER").' <span class="mention">@'.$mention_filters_str_2.'</span></div>'; | |
| // $find = array("{{ORGANIZER_SCREEN_NAME}}"); | |
| // $replace = array("@".$organizer_username); | |
| // $tweet_text_2 = translate("I_WANT_TO_PARTICIPATE_IN_DRAW_OF",$find,$replace)."! ".$draw_link; | |
| $tweet_text_2 = $pw_mention_suggested_message." (".$draw_link.")"; | |
| $mention_filters_participate_str = '<div class="autolink-text">'.translate("TWEET_WITH_MENTION_TO").'<span class="mention">@'.$mention_filters_str_2.'</span></div> | |
| <ul class="retweets-list"> | |
| <li class="retweet-item"> | |
| <!-- | |
| <a class="retweet-creator-image" href="'.$participant_profile_url.'" title="'.$participant_name.'" target="_blank"> | |
| <img src="'.$participant_image.'"> | |
| </a> | |
| --> | |
| <div class="retweet-data-wrapper"> | |
| <!-- | |
| <h3> | |
| <a target="_blank" href="'.$participant_profile_url.'">@'.$participant_username.'</a> | |
| </h3> | |
| --> | |
| <div class="retweet-text participate-flow"> | |
| <!-- <span class="prize-desc autolink-text">'.$tweet_text_2.'</span> --> | |
| <div class="noMarginBottom"> | |
| <textarea class="tweet-text-input scheduled-tweet-textarea decorated" data-maxlength="140">'.str_replace("http://", "", $tweet_text_2).'</textarea> | |
| </div> | |
| <div class="tweet-btns-container"> | |
| <!-- <div style="font-size: 10px;" class="draw-link-be-tweeted">'.translate("A_LINK_TO_THE_DRAW_WILL_BE_INCLUDED").'</div> --> | |
| <div class="chars-left-dynamic" id="chars-left">'.(140 - strlen($tweet_text_2)).'</div> | |
| <div class="clear"></div> | |
| </div> | |
| </div> | |
| </div> | |
| </li> | |
| </ul> | |
| <div class="clear"></div>'; | |
| // Create marckup for the PW | |
| $pw_html = '<li class="rule-item"> | |
| <ul class="rules-list"> | |
| <li>'.$mention_filters_str.'</li> | |
| </ul> | |
| </li>'; | |
| $pw_participate_html = '<li class="rule-item"> | |
| <ul class="rules-list participate-flow"> | |
| <span class="rules-span" >'.translate("MAKING_CLICK_ON").' <b class="hashtag colored" >'.translate("PARTICIPATE").'</b> '.translate("YOU_GIVE_US_AUTHORIZATION").':</span> | |
| <li>'.$mention_filters_participate_str.'</li> | |
| </ul> | |
| </li>'; | |
| $pw_tweet_placeholder = ""; | |
| $pw_tweet_validation_args = $pw_mention_filters; | |
| // Add hashtag filters to the array | |
| // $mention_filters = array(); | |
| // foreach ($pw_mention_filters as $mention) | |
| // { | |
| // $mention_filters[] = array( | |
| // 'mention' => $mention | |
| // ); | |
| // } | |
| // $pw_rules_actions['mention'] = array( | |
| // 'values' => $mention_filters | |
| // //'rule_id' => '??', | |
| // //'already_participate' => '??' | |
| // ); | |
| break; | |
| case 'retweet': | |
| // print_str("RT RULE HERE!"); | |
| // In this case we can have a hidden rule or a true one | |
| if($pw_rules!=null) | |
| { | |
| // Get retweet filters, this is an array with scheduled RT id's | |
| $pw_retweet_filters = $pw_rules['retweets']['retweet'][0]['args']; | |
| // Get info of each scheduled RT | |
| $rts_html = ''; | |
| // Add hashtag filters to the array | |
| // $retweet_filters = array(); | |
| foreach ($pw_retweet_filters as $rt_id) | |
| { | |
| // $tweet_exists_aux = tweetExists($rt_id); | |
| // $tweet_exists = $tweet_exists_aux['exists']; | |
| // $tweet_data = $tweet_exists_aux['object']; | |
| $scheduled_tweet = getScheduledTweet($rt_id); | |
| $scheduled_tweet_text = $scheduled_tweet['text']; | |
| $scheduled_tweet_id = $scheduled_tweet['tweet_id']; | |
| $tweet_data = array( | |
| "tweet_user_profile_url" => $owner_tw_profile_url, | |
| "tweet_user_name" => $owner_tw_name, | |
| "tweet_user_profile_image_url" => $owner_tw_image, | |
| "tweet_user_username" => $owner_tw_username, | |
| "tweet_text" => $scheduled_tweet_text, | |
| "tweet_id" => $scheduled_tweet_id | |
| ); | |
| // print_str($tweet_data, "tweet_data"); | |
| // $rts_html .= '<li>'.$tweet_data['tweet_text'].'</li>'; | |
| $rts_html .= '<li class="retweet-item"> | |
| <a class="retweet-creator-image" href="'.$tweet_data['tweet_user_profile_url'].'" title="'.$tweet_data['tweet_user_name'].'" target="_blank"> | |
| <img src="'.$tweet_data['tweet_user_profile_image_url'].'"/> | |
| </a> | |
| <div class="retweet-data-wrapper"> | |
| <h3> | |
| <a target="_blank" href="'.$tweet_data['tweet_user_profile_url'].'">@'.$tweet_data['tweet_user_username'].'</a> | |
| </h3> | |
| <div class="retweet-text"> | |
| <span class="prize-desc autolink-text">'.utf8_encode($tweet_data['tweet_text']).'</span> | |
| <a target="_blank" href="http://twitter.com/'.$tweet_data['tweet_user_username'].'/status/'.$tweet_data['tweet_id'].'" class="see-this-tweet">(ver)</a> | |
| </div> | |
| </div> | |
| </li>'; | |
| $rts_participate_html .= '<li class="retweet-item"> | |
| <a class="retweet-creator-image" href="'.$tweet_data['tweet_user_profile_url'].'" title="'.$tweet_data['tweet_user_name'].'" target="_blank"> | |
| <img src="'.$tweet_data['tweet_user_profile_image_url'].'"/> | |
| </a> | |
| <div class="retweet-data-wrapper"> | |
| <h3> | |
| <a target="_blank" href="'.$tweet_data['tweet_user_profile_url'].'">@'.$tweet_data['tweet_user_username'].'</a> | |
| </h3> | |
| <div class="retweet-text"> | |
| <span class="prize-desc autolink-text">'.utf8_encode($tweet_data['tweet_text']).'</span> | |
| </div> | |
| </div> | |
| </li>'; | |
| // $retweet_filters[] = $tweet_data; | |
| } | |
| if($rts_html!='') | |
| { | |
| $retweet_filters_str = translate("RETWEET_THIS_TWEET").': | |
| <ul class="retweets-list"> | |
| '.$rts_html.' | |
| </ul> | |
| <div class="clear"></div>'; | |
| $retweet_filters_participate_str = translate("RETWEET_THIS_TWEET").': | |
| <ul class="retweets-list"> | |
| '.$rts_participate_html.' | |
| </ul> | |
| <div class="clear"></div>'; | |
| } | |
| // Create marckup for the PW | |
| $pw_html = '<li class="rule-item"> | |
| <ul class="rules-list"> | |
| <li>'.$retweet_filters_str.'</li> | |
| </ul> | |
| </li>'; | |
| $pw_participate_html = '<li class="rule-item"> | |
| <ul class="rules-list"> | |
| <span class="rules-span" >'.translate("MAKING_CLICK_ON").' <b class="hashtag colored" >'.translate("PARTICIPATE").'</b> '.translate("YOU_GIVE_US_AUTHORIZATION").':</span> | |
| <li>'.$retweet_filters_participate_str.'</li> | |
| </ul> | |
| </li>'; | |
| // $pw_rules_actions['retweet'] = array( | |
| // 'values' => $retweet_filters | |
| // //'rule_id' => '??', | |
| // //'already_participate' => '??' | |
| // ); | |
| } | |
| else// We have a hidden rule | |
| { | |
| // print_str("HIDDEN RULE HERE!"); | |
| // Get retweet filters, this is an array with scheduled RT id's | |
| $pw_retweet_filters = $pw_hidden_rules['retweets']['retweet'][0]['args']; | |
| // Get info of each scheduled RT | |
| $rts_html = ''; | |
| // Add hashtag filters to the array | |
| $retweet_filters = array(); | |
| foreach ($pw_retweet_filters as $rt_text) | |
| { | |
| // Get owner twitter info in order to show the RT (tw image, name and username) | |
| $tweet_data = array( | |
| "tweet_user_profile_url" => $owner_tw_profile_url, | |
| "tweet_user_name" => $owner_tw_name, | |
| "tweet_user_profile_image_url" => $owner_tw_image, | |
| "tweet_user_username" => $owner_tw_username, | |
| "tweet_text" => $rt_text['text'] | |
| ); | |
| //print_str($tweet_data, "tweet_data"); | |
| // $rts_html .= '<li>'.$tweet_data['tweet_text'].'</li>'; | |
| $rts_html .= '<li class="retweet-item"> | |
| <a class="retweet-creator-image" href="'.$tweet_data['tweet_user_profile_url'].'" title="'.$tweet_data['tweet_user_name'].'" target="_blank"> | |
| <img src="'.$tweet_data['tweet_user_profile_image_url'].'"/> | |
| </a> | |
| <div class="retweet-data-wrapper"> | |
| <h3> | |
| <a target="_blank" href="'.$tweet_data['tweet_user_profile_url'].'">@'.$tweet_data['tweet_user_username'].'</a> | |
| </h3> | |
| <div class="retweet-text"> | |
| <span class="prize-desc autolink-text">'.utf8_encode($tweet_data['tweet_text']).'</span> | |
| </div> | |
| </div> | |
| </li>'; | |
| $retweet_filters[] = $tweet_data; | |
| } | |
| if($rts_html!='') | |
| { | |
| $retweet_filters_str = translate("RETWEET_THIS_TWEET").' '.translate("TWEET_NOT_PUBLISHED_YET").': | |
| <ul class="retweets-list"> | |
| '.$rts_html.' | |
| </ul> | |
| <div class="clear"></div>'; | |
| } | |
| // Create marckup for the PW | |
| $pw_html = '<li class="rule-item"> | |
| <ul class="rules-list"> | |
| <li>'.$retweet_filters_str.'</li> | |
| </ul> | |
| </li>'; | |
| } | |
| break; | |
| case 'follow_plus_hashtag': | |
| // Get follow rules | |
| $pw_follow_rules = $pw_rules['rules']['follow'][0]['args']; | |
| // print_str($pw_rules); | |
| $follow_rules_str_2 = implode('</span>, <span class="mention">@', $pw_follow_rules); | |
| $follow_rules_str = '<div class="autolink-text">'.translate("FOLLOW_TO").'<span class="mention">@'.$follow_rules_str_2.'</span></div>'; | |
| // Get hashtag filters | |
| $pw_hashtag_filters = $pw_rules['filters']['hashtag'][0]['args']; | |
| $pw_hashtag_suggested_message = utf8_encode($pw_rules['filters']['hashtag'][0]['extra']); | |
| // print_str($pw_hashtag_suggested_message); | |
| // $hashtag_filters_str_2 = implode("</b>, <b>#", $pw_hashtag_filters); | |
| // $hashtag_filters_str = 'Enviar tweet con hashtag <b>#'.$hashtag_filters_str_2.'</b>'; | |
| $hashtag_filters_str_2 = implode('</span>, <span class="hashtag">#', $pw_hashtag_filters); | |
| $hashtag_filters_str = '<div class="autolink-text">'.translate("SEND_TWEET_WITH_HASHTAG").' <span class="hashtag">#'.$hashtag_filters_str_2.'</span></div>'; | |
| // $find = array("{{ORGANIZER_SCREEN_NAME}}"); | |
| // $replace = array("@".$organizer_username); | |
| // $tweet_text_2 = translate("I_WANT_TO_PARTICIPATE_IN_DRAW_OF",$find,$replace)."! #".$hashtag_filters_str_2." ".$draw_link; | |
| $tweet_text_2 = $pw_hashtag_suggested_message." (".$draw_link.")"; | |
| $hashtag_filters_participate_str = '<div class="autolink-text">'.translate("SEND_TWEET_WITH_HASHTAG").' <span class="hashtag">#'.$hashtag_filters_str_2.'</span></div> | |
| <ul class="retweets-list"> | |
| <li class="retweet-item"> | |
| <!-- | |
| <a class="retweet-creator-image" href="'.$participant_profile_url.'" title="'.$participant_name.'" target="_blank"> | |
| <img src="'.$participant_image.'"> | |
| </a> | |
| --> | |
| <div class="retweet-data-wrapper"> | |
| <!-- | |
| <h3> | |
| <a target="_blank" href="'.$participant_profile_url.'">@'.$participant_username.'</a> | |
| </h3> | |
| --> | |
| <div class="retweet-text participate-flow"> | |
| <!-- <span class="prize-desc autolink-text">'.$tweet_text_2.'</span> --> | |
| <div class="noMarginBottom"> | |
| <textarea class="tweet-text-input scheduled-tweet-textarea decorated" data-maxlength="140">'.str_replace("http://", "", $tweet_text_2).'</textarea> | |
| </div> | |
| <div class="tweet-btns-container"> | |
| <!-- <div style="font-size: 10px;" class="draw-link-be-tweeted">'.translate("A_LINK_TO_THE_DRAW_WILL_BE_INCLUDED").'</div> --> | |
| <div class="chars-left-dynamic" id="chars-left">'.(140 - strlen($tweet_text_2)).'</div> | |
| <div class="clear"></div> | |
| </div> | |
| </div> | |
| </div> | |
| </li> | |
| </ul> | |
| <div class="clear"></div>'; | |
| // Create marckup for the PW | |
| $pw_html = '<li class="rule-item"> | |
| <ul class="rules-list"> | |
| <li>'.$follow_rules_str.'</li> | |
| <li>'.$hashtag_filters_str.'</li> | |
| </ul> | |
| </li>'; | |
| $pw_participate_html = '<li class="rule-item"> | |
| <ul class="rules-list participate-flow"> | |
| <span class="rules-span" >'.translate("MAKING_CLICK_ON").' <b class="hashtag colored" >'.translate("PARTICIPATE").'</b> '.translate("YOU_GIVE_US_AUTHORIZATION").':</span> | |
| <li>'.$follow_rules_str.'</li> | |
| <li>'.$hashtag_filters_participate_str.'</li> | |
| </ul> | |
| </li>'; | |
| $pw_tweet_placeholder = ""; | |
| $pw_tweet_validation_args = $pw_hashtag_filters; | |
| // Add rules actions to the array | |
| // $follow_actions = array(); | |
| // foreach ($pw_follow_rules as $follow_username) | |
| // { | |
| // $alreadyFollows = userFollowsBackUser($logged_user_tw_username, $follow_username); | |
| // $follow_actions[] = array( | |
| // 'username' => $follow_username, | |
| // 'already_follows' => $alreadyFollows | |
| // ); | |
| // } | |
| // $pw_rules_actions['follow'] = array( | |
| // 'values' => $follow_actions | |
| // //'rule_id' => '??', | |
| // //'already_participate' => '??' | |
| // ); | |
| // Add hashtag filters to the array | |
| // $hashtag_filters = array(); | |
| // foreach ($pw_hashtag_filters as $hashtag) | |
| // { | |
| // $hashtag_filters[] = array( | |
| // 'hashtag' => $hashtag | |
| // ); | |
| // } | |
| // $pw_rules_actions['hashtag'] = array( | |
| // 'values' => $hashtag_filters | |
| // //'rule_id' => '??', | |
| // //'already_participate' => '??' | |
| // ); | |
| break; | |
| case 'follow_plus_mention': | |
| // Get follow rules | |
| $pw_follow_rules = $pw_rules['rules']['follow'][0]['args']; | |
| // $follow_rules_str_2 = implode("</b>, <b>@", $pw_follow_rules); | |
| // $follow_rules_str = 'Seguir a <b>@'.$follow_rules_str_2.'</b>'; | |
| $follow_rules_str_2 = implode('</span>, <span class="mention">@', $pw_follow_rules); | |
| $follow_rules_str = '<div class="autolink-text">'.translate("FOLLOW_TO").' <span class="mention">@'.$follow_rules_str_2.'</span></div>'; | |
| // Get mention filters | |
| $pw_mention_filters = $pw_rules['filters']['mention'][0]['args']; | |
| $pw_mention_suggested_message = utf8_encode($pw_rules['filters']['mention'][0]['extra']); | |
| // $mention_filters_str_2 = implode("</b>, <b>@", $pw_mention_filters); | |
| // $mention_filters_str = 'Enviar tweet mencionando al usuario <b>@'.$mention_filters_str_2.'</b>'; | |
| $mention_filters_str_2 = implode('</span>, <span class="mention">@', $pw_mention_filters); | |
| $mention_filters_str = '<div class="autolink-text">'.translate("SEND_TWEET_MENTIONING_USER").' <span class="mention">@'.$mention_filters_str_2.'</span></div>'; | |
| // $find = array("{{ORGANIZER_SCREEN_NAME}}"); | |
| // $replace = array("@".$organizer_username); | |
| // $tweet_text_2 = translate("I_WANT_TO_PARTICIPATE_IN_DRAW_OF",$find,$replace)."! ".$draw_link; | |
| $tweet_text_2 = $pw_mention_suggested_message." (".$draw_link.")"; | |
| $mention_filters_participate_str = '<div class="autolink-text">'.translate("TWEET_WITH_MENTION_TO").' <span class="hashtag">#'.$mention_filters_str_2.'</span></div> | |
| <ul class="retweets-list"> | |
| <li class="retweet-item"> | |
| <!-- | |
| <a class="retweet-creator-image" href="'.$participant_profile_url.'" title="'.$participant_name.'" target="_blank"> | |
| <img src="'.$participant_image.'"> | |
| </a> | |
| --> | |
| <div class="retweet-data-wrapper"> | |
| <!-- | |
| <h3> | |
| <a target="_blank" href="'.$participant_profile_url.'">@'.$participant_username.'</a> | |
| </h3> | |
| --> | |
| <div class="retweet-text participate-flow"> | |
| <!-- <span class="prize-desc autolink-text">'.$tweet_text_2.'</span> --> | |
| <div class="noMarginBottom"> | |
| <textarea class="tweet-text-input scheduled-tweet-textarea decorated" data-maxlength="140">'.str_replace("http://", "", $tweet_text_2).'</textarea> | |
| </div> | |
| <div class="tweet-btns-container"> | |
| <!-- <div style="font-size: 10px;" class="draw-link-be-tweeted">'.translate("A_LINK_TO_THE_DRAW_WILL_BE_INCLUDED").'</div> --> | |
| <div class="chars-left-dynamic" id="chars-left">'.(140 - strlen($tweet_text_2)).'</div> | |
| <div class="clear"></div> | |
| </div> | |
| </div> | |
| </div> | |
| </li> | |
| </ul> | |
| <div class="clear"></div>'; | |
| // Create marckup for the PW | |
| $pw_html = '<li class="rule-item"> | |
| <ul class="rules-list"> | |
| <li>'.$follow_rules_str.'</li> | |
| <li>'.$mention_filters_str.'</li> | |
| </ul> | |
| </li>'; | |
| $pw_participate_html = '<li class="rule-item"> | |
| <ul class="rules-list participate-flow"> | |
| <span class="rules-span" >'.translate("MAKING_CLICK_ON").' <b class="hashtag colored" >'.translate("PARTICIPATE").'</b> '.translate("YOU_GIVE_US_AUTHORIZATION").':</span> | |
| <li>'.$follow_rules_str.'</li> | |
| <li>'.$mention_filters_participate_str.'</li> | |
| </ul> | |
| </li>'; | |
| $pw_tweet_placeholder = ""; | |
| $pw_tweet_validation_args = $pw_mention_filters; | |
| // Add rules actions to the array | |
| // $follow_actions = array(); | |
| // foreach ($pw_follow_rules as $follow_username) | |
| // { | |
| // $alreadyFollows = userFollowsBackUser($logged_user_tw_username, $follow_username); | |
| // $follow_actions[] = array( | |
| // 'username' => $follow_username, | |
| // 'already_follows' => $alreadyFollows | |
| // ); | |
| // } | |
| // $pw_rules_actions['follow'] = array( | |
| // 'values' => $follow_actions | |
| // //'rule_id' => '??', | |
| // //'already_participate' => '??' | |
| // ); | |
| // Add hashtag filters to the array | |
| // $mention_filters = array(); | |
| // foreach ($pw_mention_filters as $mention) | |
| // { | |
| // $mention_filters[] = array( | |
| // 'mention' => $mention | |
| // ); | |
| // } | |
| // $pw_rules_actions['mention'] = array( | |
| // 'values' => $mention_filters | |
| // //'rule_id' => '??', | |
| // //'already_participate' => '??' | |
| // ); | |
| break; | |
| case 'follow_plus_retweet': | |
| // print_str("FOLLOW + RT RULE HERE!"); | |
| // In this case we can have a hidden rule or a true one | |
| // print_str($pw_rules, "pw_rules"); | |
| if($pw_rules!=null) | |
| { | |
| // Get follow rules | |
| $pw_follow_rules = $pw_rules['rules']['follow'][0]['args']; | |
| // $follow_rules_str_2 = implode("</b>, <b>@", $pw_follow_rules); | |
| // $follow_rules_str = 'Seguir a <b>@'.$follow_rules_str_2.'</b>'; | |
| $follow_rules_str_2 = implode('</span>, <span class="mention">@', $pw_follow_rules); | |
| $follow_rules_str = '<div class="autolink-text">'.translate("FOLLOW_TO").' <span class="mention">@'.$follow_rules_str_2.'</span></div>'; | |
| // Get retweet filters, this is an array with scheduled RT id's | |
| $pw_retweet_filters = $pw_rules['retweets']['retweet'][0]['args']; | |
| // Get info of each scheduled RT | |
| $rts_html = ''; | |
| foreach ($pw_retweet_filters as $rt_id) | |
| { | |
| // print_str($rt_id, "rt_id"); | |
| // $tweet_exists_aux = tweetExists($rt_id); | |
| // $tweet_exists = $tweet_exists_aux['exists']; | |
| // $tweet_data = $tweet_exists_aux['object']; | |
| $scheduled_tweet = getScheduledTweet($rt_id); | |
| // print_str($scheduled_tweet, "scheduled_tweet"); | |
| $scheduled_tweet_text = $scheduled_tweet['text']; | |
| $scheduled_tweet_id = $scheduled_tweet['tweet_id']; | |
| $tweet_data = array( | |
| "tweet_user_profile_url" => $owner_tw_profile_url, | |
| "tweet_user_name" => $owner_tw_name, | |
| "tweet_user_profile_image_url" => $owner_tw_image, | |
| "tweet_user_username" => $owner_tw_username, | |
| "tweet_text" => $scheduled_tweet_text, | |
| "tweet_id" => $scheduled_tweet_id | |
| ); | |
| // print_str($tweet_data, "tweet_data"); | |
| //$rts_html .= '<li>'.$tweet_data['tweet_text'].'</li>'; | |
| $rts_html .= '<li class="retweet-item"> | |
| <a class="retweet-creator-image" href="'.$tweet_data['tweet_user_profile_url'].'" title="'.$tweet_data['tweet_user_name'].'" target="_blank"> | |
| <img src="'.$tweet_data['tweet_user_profile_image_url'].'"/> | |
| </a> | |
| <div class="retweet-data-wrapper"> | |
| <h3> | |
| <a target="_blank" href="'.$tweet_data['tweet_user_profile_url'].'">@'.$tweet_data['tweet_user_username'].'</a> | |
| </h3> | |
| <div class="retweet-text"> | |
| <span class="prize-desc autolink-text">'.utf8_encode($tweet_data['tweet_text']).'</span> | |
| <a target="_blank" href="http://twitter.com/'.$tweet_data['tweet_user_username'].'/status/'.$tweet_data['tweet_id'].'" class="see-this-tweet">(ver)</a> | |
| </div> | |
| </div> | |
| </li>'; | |
| $rts_participate_html .= '<li class="retweet-item"> | |
| <a class="retweet-creator-image" href="'.$tweet_data['tweet_user_profile_url'].'" title="'.$tweet_data['tweet_user_name'].'" target="_blank"> | |
| <img src="'.$tweet_data['tweet_user_profile_image_url'].'"/> | |
| </a> | |
| <div class="retweet-data-wrapper"> | |
| <h3> | |
| <a target="_blank" href="'.$tweet_data['tweet_user_profile_url'].'">@'.$tweet_data['tweet_user_username'].'</a> | |
| </h3> | |
| <div class="retweet-text"> | |
| <span class="prize-desc autolink-text">'.utf8_encode($tweet_data['tweet_text']).'</span> | |
| </div> | |
| </div> | |
| </li>'; | |
| // $retweet_filters[] = $tweet_data; | |
| } | |
| if($rts_html!='') | |
| { | |
| $retweet_filters_str = translate("RETWEET_THIS_TWEET").': | |
| <ul class="retweets-list"> | |
| '.$rts_html.' | |
| </ul> | |
| <div class="clear"></div>'; | |
| $retweet_filters_participate_str = translate("RETWEET_THIS_TWEET").': | |
| <ul class="retweets-list"> | |
| '.$rts_participate_html.' | |
| </ul> | |
| <div class="clear"></div>'; | |
| } | |
| // Create marckup for the PW | |
| $pw_html = '<li class="rule-item"> | |
| <ul class="rules-list"> | |
| <li>'.$follow_rules_str.'</li> | |
| <li>'.$retweet_filters_str.'</li> | |
| </ul> | |
| </li>'; | |
| $pw_participate_html = '<li class="rule-item"> | |
| <ul class="rules-list"> | |
| <span class="rules-span" >'.translate("MAKING_CLICK_ON").' <b class="hashtag colored" >'.translate("PARTICIPATE").'</b> '.translate("YOU_GIVE_US_AUTHORIZATION").':</span> | |
| <li>'.$follow_rules_str.'</li> | |
| <li>'.$retweet_filters_participate_str.'</li> | |
| </ul> | |
| </li>'; | |
| $pw_tweet_placeholder = ""; | |
| $pw_tweet_validation_args = ""; | |
| // Add rules actions to the array | |
| // $follow_actions = array(); | |
| // foreach ($pw_follow_rules as $follow_username) | |
| // { | |
| // $alreadyFollows = userFollowsBackUser($logged_user_tw_username, $follow_username); | |
| // $follow_actions[] = array( | |
| // 'username' => $follow_username, | |
| // 'already_follows' => $alreadyFollows | |
| // ); | |
| // } | |
| // $pw_rules_actions['follow'] = array( | |
| // 'values' => $follow_actions | |
| // //'rule_id' => '??', | |
| // //'already_participate' => '??' | |
| // ); | |
| // $pw_rules_actions['retweet'] = array( | |
| // 'values' => $retweet_filters | |
| // //'rule_id' => '??', | |
| // //'already_participate' => '??' | |
| // ); | |
| } | |
| else// We have a hidden rule | |
| { | |
| // Get follow rules | |
| $pw_follow_rules = $pw_hidden_rules['rules']['follow'][0]['args']; | |
| // $follow_rules_str_2 = implode("</b>, <b>@", $pw_follow_rules); | |
| // $follow_rules_str = 'Seguir a <b>@'.$follow_rules_str_2.'</b>'; | |
| $follow_rules_str_2 = implode('</span>, <span class="mention">@', $pw_follow_rules); | |
| $follow_rules_str = '<div class="autolink-text">'.translate("FOLLOW_TO").' <span class="mention">@'.$follow_rules_str_2.'</span></div>'; | |
| // Get retweet filters, this is an array with scheduled RT id's | |
| $pw_retweet_filters = $pw_hidden_rules['retweets']['retweet'][0]['args']; | |
| // print_str("HIDDEN RULE HERE!"); | |
| // Get info of each scheduled RT | |
| $rts_html = ''; | |
| // Add hashtag filters to the array | |
| $retweet_filters = array(); | |
| foreach ($pw_retweet_filters as $rt_text) | |
| { | |
| // Get owner twitter info in order to show the RT (tw image, name and username) | |
| $tweet_data = array( | |
| "tweet_user_profile_url" => $owner_tw_profile_url, | |
| "tweet_user_name" => $owner_tw_name, | |
| "tweet_user_profile_image_url" => $owner_tw_image, | |
| "tweet_user_username" => $owner_tw_username, | |
| "tweet_text" => $rt_text['text'] | |
| ); | |
| //print_str($tweet_data, "tweet_data"); | |
| // $rts_html .= '<li>'.$tweet_data['tweet_text'].'</li>'; | |
| $rts_html .= '<li class="retweet-item"> | |
| <a class="retweet-creator-image" href="'.$tweet_data['tweet_user_profile_url'].'" title="'.$tweet_data['tweet_user_name'].'" target="_blank"> | |
| <img src="'.$tweet_data['tweet_user_profile_image_url'].'"/> | |
| </a> | |
| <div class="retweet-data-wrapper"> | |
| <h3> | |
| <a target="_blank" href="'.$tweet_data['tweet_user_profile_url'].'">@'.$tweet_data['tweet_user_username'].'</a> | |
| </h3> | |
| <div class="retweet-text"> | |
| <span class="prize-desc autolink-text">'.utf8_encode($tweet_data['tweet_text']).'</span> | |
| </div> | |
| </div> | |
| </li>'; | |
| $retweet_filters[] = $tweet_data; | |
| } | |
| if($rts_html!='') | |
| { | |
| $retweet_filters_str = translate("RETWEET_THIS_TWEET").' '.translate("TWEET_NOT_PUBLISHED_YET").': | |
| <ul class="retweets-list"> | |
| '.$rts_html.' | |
| </ul> | |
| <div class="clear"></div>'; | |
| } | |
| // Create marckup for the PW | |
| $pw_html = '<li class="rule-item"> | |
| <ul class="rules-list"> | |
| <li>'.$follow_rules_str.'</li> | |
| <li>'.$retweet_filters_str.'</li> | |
| </ul> | |
| </li>'; | |
| } | |
| break; | |
| default: | |
| // code... | |
| break; | |
| }// END SWITCH | |
| $draw_pw_html .= $pw_html; | |
| $draw_pws[] = $pw_html; | |
| // Correct PW (with rules) | |
| if($pw_rules!=null) | |
| { | |
| $draw_correct_pws[] = array( | |
| "html" => $pw_participate_html, | |
| "pw_id" => $pw_id, | |
| "pw_description" => $pw_description, | |
| "pw_tweet_placeholder" => $pw_tweet_placeholder, | |
| "pw_tweet_validation_args" => $pw_tweet_validation_args | |
| ); | |
| } | |
| // ADD PW to the $draw_pws_actions array() | |
| // $draw_pws_actions[] = array( | |
| // 'pw_description' => $pw_description, | |
| // 'pw_id' => $pw_id, | |
| // 'pw_rules' => $pw_rules_actions, | |
| // 'pw_already_participate' => false | |
| // ); | |
| }// END PW_RULES != NULL | |
| }// END FOREACH DRAW PW | |
| $first_pw = $draw_correct_pws[0]; | |
| $first_pw_html = $first_pw['html']; | |
| $first_pw_id = $first_pw['pw_id']; | |
| $first_pw_desc = $first_pw['pw_description']; | |
| $first_pw_tweet_validation_args = json_encode($first_pw['pw_tweet_validation_args']); | |
| // print_str($first_pw); | |
| $draw_pw_html = ''; | |
| if(count($draw_pws)>1){ | |
| for($i=0; $i<count($draw_pws); $i++) | |
| { | |
| $draw_pw_html .= '<h3 style="margin-bottom: 0px;">'.translate("OPTION").' '.($i+1).'</h3>'.$draw_pws[$i]; | |
| } | |
| }else{ | |
| $draw_pw_html .= $draw_pws[0]; | |
| } | |
| //print_str($draw_pws_actions, "draw_pws_actions"); | |
| // $draw_pws_actions_json = json_encode($draw_pws_actions); | |
| // Show prizes | |
| // Get draw prizes | |
| $cd_prizes = getDrawPrizes($cd_id); | |
| // Process all prizes | |
| $prizes_html = ''; | |
| foreach ($cd_prizes as $prize) | |
| { | |
| //print_str($prize, "prize"); | |
| $prizes_html .= ' <li class="prize-item"> | |
| <div class=""> | |
| <span class="prize-description">'.$prize['description'].'</span> | |
| <span class="prize-count">(x'.$prize['original_count'].')</span> | |
| <div class="clear"></div> | |
| </div> | |
| </li>'; | |
| } | |
| // Get draw winners | |
| $cd_winners = getDrawWinners($cd_id); | |
| $cd_winners_count = count($cd_winners); | |
| $cd_winners_html = ''; | |
| //print_str($cd_winners,"cd_winners"); | |
| $winners_array_str = array(); | |
| foreach ($cd_winners as $winner) | |
| { | |
| $curated_name_aux1 = explode(" ", $winner['twitter_data']['tw_name']); | |
| $curated_name_aux2 = strtolower($curated_name_aux1[0]); | |
| $curated_name = ucfirst($curated_name_aux2); | |
| $cd_winners_html_aux = '<li class="winner-item"> | |
| <a class="participant-image" href="'.$winner['twitter_data']['tw_profile_url'].'" title="'.$winner['twitter_data']['tw_name'].'" target="_blank"> | |
| <img src="'.$winner['twitter_data']['tw_image'].'"/> | |
| </a> | |
| <div class="winner-prize-desc"> | |
| <div class="winner-name-wrapper"> | |
| <h3 class="winner-name"> | |
| '.$curated_name.' '.translate("WON").': | |
| </h3> | |
| <h3 class="winner-screen-name"> | |
| <a target="_blank" href="'.$winner['twitter_data']['tw_profile_url'].'">@'.$winner['twitter_data']['tw_username'].'</a> | |
| </h3> | |
| <div class="clear"></div> | |
| </div> | |
| <div class="winner-prize-wrapper"> | |
| <h3>'.$winner['prize_data']['description'].'</h3> | |
| </div> | |
| </div> | |
| <div class="clear"></div> | |
| </li>'; | |
| $winners_array_str[] = $cd_winners_html_aux; | |
| } | |
| $cd_winners_html_a = implode('<hr/>', $winners_array_str); | |
| $cd_winners_html = '<hr/>'.$cd_winners_html_a.'<hr/>'; | |
| // Check if the draw is OK and is enabled (it may happend that the RT tweet ids are not set yet) | |
| // Check if each RT tweet id exists, if not, than show some alert box | |
| // $missing_retweets = array(); | |
| // $missing_retweets_html = ''; | |
| // foreach ($draw_rules_filters_retweet as $rule_filter_retweet) | |
| // { | |
| // // Check if each tweet exists | |
| // if($rule_filter_retweet=="xxx") | |
| // { | |
| // $missing_retweets_html .= 'Tienes un id de tweet por agregar<br/><br/>'; | |
| // } | |
| // else | |
| // { | |
| // $tweet_exists_aux = tweetExists($rule_filter_retweet); | |
| // if(!$tweet_exists_aux['exists']) | |
| // { | |
| // $missing_retweets_html .= 'El id de tweet "'.$rule_filter_retweet.'" no existe, por favor ingresa uno correcto.<br/><br/>'; | |
| // } | |
| // } | |
| // } | |
| $isLogged_as_p = isLogged("participant"); | |
| // Participation module | |
| // If the user is logged as participant, then get the date he needs to complete in order to participate (special data fields for each draw) | |
| if($isLogged_as_p) | |
| { | |
| // Get the needed data for this draw | |
| $draw_needed_fields = getDrawNeededFields($cd_id, $logged_user_id); | |
| // $draw_needed_fields is an array with this format array(array('field_type'=>type, 'field_name'=>name, 'field_value'=>value)) | |
| $draw_needed_fields_json = json_encode($draw_needed_fields); | |
| // $draw_needed_fields_html = ''; | |
| // foreach ($draw_needed_fields as $d_field) | |
| // { | |
| // $field_type = $d_field['field_type']; | |
| // $field_name = $d_field['field_name']; | |
| // $field_value = $d_field['field_value']; | |
| // switch ($field_type) | |
| // { | |
| // case 'input': | |
| // $draw_needed_fields_html .= '<input data-validationmsj="El campo '.$field_name.' es obligatorio" class="decorated" placeholder="'.$field_name.'" type="text" id="'.$field_name.'" name="'.$field_name.'" value="'.$field_value.'">'; | |
| // break; | |
| // case 'select': | |
| // $draw_needed_fields_html .= getCountrySelect($field_name); | |
| // break; | |
| // default: | |
| // # code... | |
| // break; | |
| // } | |
| // } | |
| $participant_draw_data = getParticipantDrawData($logged_user_id); | |
| $participant_real_name = (isset($participant_draw_data['real_name']) && $participant_draw_data['real_name']!="") ? $participant_draw_data['real_name']: ""; | |
| $participant_email = (isset($participant_draw_data['email']) && $participant_draw_data['email']!="") ? $participant_draw_data['email']: ""; | |
| $participant_country = (isset($participant_draw_data['country']) && $participant_draw_data['country']!="") ? $participant_draw_data['country']: ""; | |
| $select_aux = getCountrySelect("country"); | |
| $draw_needed_fields_html = '<ul class="draw-needed-fields"> | |
| <li> | |
| <h3>'.translate("NAME").'</h3> | |
| <input data-validationmsj="'.translate("THE_FIELD_NAME_IS_REQUIRED").'" class="decorated" placeholder="'.translate("YOUR_NAME").'" type="text" id="real_name" name="real_name" value="'.$participant_real_name.'"> | |
| <div class="clear"></div> | |
| </li> | |
| <li> | |
| <h3 >'.translate("EMAIL").'</h3> | |
| <input data-validationmsj="'.translate("THE_FIELD_EMAIL_IS_REQUIRED").'" class="decorated" placeholder="'.translate("YOUR_EMAIL").'" type="text" id="email" name="email" value="'.$participant_email.'"> | |
| <div class="clear"></div> | |
| </li> | |
| <li> | |
| <h3 >'.translate("COUNTRY").'</h3> | |
| '.$select_aux.' | |
| <div class="clear"></div> | |
| </li> | |
| </ul>'; | |
| } | |
| // print_str($participation_popup_enabled); | |
| $h = new Header(); | |
| $h->setTitle($cd_title." - SorTwit"); | |
| // $h->setDescription(translate("DRAW_PAGE_META_DESCIPTION")); | |
| $h->setKeywords(translate("DRAW_PAGE_META_KEYWORDS")); | |
| $h->setApplicationName(translate("SITE_NAME")); | |
| $h->setApplicationTooltip(translate("APPLICATION_TOOLTIP")." - ".translate("SITE_NAME")); | |
| $h->addStylesheet('<link rel="stylesheet" href="'.STATIC_BASE_URL.'css/styles.css?v=3">'); | |
| $h->addStylesheet('<link rel="stylesheet" href="'.STATIC_BASE_URL.'css/jquery.fancybox-1.3.4.css">'); | |
| $h->addStylesheet('<link rel="stylesheet" href="'.STATIC_BASE_URL.'css/ui-lightness/jquery-ui-1.8.21.custom.css">'); | |
| $h->addStylesheet('<link rel="stylesheet" href="'.STATIC_BASE_URL.'css/styles_draw.css?v=3">'); | |
| $h->addScript('<script src="'.STATIC_BASE_URL.'js/jquery-1.7.2.min.js"></script>'); | |
| $h->addScript('<script src="'.STATIC_BASE_URL.'js/jquery-ui-1.8.21.custom.min.js"></script>'); | |
| $h->addScript('<script src="'.STATIC_BASE_URL.'js/jquery.fancybox-1.3.4.pack.js"></script>'); | |
| $h->addScript('<script src="'.STATIC_BASE_URL.'js/twitter-text.js"></script>'); | |
| //$h->addScript('<script src="'.STATIC_BASE_URL.'js/jquery.timeago.js"></script>'); | |
| $h->renderHead(); | |
| ?> | |
| <div id="wrapper"> | |
| <?php | |
| if(isset($_SESSION['user_id'])){ | |
| // print_str($_SESSION); | |
| $logged_user_id = $_SESSION['user_id']; | |
| $logged_user_tw_username = $_SESSION['username']; | |
| $logged_user_tw_name = $_SESSION['name']; | |
| $logged_user_tw_image = $_SESSION['twitter_account']['avatar_url']; | |
| $logged_user_tw_profile_url = "http://twitter.com/".$logged_user_tw_username; | |
| } | |
| // RENDER THE HEADER | |
| $h->renderHeader(); | |
| //INCLUDE THE TEMPLATE | |
| $already_participating = false; | |
| $editarLink = 'http://'.DOMAIN_BASE_URL.'/'.$owner_tw_username.'/edit/'.$draw_id; | |
| if($isLogged_as_p) | |
| { | |
| $participarLink = "#"; | |
| // Check if the user is already participating | |
| $already_participating = checkParticipation($logged_user_id, $cd_id); | |
| $is_already_visible = in_array($participant_username, $participants_items_control); | |
| if($already_participating && !$is_already_visible) | |
| { | |
| // Lets show his tw profile image in the participants mosaic | |
| $logged_user_participant_item = ' <li> | |
| <a class="participant-image" href="'.$participant_profile_url.'" title="'.$participant_name.'" target="_blank"> | |
| <img src="'.$participant_image.'"/> | |
| </a> | |
| </li>'; | |
| // Lets pop one participant and push this one | |
| array_pop($participants_html_items); | |
| array_push($participants_html_items, $logged_user_participant_item); | |
| } | |
| } | |
| else | |
| { | |
| $participarLink = getTwitterLoginLink("participant"); | |
| } | |
| $participants_html = implode("", $participants_html_items); | |
| $popup_enabled_aux = isParticipationPopupEnabled(); | |
| // Check if the user is already participating, if so then enable ParticipationPopUp, | |
| // else, enable VerifyParticipationPopup | |
| if($popup_enabled_aux) | |
| { | |
| $participation_popup_enabled = ($already_participating) ? "disabled": "enabled"; | |
| $verify_participation_popup_enabled = ($already_participating) ? "enabled": "disabled"; | |
| } | |
| else | |
| { | |
| $participation_popup_enabled = "disabled"; | |
| $verify_participation_popup_enabled = "disabled"; | |
| } | |
| $disable_participation_btn = (!$draw_has_started || $already_participating ) ? "disabled" : ""; | |
| $participate_btn_text = ($already_participating) ? translate("ALREADY_PARTICIPATING") : (($draw_has_started) ? translate("PARTICIPATE_IN_THIS_DRAW") : translate("PARTICIPATE_IN_THIS_DRAW_2").date("H:i",$cd_start_date_aux)); | |
| $draw_creation_response = getPostbackMsg("draw_creation_response"); | |
| if($draw_creation_response!=""){ | |
| $top_message = 1; | |
| } | |
| $draw_ok = ($draw_creation_response=="OK"); | |
| //$draw_ok = true; | |
| $draw_error = ($draw_creation_response=="ERROR"); | |
| $bg_color = ($draw_ok) ? "#DEF3B4" : "#F99"; | |
| require_once("templates/draw.php"); | |
| } | |
| else | |
| { | |
| if($db_error) | |
| { | |
| // Error in mysql result (or connection), redirect user to landing page | |
| header("Location:http://".DOMAIN_BASE_URL."/"); | |
| exit(); | |
| } | |
| // else | |
| // { | |
| // // The draw the person id trying to access does not exist, redirect him and show him similar ones | |
| // //header("Location:http://".DOMAIN_BASE_URL."/similar?show_similar=1&company_name=".$company_name."&draw_name=".$draw_name); | |
| // header("Location:http://".DOMAIN_BASE_URL."/similar/".$company_name."/".$draw_name); | |
| // exit(); | |
| // } | |
| } | |
| } | |
| else | |
| { | |
| // Redirect him to landng page | |
| header("Location:http://".DOMAIN_BASE_URL."/"); | |
| exit(); | |
| } | |
| ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment