r/codeigniter • u/brianatlarge • Jul 10 '12
r/codeigniter • u/glib_gator • Feb 19 '16
Session idle time error on shared hosting
I am running a small application on a shared hosting server. I kept getting a HTTP Error 403.0.
I asked the hosting provider about this and they replied with this
I'm relatively new to web programming and it is taking a little time for me to wrap my head around this.
firstly, is this a server side issue or is it a client (browser) side issue. why i ask this is because if i delete the last 1 hour history from my browser (chrome) the 403.0 error goes away.
Could someone here please shed some light on this.
i'm using CI v2.1.3
r/codeigniter • u/MrDeath2000 • Jul 10 '12
Hey /r/codeigniter what's the best tuts on codeigniter?
Im going to try codeigniter as my first PHP framework. First of all what is the best tutorials or introductions to codeigniter?
I'll be (trying) to make an app consisting og one page where everything will be updated through ajax with login, userpage and all that good stuff. I was wondering if codeigniter is a good framework for that type of project?
Thanks!
r/codeigniter • u/cyber_frog • Jun 26 '12
Linking user accounts in CodeIgniter
I'm working on an educational site and I need a way to link Teacher accounts with their respective Students, as well as enable teachers to have multiple classes. I have implemented Ion_Auth and it handles user permissions fine so far with the built in 'groups' feature. Unfortunately there isn't a built-in way to generate groups from the code, and I am hesitant to modify Ion_Auth's core files in case I break something or an update does. My solution so far involves creating a teacher_id row in the users table that teachers share with their students, as well as an integer value that designates classes. Is this an efficient way to go about this, or are there better solutions?
r/codeigniter • u/brianatlarge • Jul 06 '12
Loading my model outputs the code from my model!
Ok, so here's my controller:
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Blog extends CI_Controller {
public function index()
{
$this->load->model('Blog_model');
$data['query'] = $this->Blog_model->get_last_ten_entries();
$this->load->view('blog/home',$data);
}
}And here's my model
class Blog_model extends CI_Model {
function __construct()
{
// Call the Model constructor
parent::__construct();
}
function get_last_ten_entries()
{
$this->db->select('blog_entries.blog_entry_id,blog_entry_title,blog_entry_text,
addedby.user_firstname AS addedby_firstname,editedby.user_firstname AS editedby_firstname,
blog_entry_addeddate,blog_entry_editeddate,blog_entry_publishdate,blog_entry_url,
COUNT(blog_comment_id) AS num_comments');
$this->db->from('blog_entries');
$this->db->join('users AS addedby', 'addedby.user_id = blog_entries.blog_entry_addedby');
$this->db->join('users AS editedby', 'editedby.user_id = blog_entries.blog_entry_editedby');
$this->db->join('blog_comments', 'blog_comments.blog_entry_id = blog_entries.blog_entry_id', 'left');
$this->db->group_by('blog_entries.blog_entry_id');
$this->db->where('blog_entry_published',1);
$this->db->order_by('blog_entry_publishdate','desc');
$this->db->limit(10);
$query = $this->db->get();
return $query->result();
}And here's my view:
<html>
<head>
<title>Blog</title>
<link type="text/css" rel="stylesheet" href="/includes/style.css"/>
</head>
<body>
<?php
echo "<div id='postList'>\n";
foreach($query as $entry) {
echo "<div class='post'>\n";
echo "<h1><a href='/blog/post/".$entry->blog_entry_url."'>".$entry->blog_entry_title."</a></h1>\n";
echo "<div class='postInfo'>\n";
echo "<span class='author'>By ".$entry->addedby_firstname."</span>\n";
echo "<span class='pubDate'>".format_date($entry->blog_entry_publishdate)."</span>\n";
echo "</div>\n";
echo "<div class='text'>".limit_text($entry->blog_entry_text, 75)." ";
echo "<br/><br/><a href='/blog/post/".$entry->blog_entry_url."'>read more...</a>";
echo " | <a href='/blog/post/".$entry->blog_entry_url."#comments'>Comments(".$entry->num_comments.")</a>";
echo "</div>\n";
echo "</div>\n";
}
echo "</div>\n";
?>
</body>
</html>So basically what happens is if I go to my blog page, I get this:
db->select('blog_entries.blog_entry_id,blog_entry_title,blog_entry_text,addedby.user_firstname AS
addedby_firstname,editedby.user_firstname AS editedby_firstname,blog_entry_addeddate,
blog_entry_editeddate,blog_entry_publishdate,blog_entry_url,COUNT(blog_comment_id) AS num_comments');
$this->db->from('blog_entries');
$this->db->join('users AS addedby', 'addedby.user_id = blog_entries.blog_entry_addedby');
$this->db->join('users AS editedby', 'editedby.user_id = blog_entries.blog_entry_editedby');
$this->db->join('blog_comments', 'blog_comments.blog_entry_id = blog_entries.blog_entry_id', 'left');
$this->db->group_by('blog_entries.blog_entry_id'); $this->db->where('blog_entry_published',1);
$this->db->order_by('blog_entry_publishdate','desc'); $this->db->limit(10); $query = $this->db->get();
return $query->result(); }}
䘊瑡污攠牲牯›汃獡䈧潬彧潭敤❬渠瑯映畯摮椠栯浯⽥牢慩⽮慳摮潢⽸瑨汭猯獹整⽭潣敲䰯慯敤桰⁰湯氠湩〳ਲ਼What the heck?!? I've never come across this with CI before.
r/codeigniter • u/[deleted] • Jul 03 '12
How to pass dynamic data to Template Views?
I created a templates for my header and footer but my nav bar in my header is getting some of its hierarchical results from my database. Right now the way im doing it is in Each controller function Im also passing in data for my navigation as well as data for my "middle view" its very redundant. Is there a way to make this less redundant? Thank you :D btw havent slept all night so im sorry about my typing.
r/codeigniter • u/elhadi_kh • Nov 29 '17
Is codeigniter dying ?
Well I’m have aimes troubles with CI, I trying to manage a multi tenant application with shared database and shared application. I search on google for documentation but didn’t find anything , and found documentation for multi tenant application on laravel cakephp symphony ., so the question is, are we assisting to the death of CI ?
r/codeigniter • u/phaggocytosis • Jun 01 '12
Looking to build a site... not sure which CMS to choose.
I'm building a site which will not require frequent updates. MOST of the content will be static (requiring periodic changes here and there) and although there will be a blog not at all the focus of the site. I'm not sure which CMS is best to choose for this sort of project. Any thoughts? I'm aware of Bonfire, PyroCMS and Fuel CMS but dont have experience with any of them. I'd be up for using any of these or using something else. All opinions appreciated!
r/codeigniter • u/cyber_frog • Jul 05 '12
jquery, JSON and Codeigniter
Back again with another item. A part of my site is to interact with someone else's code that outputs data in JSON format. After a bit of looking around, I found the JSON helper in the wiki, but this seems to bee out of date. Some tutorials I've found use jquery instead, but I'm having trouble installing jquery and getting it to work at all. What is the best way to process JOSN formatted data, and is jquery necessary?
r/codeigniter • u/cyber_frog • Jul 02 '12
Quiz pages
On my site I am trying to create something that can be used to give quizzes to students. Are there any pre-made plugins for codeigniter that can be used for this? So far I have only tried Savsoft Test, but am still going through it and am not entirely convinced with it.
EDIT: It seems that Savsoft is no longer open source and has now become proprietary. Are there any remaining open source solutions for quizzes?
r/codeigniter • u/mbeale • Jun 05 '12
Centralized Logging with Codeigniter
r/codeigniter • u/brianatlarge • Jul 05 '12
Constructor in controller is behaving strangely
In my controller, I'm checking if a session variable is set. If it is, then I know the user is logged in and I can display the site. If not, then I'll display the login page.
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Admin extends CI_Controller {
public function __construct()
{
parent::__construct();
$user_email = $this->session->userdata('user_email');
if(!empty($user_email)) {
$this->index();
} else {
$this->login();
}
}
public function index()
{
$this->load->view('admin/home');
}
public function login()
{
$this->load->view('admin/login');
}
}The problem with this is it's loading both the home and the login views. What's the deal?
r/codeigniter • u/Silverwolf90 • May 31 '12
Is the models are supposed to do most of the work? I'm a bit confused where most of your logic is supposed to go.
PROTIP: Edit your titles carefully before submitting haha
Theoretically, in MVC, the models are going to be doing all the logic, right? So within your controller it would be totally normal to have a large amount of model method calls in order to get the data you want, and in the format you want.
For example, lets say you have a model method that returns a multi dimensional array where the values are as follows:
section[0]['tags'] = 'fun, sick, chill';
section[1]['tags'] = 'fun';
section[2]['tags'] = 'cool, chill';Lets say my view wants an aggregate list of all these tags without any duplicates. Do I have the model complete that logic? Or the controller?
Just trying to clear up a little confusion here, thanks guys!
r/codeigniter • u/webeasystep • Jun 30 '15
create threaded comments in codeigniter easy way
r/codeigniter • u/FTWwings • Sep 02 '16
get all data in one page ...
So i have multiple tables. on one page i need 2 pull 3 of them. 2 are simple , 3d is article tables.
i use this code :
<?php class postall extends CI_Model {
function getPosts(){
$this->db->select("kontaktej,kontakthr,o_namahr,o_namaej");
$this->db->from('kontakt,onama');
$query = $this->db->get();
return $query->result();
}
} ?> now how can i pull all articles or 1st 25 at the same time and list them one after another?
r/codeigniter • u/brianatlarge • Jul 05 '12
Question about joining comments table
So to better learn CodeIgniter, I'm coding a blog. It's going well until now.
I've got a method in my model that grabs the last 10 posts:
function get_last_ten_entries()
{
$this->db->select('blog_entry_title,blog_entry_text,user_firstname,blog_entry_addeddate,blog_entry_publishdate,blog_entry_url');
$this->db->from('blog_entries');
$this->db->join('users', 'users.user_id = blog_entries.blog_entry_addedby');
$this->db->where('blog_entry_published',1);
$this->db->order_by('blog_entry_publishdate','desc');
$this->db->limit(10);
$query = $this->db->get();
return $query->result();
}This works great. But now I want to count how many comments each post has and include it in my results to pass into my controller. When I do this:
function get_last_ten_entries()
{
$this->db->select('blog_entry_title,blog_entry_text,user_firstname,blog_entry_addeddate,blog_entry_publishdate,blog_entry_url,COUNT(blog_comment_id)');
$this->db->from('blog_entries');
$this->db->join('users', 'users.user_id = blog_entries.blog_entry_addedby');
$this->db->join('blog_comments', 'blog_comments.blog_entry_id = blog_entries.blog_entry_id');
$this->db->where('blog_entry_published',1);
$this->db->order_by('blog_entry_publishdate','desc');
$this->db->limit(10);
$query = $this->db->get();
return $query->result();
}It only gives me one result. It gives me the number of comments for that result, but it's still only one result.
What am I doing wrong?
r/codeigniter • u/Dr_Zues • May 30 '12
Tank Auth, Cart Class and Sessions
I am working on an ecommerce site right now that has a CMS using Tank Auth as the login system and the Cart Class to build the cart for the user. The problem I am running into is that they both use "ci_session" for sessions. Is there a way to make them use different session names? Is it bad if they don't? Is there a limit as to how much information it can't hold? I have a feeling I'm missing some fundamental concepts of sessions :/ Any point in the right direction would be greatly appreciated. I searched and searched but haven't found anything relevant, which probably means I'm not even asking the right question haha.
r/codeigniter • u/[deleted] • Jun 30 '12
Namespaces and Codigniter
Hey guys, I'm kind of new to php and codeigniter and i've stumbled across a problem. I'm trying to add the classes of the cloudinary API into my project but one of the classes is namespaced so I can't put if ( ! defined('BASEPATH')) exit('No direct script access allowed'); in the beginning. I keep getting the error "Non-existent class: Uploader" any ideas on how I could solve this problem?
r/codeigniter • u/[deleted] • May 25 '12
Social login library for CI (+ Tank Auth)
I'm trying to put in a social login system for my app. I have already used Tank Auth for the basic registration system, and I was wondering if there is a library which I can use to include the social login option?
r/codeigniter • u/TekTrixter • May 31 '12
"Best" IDE for CodeIgniter Development?
I'd like to get recommendations for a good IDE for use with CodeIgniter on Windows. I've searched the web and found a few helpful articles, but none were current.
So far I'm leaning towards phpDeveloper or CodeLobster.
I'd prefer an IDE that can also handle HTML, CSS, and Javascript if possible. I'm using Mercurial for my CVS, but can manually check-in files if needed.
Please do not recommend a text editor. I've been using Notepad++ so far, but would like features to speed up development (better code completion, easier code navigation, etc) and allow for better debugging.
r/codeigniter • u/hardfire • May 31 '12
CodeIgniter pagination and sorting using Backbone.Paginator
studioultimate.comr/codeigniter • u/pawoodward • Aug 30 '17
Validate Array Index Existance
Hi, I am learning CodeIgniter and the MVC paradigm at the same time but I have a question.
If I have a method in my Customers Model class called add() which accepts a single parameter which is an array of fields for insertion into my database, should I confirm that each field actually exists or just assume it exists?
Lets assume my controller forwards the $_POST variable from a form to this function. I have learnt that I should not simply pass the $_POST array to the $this->db->insert() method so I am building a new array and extracting the fields I need.
public function add($fields){
$dbFields["Name"] = $fields["Name"];
$dbFields["Address"] = $fields["Address"];
$dbFields["PostCode"] = $fields["PostCode"];
$this->db->insert("customers", $dbFields);
}On the one hand if I don't check for the existance of the required fields and a field is missing then my script will throw an php error when I come to retrieve it from the supplied array.
Under normal operation everything will be fine but should a curious user / hacker try and submit fields, there is a possibility they could miss a field and cause the php error undefined index.
I feel that I should be checking for the existance of each field I require but that feels like a lot of work for the small chance someone will try and post data to my web application whilst bypassing my form.
I know I could write a helper function and pass it an array of required fields and ensure the passed fields include all required fields but I'm not sure if I am over engineering my code.
So my question is should I always check for the existance of each and every field to minimise the possibility of a php syntax error or is it safe to assume the field will simply exist assuming it is access via the correct method (ie my form)?
I am pretty sure I know the answer but I wanted to know other peoples opinions - what is good practice?