Welcome Guest, Not a member yet? Register   Sign In
  Site Name Function
Posted by: El Forum - 10-24-2007, 11:12 PM - Replies (1)

[eluser]lszanto[/eluser]
I know this is a simple function but I just thought it could be useful for people to have a global site name e.g My Site and just to add on a string e.g - Home so when calling the function site_name() you can retrieve My Site - Home. The code to add this is below and the url helper is required.

Insert Into /system/applaction/config/config.php

Code:
/*
|--------------------------------------------------------------------------
| Site Name
|--------------------------------------------------------------------------
|
| The full name of your website to implement in your pages.
|
|    My Site
|
*/
$config['site_name'] = "My Site";

Obviously replace the site name with your own site name.

And Insert this into /system/helpers/url_helper.php
Code:
// ------------------------------------------------------------------------

/**
* Site Name
*
* Returns the "site_name" item from your config file
*
* @access    public
* @return    string
*/    
function site_name()
{
    $CI =& get_instance();
    return $CI->config->item('site_name');
}


Hopefully this has helped and is useful to you if not sorry for wasting your time Smile


  Need some advice to start building a new project
Posted by: El Forum - 10-24-2007, 10:28 PM - Replies (5)

[eluser]iive[/eluser]
Hi, I am new to CI and MVC concept. Previously, I was building my own PHP classes to handle all the coding in PHP. And currently I am going to port my previous application into CI.

But I have some queries in my mind currently, and I hope to get some advice from all of you here. I have read through the user manual and get the basic understanding on MVC.

My application is a Flash gaming portal and the homepage will have some general information and a panel that show up all the current games available.

I wonder how would my pages structure are in this homepage?

Obviously I need a HomeController, and I need to call a GameController somewhere in the function of my HomeController to pull out all the games and display them in a seperate view?

I hope I am on the right track...


  Tips for those sending double-byte emails
Posted by: El Forum - 10-24-2007, 08:36 PM - No Replies

[eluser]mipa[/eluser]
Just a tip for those wanting to send emails with double-byte character sets (eg. big5), there are two things that can screw you up:

1. CI's native Email class does a stripslashes() on the message content when preparing the mail. I would suggest extending the Email class and removing the stripslashes() call from the message() function.

2. Wordwrap - make sure you turn it off in your email configuration (it defaults to true) because it may split a double-byte character.


  xss ->EDITED: fix found, but have another question.
Posted by: El Forum - 10-24-2007, 07:55 PM - Replies (1)

[eluser]H8train[/eluser]
ok so I had this big long question about global_xss_filtering and how when i attempt to test with a simple xss:

Code:
alert('xss');

I would get this output:

Code:
Fatal error: Call to undefined function: get_instance() in /blah/blah/blah/libraries/Input.php on line 855

I wanted to get rid of this type of error reporting? so I set in the main index:
error_reporting(0);
but now I would like to redirect back to the main index after this error is generated. anyone have a quick fix?

Thanks for your replies.

Rich


  How do I make a form element required?
Posted by: El Forum - 10-24-2007, 07:47 PM - Replies (2)

[eluser]Jay Callicott[/eluser]
Is there not a way to use the validation class make form elements required? If not has anyone thought of a hack or something?


  trans_status() misdocumented
Posted by: El Forum - 10-24-2007, 07:34 PM - Replies (1)

[eluser]chriskl[/eluser]
The user guide says:

Code:
if ($this->db->trans_status() === FALSE)
{
    // generate an error... or use the log_message() function to log your error
}

However, the code for trans_status() does this:

Code:
return $this->_trans_failure;

But _trans_failure is set like this:

Code:
// Run the Query
if (FALSE === ($this->result_id = $this->simple_query($sql)))
{
    // This will trigger a rollback if transactions are being used
    $this->_trans_failure = TRUE;
}

Hence, trans_status() returns TRUE on failure, not false...


  Best strategies when storing images on fileserver
Posted by: El Forum - 10-24-2007, 02:03 PM - Replies (3)

[eluser]E1M2[/eluser]
I'm building a community site that will depend heavily on image uploads. In the beginning my thought was to store everything in one directory with a hash for the filename using SHA2 as MD5 & SHA1 have been known to have potential collisions, I don't even think they are actively used by even the gov't anymore. Anyway, my concern, I don't know when the single directory approach could become more of a hinderance than a benefit as image count piles up.

It's been asked before, 'why don't we just slap the file in a DB blob field'. Now I'm not a DBA and I have thought about that myself considering it would just be a straight shot to the DB without having to access the filesystem thereafter. But, I'm very weary if it turns out that the DB in use has to be changed to another DB down the road and I've heard horror stories of trying to move from one blob type to another. So for me I'm shooting for keeping things on the fileserver.

I've done a search through the forum as well on the interweb, here is the strategy I've decided to run with maybe someone else will find it to be of use, maybe other useful strategies will surface.


Option #1 - Month & Year
IMG_FOLDER/YYYY/MM/ID_FILENAME.EXT

While this looks like a good candidate it doesn't really spread files across the board much and still leaves room for directories to have a massive about of images something I'm trying my best to stay away from.


Option #2 - Hashed
IMG_FOLDER/a-f0-9/a-f0-9/a-f0-9/ID_FULLHASH.EXT

Use the MD5 hash of the image ID. substr() the hash as needed for the 3 sub folder names. For the filename, rename the temp file to the ID plus the full hash to thwart a collision.

Here is an example:

Code:
$id = 10;
$img_hash = md5($id);
$img_node1 = substr($img_hash, 0, 3);
$img_node2 = substr($img_hash, 3, 3);
$img_node3 = substr($img_hash, 6, 3);
        
$img_ref = IMG_DIR . $img_node1 . '/' . $img_node2 . '/' . $img_node3 . '/' .  $id . '_' . $img_hash . IMG_EXT;

// result: IMG_DIR/d3d/944/680/10_d3d9446802a44259755d38e6d163e820.JPG

Conclusion
Def going with a flavor of Option2. Not only does it spread files across directories but best of all, since we used the ID as the base for the hash there is no need to store directory meta data in the DB, we'll always know by md5($id)


  Shouldn't a custom library be logged as when its loaded ?
Posted by: El Forum - 10-24-2007, 12:59 PM - Replies (6)

[eluser]scottelundgren[/eluser]
I've written a custom library and saved it as application/libraries/LDAP.php. The library has a custom config file and it is in application/config/LDAP.php. If I have:

applicaation/config/config.php:

$config['log_threshold'] = 4;

applicaation/config/autoload.php:

$autoload['libraries'] = array('LDAP', 'database', 'session', 'validation', 'email');

when I look at my log file I have this snippet:

DEBUG - 2007-10-24 14:48:53 --> Loader Class Initialized
DEBUG - 2007-10-24 14:48:53 --> Config file loaded: config/LDAP.php
DEBUG - 2007-10-24 14:48:53 --> Helpers loaded: form, url
DEBUG - 2007-10-24 14:48:53 --> Database Driver Class Initialized
DEBUG - 2007-10-24 14:48:53 --> Session Class Initialized
DEBUG - 2007-10-24 14:48:53 --> Encrypt Class Initialized
DEBUG - 2007-10-24 14:48:53 --> Validation Class Initialized
DEBUG - 2007-10-24 14:48:53 --> Email Class Initialized
DEBUG - 2007-10-24 14:48:53 --> Controller Class Initialized

and I'm thinking shouldn't I be able to see my LDAP class loaded in my logs? I'm having some weird behaviour with my library so I'm staring my investigation wondering if the library was even loaded.


  How to add attribute like id in form_dropdown() ?
Posted by: El Forum - 10-24-2007, 12:47 PM - Replies (4)

[eluser]bijon[/eluser]
i want to create a drop_downlist like :

Quote: <select id="country">
<option value="1">Bangladesh</option>
<option value="2">India</option>
<option value="3">UAE</option>
</select>

i know that it can be done by
Quote:echo form_dropdown('country', $options_array, '1');

But it create the code like
Quote: <select name="country">
<option value="1">Bangladesh</option>
<option value="2">India</option>
<option value="3">UAE</option>
</select>

So how can id in the from_dropdown ?
Thanks
Saidur Rahman
Developer
Right Brain Solution Limited


  Preventing resize of smaller images
Posted by: El Forum - 10-24-2007, 12:28 PM - Replies (3)

[eluser]Unknown[/eluser]
Hi, I`m using Image_lib to upload resize images, but now I stopped and don`t know what to do .

I`m using these variables:

Code:
$config['width'] = 800;
$config['height'] = 800;

And the problem is, that if I try to upload an image 200x200 or other size, it will be expanded to 800px. How to allow resizing only to bigger images?

Thanks in advance Smile


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

Username
  

Password
  





Latest Threads
tool bar not showing
by Luiz Marin
2 hours ago
Tool bar not showing
by Luiz Marin
2 hours ago
curl + response body
by InsiteFX
3 hours ago
AbuseIPDB Module
by InsiteFX
4 hours ago
Heads up for users using ...
by davis.lasis
Yesterday, 12:54 PM
The Hidden Cost of “Innov...
by fcoder
Yesterday, 03:11 AM
Validation does not appea...
by grimpirate
07-01-2025, 01:55 PM
Block IP addresses of bad...
by grimpirate
07-01-2025, 01:47 PM
Override Router
by grimpirate
07-01-2025, 01:30 PM
CodeIgniter.com - Report ...
by Vikas Mehta
06-30-2025, 10:30 AM

Forum Statistics
» Members: 154,513
» Latest member: trangcacuocuytinonline
» Forum threads: 78,437
» Forum posts: 379,718

Full Statistics

Search Forums

(Advanced Search)


Theme © iAndrew 2016 - Forum software by © MyBB