Welcome Guest, Not a member yet? Register   Sign In
  Annoying codependant library problem
Posted by: El Forum - 04-02-2008, 10:07 PM - Replies (9)

[eluser]kirilisa[/eluser]
Hi folks,

I just have a quick question on the viability of codependent libraries. Let's say I have two libraries that I am autoloading: session and auth. No matter what I do, I will never be able to access them each from each other, no?

e.g. if I wrote

Code:
//session.php
$this->ci =&get;_instance();
$this->ci->load->library('auth');

AND

//auth.php
$this->ci =&get;_instance();
$this->ci->load->library('session');

it clearly doesn't make sense as that basically represents an infinite loop of the libraries' loading each other. The CI result is that it doesn't break, but the second library (auth) never gets session loaded. i.e. I can set up one of them to access the other one, but not set it up so that they can access each other.

I'm sure you wonder why I'm asking this so I will tell you. My auth class necessarily uses the session a few times (for access checking, to get a stored userId to look up page access from the DB, etc., and to point to sess_destroy from its logout method) - I don't really see any way around this. The reason I was thinking of making session access auth was for use of a particular method - $auth->log_logout(), where I was trying to log a user's logout date/time even if his logout was indirect in that it resulted from a session expiration. I can of course just write a second log_logout method within session.php but it will be redundant.

However, given that I am trying to log peoples' logouts whether via clicking 'logout' or due to session expiration, I can't think of any really clean way to do it.

Anyway else ever tried to implement something of this sort?

Thanks!


  Need Help about Lang Select
Posted by: El Forum - 04-02-2008, 09:32 PM - Replies (1)

[eluser]Đỗ Thanh Tùng[/eluser]

Code:
A PHP Error was encountered
Severity: Warning

Message: array_key_exists() [function.array-key-exists]: The first argument should be either a string or an integer

Filename: libraries/Lang_detect.php

Line Number: 193
My Website work perfect on http://localhost but when i change to http://192.168.10.5 (my Ip Address on LAN) and i got that Warning. What can i do to fix it. Thanks very much.


  How I get return number from query COUNT(*)?
Posted by: El Forum - 04-02-2008, 07:59 PM - Replies (4)

[eluser]Rubiz'[/eluser]
Hi there!!

How can I get a query result from COUNT(*)?
My print_r() returns:

Code:
Array ( [0] => stdClass Object ( [COUNT(*)] => 5 ) )

But I tried to get it like $var[0]->COUNT(*), but I knew it would be wrong, and I dont know how to proceed... I know its a basic thing but I dont know it :red:

If someone can help me, thanxs!!


  My first completed CodeIgniter web application - listing service for real estate investors
Posted by: El Forum - 04-02-2008, 06:42 PM - Replies (10)

[eluser]taewoo[/eluser]
Hi everyone.

Finally, after days and months of hard work... here it is:

http://www.RedMol.com/

Just wanted to thank everyone in the CI community. You guys were a tremendous help. All the way from setting up to figuring out some complicated stuff.... Thanks. The job isn't complete but it's good enough to launch for now. (i.e. there will be much more questions I will be posting ... hehe)

Special shoutout to CI team as well as the FreakAuth team. You guys write freakin' awesome code.

PS: If you need a Zillow map on your real estate focus site, check out this little widget - http://www.RedMol.com/developer/


  Problem Uploading & Resizing Square Images
Posted by: El Forum - 04-02-2008, 06:30 PM - Replies (7)

[eluser]BrandonDurham[/eluser]
I'm not sure why it's happening, but uploading square images breaks the following function. If they're tall or wide, it works fine. Any idea why? I appreciate any help I can get.

Code:
class Functions
{

    function uploadHeaderImage($directory) {
        $CI =& get_instance();

        // Upload image
        $config['upload_path'] = $CI->config->item('live_server_path') . 'mbg/images/' . $directory . '/originals/';
        $config['allowed_types'] = 'jpg';
        $config['max_size']    = '6000';
        $CI->load->library('upload', $config);

        if (!$CI->upload->do_upload("cover"))
        {
            echo "Original: ".$CI->upload->display_errors();
            return false;
        }

        // Create various images sizes
        $CI->load->library('image_lib');
        $data = $CI->upload->data();
        $image_path = $data['full_path'];
        $extension = $data['file_ext'];

        $config['image_library'] = 'GD2';
        $config['source_image'] = $image_path;
        $config['maintain_ratio'] = TRUE;

        // Resize image
        $config['new_image'] = $CI->config->item('live_server_path') . 'mbg/images/' . $directory . '/' . $data['raw_name'] . $extension;
        $config['width'] = 590;
        $config['height'] = 2000;
        $CI->image_lib->initialize($config);

        if (!$CI->image_lib->resize()) {
            echo $CI->image_lib->display_errors();
            return false;
        }

        // Crop and make thumb
        $img_width = $data['image_width'];
        $img_height = $data['image_height'];
        $crop_ratio = ($img_width >= $img_height) ? $img_height/150 : $img_width/130;
        $config['new_image'] = $CI->config->item('live_server_path') . 'mbg/images/' . $directory . '/email/' . $data['raw_name'] . $extension;
        $config['width'] = 130 * $crop_ratio;
        $config['height'] = 150 * $crop_ratio;
        $config['x_axis'] = ($img_width - $config['width'])/2;
        $config['y_axis'] = ($img_height - $config['height'])/2;
        $config['maintain_ratio'] = FALSE;
        $CI->image_lib->initialize($config);
        if (!$CI->image_lib->crop()) {
            echo $CI->image_lib->display_errors();
            return false;
        }

        $CI->image_lib->clear();
        $config['image_library'] = 'GD2';
        $config['source_image'] = $CI->config->item('live_server_path') . 'mbg/images/' . $directory . '/email/' . $data['raw_name'] . $extension;
        $config['width'] = 130;
        $config['height'] = 150;
        $CI->image_lib->initialize($config);
        if (!$CI->image_lib->resize()) {
            echo $CI->image_lib->display_errors();
            return false;
        }

        return $data['raw_name'] . $extension;
    }

}


  MIME and CI
Posted by: El Forum - 04-02-2008, 03:09 PM - No Replies

[eluser]new_igniter[/eluser]
Hello,
I am working towards replicating some functionality in Yahoo groups where basically a member of a group on our site can send an email to a group alias email and have it post to the group, validated by the email it is coming from. Has anyone done something like this in the pas they can share?


  proper use of two conditions in using sessions?
Posted by: El Forum - 04-02-2008, 02:48 PM - Replies (2)

[eluser]new_igniter[/eluser]
Hello,
Can anyone tell me the right syntax for using two conditions (in an if statement) while using CI sessions?

I tried:

if ($this->session->userdata('stat') != "OK" && $this->session->userdata('name') != "fred")
{
do something
}

this doesnt work and throws errors. My apologies in advance for being dumb.


  Validation and GET values
Posted by: El Forum - 04-02-2008, 01:56 PM - Replies (6)

[eluser]Zarate[/eluser]
Hi there,

I'm looking at the validation class and it seems it only works with POST data, is this true? I've looking through the docs, the forum and the actual code and i haven't found a way of using the validation class with GET params.

Am i missing something?

What i want to do is validate the data coming in the URL. For example:

wadus.com/products/123

I want to check out 123 is a number, no longer than 8 characters, no SQL injection, bla, bla, bla. Can't i do that?

Right now i'm just thinking about copying the GET array to the POST array and run the validation class... but i'd want to do it "right".

Thanks!


  validation functions from helpers
Posted by: El Forum - 04-02-2008, 12:21 PM - Replies (2)

[eluser]Unknown[/eluser]
How can I make functions loaded from helpers visible for validation rules?

Example:
function validate_url() loaded from helper...
so, $rules['siteurl'] = "callback_validate_url"; don't work.
It's work only if I declared validate_url inside current controller


  NULL as string in WAMP vs LAMP/MAMP
Posted by: El Forum - 04-02-2008, 12:16 PM - Replies (1)

[eluser]andjules[/eluser]
Something tells me this hasn't anything to do with CI, but I'm hoping one of you smart folks could help.

I've got a CI app with a search function that returns records from a MySQL database.
In my view, I loop through the rows and output conditionally like this:

Code:
if ($myfield) echo $myfield
works fine on my dev machine (MAMP/OS X) and my shared hosting server (LAMP).

However, I've ported over to a WAMP stack (actually server2go), and now my view is showing NULL everywhere when a field is empty. null values have become strings of "NULL".

I can painfully work around it by rewriting the view to test for "NULL", but does anyone have an idea why it's happening or if there is a config somewhere to control this?

thanks


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

Username
  

Password
  





Latest Threads
Limiting Stack Trace Erro...
by byrallier
3 hours ago
Bug with sessions CI 4.5....
by ALTITUDE_DEV
4 hours ago
codeigniter 3.0.1 equiped...
by JustJohnQ
8 hours ago
Display a custom error if...
by b126
11 hours ago
Type error in SYSTEMPATH\...
by DXArc
11 hours ago
v4.5.1 Bug Fix Released
by LP_bnss
Today, 04:52 AM
Retaining search variable...
by Bosborne
Today, 03:20 AM
Getting supportedLocales ...
by InsiteFX
Today, 12:24 AM
composer didn't update to...
by Sarog
Yesterday, 03:56 PM
Pipe on url modified in %
by kenjis
Yesterday, 02:52 PM

Forum Statistics
» Members: 85,078
» Latest member: apkmixi
» Forum threads: 77,572
» Forum posts: 375,955

Full Statistics

Search Forums

(Advanced Search)


Theme © iAndrew 2016 - Forum software by © MyBB