Guest User

Untitled

a guest
Dec 26th, 2012
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 11.69 KB | None | 0 0
  1. <?php
  2.  
  3. class Wizard extends CI_Controller{
  4.     public function index()
  5.     {
  6.         $this->load->helper('form');
  7.         $this->load->view('survey');
  8.     }
  9.  
  10.     public function results () {
  11.         $id= $this->uri->segment(3,0);
  12.         if($this->survey_model->exists($id) == 0){
  13.             redirect('/wizard/', 'refresh');
  14.         }
  15.         else {
  16.            
  17.             $data['results'] = $this->survey_model->get_results($id);
  18.             $this->load->view('show_results', $data);
  19.         }
  20.     }
  21.  
  22.     public function process() {
  23.     $name = $this->input->post('name');
  24.     $email = $this->input->post('email');
  25.     $priceRange = $this->input->post('priceRange');
  26.     $sharedImportant = $this->input->post('mostImportant');
  27.     $numWebsites = $this->input->post('numberSites');
  28.     $helpPref = $this->input->post('managePref');
  29.     $useWordPress = $this->input->post('wordpressChoice');
  30.     $resellerIn = $this->input->post('reseller');
  31.     $traffic = $this->input->post('traffic');
  32.  
  33.     $typeHost = NULL;
  34.     $hostMsg = NULL;
  35.     $hostAffMsg = NULL;
  36.  
  37.     $shared = 0;
  38.     $managedWp = 0;
  39.     $vps = 0;
  40.     $dedicated = 0;
  41.     $reseller = 0;
  42.  
  43.     $topCoupon = NULL;
  44.     $secondCoupon = NULL;
  45.     $thirdCoupon = NULL;
  46.        
  47.     $wpengineImg = 'http://www.artofblog.com/survey-email/ratings/wpengine-rating.jpg';
  48.     $arvixeImg = 'http://www.artofblog.com/survey-email/ratings/arvixe-rating.jpg';
  49.     $dreamhostImg = 'http://www.artofblog.com/survey-email/ratings/dreamhost-rating.jpg';
  50.     $synthesisImg = 'http://www.artofblog.com/survey-email/ratings/synthesis-rating.jpg';
  51.     $pagelyImg = 'http://www.artofblog.com/survey-email/ratings/pagely-rating.jpg';
  52.     $bluehostImg = 'http://www.artofblog.com/survey-email/ratings/bluehost-rating.jpg';
  53.     $hostgatorImg = 'http://www.artofblog.com/survey-email/ratings/hostgator-rating.jpg';
  54.  
  55.     $hostgatorUrl = 'http://whattypeofhosting.com/track?go=http://hostgator.com&utm_campaign=e-WhatHosting';
  56.     $arvixeUrl = 'http://whattypeofhosting.com/track?go=http://arvixe.com&utm_campaign=e-WhatHosting';
  57.     $dreamhostUrl = 'http://whattypeofhosting.com/track?go=http://dreamhost.com&utm_campaign=e-WhatHosting';
  58.     $bluehostUrl = 'http://whattypeofhosting.com/track?go=http://bluehost.com&utm_campaign=e-WhatHosting';
  59.     $wpengineUrl = 'http://whattypeofhosting.com/track?go=http://wpengine.com&utm_campaign=e-WhatHosting';
  60.     $synthesisUrl = 'http://whattypeofhosting.com/track?go=http://websynthesis.com&utm_campaign=e-WhatHosting';
  61.     $pagelyUrl = 'http://whattypeofhosting.com/track?go=http://page.ly&utm_campaign=e-WhatHosting';
  62.  
  63.     $hostgatorMsg = 'We know you will love Hostgator because they have amazing customer service and have established themselves over the past 10 years with great service.';
  64.     $arvixeMsg = 'Not only do they have great service and some of the best prices on the market, but they also have 24-7 US based phone support, a gigantic selection of one-click installs, and free domain for life.';
  65.     $dreamhostMsg = 'These guys have been in business for over 14 years and have one of the best reputations online. With shared hosting you get a free domain for life, unlimited everything, AND 50 GB backup space!';
  66.     $bluehostMsg = 'Bluehost is a good alternative as they give you unlimited domains, emails, etc. They also provide 24-7 US based customer support and give you full resource control to prevent overage errors.';
  67.     $wpengineMsg = 'These guys are the best in the managed WordPress hosting business. They have THE BEST customer support, features that you won\'t find anywhere else, and the will fix your website if it is ever hacked for FREE.';
  68.     $synthesisMsg = 'They are ran by Copyblogger media, whose websites get over 2.5 Million monthly page views. Bottom line, these guys have the experience to make your WordPress experience a dream. They have great service and super smart people.';
  69.     $pagelyMsg = 'If you want secure hosting, then Pagely is a great choice since they use Firehost\'s secure architecture. Pagely also has super fast email support for those times you have issues.';
  70.  
  71.     $dreamhostSharedCoupon ='<p>Save $25 off your first year with Dreamhost by using coupon code <a href="http://whattypeofhosting.com/track?go=http://dreamhost.com&utm_campaign=e-WhatHosting">ARTOFBLOG</a></p><p>Get a FREE domain registration and $7 off with Dreamhost by using coupon code <a href="http://whattypeofhosting.com/track?go=http://dreamhost.com&utm_campaign=e-WhatHosting">NEWBLOG</a></p>';
  72.     $hostgatorSharedCoupon = '<p>Save 25% off Host Gator by using coupon code <a href="http://whattypeofhosting.com/track?go=http://hostgator.com&utm_campaign=e-WhatHosting">ARTOFBLOG25</a>.</p><p>Save 25% off your yearly purchase with Hostgator by using coupon code <a href="http://whattypeofhosting.com/track?go=http://hostgator.com&utm_campaign=e-WhatHosting">YearlyDiscount</a>.</p>';
  73.     $arvixeSharedCoupon = '<p>Save up to 25% on your hosting with Arvixe when you use coupon code <a href="http://whattypeofhosting.com/track?go=http://arvixe.com&utm_campaign=e-WhatHosting">AOB</a> and pay for 2 years. Save 10% if you pay by the month.</p>';
  74.     switch ($priceRange) {
  75.         case '$0-20':
  76.             $shared += 10;
  77.             $managedWp += 3;
  78.             $vps += 6;
  79.             $dedicated += 0;
  80.             break;
  81.        
  82.         case '$20-100':
  83.             $shared += 8;
  84.             $managedWp += 10;
  85.             $vps += 8;
  86.             $dedicated += 0;
  87.             break;
  88.  
  89.         case '$100+':
  90.             $shared += 4;
  91.             $managedWp += 8;
  92.             $vps += 8;
  93.             $dedicated += 8;
  94.             break;
  95.     }
  96.  
  97.     switch ($sharedImportant) {
  98.         case 'price':
  99.             $shared += 8;
  100.             $managedWp += 2;
  101.             $vps += 8;
  102.             $dedicated += 0;
  103.             break;
  104.        
  105.         case 'support':
  106.             $shared += 4;
  107.             $managedWp += 10;
  108.             $vps += 6;
  109.             $dedicated += 10;
  110.             break;
  111.     }
  112.  
  113.     switch ($helpPref) {
  114.         case 'self':
  115.             $shared += 8;
  116.             $managedWp += 2;
  117.             $vps += 8;
  118.             $dedicated += 6;
  119.             break;
  120.        
  121.         case 'managed':
  122.             $shared += 0;
  123.             $managedWp += 10;
  124.             $vps += 4;
  125.             $dedicated += 4;
  126.             break;
  127.     }
  128.  
  129.     switch ($useWordPress) {
  130.         case 'yes':
  131.             $managedWp += 10;
  132.             break;
  133.        
  134.         case 'no':
  135.             // nothing yet
  136.             break;
  137.     }
  138.  
  139.     switch ($resellerIn) {
  140.         case 'yes':
  141.             $reseller += 200;
  142.             break;
  143.        
  144.         case 'no':
  145.             $reseller -= 500;
  146.             break;
  147.     }
  148.  
  149.     switch ($traffic) {
  150.         case 'medium':
  151.             $managedWp += 10;
  152.             $vps += 6;
  153.             $dedicated += 6;
  154.             break;
  155.        
  156.         case 'large':
  157.             $managedWp += 10;
  158.             $vps += 4;
  159.             $dedicated += 10;
  160.             break;
  161.     }
  162.     $sorting = array ($shared, $managedWp, $reseller, $vps, $dedicated);
  163.  
  164.             rsort($sorting);                // sort high to low
  165.  
  166.             if ($sorting[0] == $shared){
  167.                 $hostMsg = 'since your budget is low and price is an important factor to you, shared hosting is the way to go.';
  168.                
  169.                 $topChoiceMsg = $arvixeMsg;
  170.                 $secondChoiceMsg =$dreamhostMsg;
  171.                 $thirdChoiceMsg = $hostgatorMsg;
  172.  
  173.                 $topChoiceUrl = $arvixeUrl;
  174.                 $secondChoiceUrl = $dreamhostUrl;
  175.                 $thirdChoiceUrl = $hostgatorUrl;
  176.  
  177.                 $firstChoiceImage = $arvixeImg;
  178.                 $secondChoiceImage = $dreamhostImg;
  179.                 $thirdChoiceImage = $hostgatorImg;
  180.  
  181.                 $topChoiceName = 'Arvixe';
  182.                 $secondChoiceName = 'Dreamhost';
  183.                 $thirdChoiceName = 'Hostgator';
  184.  
  185.                 $hostType = 'shared';
  186.  
  187.                 $topCoupon = $arvixeSharedCoupon;
  188.         $secondCoupon = $dreamhostSharedCoupon;
  189.         $thirdCoupon = $hostgatorSharedCoupon;
  190.     }
  191.     elseif ($sorting[0] == $managedWp){
  192.         $hostMsg = 'you should consider managed WordPress hosting. Managed WordPress hosting is a bit more expensive than getting a VPS and managing the hosting yourself, but you will not have to worry about your site going down due to high traffic or getting hacked.';
  193.  
  194.         $topChoiceMsg = $wpengineMsg;
  195.                 $secondChoiceMsg =$synthesisMsg;
  196.                 $thirdChoiceMsg = $pagelyMsg;
  197.  
  198.                 $topChoiceUrl = $wpengineUrl;
  199.                 $secondChoiceUrl = $synthesisUrl;
  200.                 $thirdChoiceUrl = $pagelyUrl;
  201.  
  202.                 $firstChoiceImage = $wpengineImg;
  203.                 $secondChoiceImage = $synthesisImg;
  204.                 $thirdChoiceImage = $pagelyImg;
  205.  
  206.                 $topChoiceName = 'WpEngine';
  207.                 $secondChoiceName = 'Synthesis';
  208.                 $thirdChoiceName = 'Pagely';
  209.  
  210.                 $hostType = 'managedWp';
  211.     }
  212.     elseif ($sorting[0] == $reseller){
  213.         $hostMsg = 'since you want to sell hosting to others, we recommend you get a reseller hosting account. Each of these reseller plans allow unlimited domains, accounts, and emails so you can handle all of your customers.';
  214.  
  215.         $topChoiceMsg = $arvixeMsg;
  216.                 $secondChoiceMsg =$hostgatorMsg;
  217.                 $thirdChoiceMsg = $bluehostMsg;
  218.  
  219.                 $topChoiceUrl = $arvixeUrl;
  220.                 $secondChoiceUrl = $hostgatorUrl;
  221.                 $thirdChoiceUrl = $bluehostUrl;
  222.  
  223.                 $firstChoiceImage = $arvixeImg;
  224.                 $secondChoiceImage = $hostgatorImg;
  225.                 $thirdChoiceImage = $bluehostImg;
  226.  
  227.                 $topChoiceName = 'Arvixe';
  228.                 $secondChoiceName = 'Hostgator';
  229.                 $thirdChoiceName = 'Bluehost';
  230.  
  231.                 $hostType = 'reseller';
  232.     }
  233.     elseif ($sorting[0] == $vps){
  234.         $hostMsg = 'since you are getting high traffic, that it would be best if you looked into a VPS solution. A VPS server will give you dedicated resources and will allow you to adjust your resources as needed. ';
  235.  
  236.         $topChoiceMsg = $hostgatorMsg;
  237.                 $secondChoiceMsg =$arvixeMsg;
  238.                 $thirdChoiceMsg = $dreamhostMsg;
  239.  
  240.                 $topChoiceUrl = $hostgatorUrl;
  241.                 $secondChoiceUrl = $arvixeUrl;
  242.                 $thirdChoiceUrl = $dreamhostUrl;
  243.  
  244.                 $firstChoiceImage = $hostgatorImg;
  245.                 $secondChoiceImage = $arvixeImg;
  246.                 $thirdChoiceImage = $dreamhostImg;
  247.  
  248.                 $topChoiceName = 'Hostgator';
  249.                 $secondChoiceName = 'Arvixe';
  250.                 $thirdChoiceName = 'Dreamhost';
  251.  
  252.                 $hostType = 'vps';
  253.     }
  254.     else {  // case for dedicated
  255.         $hostMsg = 'you should look into a dedicated server or custom solution to handle your high traffic. Once we get to this level, hosting often times has to be custom tailored. This depends upon the needs of your website.';
  256.  
  257.         $topChoiceMsg = $wpengineMsg;
  258.                 $secondChoiceMsg =$arvixeMsg;
  259.                 $thirdChoiceMsg = $dreamhostMsg;
  260.  
  261.                 $topChoiceUrl = $wpengineUrl;
  262.                 $secondChoiceUrl = $arvixeUrl;
  263.                 $thirdChoiceUrl = $dreamhostUrl;
  264.  
  265.                 $firstChoiceImage = $wpengineImg;
  266.                 $secondChoiceImage = $arvixeImg;
  267.                 $thirdChoiceImage = $dreamhostImg;
  268.  
  269.                 $topChoiceName = 'WpEngine';
  270.                 $secondChoiceName = 'Arvixe';
  271.                 $thirdChoiceName = 'Dreamhost';
  272.  
  273.                 $hostType = 'dedicated';
  274.     }
  275.  
  276.     /* ******** Save to database. Redirect to results.*********** */
  277.  
  278.     $data = array(
  279.         'name' => $name,
  280.         'email' => $email,
  281.         'price' => $priceRange,
  282.         'important' => $sharedImportant,
  283.         'prefer' => $helpPref,
  284.         'numweb' => $numWebsites,
  285.         'wordpress' => $useWordPress,
  286.         'resell' => $reseller,
  287.         'traffic' => $traffic,
  288.         'category' => $hostType,
  289.         'topNAme' => $topChoiceName,
  290.         '2ndNAme' => $secondChoiceName,
  291.         '3rdNAme' => $thirdChoiceName,
  292.         'topMSg' => $topChoiceMsg,
  293.         '2ndMsg' => $secondChoiceMsg,
  294.         '3rdMsg' => $thirdChoiceMsg,
  295.         'topUrl' => $topChoiceUrl,
  296.         '2ndUrl' => $secondChoiceUrl,
  297.         '3rdUrl' => $thirdChoiceUrl,
  298.         'topImg' => $firstChoiceImage,
  299.         '2ndImg' => $secondChoiceImage,
  300.         '3rdImg' => $thirdChoiceImage,
  301.         'hostMsg' => $hostMsg,
  302.         'topCoupon' => $topCoupon,
  303.         '2ndCoupon' => $secondCoupon,
  304.         '3rdCoupon' => $thirdCoupon
  305.     );
  306.  
  307.     $this->survey_model->add_record($data);
  308.  
  309.     $Max = $this->survey_model->get_max_id();
  310.  
  311.     // Let's set a cookie with value of the ID for 1 week
  312.     // to remind people if they have already filled out survey
  313.  
  314.     $cookie = array(
  315.             'name'   => 'visited',
  316.             'value'  => $Max,
  317.             'expire' => '604800',
  318.             'domain' => '',
  319.             'path'   => '',
  320.             'prefix' => '',
  321.         );
  322.         set_cookie($cookie);
  323.  
  324.     $to = base_url()."wizard/results/".$Max;
  325.     redirect( $to, 'refresh'); 
  326. }
Advertisement
Add Comment
Please, Sign In to add comment