PHP BBcode to HTML parser
0Just another class to convert from a BBcode to HTML.
It has all the BBcode basics and also converts youtube video. It’s developed to be compatible with the nice WYSIWYG JQuery BBcode SCEditor
Usage:
if ($_POST) { include 'bbcode.php'; //parses posted BBcode to HTML $html_code = bbcode::tohtml($_POST['description'],TRUE); //removes the bbcode $nobbcode = bbcode::remove($_POST['description']); }
Download the class here with a full example.
Google Charts API – PHP Class
0This class can embed charts in a Web page with Google Charts API.
It can generate HTML and JavaScript to make calls to the Google Charts API to display several types of charts in a Web page.
Currently it supports embedding charts of type pie, column, area, line, bar, bubble, geographic markers and gauge.
Download at phpclasses.org
Simple example:
(more…)
PHP class to export MySQL tables and optimize them
0Hello,
Today I am going to share a helpful library that I use some times to perform backups of the schema from a DB.
It will create a unique file with the schema for each table you have in your DB for example. Also I added an option to get all the data and you can optimize a set of tables.
How to use it:
(more…)
Cross-site Request Forgery prevention in PHP
0Simple way to prevent Cross-site Request Forgery in php.
//trying to prevent CSRF attacks function checkCSRF($key=''){ //correct referer or empty sent by browser, checkign the form if ( (!empty($_SESSION['token_'.$key])) && (!empty($_POST['token_'.$key])) ) { if ($_SESSION['token_'.$key] == $_POST['token_'.$key]) {//same token session than form return true; } } return false; } //create an input with a token that we check later to prevent CSRF function createCSRF($key){ //$key variable allows us to have more than 1 form per page and to have more than 1 tab opened with different items $token = md5($key.uniqid(rand(), true));//unique form token $_SESSION['token_'.$key] = $token; return '<input type="hidden" name="token_'.$key.'" value="'.$token.'"/>'; }
Usage:
(more…)
Domain name sales
0Hello,
Since I don’t have much time to keep many of these domains, I decided to sell them to the best bidder.
Classifieds sites:
ocaku.com / ocacu.com - classifieds community. 13K web sites, 759K advertisements, Custom code and design. Expensive.
aderous.com – 5K advertisements and PR 4 – Generates 20€ month in adsense
classifiedsbarcelona.com – Great domain name
phpmarket.org – Custom development
Others:
deambulando.com – 80K unique visitors month, 6 years domain name, Spanish
dontcode.com – I sell it for little amount
rir.li – really nice short name.
Please contact me if you need further information or you want to purchase.
Simple email function for PHP
1Simple function to send an email in PHP, and that actually works ;)
Just be aware that I added a Hook (check the PHP Hook class).
(more…)
Help Wanted: Open Classifieds 2.0.
0Hello Friends,
Since long time a go I’ve been thinking in the future of OC and we need to move forward to grow more ;)
I think right now OC is a great product and is helping a lot of people, more than 100K downloads and thousands of sites running this software are the best indicators.
The biggest problem as development team we’ve been facing is the scalability of the code. This started as an small script with really limited functionality, that I used to learn PHP. Not best practices implemented and lot of technological debt that needs to be paid.
(more…)
PHP Hook System
9You know the hooks for WordPress? So here you have a simple workaround to achieve a similar aproach to what WordPress does.
Usage and instuctions
//Adding action to a hoook: Hook::add_action('unique_name_hook','some_class::hook_test'); //OR shortcut: add_action('unique_name_hook','other_class::hello'); add_action('unique_name_hook','some_public_function'); //Performing all the actions for the hook do_action('unique_name_hook');//you can use too Hook::do_action();
PHP – Garbage Collector
0Memory cleanup for long-running scripts.
gc_enable(); // Enable Garbage Collector var_dump(gc_enabled()); // true var_dump(gc_collect_cycles()); // # of elements cleaned up gc_disable(); // Disable Garbage Collector
More info:
http://php.net/manual/en/features.gc.php
http://es.php.net/manual/en/function.gc-collect-cycles.php
Via: http://talks.php.net/show/pbc11/25