tag:blogger.com,1999:blog-51570681604241282202009-02-20T22:09:08.189-08:00PHPbb- The Ultimate PHP script for creating Forums and communities.Silver Manihttp://www.blogger.com/profile/10584110258226203263noreply@blogger.comBlogger12125tag:blogger.com,1999:blog-5157068160424128220.post-13952278842692966512008-04-17T01:24:00.000-07:002008-05-19T03:24:42.012-07:00Flexible CGI output with HTML templatesConsider our free search engine script. It is an excellent application, but it wouldn't be very helpful for others if it could display its results only in the output page format that we use for our site. Somebody else's site will probably need the output page to contain site-specific navigation links, different colors, or even a completely different layout concept. It is not uncommon to see CGI programs that contain the HTML code that is returned to the browser, inside one or more print statements in the code of the script. Clearly this is not a good idea, since it makes it at least difficult, if not nearly impossible, for a non-programmer to alter the output format. At best, a webmaster with little understanding of perl could identify the HTML code inside the program and alter some obvious items, like colours. Still, as applications grow more complex, this approach becomes even more difficult to manage. If control structures (<tt>if</tt>, <tt>while</tt> etc) are being used to generate the output, or if there are multiple pages of output composed by chunks of html that are being generated in different places in the code, even someone who is comfortable with perl could find it hard to figure out how to alter the look of the output. And this is not the only problem. The code itself becomes difficult to manage and maintain. Program code is difficult to read an maintain on its own right. Cluttering it with HTML here and there does not help the situation at all. I will describe a different approach to the problem here, the one that we use for our programs and which proves to be a very good solution for almost any type of application. The idea in this approach is to isolate the HTML code in a separate file, which we call a <i>template</i>. A template is just like any regular HTML file, but it contains some special markup dictating where to insert the various dynamic data that will be produced by the CGI program. The program need only be concerned with generating the actual dynamic content, then it can simply insert it in appropriate place in the template and thus come up with the final output. <h2>What a template looks like</h2> The only thing that sets a template apart from a regular HTML file is that it contains comments of the form <tt><!--cgi:variable--></tt>. Such comments will be identified by the CGI program and replaced with the appropriate value for <tt>variable</tt>. The template may contain references to as many such variables as the CGI program is made to define. For example, take our search engine program. On the top of the search results page there appears some text saying what search was made and how many results it came up with. Assuming the program defines variables <tt>search_string</tt> and <tt>total_results</tt>, our template could look like: <code> ... Your search for <b><!--cgi:search_string--></b> resulted in <b><!--cgi:total_results--></b> matching pages. ... </code> <h2>Filling in the template</h2> A simple way of doing this is the following: <code>open(TEMPLATE, $template_file); while(<template>) { $buffer .= $_; } $buffer =~ s/<!--cgi:search_string-->/$search_string/g; $buffer =~ s/<!--cgi:total_results-->/$total_results/g; print $buffer;</template></code> This will do the job, but we can certainly do much better than that. A realistic CGI-based application might contain many scripts generating many pages each, and each of those pages might contain much more than just a handful of variable data. Clearly we could write something much more general, a little module, that can handle output generation in the same way, but without requiring the programmer to explicitly perform substitutions of the template directives in the CGI program. <h2>Perlfect::Template</h2> As I already mentioned, we use that technique in all our programs here at Perlfect, and to make our life easier we have made a simple module that encapsulates all the functionality relating to templates that could be of use for CGI programming. The module is freely available for anyone to download and use for their own programs. To introduce you to the use of Perlfect::Template I will show a simple example: <code>my $template = new Perlfect::Template("template.html"); my %data = ( name => 'Nick', email => 'nick@perlfect.com', homepage => 'http://www.perlfect.com', ); my $html = $template->cast(\%data);</code> First of all we create a Perlfect::Template object corresponding to the template file we want to use. The filename (or fully qualified path to it) is passed as an argument to the object constructor that returns a reference to the newly created object. Then we prepare the data that we are going to <i>cast</i> to the template. Perlfect::Template expects us to supply it with a reference to a hash table (associative array) mapping data keys (template variables) to the values that should be inserted for them in the template. Thus all the processing done by the CGI program should end up defining a set of such key-value pairs in a hash reflecting the dynamic content of the output. Finally, we call the <tt>cast</tt> method of the template object passing a reference to our data hash. The cast method does not alter the template, but simply uses it to produce a filled-in copy of it that is returned by the call. That means, that you can reuse a template as much as you like in a program. This allows you to construct your output from 'sub-templates'. For example, in our search engine script, there is one template that defines the general layout of the results page, but there is also a template that defines the format of a single result listing. The program uses the latter to generate result listings by substituting, title, description, url, score, etc and thenputs them all together and inserts them in the general layout template. To create the result listings we only create one template object and use it for all results, each time passing a different hash reference to it. This has the advantage that the template file is read only once and that the processing needed to generate an other instance of the html output is minimal. <h2>Passing substitution handlers..</h2> In most cases the functionality we discussed so far is more than enough to do the job. There are cases though where passing static values for substitution in a template is a too restrictive mechanism. Sometimes you want the template to be able to describe not only the location of the substitutions but also some dynamic behaviour. In the example above I might want to let the template author choose whether the homepage url should appear in linked or plain text form. Of course, the template variable could just store the url and the template could contain a directive: <tt><a href="http://www.blogger.com/post-edit.g?blogID=5157068160424128220&amp;postID=1395227884269296651">"><!--cgi:homepage--></a></tt> to construct the linked form, but in other situations ther might not be such workarounds. I would like to let the user pass <i>parameters</i> in a template directive, and instead of substituting a static string for the directive, I would like the substitution string to be generated by a function that will be called with the parameters in the directive. Perlfect::Template allows you to use references to subroutines instead of scalars as values of the substitution hash. When a directive for suvh a template variable (that really is a subroutine) is met, Perlfect::Template will arrange for the subroutine to be called and will use ts return value as a substitution string. Further if the template directive includes arguments in parentheses as in <tt><!--cgi:homepage('linked')--></tt> the subroutine will be passed those aruments using perl's standard argument passing mechanism. Arguments in the parentheses follow standard perl syntax for subroutine calls. So let's review our example above, now using the subroutine calling mechanism... <code>my $template = new Perlfect::Template("template.html"); my %data = ( name => 'Nick', email => 'nick@perlfect.com', homepage => sub { if($_[0] eq 'linked') { return ... } else { return ... } } ); my $html = $template->cast(\%data);</code> <h2>And who said it's only for HTML?</h2> A final note to be made is that, while this tool was initially developed to aid the writing of CGI scripts that produce HTML output, it is absolutely fine to use for any kind of program that needs to format text files into a configurable layout. For example, one great use we've found is to create personalized email from a standard text template of the message and a database of names and email addresses of the recipients. In general any text file who is not likely to clash syntactically with the directive format of Perlfect::Template is perfectly suitable for processing with it.<br /><br />[Via - <a href="http://www.perlfect.com/articles/templates.shtml">Flexible CGI output with HTML templates</a>] <a href="http://www.ukwebmasterworld.com/">uk webmaster world</a><div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5157068160424128220-1395227884269296651?l=www.thephpbb.net'/></div>Silver Manihttp://www.blogger.com/profile/10584110258226203263noreply@blogger.com0tag:blogger.com,1999:blog-5157068160424128220.post-10571890606046093142008-04-17T01:20:00.000-07:002008-04-17T01:22:51.097-07:00Multiplexing filehandles with select() in perl.The problem<br />I/O requests such as read() and write() are blocking requests. Suppose you have a line in a program that get STDIN from a terminal like the following:<br /><br />$input = <stdin>;<br /><br />What will happen here is that the program's execution will block until there a line of input is available, i.e. the user types something followed by a newline. In many cases this is the desired behavior. Suppose you have a program that accepts requests through a socket and does some processing for each request, then moves on to the next request. <br /><br />01 # Create the receiving socket 02 my $s = new IO::Socket ( 03 LocalHost => thekla, 04 LocalPort => 7070, 05 Proto => 'tcp' 06 Listen => 16, 07 Reuse => 1, 08 ); 09 die "Could not create socket: $!\n" unless $s; 10 11 my ($ns, $buf); 12 while( $ns = $s->accept() ) { # wait for and accept a connection 13 while( defined( $buf = <$ns> ) ) { # read from the socket 14 # do some processing 15 } 16 } 17 close($s);<br /><br />Although this is a perfectly valid way of handling the incoming requests, it does suffer some serious problems, especially if the frequency of incoming requests is high and the processing that needs to be performed for each is a lot.<br /><br />Clearly, the problem is that, once a request has been accepted, we have to keep other requests hanging in the queue while we read the request message and process it. Now, reading from a socket is a blocking call, so if the client takes too long to transmit the request message, we just sit there waiting while we could be doing useful processing of other requests. Obviously, not only this is not acceptable, but in cases where the demand for request processing is high, the program may not be able to meet its operating reqiurements. Also think that a single client failure at a critical point (in the middle of an ongoing transmission) poses the risk of making the server block indefinetly.<br /><br />What can we do about it?<br /><br />What we need to deal with situations like the above, is a way to handle I/O (we use sockets for this example, but the rules apply in general to any kind of filehandles) independently and with some sort of apparent parallelism/multiprocessing. There are two very common approaches to deal with this.<br /><br />One approach is to spawn separate threads of control to handle each request. This can be done either at process-level, using fork() to create a new process for each request, or at thread-level using perl's threading capabilities to create multiple threads within the same process. (Perl's support for threads was introduced in version 5.005)<br /><br />The other approach - which is the one that we will discuss here - is to use the select() to multiplex between several filehandles within a single thread of control, thus creating the effect of parallelism in the handling of I/O.<br /><br />What does select() do?<br /><br />The idea behind select() is to avoid blocking calls by making sure that a call will not block before attempting it. How do we do that? Suppose we have two filehandles, and we want to read data from them as it comes in. Let's call them A and B. Now, let's assume that A has no input pending yet, but B is ready to respond to a read() call. If we know this bit of information, we can try readin from B first, instead of A, knowing that our call will not block. select() gives us this bit of information. All we need to do is to define sets of filehandles (one for reading, one for writing and one for errors) and ask call select() on them which will return a filehandle which is ready to perform the operation for which it has been delegated (depending on which set it is in) as soon as such a filhandle is ready.<br /><br />Obviously this provides us with the advantage of always picking up a filehandle that will not block thus avoiding the possibility of delaying the entire program for one lazy filehandle just because it happened to be the first we picked at random. Still, it does not guarantee that the selected filehandle is the best choice, because we still don't know how much data can be read, or how qucikly it can take in data that we wrte to it. But it is definetly a big step forward from our initial program.<br /><br />Using select()<br /><br />We will try writing the example program we attempted on the beginnign of this article, but now using the select() method. Instead of using perl's select call directly we will use a wrapper module, IO::Select that makes life easier for us.<br /><br />... create socket as before ... 11 use IO::Select; 12 $read_set = new IO::Select(); # create handle set for reading 13 $read_set->add($s); # add the main socket to the set 14 15 while (1) { # forever 16 # get a set of readable handles (blocks until at least one handle is ready) 17 my ($rh_set) = IO::Select->select($read_set, undef, undef, 0); 18 # take all readable handles in turn 19 foreach $rh (@$rh_set) { 20 # if it is the main socket then we have an incoming connection and 21 # we should accept() it and then add the new socket to the $read_set 22 if ($rh == $s) { 23 $ns = $rh->accept(); 24 $read_set->add($ns); 25 } 26 # otherwise it is an ordinary socket and we should read and process the request 27 else { 28 $buf = <$rh>; 29 if($buf) { # we get normal input 30 # ... process $buf ... 31 } 32 else { # the client has closed the socket 33 # remove the socket from the $read_set and close it 34 $read_set->remove($rh); 35 close($rh); 36 } 37 } 38 } 39 }<br /><br />We create an IO::Select object, $read_set, which is our set of handles to test for readability, and add all open handles to it. We start by adding the main socket and each time a new connection is made returning a new socket for it, we add that socket to the set. Then we go into a loop where we ask select to give us a list of readable handles and we examine each one in turn. If it is the main socket then we want to call accept() to receive the incoming connection and add the new socket to the read set. Otherwise it must be an ordinary socket in which case we read from it and process its input. If the read fails, that means the socket has been closed on the client side, so we close it, too, and remove it from the read set. So we work our way continuously through the incoming requests, by making sure that a call for I/O on any filehandle will progress since select() tells us it will.<br /><br />As we already mentioned earlier, this method does not guarantee progress as it only tests whether a handle is ready to respond to I/O. The question still remains, whether the handle we pick from the ready ones is the one that will respond faster to I/O, and how much data there is available for reading or how much data it is ready to receive. So it is still possible to block a bit after the point where we picked the handle. Also, we did not take into account the impact on performance that the actual processing of requests will have. We might just be printing incoming data to a file, but then again, each request might need heavy processing that would slow down the entire handle processing loop. But these are issues that must be considered in the context of the individual application.<br /><br />[Via - <a href="http://www.perlfect.com/articles/select.shtml">Multiplexing filehandles with select() in perl</a>]</stdin><div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5157068160424128220-1057189060604609314?l=www.thephpbb.net'/></div>Silver Manihttp://www.blogger.com/profile/10584110258226203263noreply@blogger.com0tag:blogger.com,1999:blog-5157068160424128220.post-75224210219481493322008-04-16T04:59:00.000-07:002008-05-23T03:47:52.252-07:00International Profit AssociatesInternational Profit Associates <a onclick="return top.js.OpenExtLink(window,event,this)" href="http://www.biz-doctor.com/" target="_blank" rel="nofollow">IPA-IBA</a> is a U.S. leader in business development and management consulting services for small and medium-size companies. <a onclick="return top.js.OpenExtLink(window,event,this)" href="http://www.ipasbrb.com/" target="_blank" rel="nofollow">IPA-IBA</a> is one of the fastest growing management consulting companies. It is widely held that it is one of the only management consulting firm in the world that delivers such a broad array of professional services to the small and medium-size business marketplace.<div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5157068160424128220-7522421021948149332?l=www.thephpbb.net'/></div>Silver Manihttp://www.blogger.com/profile/10584110258226203263noreply@blogger.com0tag:blogger.com,1999:blog-5157068160424128220.post-13218785554097091882008-04-16T04:58:00.000-07:002008-05-23T03:47:22.568-07:00My space LayoutsMy space layout is a place where you can find all kind of layouts that you allways require to design a cool business website which will provide all the necessary solutions to make your business grow.<a onclick="return top.js.OpenExtLink(window,event,this)" href="http://grow.myspacemaster.net/" rel="nofollow" target="_blank"> </a>MyspaceMaster.Net offers <a onclick="return top.js.OpenExtLink(window,event,this)" href="http://myspacemaster.net/" target="_blank">Myspace layouts</a>, myspace codes, myspace backgrounds, myspace graphics, myspace generators. Customize myspace profile to make sure you are seen.<div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5157068160424128220-1321878555409709188?l=www.thephpbb.net'/></div>Silver Manihttp://www.blogger.com/profile/10584110258226203263noreply@blogger.com0tag:blogger.com,1999:blog-5157068160424128220.post-55436522382763395682008-01-25T01:44:00.000-08:002008-04-17T01:20:39.092-07:00Tutorial: Writing Classes in PHP<div style="text-align: justify;">Some consider classes one of the hardest components of PHP to figure out, but the reality is that classes are extremely straightforward and easy to use. The trouble comes from the fact that not all programmers have worked with Object-Oriented Programming (OOP) before. <br /> <br />Classes are little more than a container for variables and functions affecting those variables, but they can be very useful for building small components - almost miniture programs. The difference is that you dont need to shell out to them or anything, and they can be plugged into most scripts with ease - Just a require or include statement at the top. A class describes an 'object'. An object is a collection of smaller objects, just like in a class. Say for instance, we want to describe a simple door lock. A lock class might contain: <br /> <br /> variable $Bolt <br /> variable $Position <br /> <br /> function TurnKey( $Direction, $Distance ) <br /> function CheckLock( ) <br /> <br />TurnKey would accept a direction value that would in turn determine if the bolt should be locked or unlocked. Once the key is turned far enough in either direction ($Distance) the Bolt will either set or clear. The $Bolt variable shows the current state of the door lock, and $Position is used to track how far the key has been turned in any direction. Now, obviously this could all be done with regular variables and functions, and if you only need to use one lock in the code, it would probably work just fine. But what if you want more than one lock? One if you wanted more details about the lock, or even something else? Maybe you want a door in the code, too - And the lock would just be a subset of the door. Maybe you have a whole house. You might have more than one door, or you might not. But each door certainly needs a lock. You can see how complex object-related problems can get. <br /> <br />By using classes, you can define an object once, and then include it in several scripts also. You'll be assured that your object will funciton the same in all of the scripts! Its good practice to write your classes in a seperate file usually, that way you only have to change it in one location. Make full use of PHP's include and require functions, they have many uses. <br /> <br />In the next section, I will walk you through creating a simple class. <br /> <br />Class Structures <br /> <br />For lack of a better example right now, i'm going to show you how to create a simple page object. The page object encompasses a few of the basic page necessities in building an HTML page. Now, there is a lot more you could do with this class, but i'm going to keep it simple for the time being. You guys can expand on it if want later. Okay, lets start by looking at what the basic elements of an HTML page are. First, you have the open and closing tags, and . Those will need to be included in the output. Also, you have the page Title, Keywords for the Metatag field, and naturally the main content, or body. Now that we know what we need, lets start building our class. <br /> <br />First thing we need is the class itself: <br /> <br /> <br /> <br /> <br />This is a basic class. No variables, no functions, nothing - Completely empty. All class structures look the same here with the exception of the 'Page' name. Every class/object is assigned a name for reference. You'll need to know this to create new copies of the object, so pick something straightforward and sensible. <br /> <br />Next, we need to put in our variables. We need a title for the page, keywords, and a content body, like so: <br /> <br /> <br /> <br /> <br />Now, we could actually start using the class here. We have an object. But it isn't done - We still want to add some functions, to make it easier to work with. <br /> <br />What functions do we need? Well, we need something to build the output HTML. Lets call that 'Display'. Lets create simple functions for displaying the Title and Keywords, also. Lets make a function for setting the content as well. <br /> <br />The final class code is: <br /> <br />\n\n"; <br />$this->DisplayTitle( ); <br />$this->DisplayKeywords( ); <br />echo "\n\n\n"; <br />echo $this->Content; <br />echo "\n\n\n"; <br />} <br /> <br />function DisplayTitle( ) { <br /><title>" . $this->Title . "</title> echo "\n"; <br />} <br /> <br />function DisplayKeywords( ) { <br />echo '<meta name="keywords" content="">Keywords . '">'; <br />} <br /> <br />function SetContent( $Data ) { <br />$this->Content = $Data; <br />} <br />} <br />?> <br /> <br />Now, at first glance this looks pretty simple. And you know what? It is. Its just basic PHP code wrapped into a class. Let me point a few things out before we go any farther though. <br /> <br />VAR - <br />All variables declared in the class must be placed at the top of the class structure, and preceeded with the VAR statement. <br />$THIS - <br />$this is a variable that incidates the current object. That way, the object knows how to find itself while running functions contained within it. <br />For instance, $this->Keywords gets the data from the $Keywords variable in the object. You'll also notice that when using variables contained <br />within a class, you can't use the $ to reference them - But you have to use it to reference the object itself. <br /> <br />Lets save this class file out before we continue. If your following along, save it out as page.class for now. You'll need it for the example coming up. <br />Using the Class <br /> <br />Now that we have a class created, lets try using it in a normal script. <br /> <br />This page was generated by the Page Class example.<p></p>"; <br /> <br />$Sample->Title = "Using Classes in PHP"; <br />$Sample->Keywords = "PHP, Classes"; <br />$Sample->SetContent( $Content ); <br /> <br />$Sample->Display( ); <br /> <br />?> <br /> <br />Doesn't get much simpler than that, does it? We use the include statement to bring in the class from its external file. We use the 'new' statement to create a new copy of the object so we can work with it. The new copy is stored into a variable called $Sample. Then we just set some variables - The Title, Keywords and Content - And use the Display function to output it. Easy or what? <br /> <br />[Via - <a href="http://www.php-editors.com/articles/simple_php_classes.php">Tutorial: Writing Classes in PHP</a>] <a href="http://www.plasticplace.net/">Garbage Bags</a> <a href="http://www.makefastmoneyonline.co.uk/">Make Money Online</a><a href="http://www.plasticplace.net/"> <br /></a></div><div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5157068160424128220-5543652238276339568?l=www.thephpbb.net'/></div>Silver Manihttp://www.blogger.com/profile/10584110258226203263noreply@blogger.com0tag:blogger.com,1999:blog-5157068160424128220.post-59812472324704522742008-01-25T01:23:00.000-08:002008-02-11T04:24:43.876-08:00Forum Login using cURLForum Login using cURL<br /><br />In this article, we're going to walk you through how you might<br />login to a forum such as phpbb2 programatically. First off, why<br />would you care to do such a thing? Well, out of the box forum<br />scripts such as SMF and phpbb2 won't make much impact on their<br />own for simply that reason, that they are out of the box and a<br />few clicks in cPanel or Plesk can get you up and running in a<br />couple of minutes. Ordinarily, to pack any punch (and of course<br />to be useful and provide value to the end user), the forum script<br />of choice will need to be installed and integrated as part of a<br />larger container site.<br /><br />Now that that scenario has been painted, continue down this<br />imaginary path ever so briefly. Say you have an existing members<br />area with which you wish to integrate your new forum, it would be<br />generally unacceptable practice to ask your users to first login<br />to your existing members area and then once inside, ask them to<br />login again to the forum.<br /><br />We won't go over in detail the whole integration process here,<br />just the actual login process which is definitely the most<br />complicated aspect of integration. For the sake of completeness,<br />the other aspects of integration include creating the record in<br />the new forum when a user signs up to your existing<br />'members-only' area, deleting the record if their account becomes<br />deactivated and ensuring database integrity on account management<br />functions, i.e. the user changing their password, their username,<br />language preferences &amp;c.<br /><br />At a high level of abstraction, this is what we are going to do;<br />we are going to validate the supplied username and password using<br />our existing login system. Then we are going to establish any<br />session variables and cookies that we use in our existing system,<br />i.e. you might set a cookie with the md5'd value of the users<br />password along with their id and validate this each time the user<br />requests a 'members-only' page. After that, we will construct a<br />cURL request to our forum login page passing along the supplied<br />username and password and a bit of other information which we'll<br />get to shortly. We process the response including cookies and the<br />session id and then we redirect over to our 'members-only' index<br />page. Done and dusted!<br /><br />Let's get down to it. We'll encapsulate this logic in a function<br />called checkLogin which will take 3 parameters (the<br />supplied username, the supplied password and a flag indicating<br />whether the user would like us to remember him/her on subsequent<br />visits). The function which logs a user into a phpbb2 forum might<br />look like this:<br /><br /><br /><br /><br />/*<br />$pu = passed username<br />$pp = passed password<br />$pr = passed remember flag<br />*/<br /><br />function checkLogin($pu, $pp, $pr)<br />{<br /><br />// Validate the username password combo<br />// using the current system. This assumes<br />// that you are working off a table called<br />// members and that all user passwords are<br />// stored as md5'd strings.<br /><br />$sql = "SELECT * FROM members WHERE username = '$pu' AND<br />password = '".md5($pp)."' LIMIT 1;";<br />$result = mysql_query($sql, $GLOBALS['db']);<br />if (mysql_num_rows($result)>0)<br />{<br /><br /> // At this point, we have validated the<br /> // user credentials, we should now<br /> // perform any perfunctory login actions,<br /> // such as setting cookies for remembering<br /> // the user, establishing the session<br /> // variables. Details on this are beyond<br /> // the scope of this article.<br /><br /> setSession(mysql_fetch_array($result), $pr);<br /><br /> // This is where it gets interesting,<br /> // construct an array of POST variables<br /> // that will be passed to the login script<br /> // of the phpbb2 forum. To modify this<br /> // function for a different forum,<br /> // download a HTTP packet sniifer (such<br /> // as HTTPLook), login to your forum in<br /> // the normal manner and see what POST<br /> // variables are passed to the login<br /> // script in the HTTP request. Then simply<br /> // replicate those variables here.<br /><br /> $post_data = array();<br /> $post_data['username'] = $pu;<br /> $post_data['password'] = $pp;<br /> $post_data['autologin'] = ($pr) ? 'on' : '';<br /> $post_data['login'] = 'Log in';<br /><br /> // The forum login script may attempt to<br /> // set cookies depending on what the login<br /> // mode is (i.e. whether the user should be<br /> // remembered or not). To facilitate that<br /> // functionality, we need to define a<br /> // temporary file to hold the contents of<br /> // the cookie.<br /><br /> $cookie_new = tempnam("/tmp","MKUP");<br /><br /> // Construct the cURL request, the<br /> // options to note here are:<br /> // 1) The URL of the forum login script<br /> // using CURLOPT_URL<br /> // 2) The incorporation of post data using<br /> // CURLOPT_POST/CURLOPT_POSTFIELDS<br /> // 3) The cookie handlers, CURLOPT_COOKIEFILE<br /> // and CURLOPT_COOKIEJAR<br /> // 4) The inclusion of the response header<br /> // in the result using CURLOPT_HEADER<br /><br /> $ch = curl_init();<br /> curl_setopt($ch, CURLOPT_URL,<br />"http://mysite.com/forum/login.php");<br /> curl_setopt($ch, CURLOPT_POST, 1 );<br /> curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);<br /> curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie_new);<br /> curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie_new);<br /> curl_setopt($ch, CURLOPT_HEADER,1);<br /> curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);<br /> curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);<br /><br /> // Storing the result of the request<br /> // including the HTTP response header is<br /> // highly recommended as it can be used most<br /> // effectively to decipher what, if anything,<br /> // has gone wrong.<br /><br /> $postResult = curl_exec($ch);<br /><br /> // Trigger any cURL related errors at this point<br /><br /> if (curl_errno($ch))<br /> {<br /> // Trigger error<br /> }<br /><br /> // Close the cURL session<br /><br /> curl_close($ch);<br /><br /> // If everything went according to plan,<br /> // the contents of any cookies the login<br /> // script wanted to set will be stored in<br /> // $cookie_new. At this point then we must<br /> // actually set the cookies as simply requesting<br /> // them via cURL will not set them on the client<br /> // browser. Read the contents into a variable<br /> // using the file_get_contents function.<br /><br /> $cookie_status = array();<br /> $cookie_contents = file_get_contents($cookie_new);<br /><br /> // Now that we have the contents of the<br /> // "cookie jar", we can delete the temporary<br /> // file to save resources.<br /><br /> if(file_exists($cookie_new))<br /> {<br /> unlink($cookie_new);<br /> }<br /><br /> // Split the jar into it's individual cookies<br /> // by using the "\n" delimiter.<br /><br /> $cookie_contents_array = explode("\n",$cookie_contents);<br /><br /> // Cycle through each cookie in<br /> // $cookie_contents_array and if the cookie<br /> // applies to our domain "mysite.com",<br /> // process it. It's hard to imagine a situation<br /> // where a cookie belonging to another domain<br /> // would get into the temporary cookie file yet<br /> // I can't help but check!<br /><br /> for($i = 0; $i < cookie_array =" explode(" expires=".date(" path="/" path="/" phpsessid=".session_id()." path="/" url="/members/index.php&amp;delay=" equiv="refresh" content="">;url="><br /><br /><br /><br /><br /><br /><br /><br />This way, the page where the cookies were sent in the header<br />actually loads, but the user doesn't really see this. This gives<br />your cookies the best chance of actually being interpreted and<br />processed by the browser. All your unsuspecting user sees is the<br />"members-only" index page after the meta refresh. Easy as!<br /><br />That's it, I hope this article offers a little bit of insight<br />into the faculty of remote login using cURL. It need not apply<br />specifically to phpbb2 or even a forum, it can be used to login<br />to any web based login system where, of course, you are<br />privileged to have the password. Enjoy!<br /><br />As with all articles on Celtic Productions, this article is<br />protected by international copyright laws. It may be linked to<br />(we are of course most grateful of links to our articles),<br />however, it may never be reproduced without the prior express<br />permission of its owners, Celtic Productions. It's not a case of<br />writing to Sony Music and asking can you lawfully reproduce and<br />distribute their hottest selling CD, if you do actually want to<br />reproduce this article on your website, just ask, you might be<br />surprised ;-)<br /><br />[Via - <a href="http://www.celticproductions.net/articles/4/php/forum+login+using+curl.html">Forum Login using cURL</a>]2.<div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5157068160424128220-5981247232470452274?l=www.thephpbb.net'/></div>Silver Manihttp://www.blogger.com/profile/10584110258226203263noreply@blogger.com2tag:blogger.com,1999:blog-5157068160424128220.post-22586454159230274342008-01-25T01:20:00.000-08:002008-01-25T01:23:34.360-08:00Practical Web 2.0 Applications with PHP by Quentin Zervaas releasedThe owner of PhpRiot, Quentin Zervaas, has released his first PHP book, entitled Practical Web 2.0 Applications with PHP. This book walks the reader through creating a complete web application from start to finish.<br /><br />The back cover of the book reads as follows:<br /><br />Many programming books on the market today focus specifically on a particular methodology or software package, and although you will gain a solid understanding of the subject matter from these books, you won't always know how to apply what you've learned in a real-world situation. This book is designed to show you how to bring together many different ideas and features by starting with a clean slate and gradually building the code base so it evolves into a complete web application.<br />Read the rest of the back cover »<br /><br />The premise of the application we build in this book is that it is a "Web 2.0" application. What this means is that (among other things) our application generates accessible and standards-compliant code while making heavy of use of Ajax. We achieve this by using the Smarty Template Engine and Cascading Style Sheets, as well as the Prototype JavaScript library. Additionally, we create a fun and intuitive interface by applying simple visual effects on various pages using the Scriptaculous JavaScript library.<br /><br />To help with the development of the extensive PHP code in this book, we use the Zend Framework. This is an open source PHP 5 library that contains many different components that you can easily use in any of your day-to-day development. We use many of the Zend Framework components in this book, such as database abstraction (with a focus on MySQL and PostgreSQL), logging, authentication, and search.<br /><br />The application we build in this book is a collaborative blogging tool. It will allow users to register and create a personal blog. When creating blog posts, users will be able upload images, apply tags, and assign locations (using Google Maps). We will also look at how to use microformats when displaying user blog posts.<br /><br />More information about can be found on this web site at<br /><a href="http://www.phpriot.com/news/3"><span style="font-weight: bold;">Web 2.0 Applications with PHP</span></a>.<div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5157068160424128220-2258645415923027434?l=www.thephpbb.net'/></div>Silver Manihttp://www.blogger.com/profile/10584110258226203263noreply@blogger.com0tag:blogger.com,1999:blog-5157068160424128220.post-37960533014142647392008-01-25T01:11:00.000-08:002008-01-25T01:15:59.964-08:00Monitoring File Uploads using Ajax and PHPIntroduction<br /><br />Because of the limitations of HTTP, it is difficult to monitor the status of files as they are uploaded via HTML forms. While other programming languages have built-in methods to monitor file uploads, PHP does not. This article shows how to implement such a solution in PHP.<br /><br />In order to achieve this, the APC (Alternative PHP Cache) PHP extension is required, as well as PHP 5. Specifically, APC 3.0.13 or newer and PHP 5.2 or newer are required for the code in this article to work. We will cover installation of APC in the next section. It is assumed you already have a working PHP 5.2 installation.<br /><br />In this article we will develop a solution that will allow users to upload a file from their computer using HTML forms. We will then determine the progress of the upload while it is in progress using Ajax, and display the status to the user.<br /><br />In addition to using PHP, we will also be using the Prototype JavaScript library (version 1.6.0), which you can download for free from http://www.prototypejs.org.<br /><br />The steps we will follow in this article are as follows:<br /><br /> * Installation of the APC extension for PHP.<br /> * How to monitor uploads using APC.<br /> * Creating a PHP class to manage file uploads.<br /> * Implementing a traditional file uploader.<br /> * Extending the uploader to display upload status.<br /><br /> * Next: Installing APC<br /><br />[Via - <a href="http://www.phpriot.com/articles/php-ajax-file-uploads">Ajax and PHP</a>]<div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5157068160424128220-3796053301414264739?l=www.thephpbb.net'/></div>Silver Manihttp://www.blogger.com/profile/10584110258226203263noreply@blogger.com0tag:blogger.com,1999:blog-5157068160424128220.post-84054708941195149792007-12-21T12:48:00.000-08:002008-02-11T04:23:50.039-08:00phpBB Launches Next Wave of Social Networking and Forum Features.London, UK (PRWEB) December 13, 2007 -- phpBB™, the leading open source forum and online collaboration system, announced today the availability of phpBB Version 3.0. This release includes enhanced collaboration features, better security and delegated administration features, extended support for open source and commercial database management systems, and optimisation for mobile devices and search engines. phpBB is available at no cost, released under the GNU General Public License.<br /><br />News Image<br /><br />Online discussion forums and user-generated content represent the largest source of new information on the Internet. phpBB is used throughout the world by commercial and non-commercial companies to share documents, collaborate and encourage peer-to-peer resolution of issues to reduce the cost of product and/or technical support.<br /><br />"phpBB is a highly scalable, feature rich environment that can be easily deployed and integrated into any Web site or online application," says Bob Norton of HREnhancement. "phpBB version 3 represents a huge milestone and we continue to be amazed by this project and its community."<br /><br />phpBB is easy-to-use with an intuitive administration system and extensive customisation capabilities. It is capable of supporting hundreds of millions of discussions in any language and boasts some of the largest forum communities on the Internet. phpBB is developed by six core developers, more than forty team members and is supported by a community of almost 300,000 users and developers. Among the new features announced today, phpBB has been specifically optimised for the mobile market.<br /><br />"With the enhanced search engine optimisation of phpBB, we see a huge opportunity for companies to deploy more customer self-service and collaboration features for their customers," says William Leake, Chief Executive Officer of Apogee Search. "The mobile Web is a key component for every 2008 Web strategy and phpBB is a perfect fit for the growing mobile collaboration market."<br /><br />The phpBB community, comprised of users, Web developers and designers, have produced more than 5,000 add-ons and 400 styles for phpBB2 making it easy for Website owners to customise the system to their needs. The phpBB community has already made nearly 500 enhancements, modifications and extensions for phpBB version 3.0, even before final release.<br /><br />Organisations can quickly build advanced social and peer networking communities using phpBB and it can be deployed with "one-click" through cPanel, Plesk, Ensim, DirectAdmin and Fantastico. Hosting providers such as GoDaddy, The Planet, and 1and1 provide phpBB with many standard hosting packages.<br /><br />"phpBB version 3 represents over five years of development from some of the most talented developers in the world. As the project continues to grow, we hope to serve our community better and deliver innovative software that is released under the GPL. Our sincere thanks go to our users, developers, team members and partners." Says Meik Sievertsen, Lead Developer of the phpBB project. With phpBB version 3, detailed source code analysis and penetration testing has also been performed to proactively make steps toward improved enterprise security.<br /><br />For developers who want to quickly and inexpensively integrate collaboration and forum capabilities into their own Web applications, phpBB provides a flexible framework, documented Application Programming Interfaces (APIs), customisable themes, and extensions. phpBB can quickly integrate into almost any content management system (CMS) or static Website.<br /><br />About phpBB<br />phpBB™ ("PHP Bulletin Board") is the world's leading Open Source forum software. Distributed under the GNU General Public License, phpBB is free software, developed by volunteers from around the world. phpBB is used on over 2.4 million commercial, non-profit, social networking and community websites in over sixty languages. For more information and to learn how you can contribute, please visit <a href="http://www.phpbb.com/" rel="nofollow">http://www.phpbb.com</a><br /><br />We have all the <a href="http://www.cert-world.com/">top certifications</a> exams of all popular vendors around the world like <a href="http://www.cert-world.com/VCP-310.html">VCP-310</a>.<br /><br />Check more this sites also: <a href="http://www.gate13.com.au/">Online Store</a> &amp; <a href="http://www.roi.com.au/">Search Engine Marketing</a> &amp; <a href="http://www.newlitho.com.au/">Printing Services</a><div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5157068160424128220-8405470894119514979?l=www.thephpbb.net'/></div>Silver Manihttp://www.blogger.com/profile/10584110258226203263noreply@blogger.com0tag:blogger.com,1999:blog-5157068160424128220.post-57557574888700753702007-12-21T12:37:00.000-08:002008-05-23T03:50:35.373-07:00phpBB Hits Gold with Version 3.0phpBB announced today the release of <a href="http://www.phpbb.com/" rel="nofollow">phpBB 3.0 Gold</a>, pushing its open-source software back into the limelight of online community solutions. Since its creation in 2000, phpBB has grown to become one of the most widely-used bulletin board systems online. Its volunteer support base has created over 5,000 add-ons and 400 themes for phpBB2, with 500 enhancements already published for phpBB3, according to a press release.<br /><br />"phpBB version 3 represents over five years of development from some of the most talented developers in the world. As the project continues to grow, we hope to serve our community better and deliver innovative software that is released under the GPL. Our sincere thanks go to our users, developers, team members and partners." Says Meik Sievertsen, Lead Developer of the phpBB project.<br /><br />New features include expanded administrative control and database management, improved plug-in support, new messaging and navigation features, advanced usergroup support, Web standards compliancy, and Joomla CMS integration. Labeling this latest version "Gold" implies phpBB developers are satisfied with the product and believe it is finally ready for full mainstream dissemination. Having no paid, immediate support staff, phpBB has struggled with exploits and bugs in the past.<br /><br />Commercial online forum software, such as <a href="http://www.vbulletin.com/" rel="nofollow">Jelsoft's vBulletin</a> and <a href="http://www.invisionpower.com/community/board/index.html" rel="nofollow">Invision Power's IP.Board</a>, have absorbed a huge portion of the online forum market in recent years. phpBB, continued with the release of 3.0, remains the most widely-accept free solution for community-developement. With user-generated Web content and online discussion environments growing exponentially, phpBB seeks to stay at the forefront of community project development.<br /><br /><a href="http://www.miragelondon.co.uk/" rel="nofollow">Designer Clothes</a> 2. We have all the <a href="http://www.cert-world.com/" rel="nofollow">top certifications</a> exams of all popular vendors around the world like <a href="http://www.cert-world.com/VCP-310.html" rel="nofollow">VCP-310</a><br /><br />One does not have to necessarily contact a <a href="http://www.access-board.gov/sec508/guide/1194.22.htm" rel="nofollow">web design consulting</a> at all. After having done with <a href="http://www.envisionwebhosting.com/domain-registration.htm" rel="nofollow">domain name registration</a>, the rest can be taken care of himself as well. A <a href="http://newhaven.fbi.gov/dojpressrel/2007/nh030707.htm" rel="nofollow">cheap hosting site</a> if offers the desired features, should be preferred to the <a href="http://www.complete-website-hosting.com/" rel="nofollow">best web hosting</a> if it lacks in the features one needs. This holds true for any case. After getting the <a href="http://www.registeranydomain.com/" rel="nofollow">cheapest domain name</a>, one can proceed with the <a href="http://www.topthechart.com/Marketing-Info.html" rel="nofollow">marketing</a> aspect. For any site, if <a href="http://www.topthechart.com/Advertising-Info.html" rel="nofollow">advertisin</a><a href="http://www.topthechart.com/Advertising-Info.html" rel="nofollow">g</a> is done correctly, it can do wonders.<div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5157068160424128220-5755757488870075370?l=www.thephpbb.net'/></div>Silver Manihttp://www.blogger.com/profile/10584110258226203263noreply@blogger.com0tag:blogger.com,1999:blog-5157068160424128220.post-23020798794926201852007-11-27T09:39:00.001-08:002008-02-26T01:16:44.816-08:00PHP 5.2.4 Released<div class="newsItem"> <span style="font-size:85%;"><a name="2007-08-30-1" id="2007-08-30-1"><h1>PHP 5.2.4 Released</h1></a></span> <div> <span class="newsdate">[30-Aug-2007]</span> <p> The PHP development team would like to announce the immediate <a href="http://livedocs.phpdoc.info/downloads.php#v5" rel="nofollow">availability of PHP 5.2.4</a>. This release focuses on improving the stability of the PHP 5.2.X branch with over 120 various bug fixes in addition to resolving several low priority security bugs. All users of PHP are encouraged to upgrade to this release. </p> <p> Further details about the PHP 5.2.4 release can be found in the <a href="http://livedocs.phpdoc.info/releases/5_2_4.php" rel="nofollow">release announcement for 5.2.4</a>, the full list of changes is available in the <a href="http://livedocs.phpdoc.info/ChangeLog-5.php#5.2.4" rel="nofollow">ChangeLog for PHP 5</a>. </p> <p> <b>Security Enhancements and Fixes in PHP 5.2.4:</b> </p> <ul><li>Fixed a floating point exception inside wordwrap() (Reported by Mattias Bengtsson)</li><li>Fixed several integer overflows inside the GD extension (Reported by Mattias Bengtsson)</li><li>Fixed size calculation in chunk_split() (Reported by Gerhard Wagner)</li><li>Fixed integer overflow in str[c]spn(). (Reported by Mattias Bengtsson)</li><li>Fixed money_format() not to accept multiple %i or %n tokens. (Reported by Stanislav Malyshev)</li><li>Fixed zend_alter_ini_entry() memory_limit interruption vulnerability. (Reported by Stefan Esser)</li><li>Fixed INFILE LOCAL option handling with MySQL extensions not to be allowed when open_basedir or safe_mode is active. (Reported by Mattias Bengtsson)</li><li>Fixed session.save_path and error_log values to be checked against open_basedir and safe_mode (CVE-2007-3378) (Reported by Maksymilian Arciemowicz)</li><li>Fixed a possible invalid read in glob() win32 implementation (CVE-2007-3806) (Reported by shinnai)</li><li>Fixed a possible buffer overflow in php_openssl_make_REQ (Reported by zatanzlatan at hotbrev dot com)</li><li>Fixed an open_basedir bypass inside glob() function (Reported by dr at peytz dot dk)</li><li>Fixed a possible open_basedir bypass inside session extension when the session file is a symlink (Reported by c dot i dot morris at durham dot ac dot uk)</li><li>Improved fix for MOPB-03-2007.</li><li>Corrected fix for CVE-2007-2872.</li></ul> <p> For users upgrading to PHP 5.2 from PHP 5.0 and PHP 5.1, an upgrade guide is available <a href="http://livedocs.phpdoc.info/migration52" rel="nofollow">here</a>, detailing the changes between those releases and PHP 5.2.4.</p><p style="text-align: left;">The trend of <a href="http://www.affiliateladder.net">affiliate marketing</a> has been increasing day by day due to the great margin of profitability. There is a need of secured email account and password to login if you are representative of <a href="http://www.seoprojection.com/Email-Marketing.html">email marketing</a> enterprisers. There are a wider range of web hosts which are offering the <a href="http://www.businesshostingprovider.com/domain-registration.htm">cheapest domain name</a> registration. <a href="ttp://www.hostseeq.com">cheap web </a> services are not offering all-inclusive features of high quality. There is a great name and fame of for the extraordinary features of hosting companies. The <a href="http://blog.case.edu/webdev/2006/12/12/favorite_recommended_web_hosts">cheap domain hosts</a> are enlisted by different web hosting directories for easy searching out. You may decide to get services of the web host by studying the <a href="http://www.fbi.gov/congress/congress03/farnan090403.htm">webhosting reviews</a> of experts.<br /></p> </div> </div><div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5157068160424128220-2302079879492620185?l=www.thephpbb.net'/></div>Silver Manihttp://www.blogger.com/profile/10584110258226203263noreply@blogger.com0tag:blogger.com,1999:blog-5157068160424128220.post-58974567590447137602007-11-27T02:13:00.000-08:002008-08-25T04:30:56.424-07:00Blog Has LaunchedThe PHP guidebook is accessible online in a collection of languages. give pleasure to select a language from the listing below.<br />You can study how to amalgamate our online manual with a variety of tools, including your net web browser, on our rapid orientation tips page. You can too get more information about php.net URL shortcuts by visit our URL how-to page.<br />Note that a lot of languages are just below conversion, and the untranslated parts are still in English. Also a number of translated parts might be out-of-date. The translation team are open to assistance &amp; contributions.<br /><br />The <a href="http://www.1-hit.com/">internet marketing</a> trends are majorly influenced by <a href="http://marketing.byu.edu/htmlpages/courses/490r/chapters/text.html">internet users and markets</a> habits. The <a href="http://www.seoprojection.com/Advertising-Agency.html">advertising agencies</a> basically make use of this information. Whether it is for an <a href="http://www.theaffiliatereport.net/">affiliate program</a> or a marketing technique like <a href="http://sanfrancisco.fbi.gov/dojpressrel/2006/sf032906.htm">pay per click ad</a>, the information is carefully evaluated and only then a conclusion is reached. Of course with <a href="http://www.1-hit.com/web-hosting.htm">site hosting</a> taken care of, full attention can be paid to marketing.<br /><br /><p><a href="http://www.ferag.info/">Ferag</a> <a href="http://www.pure-foods.com/">Puer-Foods</a> <a href="http://www.electroluxe.net/">Electroluxe</a> <a href="http://www.icota.org/">Icota</a> <a href="http://www.theelmsgolfclub.com/">Elms Golf Club</a> <a href="http://www.digitalkami.org/">Digitalkami</a> <a href="http://www.innatpennytown.com/">Innatpennytown</a></p><div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5157068160424128220-5897456759044713760?l=www.thephpbb.net'/></div>Silver Manihttp://www.blogger.com/profile/10584110258226203263noreply@blogger.com0