Jump to content
Killersites Forums

cornetofreak

Member
  • Posts

    21
  • Joined

  • Last visited

Profile Information

  • Location
    United Kingdom

Contact Methods

  • Website
    http://N/A
  • Other
    cornetofreak@gmail.com

cornetofreak's Achievements

Newbie

Newbie (1/14)

0

Reputation

  1. there's a system i know of called "Ajax 4 five star rating" and using Ajax/Php/Mysql.. heres the link Link 1: http://masugadesign.com/the-lab/scripts/unobtrusive-ajax-star-rating-bar/ But i would say you can use this for a more acute rating http://nofunc.org/AJAX_Star_Rating/
  2. Change header( "Location: http://www.mysite.com/contactthanks.html\"); to if(!headers_sent()){ header("Location: /contactthanks.html"); exit(); }
  3. I have wave account and willing to give them away, just PM me
  4. you might want to look into the php zip class that comes in PHP5... this way you can loop all your images and the output a zip file containing your images
  5. a simple referer check in php would work or if there already using a stats program they will be able to see.. on every outbound link to the checkout just add a variable to the URI for e.g. http://www.store.com/product/87/dome-product-name/?referrer=mysite.com then they can filter there tracking by the referrer variable and see how many times that url has been open with the value of mysite.com
  6. The least i could do was secure it and neaten it up for you.. hate to see code like this... <?php mysql_connect('localhost','bcheight_mbdc','frog123'); mysql_select_db('bcheight_mbdc'); $s = mysql_real_escape_string($_GET['s']); $result = mysql_query(sprintf("SELECT * FROM after_school_services WHERE Student_name = '%%%s%%'",$s)); $Data = ""; while($row = mysql_fetch_assoc($result)){ $Data .= sprintf( '%s Student Id: %s Student Name: %s D.O.B.: %s Sex: %s Grade: %s Class Room: %s Teacher: %s Parent\'s Name: %s Language: %s Home Number: %s Work Number: %s Cell number: %s Email: %s Address: %s Apt: %s City: %s Zip: %s Emergency Name: %s Emergency Number: %s ', $row['Student_name'],$row['ff_id'],$row['ff_id'],$row['Student_name'],$row['dob'],$row['Sex'], $row['grade'],$row['class_room'],$row['teacher'],$row['Parent_name'],$row['language'], $row['home_num'],$row['work_num'],$row['cell_num'],$row['email'],$row['address'],$row['apt'], $row['city'],$row['zip'],$row['emergency_name'],$row['emergency_contact_number'] ); } echo $Data; ?>
  7. Heres my version you can use Key-Features: Simple OOP Plain-Text OR Html Formatted Use both Plain-Text and Html to help with unsupported clients Able to add attachments of any sort Based on PHP-Mail Multiple Recipients in one batch Built for "Php Newbies" Available on PhpClasses for download Some Usage Smaples Simple Plain text <?php //Include the emailer class include 'Emailer.class.php'; //Load the Emailer class into a variable $Emailer = new Emailer; //Setup where and where from the message is being sent. $Emailer->set_to("some_email@some_domain.tld"); $Emailer->set_from("admin@localhost"); $Emailer->set_sender("me@domain.com"); //Afdd some message stuff $Emailer->set_subject("This is a plain-text email"); $Emailer->set_text("Hello World!"); $Emailer->send(); ?> HTML formatted with <?php //Include the emailer class include 'Emailer.class.php'; //Load the Emailer class into a variable $Emailer = new Emailer; //Setup where and where from the message is being sent. $Emailer->set_to("some_email@some_domain.tld"); $Emailer->set_from("admin@localhost"); $Emailer->set_sender("me@domain.com"); //Add some message stuff $Emailer->set_subject("This is a html formatted email"); /*Set the text if the end-user does not have the correct software to view html*/ $Emailer->set_text("Hello World! (Non html version)"); $Emailer->set_html("Hello World! (html Version)"); //html will show if supported otherwise they will be sent a nice plain-text version $Emailer->send(); ?> HTML Formatted with Attachments <?php //Include the emailer class include 'Emailer.class.php'; //Load the Emailer class into a variable $Emailer = new Emailer; //Setup where and where from the message is being sent. $Emailer->set_to("some_email@some_domain.tld"); $Emailer->set_from("admin@localhost"); $Emailer->set_sender("me@domain.com"); //Afdd some message percifics $Emailer->set_subject("This is a html formatted email with files"); /*Set the text if the end-user does not have the correct software to view html*/ $Emailer->set_html("Here's your files"); //Add some files $Emailer->add_attachments( array( "test/account_details.txt", "test/your_avater.png", "test/some_sample_source.php", "test/some_random.ext" /*Add as many as you wish but try not overload the message size by sending 100MB download lol*/ ) ); $Emailer->send(); ?>
  8. Your webserver is bot set up to auoload .swf files as indexable.... you need to create a html document called index.htlm and within there place the embed code for the flash object/video
  9. theres a script called opencart.... and in there libary they have a PHP5 class for sending emails and its not built into the open cart system.. meaning you can just take the file and use it in other scripts that has attachment support
  10. You should use the force http header commend for content disposition <?php $link=mysql_connect("localhost","root",""); if(!$link) { die("could not connect:".mysql_error()); } mysql_select_db("media",$link); $que="select imageBlob from images where imageId=10"; $ret=mysql_query($que)or die("Invalid query: " . mysql_error()); $data = mysql_result($ret, 0); header("Content-type: image/jpeg"); header('Content-Disposition: attachment; filename="image.jpg"'); header('Content-Length: '.strlen($data)); echo $data; mysql_close($link); ?> should work fine
  11. Heya everyone, First of all i would just like to thank Stephan for the hard work and dedication he puts into Killer..... throughout the entire www its hard to discover PHP at its greatest potential, and Stephan is the only person i know who can explain PHP more in depth, So thanks for what your Tutorials/Tips/Videos etc.. Highly appreciated. __________________________________________________________________ Introduction What you will learning to day is how to create a registry type of system for your "Framworke/Website" and how it will help you to manage all of your objects. What is a Registry you say? A registry is a class that will be used to hold other classes in an array/stdClass and create a type of "SperGlobal" for your script. The Steps. 1. Create index.php 2. Create create a bootloader 3. Create the registry 4. Create create some sub-classes 5. Use sub-class via registry Step 1. (Create index.php) The index.php is extremely simple to create as this is the just an output file so to speak.... its the very first file that initiates the core logic and is what files you will be creating for new pages on your site.. this is why it has to be simple. <?php /* ** *** First lets create a constant that we will be using for 2 main things. *** 1. Used for security *** 2. Used to help know where we am on the filesystem. *** E.G. of the value is /root/sites/mySite/htdocs/ ** */ define("APPLICATION_PATH" , str_replace("\","/",dirname(__FILE__)) . "/"); /* ** *** No lets include the bootloader file ** */ require_once APPLICATION_PATH . "system/boot.php"; ?> Step 2. (Create the bootloader) What the bootloader will be doing in this "system" is 1. including all the main class files 2. Creating an instance of the registry object 3. Creating an instance of other objects and adding to the registry. Create a new directory next to "index.php" and call it system.. after that just create a new php document and call it "boot.php" <?php /* ** *** In step one we created a constant called APPLICATION_PATH. *** Now a smarty security check is to make sure that constant is set. *** This will stope hackers from directly accessing the file from the browser. *** So we just make sure that the APPLICATION_PATH is in the scope ** */ if(!defined("APPLICATION_PATH")){ die("No DIRECT Access"); } /* ** *** Now at this point we can start including our files, and creating the objects etc. *** The first object were going to be including is the regsitry object. ** */ require_once APPLICATION_PATH . "system/includes/classes/registry.php"; /* ** *** As the object will be a "static" class we wont need to create an instance of the object ** */ ?> At a later date in the script we will add more includes etc to the bootloader but nothing for now [*]3. (Create the registry) Firstly we nned to create a 2 new directories and a new php file so 1st. create a directory in "system" called "includes" and then within includes called "classes" so we have this structure "system/includes/classes/" 2nd. Create a new php file called Registry.php with capital R for consistency. lets take a look at the Registry class now <?php /* ** *** The registry class contains 2 "Magic Methods" and one object holder *** Tip: if your not sure about magic methods, please look at Stephans videos on PHP6 *** http://killerphp.com/tutorials/advanced-php/ *** Lets create the object now ** */ class Registry{ /* ** *** The $objects variable will contain all the classes/variables/data ** */ var $objects = array(); /* ** *** The __constructor method will run when the class is first created *** Please not that in the constructor it should take 0 args if posible ** */ public function __construct(){ } /* ** *** The __set magic method will be used to add new objects to the $objects *** (http://www.php.net/manual/en/language.oop5.overloading.php#language.oop5.overloading.members) ** */ public function __set($index,$value){ $this->objects[$index] = $value; } /* ** *** The magic method __get will be used when were trying to pull objects from the storage variable ** */ public function __get($index){ return $this->objects[$index]; } /* ** *** The magic methos sleep and wake are used to compress the data when there not being used, this helps save system *** Resources if your Registry gets on the larger side. ** */ function __sleep(){ /*serialize on sleep*/ $this->objects = serialize($this->objects); } function __wake(){ /*un serialize on wake*/ $this->$objects = unserialize($this->objects); } } ?> Ok so the basic outlay of the Registry is like a big box... and this box floats in mid air "so to speak" the reason its a box is because you can put any thing inside it.. I.e Data/Objects/Arrays etc.. and the reason i used the metaphore "Floats in mid air" is due to the fact its a static class and you will be able to used it everywhere in the script! step 4. (Create create some sub-classes) Ok now first what were going to be doing is creating a libary folder so we can store a web related classes there. so if you like to go a head and create a directory called "libary" within the includes folder our directory structure should be like "system/includes/libary/"... After you have that folder we can now add our first class witch will be an Http input class (used for working with the global $_GET,$_POST,$_COOKIE). Go ahead and create a file called HTTPInput.class.php and place within the "libary" folder Below is just an small example of a HTTP Input. if you want to look at one more in-depth the download the CodeIgnighter source package and look in there libary. <?php if(!defined("APPLICATION_PATH")){ die("No DIRECT Access"); } final class HttpInput{ function __construct(){ $this->unregistryGlobals(); // sample function you ahve to build. //Clean user input $_GET = $this->_processGET($_GET); $_POST = $this->_processPOST($_POST); $_COOKIE = $this->_processCOOKIE($_COOKIE); $_FILES = $this->_processCOOKIE($_FILES); } //Cleaning Functiions private function _processGET($_){ //Here we will just be recursivly escaping the data for example usage if(is_array($_)){ $tmp = array(); foreach($_ as $key => $val){ //Check the $key is valid here if you wish $tmp[$key] = $this->_processGET($val); } return $tmp; } //Here we can check the single values if(get_magic_quotes_gpc()){ $_ = stripslashes($_); } //Other checking here.... //Return return $_; } private function _processPOST($_){ //Check Post } private function _processCOOKIE($_){ //Check Cookie } private function _processFILES($_){ //Check Files } private function unregistryGlobals(){ //Here you can do some work on unregistering globals for security etc } } ?> No we have created the HTTP-Input class we have to tell the boot.php to use it and we need to place it within the registry. so withing your boot.php we will be adding some more code at the bottom.. so it should now look like the following. <?php /* ** *** In step one we created a constant called APPLICATION_PATH. *** Now a smarty security check is to make sure that constant is set. *** This will stope hackers from directly accessing the file from the browser. *** So we just make sure that the APPLICATION_PATH is in the scope ** */ if(!defined("APPLICATION_PATH")){ die("No DIRECT Access"); } /* ** *** Now at this point we can start including our files, and creating the objects etc. *** The first object were going to be including is the regsitry object. ** */ //System:: require_once APPLICATION_PATH . "system/includes/classes/registry.php"; //Libary:: require_once APPLICATION_PATH . "system/includes/libary/HTTPInput.class.php"; /* ** *** As the object will be a "static" class we wont need to create an instance of the object ** */ ?> You will notice we have just added the require_once line //Libary:: require_once APPLICATION_PATH . "system/includes/libary/HTTPInput.class.php"; No this means that we have pulled the un registered class into the boot but it wont be doing any thing unto we make and instance of the class so now were just going to add one line of code "after" the comment /* ** *** As the object will be a "static" class we wont need to create an instance of the object ** */ and were going to add //Create the $Registry Object $Registry = new Registry; //Add Httpnput to the registry $Registry->HttpInput = new HttpInput(); Ok so now we have a libary file thats used for accessing Http input globals such as $_GET and $_POST but we want to access them.. Well as you have loaded all this class objects etc etc before any real work in index.php this means where ever yu include the bootloader (boot.php) you have accesss to all your classes within 1 single variable called $Registry.. step 5. (Using the subclasses via Registry on yopur root pages) so now if you if you would just like to run the scipt you should ge no errors atall... should be a blank page. but now lets test the $Regsitry variable. within the index... ive added some more code to the index.php and heres what it looks like now <?php /* ** *** First lets create a constant that we will be using for 2 main things. *** 1. Used for security *** 2. Used to help know where we am on the filesystem. *** E.G. of the value is /root/sites/mySite/htdocs/ ** */ define("APPLICATION_PATH" , str_replace("\","/",dirname(__FILE__)) . "/"); /* ** *** No lets include the bootloader file ** */ require_once APPLICATION_PATH . "system/boot.php"; /* ** *** Anything below the inclusion of the system/boot.php should have all your libaries ready for usage! ** */ //lets do a test now. $id = $Registry->HttpInput->get("id"); echo $id; // this outputs 7 when the uri is index.php?id=7 ?> as you can see by the ablove you have all your classes based around one registry system.. Now as we come to the end of this tutorial i would just like to point out the possibilities by using a system like this. I have a website running like this with some big libaries loaded into the registry such as > Session Manager > Database Wrapper > Debug System > PHP Speed logging class > Smarty Template Engine > Sub Database classes AKA Models (18 or more classes loaded) > stdClass type DB config wrapper. And with this system i have a bog/forum/directory and admin etc all running threw the primary Regsitry class... And this is running a website with about 10-12K hits per day.... and is a very stable structure. So if you are just learning PHP5-6 then you will need to know that the concepts i have showed yout today has only scratched the surface... PHP i believe is untapped potential and its only limited by the programmer. and i hope i have shared a nice tutorial here with you all Regards, Robert Pitt (Cornetofreak). Files: http://rapidshare.com/files/311927297/Tutorial_Files.zip.html
  12. also you should load your images from a cascading style sheet, by using on page change the images reload but if you use css they will be catched and your site will load much faster!
  13. make sure in your robots.txt or headers that you are disallowing google ips or hosts.
  14. maybe the theme developer created the theme for a blog that has the login system disabled!. you should look into the wordpress help & support section and there will be some to show you what code to use and where to place it within your template files
×
×
  • Create New...