Advertisement
Guest User

contact

a guest
Jul 19th, 2011
133
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 8.32 KB | None | 0 0
  1. <?php
  2.  
  3. /**
  4.  
  5.  * Template Name: Jobs
  6.  
  7.  *
  8.  
  9.  * A custom page template without sidebar.
  10.  
  11.  *
  12.  
  13.  * The "Template Name:" bit above allows this to be selectable
  14.  
  15.  * from a dropdown menu on the edit page screen.
  16.  
  17.  *
  18.  
  19.  * @package WordPress
  20.  
  21.  * @subpackage Twenty_Ten
  22.  
  23.  * @since Twenty Ten 1.0
  24.  
  25.  */
  26.  
  27. /* Mailer with Attachments */
  28.  
  29. $action = "";
  30. $action = $_REQUEST['action'];
  31. global $action;
  32.  
  33. function showForm() {
  34. echo '<form enctype="multipart/form-data" name="send" method="post">
  35.  <input type="hidden" name="action" value="send" />
  36.  <input type="hidden" name="MAX_FILE_SIZE" value="10000000" />
  37.    <p>Name:  <input name="from_name" size="40" /></p>
  38.    <p>Email:  <input name="from_email" size="40" /></p>
  39.    <p>Subject:  <input name="subject" size="40" /></p>
  40.    <p>Message: <textarea name="body" rows="5" cols="31"></textarea></p>
  41.    <p>Attachment: <input type="file" name="attachment" size="30" /></p>
  42.    <p><input type="submit" value="Send Your CV" /></p>';
  43. }
  44.  
  45. function sendMail() {
  46.     $from_name = stripslashes($_POST['from_name']);
  47.     $subject = stripslashes($_POST['subject']);
  48.     $body = stripslashes($_POST['body']);
  49.     $attachment = $_FILES['attachment']['tmp_name'];
  50.     $attachment_name = $_FILES['attachment']['name'];
  51.  
  52. // check for valid file types
  53. if (is_uploaded_file($attachment)) { //Do we have a file uploaded?
  54.   $allowedExtensions = array("doc","docx","txt");
  55.   foreach ($_FILES as $file) {
  56.     if ($file['tmp_name'] > '') {
  57.       if (!in_array(end(explode(".",
  58.             strtolower($file['name']))),
  59.             $allowedExtensions)) {
  60.        die($file['name'].' is an invalid file type!
  61. '.
  62.         ''.
  63.         '<&lt Go Back');
  64.       }else{
  65.  
  66.       $fp = fopen($attachment, "rb"); //Open it
  67.       $data = fread($fp, filesize($attachment)); //Read it
  68.       $data = chunk_split(base64_encode($data)); //Chunk it up and encode it as base64 so it can emailed
  69.         fclose($fp);
  70.             }
  71.     }
  72.   }
  73. }
  74.     //Let's start our headers
  75.     $headers = "From: $from_name<" . $_POST['from_email'] . ">\n";
  76.     $headers .= "Reply-To: <" . $_POST['from_email'] . ">\n";
  77.     $headers .= "MIME-Version: 1.0\n";
  78.     $headers .= "Content-Type: multipart/related; type=\"multipart/alternative\"; boundary=\"----=MIME_BOUNDRY_main_message\"\n";
  79.     $headers .= "X-Sender: $from_name<" . $_POST['from_email'] . ">\n";
  80.     $headers .= "X-Mailer: PHP4\n";
  81.     $headers .= "X-Priority: 3\n"; //1 = Urgent, 3 = Normal
  82.     $headers .= "Return-Path: <" . $_POST['from_email'] . ">\n";
  83.     $headers .= "This is a multi-part message in MIME format.\n";
  84.     $headers .= "------=MIME_BOUNDRY_main_message \n";
  85.     $headers .= "Content-Type: multipart/alternative; boundary=\"----=MIME_BOUNDRY_message_parts\"\n";
  86.    
  87.     $message = "------=MIME_BOUNDRY_message_parts\n";
  88.     $message .= "Content-Type: text/plain; charset=\"iso-8859-1\"\n";
  89.     $message .= "Content-Transfer-Encoding: quoted-printable\n";
  90.     $message .= "\n";
  91.     /* Add our message, in this case it's plain text.  You could also add HTML by changing the Content-Type to text/html */
  92.     $message .= "$body\n";
  93.     $message .= "\n";
  94.     $message .= "------=MIME_BOUNDRY_message_parts--\n";
  95.     $message .= "\n";
  96.     $message .= "------=MIME_BOUNDRY_main_message\n";
  97.     $message .= "Content-Type: application/octet-stream;\n\tname=\"" . $attachment_name . "\"\n";
  98.     $message .= "Content-Transfer-Encoding: base64\n";
  99.     $message .= "Content-Disposition: attachment;\n\tfilename=\"" . $attachment_name . "\"\n\n";
  100.     $message .= $data; //The base64 encoded message
  101.     $message .= "\n";
  102.     $message .= "------=MIME_BOUNDRY_main_message--\n";
  103.  
  104.     // send the message
  105.     mail("admin@primarycarecommunity.net", $subject, $message, $headers);
  106. print "Mail sent. Thank you for using the Mailer.";
  107.   }
  108.  
  109.  
  110. ?>
  111. <!DOCTYPE html>
  112. <html <?php language_attributes(); ?>>
  113. <head>
  114. <meta charset="<?php bloginfo( 'charset' ); ?>" />
  115. <title><?php
  116.     /*
  117.      * Print the <title> tag based on what is being viewed.
  118.      */
  119.     global $page, $paged;
  120.  
  121.     wp_title( '|', true, 'right' );
  122.  
  123.     // Add the blog name.
  124.     bloginfo( 'name' );
  125.  
  126.     // Add the blog description for the home/front page.
  127.     $site_description = get_bloginfo( 'description', 'display' );
  128.     if ( $site_description && ( is_home() || is_front_page() ) )
  129.         echo " | $site_description";
  130.  
  131.     // Add a page number if necessary:
  132.     if ( $paged >= 2 || $page >= 2 )
  133.         echo ' | ' . sprintf( __( 'Page %s', 'twentyten' ), max( $paged, $page ) );
  134.  
  135.     ?></title>
  136. <link rel="profile" href="http://gmpg.org/xfn/11" />
  137. <link rel="stylesheet" type="text/css" media="all" href="<?php bloginfo( 'stylesheet_url' ); ?>" />
  138. <link rel="pingback" href="<?php bloginfo( 'pingback_url' ); ?>" />
  139. <?php
  140.     /* We add some JavaScript to pages with the comment form
  141.      * to support sites with threaded comments (when in use).
  142.      */
  143.     if ( is_singular() && get_option( 'thread_comments' ) )
  144.         wp_enqueue_script( 'comment-reply' );
  145.  
  146.     /* Always have wp_head() just before the closing </head>
  147.      * tag of your theme, or you will break many plugins, which
  148.      * generally use this hook to add elements to <head> such
  149.      * as styles, scripts, and meta tags.
  150.      */
  151.     wp_head();
  152. ?>
  153.  
  154.  
  155. </head>
  156.  
  157. <body <?php body_class(); ?>>
  158.     <div id="wrap">
  159.         <div id="header">
  160.  
  161.             <img class="sitename" src="<?php bloginfo('template_directory'); ?>/images/logo.gif"/>
  162.  
  163.                 <div id="topnav">
  164.                     <ul>
  165.                         <li id="hom"><a href="http://www.primarycarecommunity.net">Home</a></li>
  166.                         <li id="new"><a href="../news">News</a></li>
  167.                         <li id="eve"><a href="../events">Events Calendar</a></li>
  168.                         <li id="ser"><a href="../services">Services</a></li>
  169.                         <li id="abo"><a href="../about">About Us</a></li>
  170.                         <li id="con"><a href="../contact">Contact Us</a></li>
  171.                         <li id="vac"><a href="../vacancies">Vacancies</a></li>
  172.                         <li id="for"><a href="../forum">Forum</a></li>
  173.                         <li id="mem"><a href="../members">Members Zone</a></li>
  174.                     </ul>
  175.                 </div>
  176.  
  177.                 <div class="clear"></div>
  178.  
  179.                 <div id="headercolumn1">
  180.                     <p class="description">There are approximately 8900 GP practices in England, each with one or two practice managers and assistant/deputy managers. Some are new to the industry and others have been within primary care management for many years.  We are here to help you share your knowledge and experiences in order to help others progress in their career. <a href="about.html" title="About Us">Read more...</a></p>
  181.                 </div>
  182.  
  183.                 <div id="headercolumn2">
  184.                     <div id="search_top">
  185.                         <form action="/search/search.php" method="get">
  186.                         <p><input type="text" name="query" id="query" class="keyword"/> </p>
  187.                         <p class="button"><input name="" type="image" src="<?php bloginfo('template_directory'); ?>/images/searchbutton.gif" alt="Search" /></p>
  188.                         <p class="hide">    <input type="hidden" name="search" value="1" /> </p>
  189.                         </form>
  190.                     </div>
  191.                 </div>
  192.                
  193.                 <div class="clear"></div>
  194.  
  195.         </div> <!-- End of Header -->
  196.  
  197.     <div id="contents">
  198.  
  199. <div id="left">
  200. <?php if ( have_posts() ) while ( have_posts() ) : the_post(); ?>
  201.  
  202.                 <div id="post-<?php the_ID(); ?>" class="post">
  203.  
  204.                     <div class="entry-content">
  205.  
  206.                         <?php the_content(); ?>
  207.  
  208.                         <?php wp_link_pages( array( 'before' => '<div class="page-link">' . __( 'Pages:', 'twentyten' ), 'after' => '</div>' ) ); ?>
  209.  
  210.                     </div><!-- .entry-content -->
  211.  
  212.                 </div><!-- #post-## -->
  213.  
  214.  
  215.  
  216. <?php endwhile; ?>
  217. <div class="post">
  218. <?php query_posts('cat=4');
  219.               if (have_posts()) : while (have_posts()) : the_post(); ?>
  220.              
  221.               <li>
  222.                 <a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>">
  223.                   <p class="listtitle"><?php the_title_attribute(); ?></p></a>
  224.                   <p class="listmeta">Published on: <?php the_time('F jS, Y'); ?></p>
  225.                
  226.  
  227.         <div class="entry-content">
  228.             <?php the_excerpt(); ?>
  229.         </div><!-- .entry-content -->
  230.               </li>
  231.              
  232.             <?php endwhile; ?>
  233.             <?php else : ?>
  234.               <h2>Nothing Found</h2>
  235.              
  236.             <?php endif; ?>
  237.  
  238. </div>
  239. </div>
  240.  
  241. <div id="right">
  242. <?php
  243. switch ($action) {
  244.   case "send":
  245.     sendMail();
  246.     showForm();
  247.     break;
  248.   default:
  249.     showForm();
  250. }
  251. ?>
  252. </div>
  253.         <div class="clear"></div>
  254. <?php get_footer(); ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement