Jump to content

DarkerAngel

Members
  • Posts

    330
  • Joined

  • Last visited

Everything posted by DarkerAngel

  1. You would have to explain to me exactly what it is your trying to accomplish. There is to much unknown for me to come up with a DB structure for you.
  2. emailer.class.php <?php /** * Simple E-Mailer * @copyright 2008 DarkAngelArts * @author Brandon LaRue <darkerangel (at) gmail (dot) com> * @version 2.0.0.0 * * This Application runs under the MIT License Copyright (c) 2008 DarkAngelArts Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ class simple_email { public $from_email, $to_email, $body, $subject, $template, $landing_page, $error_page; /** * Simple Emailer Construct * * @param string $from Address that email will appear to be from, "Name <email>" format or just "email" * @param string $to Address that the email will be sent to in, "Name <email>" format or just "email" * @param string $landing_page Page that users will be directed to on successful send. * @param string $error_page Page that users will be directed to on the event there is an error. * @param string $template [Optional] Loads the template file from the construct. * @return simple_email */ public function simple_email($from, $to, $landing_page, $error_page, $template = false) { $this->to_email = $to; $this->from_email = $from; $this->landing_page = $landing_page; $this->error_page = $error_page; if($template) { $this->load_template($template); } } /** * Template Loader * Loads the template into the class. * * @param string $template_file File Name of the template file. */ public function load_template($template_file) { $this->template = file_get_contents($template_file); preg_match("#<subject>(.*)</subject>#i", $this->template, $this->subject); preg_match("#<body>(.*)</body>#is", $this->template, $this->body); $this->subject = $this->subject[1]; $this->body = $this->body[1]; } /** * Template Data Parser * Generates the email based on form method used. * * @param string $method GET | POST on false uses the $_REQUEST method (not recommended) */ public function parse_template($method = false) { $method = strtolower($method); if($method == "post") { foreach($_POST as $key => $value) { $this->subject = str_replace('{$'.$key.'}', addslashes(strip_tags($value)), $this->subject); $this->body = str_replace('{$'.$key.'}', addslashes(strip_tags($value)), $this->body); } } elseif($method == "get") { foreach($_GET as $key => $value) { $this->subject = str_replace('{$'.$key.'}', addslashes(strip_tags($value)), $this->subject); $this->body = str_replace('{$'.$key.'}', addslashes(strip_tags($value)), $this->body); } } else { foreach($_REQUEST as $key => $value) { $this->subject = str_replace('{$'.$key.'}', addslashes(strip_tags($value)), $this->subject); $this->body = str_replace('{$'.$key.'}', addslashes(strip_tags($value)), $this->body); } } } public function custom_parse($key, $value) { $this->subject = str_replace('{$'.$key.'}', $value, $this->subject); $this->body = str_replace('{$'.$key.'}', $value, $this->body); } /** * Sends email and redirects based on settings * */ public function send_email() { if(mail($this->to, $this->subject, $this->body, $this->email_headers())) { header("Locarion: {$this->landing_page}"); } else { header("Location: {$this->error_page}"); } } /** * Email Checker * * @param string $email * @return bool */ public function checkemail($email) { if(preg_match('#[a-zA-Z0-9][a-zA-Z0-9\.\-\_]*@[a-zA-Z0-9\-\_]*\.[a-zA-Z0-9\_\.\-]*[a-zA-Z0-9]#', $email)) return true; else return false; } /** * Generates Standard required headers for HTML emails. * * @return string Header String. */ private function email_headers() { $headers = array(); $headers[] = "From: {$this->from_email}"; $headers[] = "Reply-To: {$this->from_email}"; $headers[] = "Return-Path: {$this->from_email}"; $headers[] = "X-Mailer: PHP/".phpversion(); $headers[] = "MIME-Version: 1.0"; $headers[] = "Content-type: text/html; charset=iso-8859-1"; $headers = implode("\r\n", $headers); return $headers; } } ?> Sample Email Code: <?php /** * Simple Emailer Sample configuration page. */ require_once("emailer.class.php"); $emailer = new simple_email("Me <me@mysite.com>", "You <you@yoursite.com>", "email_sent.html", "email_error.html", "email.tpl"); /** class simple_email( Sent_From , Sending_To , Success_Page , Error_Page , Email_Template ) **/ $emailer->parse_template("post"); /** Parses Template based on Post Data (or GET) **/ /** * ->custom_parse( replace, value ); * This will custom replace {$replace} with value */ $emailer->send_email(); /** Sends the Email **/ ?> Sample Template <subject>Thank You {$first_name} for your submission</subject> <body><a href="http://blah.com">Text</a> {$some_field} </body> Its really easy to use all you do is match {$field_name} to the <input name="field_name"> It works similar to smarty in a way. You can try it if you want. It's just something i came up with in my spare time, I gave it a MIT license, so feel free to mod it any way you wish.
  3. well I was just making an educated guess, I don't know your table structure or how you have your data setup.
  4. I have a really simple and easy emailer script if you want it.
  5. my preg_match did a case insensitive search also I guess this works too: if(preg_match("/\Wno\W/i", $test);
  6. if(preg_match("#[^a-zA-Z0-9]no[^a-zA-Z0-9]#i", $test)) { ... } just something to start with
  7. $sql = "SELECT * FROM rank WHERE '".$exp."' BETWEEN start AND end"; Would that work? I dont know... lol I'm lost to exactly what your trying to do...
  8. its going to always produce no results the way your doing it Start = 0 0 >= 0: true End = 100 100 <= 0: false 0 results!
  9. Thats what I was going to say, I have a very simple code running at: http://darkangel.myartsonline.com/ip.php all that is: IP: <?=$_SERVER['REMOTE_ADDR'] ?>
  10. Never a Problem Make sure you mark the thread as solved
  11. header("Location: ".str_replace("v=", "", $_SERVER['QUERY_STRING'])."+help"); Just off the top of my head...
  12. The only thing I could suggest is maybe a ping command if you have SSH access, Either that or I have this: /** * Quick cURL Function * * @param string $url URL To Site access * @param array $postdata Data Array to Send to Page in POST Form * @param string $refer Referring URL * * @return string HTML Document, Text, or Content Data returned from the site. */ function gethtml($url, $postdata = false, $refer = false) { $ch = curl_init(); curl_setopt($ch, CURLOPT_URL,$url ); curl_setopt($ch, CURLOPT_AUTOREFERER, 1); if($postdata) { curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS,$postdata); } curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.5) Gecko/2008120122 Firefox/3.0.5"); curl_setopt($ch, CURLOPT_COOKIEFILE, "cookie.txt"); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); curl_setopt($ch, CURLOPT_REFERER, $refer); curl_setopt($ch, CURLOPT_COOKIEJAR, "cookie.txt"); $html = curl_exec ($ch); curl_close($ch); return $html; } /*** Example of how to call the function ***/ $content = gethtml("http://website.com/"); /*** Example of Posting Fields ***/ $post = array(); $post['field_name'] = "field value"; $content = gethtml("http://website.com/form.php", $post); /** * The Last parameter is for sites that refuse to return content with out a referral header */
  13. I'm not sure what exactly you are trying to achieve bout it sounds like you might want to use javascript. That is if you want to edit the contents of the DIV based on the id tag alone. You could so something like: <div id="bodyHTML"><?=$bodyHTML ?></div> but that don't sound to me what you are trying to do. More information would help.
  14. Yes but the way you have it written any page that ends in ".html" will be matched and then directed through the first rule.
  15. Options +FollowSymlinks RewriteEngine on RewriteBase / RewriteRule ^yourfile.xml$ /yourfile.xml.php [nc] Save as .htaccess
  16. I think what he's trying to do is fix the problem with the quote nested within a quote.
  17. code it in a way that its hard coded into a php document or store it in a session variable
  18. I'm not sure, I think it has something to do with the predefined function and I don't know how its coded.
  19. function checkemail($email) { if(preg_match('#[a-zA-Z0-9][a-zA-Z0-9\.\-\_]*@[a-zA-Z0-9\-\_]*\.[a-zA-Z0-9\_\.\-]*[a-zA-Z0-9]#', $email)) return true; else diefalse; }
  20. you can use cURL to submit form data, then the session and cookies are /** * cURL Quick Client * * @param string $url URL To access * @param array $postdata Data Array to Send to Page in POST Form * @param string $refer Referring URL * @return string HTML Document or Text returned from the site. */ function gethtml($url, $postdata = false, $refer = false) { $ch = curl_init(); curl_setopt($ch, CURLOPT_URL,$url ); curl_setopt($ch, CURLOPT_AUTOREFERER, 1); if($postdata) { curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS,$postdata); } curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.12) Gecko/20080201 Firefox/2.0.0.12"); curl_setopt($ch, CURLOPT_COOKIEFILE, "cookie.txt"); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); curl_setopt($ch, CURLOPT_REFERER, $refer); curl_setopt($ch, CURLOPT_COOKIEJAR, "cookie.txt"); $html = curl_exec ($ch); curl_close($ch); return $html; } $content = gethtml($url, $postdata, $refer); echo($content);
  21. I have a cURL function that makes it really easy to use, I could give you the code, but if the file contents are on the same server I suggest using file_get_contents(); $string = file_get_contents($filename);
  22. I'd give him my emailer that works really well, but it's OOP and requires PHP5 anyways so it won't help him. So like everyone says talk to your hosting provider about PHP5.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.