Guest User

Untitled

a guest
Nov 2nd, 2012
211
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.52 KB | None | 0 0
  1. <?php
  2. /**
  3. * Template Name: Contact
  4. * The main template file for display contact page.
  5. *
  6. * @package WordPress
  7. */
  8.  
  9. session_start();
  10.  
  11. /**
  12. * if not submit form
  13. **/
  14. if(!isset($_GET['your_name']))
  15. {
  16. ?>
  17.  
  18. <?php
  19. if(!isset($hide_header) OR !$hide_header)
  20. {
  21. ?>
  22. <script type="text/javascript">
  23. $j(document).ready(function(){
  24. setTimeout(function() {
  25. $j('#map_contact').css('visibility', 'visible');
  26. $j('#homepage_wrapper').animate({width: 'toggle'},{
  27. duration: 500,
  28. complete: function() {
  29. $j('#homepage_wrapper').fadeIn();
  30. $j('#homepage_wrapper').children('.inner').fadeIn('slow');
  31. $j('#corner_right').css('display', 'block');
  32. $j('#corner_right_bottom').css('display', 'block');
  33. $j('#slidecaption').css('visibility', 'visible');
  34. $j('#supersized-loader').css({display: 'none'});
  35. $j('#slidecaption').css('visibility', 'hidden');
  36. }
  37. });
  38. }, 2000);
  39. });
  40. </script>
  41. <link rel="stylesheet" href="<?php echo get_stylesheet_directory_uri(); ?>/css/screen.css" type="text/css" media="screen" />
  42. <?php
  43. if(isset($_SESSION['pp_skin']))
  44. {
  45. $pp_skin = $_SESSION['pp_skin'];
  46. }
  47. else
  48. {
  49. $pp_skin = get_option('pp_skin');
  50. }
  51.  
  52. if($pp_skin == 'dark')
  53. {
  54. ?>
  55. <link rel="stylesheet" href="<?php echo get_stylesheet_directory_uri(); ?>/css/dark.css" type="text/css" media="screen" />
  56. <?php
  57. }
  58. elseif($pp_skin == 'transparent')
  59. {
  60. ?>
  61. <link rel="stylesheet" href="<?php echo get_stylesheet_directory_uri(); ?>/css/transparent.css" type="text/css" media="screen" />
  62. <?php
  63. }
  64. ?>
  65. <script type="text/javascript" src="<?php echo get_stylesheet_directory_uri(); ?>/js/custom.js"></script>
  66.  
  67. <div id="page_content_wrapper">
  68. <div class="inner">
  69. <div class="sidebar_content">
  70.  
  71. <h1 class="page_header"><?php the_title(); ?></h1><hr/>
  72.  
  73. <?php the_content(); ?>
  74.  
  75. <!-- Begin main content -->
  76. <?php if ( have_posts() ) while ( have_posts() ) : the_post(); ?>
  77.  
  78. <?php do_shortcode(the_content()); ?><br class="clear"/><br/>
  79.  
  80. <?php endwhile; ?>
  81.  
  82. <?php
  83. $target_url = curPageURL();
  84. }
  85. else
  86. {
  87. $obj_contact = get_page($current_page_id);
  88. $target_url = $obj_contact->guid;
  89. $pp_contact_content = $obj_contact->post_content;
  90.  
  91. echo do_shortcode($pp_contact_content).'<br class="clear"/><br/>';
  92. }
  93. ?>
  94.  
  95. <form id="contact_form" method="post" action="<?php echo $target_url; ?>">
  96. <p>
  97. <input id="your_name" name="your_name" type="text" title="<?php _e( 'Name', THEMEDOMAIN ); ?>*" style="width:94%"/>
  98. </p>
  99. <p style="margin-top:20px">
  100. <input id="email" name="email" type="text" title="<?php _e( 'Email', THEMEDOMAIN ); ?>*" style="width:94%"/>
  101. </p>
  102. <p style="margin-top:20px">
  103. <textarea id="message" name="message" style="width:94%" title="<?php _e( 'Message', THEMEDOMAIN ); ?>*"></textarea>
  104. </p>
  105. <p style="margin-top:30px"><br/>
  106. <input type="submit" value="<?php _e( 'Send Message', THEMEDOMAIN ); ?>"/>
  107. </p>
  108. </form>
  109. <div id="reponse_msg"></div>
  110. <br/><br/>
  111. <!-- End main content -->
  112.  
  113. <?php
  114. if(!isset($hide_header) OR !$hide_header)
  115. {
  116. ?>
  117. </div>
  118. </div>
  119. </div>
  120.  
  121. <?php
  122. get_footer();
  123.  
  124. } // En if not hide header
  125. }
  126.  
  127. //if submit form
  128. else
  129. {
  130.  
  131. /*
  132. |--------------------------------------------------------------------------
  133. | Mailer module
  134. |--------------------------------------------------------------------------
  135. |
  136. | These module are used when sending email from contact form
  137. |
  138. */
  139.  
  140. //Get your email address
  141. $contact_email = get_option('pp_contact_email');
  142.  
  143. //Enter your email address, email from contact form will send to this addresss. Please enter inside quotes ('[email protected]')
  144. define('DEST_EMAIL', $contact_email);
  145.  
  146. //Change email subject to something more meaningful
  147. define('SUBJECT_EMAIL', __( 'Email from contact form', THEMEDOMAIN ));
  148.  
  149. //Thankyou message when message sent
  150. define('THANKYOU_MESSAGE', __( 'Thank you! We will get back to you as soon as possible', THEMEDOMAIN ));
  151.  
  152. //Error message when message can't send
  153. define('ERROR_MESSAGE', __( 'Oops! something went wrong, please try to submit later.', THEMEDOMAIN ));
  154.  
  155.  
  156. /*
  157. |
  158. | Begin sending mail
  159. |
  160. */
  161.  
  162. $from_name = $_GET['your_name'];
  163. $from_email = $_GET['email'];
  164.  
  165. $mime_boundary_1 = md5(time());
  166. $mime_boundary_2 = "1_".$mime_boundary_1;
  167. $mail_sent = false;
  168.  
  169. # Common Headers
  170. $headers = "";
  171. $headers .= 'From: '.$from_name.'<'.$from_email.'>'.PHP_EOL;
  172. $headers .= 'Reply-To: '.$from_name.'<'.$from_email.'>'.PHP_EOL;
  173. $headers .= 'Return-Path: '.$from_name.'<'.$from_email.'>'.PHP_EOL; // these two to set reply address
  174. $headers .= "Message-ID: <".$now."webmaster@".$_SERVER['SERVER_NAME'].">";
  175. $headers .= "X-Mailer: PHP v".phpversion().PHP_EOL; // These two to help avoid spam-filters
  176.  
  177. # Boundry for marking the split & Multitype Headers
  178. $headers .= 'MIME-Version: 1.0'.PHP_EOL;
  179. $headers .= "Content-Type: multipart/mixed;".PHP_EOL;
  180. $headers .= " boundary=\"".$mime_boundary_1."\"".PHP_EOL;
  181.  
  182. $message = 'Name: '.$from_name.PHP_EOL;
  183. $message.= 'Email: '.$from_email.PHP_EOL.PHP_EOL;
  184. $message.= 'Message: '.PHP_EOL.$_GET['message'];
  185.  
  186.  
  187. if(!empty($from_name) && !empty($from_email) && !empty($message))
  188. {
  189. mail(DEST_EMAIL, SUBJECT_EMAIL, $message, $headers);
  190.  
  191. echo THANKYOU_MESSAGE;
  192.  
  193. exit;
  194. }
  195. else
  196. {
  197. echo ERROR_MESSAGE;
  198.  
  199. exit;
  200. }
  201.  
  202. /*
  203. |
  204. | End sending mail
  205. |
  206. */
  207. }
  208.  
  209. ?>
Advertisement
Add Comment
Please, Sign In to add comment