Code Igniter - Get Last URI Segment

I'm tying to get the last URI segment in CI, however I don't know what the number for it will be, as parameters (an integer) will be appended as the user clicks links within the page. These are then used in a controller to pull relevant database records into the page via ajax.

How can I tell CI to get the last segment?

Something like:

$record_num = $this->uri->segment($last);



ADVERTISEMENT

Strip Tags That's Are NOT In [code] [/code] Segment?

I'm trying to find a way to strip tags from a user-inputted string except from tags that are wrapped in the [code] [/code] BB style tag.

For example, a user may enter this:

<script>alert("hacked");</script>
[code]<script>alert("hello");</script>[/code]

What I would like is the "hacked" alert to be removed, but not the "Hello" alert.

I would like to remove ALL tags (php, html, css, js) outside of the [code] but allow anything within them.

So far, I've got the following code to do the reverse of what I would like:

preg_replace('/[code](.*?)[/code]/ise','strip_tags('$1')',$code)

View 4 Replies View Related

Javascript - Beginner - Pass Variable From One Code Segment To Another ?

I have index.php which uploads a file to server and sets several PHP variables (like $target_folder_and_file_name).

index.php also has the following line (it was originally index.html):

<script language="JavaScript" src="main.js.php"></script>

After index.php returned to the browser, the browsers asks for main.js.php from the server (right?).

Can I access somehow $target_folder_and_file_name from the PHP code in main.js.php ?

View 3 Replies View Related

Execute Code Segment Only If Loop Reaches Its Last Cycle

Where is the most efficient position for a code block, which shall only execute, if a loop has reached its end, without having previously been aborted (via break or return)? Provided: "Some Code X" is always the same, only at different Code Segment Positions 1 and 2. I assume: 2 will be executed with the same reliability as 1. Am I wrong I know: 2 is obviously more efficient, as it is only called once after the loop ran $limit times, compared to 1, whose enclosing if-condition is called $limit times, and if once true, the code itself is called. Thus the efficiency difference is if-condition queried $limit times. Hence I conclude: To prefer using Code Segment 2 rather than Code Segment 1, unless my assumption is wrong!

[CODE....]

View 3 Replies View Related

Code Igniter Form_input?

A couple questions here..What is the following syntax? What do all the pieces mean?

(( ! is_array($data)) ? $data : '')

How is it used in the function at the end?

function form_input($data = '', $value = '', $extra = '')
{
$defaults = array('type' => 'text', 'name' => (( ! is_array($data)) ? $data : ''), 'value' => $value);
return "<input "._parse_form_attributes($data, $defaults).$extra." />";
}

View 4 Replies View Related

Implement RSS 2 In Code Igniter?

How can I implement RSS 2 in Code Igniter?

View 1 Replies View Related

Using Lightbox With Code Igniter?

I'm trying to use Lightbox with my CodeIgniter application. Lightbox says to put the following in the head tag:

<script type="text/javascript" src="js/prototype.js"></script>
<script type="text/javascript" src="js/scriptaculous.js?load=effects,builder"></script>
<script type="text/javascript" src="js/lightbox.js"></script>
<link rel="stylesheet" href="css/lightbox.css" type="text/css" media="screen" />

[Code].....

This displays the thumbnail version, and then when clicked I want it to go to the lightbox, but now it goes to a new tab with the large image.

I've used lightbox before and have always gotten it to work, I'm not really sure what the problem is now, and I tried moving the files all around to different spots but nothing worked.

View 1 Replies View Related

Code Igniter :: Use Get Values In CI?

In my projects i often use get params as a temporary way to test things with different values.However it seems like you cannot access get params in code igniter?I am aware I could build a param into my functions and pass the value as a url segment.But i dont want to be doing that every time I wish to test something.So,is there any way to use get values in CI?

View 2 Replies View Related

Obfuscator For Use With Code Igniter Code?

I am looking for an obfucator for my PHP code, the code which I am trying to obfucate uses the codeigniter framework. The obfuscators that I have tried, don't seem to be able to do it.

View 4 Replies View Related

Serving Different Views In Code Igniter

Is there best practice for serving different view for different context.For example, I'd like to serve specific pages for mobile user agents with the same controllers.

View 1 Replies View Related

Deploying Code Igniter 1.7.2 Application On IIS 7?

I developed a Codeigniter 1.7.2 on wamp and it's almost completed. Now i am trying to host it on IIS 7 (yes IIS! because the control panel that is offered to me only has IIS in it) i am getting errors. This is what i get

[Code]....

View 1 Replies View Related

Use A Code Igniter Class In Wordpress?

The class I wish to use is: url. How can I use this in a Wordpress project? Do I just take out the code igniter specific snippets out?

View 2 Replies View Related

Code Igniter Function Call 404?

I was going through the official Code Igniter tutorial when I hit a snag...The tutorial had me save and run this code:

<?php
class Blog extends Controller {
function index()

[code]...

View 5 Replies View Related

Tell Code Igniter To Ignore / Lib / Css Path?

How can I tell CodeIgniter to ignore the /lib/css folder and load my stylesheets instead of trying to load things via my controller?

View 2 Replies View Related

CakePHP To Code Igniter Conversion?

I want to convert an application from CakePHP to Code Igniter. Has anyone tried to do this? With my CakePHP application almost all the coding has been done in the controller layer, with the models pretty much exactly as they come out of baking.

View 1 Replies View Related

Code Igniter Captcha Not Working?

code igniter captcha is not working in my page.My php gd library enabled but no change result.

View 3 Replies View Related

Setting Up Emails In Code Igniter 2.02

I'm getting a lot of errors. And I've tried several suggestion across different sites, deleted the parent function, removed the array, updated my php ini file, no luck. This is the first of 13 errors I'm getting. A PHP Error was encountered Severity: Warning Message: fsockopen() [function.fsockopen]: unable to connect to [URL] (Unable to find the socket transport sslā did you forget to enable it when you configured PHP?) Filename: libraries/Email.php Line Number: 1673

class Email extends CI_Controller
{
function index()
{
$config['protocol'] = 'smtp';
$config['smtp_host'] = 'ssl://smtp.googlemail.com';
$config['smtp_port'] = 465;
$config['smtp_user'] = 'myemail@gmail.com';
[Code]....

View 1 Replies View Related

Jumping Controllers In Code Igniter

I am wanting to have a form of dynamic routing.

Basically I want to catch the 404 (done through routes.php 404_override).

This is easy enough.

But then what I want to do is run through a series of checks.

e.g pay no attention to the fact the is_xxx functions are not coming from anywhere

$what = $this->uri->segment(1);
if(is_vanity_name($what)){
//now I want to route this to the profile controller and call the display function like so
//display('vanity', $what);
}

[Code]....

How would I go about re-routing to the other controllers once the decision has been made?

View 1 Replies View Related

Insert AT&T It Will Add Semicolon In Code Igniter?

Whenever I was inserting AT&T to database it was added as AT&T; semicolon is added extra in code igniter.My code is like this:

$this->input->post('carrier_name');
$this->db->insert('cs_carrier',$insert);

View 2 Replies View Related

Logout Feature In Code Igniter?

I started using codeigniter for my project. I have user authentication system for my website. I have seen the videos from nettuts for the login information. I am confused why the logout is not working properly. I have the following logout function in my login controller.

function logout() {
$this->session->sess_destroy();
redirect('main');
}

If I click on the logout button I am redirecting the user to the main page. But after redirecting the user to the main page, if click on the back button on the browser I will see the logoff and my name on the top of the page. I need some help on where I am going wrong or is there any important piece of code I am missing in my controller I think I found the solution. I should append the following code into the appropriate controller

$this->output->set_header("Cache-Control: no-store, no-cache, must-revalidate, no-transform, max-age=0, post-check=0, pre-check=0");
$this->output->set_header("Pragma: no-cache");

View 1 Replies View Related

Make A Breadcrumb With Code Igniter ?

best way to make a breadcrumb with Code Igniter.1 : Retrieve the strings with URLexample : this->uri->segment(2) 2 : Do you know another way ?I'd really like to have your opinion

View 1 Replies View Related

Set_value() Default In Code Igniter?

I've used formigniter to generate a form forThat bit works great. However I want to set a default value for the name field.The input code looks like this:

<label for="forename">Forename</label>
<?php echo form_error('forename'); ?>
<br /><input id="forename" type="text" name="forename" maxlength="255" value="<?php echo set_value('forename'); ?>" />

View 1 Replies View Related

Code Igniter Controller/Model Name Conflicts?

I have a controller and model both named "account" without getting "cannot redeclare class". I'd like to add a prefix to Models or Controllers, or preferably both.

View 2 Replies View Related

Code Igniter - Use Only Shopping Cart Class?

A client of mine has a big php website, and wants to add shopping cart functionality. Is it possible to use Code Igniter's shopping cart class, without writing the whole site in the Code Igniter framework? How?

View 3 Replies View Related

Routes - Moving First Steps With Code Igniter

I just moving my first steps with Code Igniter

I have a application/controller/login.php file containing the following

[Code...........]

My routes definition looks like the following:

$route['default_controller'] = "welcome";
$route['login'] = 'login';
$route['scaffolding_trigger'] = "";

The problem is that i keep getting a 404 when i try to access [URL]. What did i do wrong? I've checked CI routes docs and cannot spot anything.

View 2 Replies View Related

Code Igniter With Flex Is It Good Combination?

im looking forward flex php developers about their works with CI and flex combination.did you guys feels good and keep things innovativeand im just looking for working samples you have or you came across

View 2 Replies View Related

Redirect With Code Igniter Doesn't Work

i'm trying to redirect to the index method of my main controller like so:

if($provider == '') {
redirect('/index/provider1/', 'location');
}

but that takes me [URL] when it should go to [URL]. does that make sense can anyone give any advice? this is what my htaccess looks like and i have index_page in config set to blank, although i don't think that the issue is htaccess here it is in case:

[Code........]

View 2 Replies View Related

Code Igniter [did Not Found Page Created]

My first page is leave_app.php. In this page I put a link to apply leave, using the normal code:
<a href="add.php">New Leave Application</a>

However the link didn't display as I had wished for.

"The requested URL /ci/add.php was not found on this server." and the link in the browser leads to this "url".

I don't know why the server didn't find the page. I already made add.php page, also add at the leave_app controller the function add().

In the config.php file I put $config['index_page'] = '';

I have asked around but no one can help. I have already surfed around, but still don't know how to solve.

View 1 Replies View Related

Having Code Igniter URI Segments For Multiple Variables?

I'm writing an app that allows you to filter database results based on Location and Category. If someone was to search for Liverpool under the Golf category the URI would be /index.php/search/Liverpool/Golf. Should someone want to search by Location but not category, they would be sent to /index.php/search/Liverpool However, should someone want to filter only by category they would be unable to use /index.php/search/Golf because that would be caught by the location search.

Is there a best practice way to have /index.php/search/Golf be recognised? Some best practice as to what else to add to the URI to make these two queries distinct? /index.php/search/category/Golf perhaps? Though that is beginning to show characteristics of /index.php?search&category=Golf which is exactly what I'm trying to avoid.

View 4 Replies View Related

Code Igniter Overriden DB Active Record?

I want to override the Active Record class (some functions of it at least). And I made a file called spj_DB_active_rec.php in a folder named "database" in my "application" folder but it does not work.class name is spj_DB_active_record

<?php
class spj_DB_active_record extends CI_DB_active_record {
[code]....

View 1 Replies View Related

Load Code Igniter In An External File?

I have a problem with a flash call and I need to debug, before messing with the code I was wondering if it's possible to load the whole CI environment inside a xxx.php file.

Basically I would need to do this:

$CI->controller->method();

and only that, nothing should be loaded automagically, the thing is that once loaded the controller should be able to "see" all the models, libraries and config files.

Basically what I want is to be able to call CI forcing to load a specific controller->method.

EDIT:

I have been able to achieve this. If anybody stumbles upon this question and needs to do this, here is the file: [URL]

View 2 Replies View Related

Add Dynamic Content To A Template In Code Igniter?

I am trying a HTML/CSS file to convert to a template. I asked for help but I didn't receive any suggestions in that post yet I tried to figure out a way to create a template. I am having few glitches in doing that. My controller has main.php file which is the main page of the website, and I have register where the header, footer, and rest remain same except that main content changes when the page loads.

I have the following template in the views folder:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">[code].....

This is the div tag which would be changing when a site loads. In my template I have included <

<?= $flashcontent ?> <?= $resource ?> and <?= registerForm ?>

The flashcontent and resources are supposed to be in the main page and registerForm is supposed to be shown when I click on register in the main page. I have been reading the template user guide in the code igniter but I am unable to understand how to make this dynamic.This is the template.php in config folder.

$template['active_group'] = 'default';
$template['default']['template'] = 'template.php';
$template['default']['regions'] = array([code]....

View 3 Replies View Related

Can't Use Xdebug To Debug Code Igniter App Using Netbeans 6.8 IDE

I can't use Xdebug to debug a application built with Code Igniter, but i can use it to debug any other PHP file as long it doesn't use the same Structure for url solving that Code Igniter uses.

Meaning: In a simple PHP file with no Code Igniter, when i use NetBeans debugging the browser goes to: http://localhost:86/index.php?XDEBUG_SESSION_START=netbeans-xdebug

Since no Code Igniter or other framework as been used, NetBeans can actually debug the PHP.

But when using Code Igniter when hit the debug button in NetBeans, and the browser goes to:

http://localhost:86/index.php?XDEBUG_SESSION_START=netbeans-xdebug

the root index.php where all happens in Code Igniter no luck, instead i get the standard CodeIgniter "404 Page not Found".

My guess its that due to the structure Segments that Code Igniter uses for url solving, xdebug can't debug nothing.

Example: [URL]

How can i make xdebug work with Code Igniter?

View 3 Replies View Related

Extend The Code Igniter Controller Class?

In my CI systemlibraries directory I have a new class named DD_Controller.php. This file looks like this:

<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class DD_Controller extends Controller
{
protected $ddauthentication;
function __construct()
{
parent::Controller();
[Code].....

The Inquiry class works fine when I extend Controller, but I get a Fatal error: Class 'DD_Controller' not found in C:developmentlocalhostapplicationsinquirycontrollersinquiry.php on line 4 When I extend DD_Controller. In the config file I have the prefix defined as such: $config['subclass_prefix'] = 'DD_';

View 2 Replies View Related

Codeigniter - Code Igniter - Unserialize An Array?

I have previously serialized an array in PHP and submitted it to a database. Now, in my model in Code Igniter, I want to unserialize that data but I'm not sure how to reference it. Here's my code:

function get_selected_member($member = null){
if($member != NULL){
$this->db->where('id', $member); //conditions
}
$query = $this->db->get('members'); //db name
if($query->result()){
$member_result = $query->row();

[Code]...

So member_result is an object containing all of values for the table row matching the member a user selected from a form. Within this object, one of the column values is member_dep - but referencing it as $member_result[$member_result->member_dep] does not work. How do I refer to this. I basically want to pull that value out, declare it as a variable, call unserialize(), and then put it back into place so that it can be read by JQuery / HTML as an array.

View 1 Replies View Related

Call A Function In Another Controller In Code Igniter?

I want to call a function in another controller. for example if user try to log in with incorrect parameter then the application will redirect to another controller and passing a variable (array).

class User extends Controller {
function User()
[code]....

View 2 Replies View Related

Zend Framework To Use BaseUrl As Used In Code Igniter?

In Zend Framework, baseUrl adds path as '/user/local/path_tyo_file'. Is there any function which adds path like '[URL]........ , as base_url in code igniter does?

View 2 Replies View Related

Code Igniter Queries: How To Build The Query?

I am attempting to build a query using code igniter's active records class that looks like this:

SELECT * from contacts where account = 1 and (fname like 'k%' or lname like 'k%')

however I am not sure how to use the functions to do this.

View 3 Replies View Related

Simple Code Igniter Sidebar Implementation?

I posted a thread a few days back but it didnā take the direction I was looking for, so I will try again and fingers cross explain a little better.I have a list of controllers.. Home, League, Forum as so on. Once the controller has its data it calls down to a view named template which in turn calls the default header, footer, content and sidebar views. (The content variable is set by the controller).So far so good, this works great until I realise the need the sidebar data to be dynamic instead of its current static state.. Now as the site grows larger I would prefer not to have to specify the data that gets called for the sidebar each time.I would prefer to set a variable in the controller that loads possibly, I see this being done in the template view, however I know controllers can not be called in view, so I am stuck.

View 1 Replies View Related

Create Token For Each Record Using Code Igniter And Doctrine ORM?

I have a model setup using Doctrine. I would like to generate a token for each record, so I think I need to overload Doctrine's save() function with something like this that I found using Symfony:

[Code...]

View 2 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved