Skip to main content

php

Random Joomla 1.5 Logout

Posted in

I was receiving some complaints from a customer that he was getting randomly logged out when using the administration section of his website.

He has a Joomla 1.5 install with the legacy plugin enabled and according to this Joomla Bug you have to have the Remember me Plugin to have an higher priority than the Cache and Legacy plugins.

For solving this, I've made Remember me to have priority 1, Legacy 2 and Cache 3.

SolarPHP How to use unlimited functions in a View Helper

I was chatting on irc with dmytrok (kudos to him about the tip below) about the Solar View Helpers and it seems there's a very simple way of using multiple functions in a solar view helper.

As you know, for creating a Solar View Helper you create a class like:

  1. class Vendor_View_Helper_MyTest extends Solar_View_Helper {
  2.  
  3.     public function myTest()
  4.     {
  5.         // logic here
  6.     }
  7. }

And then you can call it in your views by using $this->myTest() and all will go well.

SolarPHP How to use Make Model with underscore separated table names

Posted in

It's easy, make-model takes an aditional --table parameter.
So you can do something like

  1. ./script/solar make-model myApp_Model_NiceTableName --table nice_table_name

SolarPHP User Roles and ACL Example

As I promised, here's the more "advanced" tutorial regarding roles and acl in SolarPHP using the sql adapter.

I'll continue the previous tutorial, so if you didn't had chance to read it here's a link.

Now let's continue.
Here's the config required for the roles / acl

  1. $config['Solar_Role']['adapter']  = 'Solar_Role_Adapter_Sql';
  2. $config['Solar_Role_Adapter_Sql'] = array(
  3.     'table'      => 'roles',
  4.     'handle_col' => 'username',
  5.     'role_col'   => 'name',
  6. );
  7.  

SolarPHP Basic User Authentication Example

Here's another short tutorial for solar php in which I'm going to try to explain how to achieve a simple authentication system in SolarPHP.

User Roles and ACL's will follow in another tutorial.

Let's get started:
I'm using the SQL adapter for the authentication system. I'm assuming you're already have the config file setup for connecting to the sql server.

The config file is as follows:

  1. // Specify our authentication adapter
  2. $config['Solar_Auth']['adapter']= 'Solar_Auth_Adapter_Sql';
  3.  
  4. // authentication adapter information

Simple SolarPHP Pagination Example

Being new to the SolarPHP scene I was trying to grasp some concepts around it, that for the lack of knowledge seem hard to do (and lack of any written articles found with google).

Pagination is implemented in SolarPHP by using a View Helper class called Pager.
At first I was perplexed about the fact that it took as parameters, among the usual number of items, number of pages etc., also the amount of pages, a minor detail that, usually, other pagination classes calculate automatically.

Simple PHP Calendar

Posted in

Posted it on my blog, but I decided that I should share it here as well, for those of you that need a simple php calendar.

  1. <?php
  2. // This gets today's date
  3. $date = time ();
  4.  
  5. // This puts the day, month, and year in seperate variables
  6. $day  = date('d', $date);
  7. $month= date('m', $date);
  8. $year = date('Y', $date);
  9.  
  10. // Here we generate the first day of the month
  11. $first_day = mktime(0,0,0,$month, 1, $year);
  12.  
  13. //This gets us the month name
  14. $title = date('F', $first_day);

T_PAAMAYIM_NEKUDOTAYIM PHP error

Posted in

Ok so i've hit this nasty php error T_PAAMAYIM_NEKUDOTAYIM that sounded like a language from another planet for me (found out that it's Hebrew for "missing double dots")

The problem is that with static class functions you can't do dynamic loading (or at least it didn't work for me)
So while this

  1. $module = $_GET['module']
  2. $stuff = new $module();
  3. $stuff->data;

works, you can't do
$module::data()
even if the name of the module is the name of the class.

Image magick / GD transparency clipping of animated gif frames

Let's consider the following scenario:
You want to split a gif in individual frames, that can be done nicely with image magick with the following code
convert canvas_prev.gif -scene 1 +adjoin  frame_%03d.gif
Then you want to copy another image over each resulting frame
composite -gravity center frame_001.gif new.gif composed_frame.gif
And here's the catch. When you copy the frame over the new image image magick the transparency around the image frame gets clipped and the positioning will be different.

Php make error ltdl

If you get the following make error:


/usr/bin/ld: cannot find -lltdl
collect2: ld returned 1 exit status

then you need to install the libtool-ltdl-devel package.
On CentOS run
yum install libtool-ltdl-devel
and everything should be fine

If you need more help on the topic feel free to add a comment or create a new post on the Forum

Syndicate content