Welcome, Guest
You have to register before you can post on our site.



Search Forums

(Advanced Search)

Forum Statistics
» Members: 9,656
» Latest member: jewe
» Forum threads: 66,775
» Forum posts: 418,542

Full Statistics

Latest Threads
Does the controller name ...
Forum: CodeIgniter 4 Discussion
2 hours ago
» Replies: 0   » Views: 16
Improve Pagination CI 3x
Forum: CodeIgniter 3.x
4 hours ago
» Replies: 2   » Views: 135
use active records in lib...
Forum: General Help
5 hours ago
» Replies: 1   » Views: 23
input post empty
Forum: General Help
11 hours ago
» Replies: 9   » Views: 213
Dynamic Meta Description
Forum: General Help
Yesterday, 10:26 AM
» Replies: 1   » Views: 72
redis driver _get_lock se...
Forum: Issues
Yesterday, 09:05 AM
» Replies: 6   » Views: 165
Release date for 3.2.0?
Forum: CodeIgniter 3.x
Yesterday, 09:01 AM
» Replies: 1   » Views: 123
How do you access the $th...
Forum: CodeIgniter 4 Discussion
10-20-2017, 08:25 PM
» Replies: 7   » Views: 352
new User of CodeIgniter
Forum: Lounge
10-20-2017, 07:57 PM
» Replies: 2   » Views: 132
Login library
Forum: Best Practices
10-20-2017, 05:18 PM
» Replies: 3   » Views: 239

  Sparks : Caching Template system
Posted by: El Forum - 07-14-2007, 03:52 PM - Forum: Archived Libraries & Helpers - Replies (23)

[eluser]Al James[/eluser]
Update Version 1.1 is here

Hi there,

For my project I require a caching system, however caching in CI is a all or nothing affair, i.e. I can either cache the entire page or nothing at all.

In real life, this is not sutible. For my site (and I should imagine most sites that are not entirely static) elements on the pages an be divided into those that are cacheable and those that are not (must be generated for each page view).

For example: On all my pages, the message "You are logged in as XXX" is displayed in the top corner of the screen. Obviously, this must be generated for each page view. The rest of the page is (often) cacheable.

Out of the box, CI would not be able to help as it can only cache the entire page or nothing at all.

In order to solve this, I have developed a caching template system that allows you to divide the php blocks into those that can be cached and those that cannot. I have called it 'SPARKS' and this is a request for comments. If people like the idea, I will post the code in the wiki.

Basically, you create view files with the following syntax:

<p>&lt;?php echo("This block is cacheable"); ?&gt;</p>
<p><$?php echo("This block is NOT cacheable"); ?$></p>

Thus, we simply use <$?php ?$> tags for non-cacheable php blocks.

On the first view, the above template gets eval'ed and stored in a cache file. The <$php $> blocks get re-written as &lt;?php ?&gt; blocks. I.e. it becomes:

<p>This block is cacheable</p>
<p>&lt;?php echo("This block is NOT cacheable"); ?&gt;</p>

So that when this cache file is included, it will execute the non-cacheable php blocks.

Roughly, the pseudo-code for the controller would look like:

1) Load libraries and helpers for non-cacheable content
2) Calculate non-cacheable content
3) Check for a current cached version of the template. If it exists, display it and return.
4) Load libraries and helpers for cacheable content.
5) Calculate cacheable content.
6) Render page to cache.
7) Display page.

Thus is a cached version of the page exists, the controller function returns at step 3 and does not complete steps 4-7.

What do people think of this approach? Its got me out of a sticky situation.

If people think the concept is a good one, I will post the code!

  Help with thumbnail generation
Posted by: El Forum - 07-14-2007, 02:24 PM - Forum: Archived Development & Programming - Replies (1)

I can't seem to get the image_lib library to generate a thumbnail. The following code generates an error message:

function test()
        // Create thumbnail            
        $config['image_library'] = 'GD';
        $config['source_image'] = './public/images/avatars/brigham.jpg';
        $config['create_thumb'] = TRUE;
        $config['maintain_ratio'] = TRUE;
        $config['width'] = 50;
        $config['height'] = 50;
        $this->load->library('image_lib', $config);
...and the error message is
Quote:A PHP Error was encountered
Severity: Notice
Message: Undefined property: CI_Image_lib::$dest_image
Filename: libraries/Image_lib.php
Line Number: 476
What am I doing wrong? I've tried specifying 'dest_image' and 'new_image' in the config file, but the same error appears.

  CI and electronic patiend record app
Posted by: El Forum - 07-14-2007, 09:07 AM - Forum: Archived General Discussion - Replies (5)

I was landed with a project involving an electrinic patiend record.
We have a software that manages the patients based on Inoformix that is lacking the epr functionalities.
My boss decided to implement these new functionalities and I suggested the use of php and mysql, accessing informix data using odbc.
Since there will be only me working on the project I am looking at a way to save time and was wandering if CI could be right for me.
I have knowledge of php and sql but not a big knowledge of OOP even if I use adodb classes and complitely new to framworks
Also a big part of the project will be authorization (I was looking at liveuser but it seems quite difficult and not very well documented) and I understand that CI can use FreakAuth lite.
How long will it take to learn CI (considering I could spend 4-6 hours a day doing this)?
Was also looking at cakephp but it seems more complicated even if there is ACL built into it.
Thanks and excuse me for my long post and my poor English

  how safe is $this->session ?
Posted by: El Forum - 07-14-2007, 06:38 AM - Forum: Archived General Discussion - Replies (5)

I'm seeing a lot of people using the internal session library where they store if an user is autenticated(and they didn't talk about sessions in the db).
But if i'm storing something like "auth=1" in there
and after that i do an 'var_dump($_SESSION)' i seee the 'auth=1' serialized
I would say that session is a cookie and can be easily tempered with..
Or am i wrong...

  multiple sites, 1 codebase, using symlinks (with smarty)
Posted by: El Forum - 07-14-2007, 01:27 AM - Forum: Archived Development & Programming - Replies (13)

Greetings all,

First, I'd like to say thanks for making a great framework, its flexible and fun to use! I've only been at it a few days but am very impressed. I even managed to get Smarty templates integrated with very little trouble. (not required I know but was my preference)

Now onto the meat ...


My project called for a specific configuration of sites and applications:

site #1: one application
site #2: has both frontend and backend applications
     (will also operate on wildcard sub-domains)
site #3: uses ssl with one application
site #4: one application (internal access)

All 4 sites are heavily related ... and will often want to use the same models, libraries, helpers, views etc. Unfortunately CI doesn't give me a place to store these resources cross-application, and I really didn't feel comfortable editing or extending the core CI classes. That might have made upgrading the framework painful with later releases. I like the idea of just 'dropping in' a new system folder without worry.


So as I was looking into CI initially, I found a lot of posts about running multiple-application sites. Overall, I got the impression that this was something CI 'could' do with tweaking (depending on your specific sites/applications) but wasn't particularly great at out of the box. Thankfully, CI is so easy to work with that there are a number of solutions to consider.

Option 1:

One alternative was to run all my apps out of the same application folder, and just give them unique controllers ... I considered this but thought it might be difficult to keep site #1 from calling site #2's controllers by editing the urls. My sites needed to be fairly secure in this regard.

Option 2:

Another alternative was to modify the loader of the CI core classes to include a new search path, essentially adding a Library level where cross-application code goes. This would have been the most attractive option if I felt more comfortable editing core files. But I don't ... ick! Hopefully CI adopts a similar solution officially in a later release.

Some related links on that method:


And other options I won't get into right now ...


My situation is unique to me perhaps. I happen to own the box my sites are being hosted on, so all configuration options are available. My sites use the traditional php5, mysql5, apache2 on Free(as in beer)BSD. I can edit httpd.conf freely and create .htaccess files as needed.


I found I was able to share a (parent) application folder (located outside each site's root) with a specific site's (local) application folder ... I did this by creating a series of symbolic links in each (local) application folder to represent the corresponding folders in my (parent) application folder ...

I literally matched symbolic links to parent folders exactly ... EXCEPT for the (local) application's 'controllers' folder, which was really the meat of each website.

It might be easier to show you the following folder hierarchy I used:
    my global application folder, where most the code goes
    my CI installs system folder and other files, I leave the version
    number so that I can link to a new system in the index.php if
    needed for testing
    an apache directory alias called common lets me link to subfolders here
    called img, js, css, file, etc. Having one folder with all my includes makes
    it easy to specify in an .htaccess file that CI should leave links alone with
    the word common in it.
    my smarty install, contains the actual libraries
    the site root for site #1
    the site root for site #2
    the site root for site #3
    the site root for site #4

  Fix DSN connect!
Posted by: El Forum - 07-14-2007, 01:07 AM - Forum: Archived Development & Programming - No Replies

[eluser]Claudiu CISMARU[/eluser]
The CI doesn't works properly with DSN!

I've been writted here, last message:

  Validation and Select Item? [solved]
Posted by: El Forum - 07-13-2007, 08:04 PM - Forum: Archived Development & Programming - Replies (1)

I'm successfully using the validation class with text and textarea fields, but I can't get it to validate a <select> field. How do I do this? In this example, the menu is of all of the states and the values are all two-digit codes. I want to make it required and two digits only.

Controller Snippet

$rules['state_abbr'] = "exact_length[2]";

View Snippet
<select name="state_abbr" size="1">
<option value="">Select a State</option>
&lt;?php while (list($state_abbr, $state) = each($states)):?&gt;
<option value="&lt;?=$state_abbr;?&gt;" &lt;?=$this->validation->set_select('state_abbr', $state_abbr);?&gt; >&lt;?=$state;?&gt;</option>            
&lt;?php endwhile;?&gt;

It's in a form with other text fields and they are getting validated. This one select field is getting skipped. What's the trick? Thanks!

  default value paramater for get/post/cookie input class
Posted by: El Forum - 07-13-2007, 05:59 PM - Forum: Archived Libraries & Helpers - No Replies

I don't see any better outlet for this type of recommendation - I would love to contribute more to CI as my team and I have been using it recently on several projects.

Anyway, instead of sending a default value of false if a parameter is not set, I would recommend that it be a third option in the function.

For example:

function post($index = '', $xss_clean = FALSE, $default = FALSE)
        if ( ! isset($_POST[$index]))
            return $default;

Instead of returning false, I could assign a default value (which, by if not provided is false). I frequently need to assign something else, like a string or a non-zero integer.

I would recommend this for the get/post functions, if not the cookie/session functions as well.

  Combining EE and CI?
Posted by: El Forum - 07-13-2007, 05:23 PM - Forum: Archived General Discussion - Replies (2)

I'm going crazy. OK, admittedly that's a pretty short drive. Maybe even a putt. But, still....

Over the past three weeks or so I've bounced back and forth between CI and EE as the solution to a Web design/development project in which I'm engaged. Almost the instant I reach a conclusion, something causes me to rethink it.

I think I can finally articulate why I'm having the problem, so please bear with me. I'll try hard to be brief.

This is an existing site. It has two faces. One is a public face that has a fair amount of application-style interactivity associated with it (signups, logins, qualifications, validations, etc.). The other side is the member side which essentially features a lot of information that doesn't change over time but which needs to be easy for the non-technical marketing team to add to and modify. Aside from basic login and validation, the member site features relatively little executable PHP code at this moment. That may change but for now, that's the story.

So what I think I want is a CI site for the public side and an EE site for the member side. But I'm not at all sure that makes sense or is even feasible.

It occurred to me as I reflected on all of this this morning, that it would approach perfection if I could use EE as my CMS and have its templates sort of become my CI views. That may not be precisely the best way of describing what I mean, but it's as close as I can come.

Anyone have any interesting insights, guidance, ideas?

  Fix to PostgreSQL driver
Posted by: El Forum - 07-13-2007, 04:55 PM - Forum: Archived Development & Programming - No Replies

All parameters to the pg_connect() and pg_pconnect() PHP functions are optional, but the CI driver incorrectly assumes that they will all be defined as non-empty in the config file. As a result, it is not possible for CI to connect to a server via Unix domain sockets, which is the default configuration for PostgreSQL.

If "host=" is left out, it will default to Unix domain sockets instead of TCP/IP. If "user=" is left out, it will default to the user making the request. If "dbname=" is left out, it will also default to the user making the request. None of these default actions can be utilized in the current driver however, because it assumes that these values will be provided. Thus, if not provided, the connection string will look like "host= user= dbname=", which is invalid, and not the same as the desired empty connection string. Here is a patch against 1.5.4 to fix:

--- postgre_driver.php.orig     2007-07-12 06:56:22.000000000 -0500
+++ postgre_driver.php  2007-07-13 16:30:21.000000000 -0500
@@ -38,9 +38,13 @@
        function db_connect()
+               $database = ($this->database == '') ? '' : " dbname=".$this->database;
+               $hostname = ($this->hostname == '') ? '' : " host=".$this->hostname;
                $port = ($this->port == '') ? '' : " port=".$this->port;
+               $username = ($this->username == '') ? '' : " user=".$this->username;
+               $password = ($this->password == '') ? '' : " password=".$this->password;

-               return @pg_connect("host=".$this->hostname.$port." dbname=".$this->database." user=".$this->username." password=".$this->password);
+               return @pg_connect($database.$hostname.$port.$username.$password);

        // --------------------------------------------------------------------
@@ -53,9 +57,13 @@
        function db_pconnect()
+               $database = ($this->database == '') ? '' : " dbname=".$this->database;
+               $hostname = ($this->hostname == '') ? '' : " host=".$this->hostname;
                $port = ($this->port == '') ? '' : " port=".$this->port;
-               return @pg_pconnect("host=".$this->hostname.$port." dbname=".$this->database." user=".$this->username." password=".$this->password);
+               $username = ($this->username == '') ? '' : " user=".$this->username;
+               $password = ($this->password == '') ? '' : " password=".$this->password;
+               return @pg_pconnect($database.$hostname.$port.$username.$password);

        // --------------------------------------------------------------------
@@ -482,4 +490,4 @@


\ No newline at end of file

  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2017 MyBB Group.