Welcome Guest, Not a member yet? Register   Sign In
  bypass controller and modify headers for flv output
Posted by: El Forum - 09-29-2008, 05:54 AM - Replies (3)

[eluser]alectrash[/eluser]
I want to have on my site the url

www.mydomain.com/video/view/a-lake

which upon being requested basically does this

Code:
//query db to get filename and filesize where file id is "a-lake" (simple)

      echo 'header("Content-Type: video/x-flv")';
      echo 'header("Content-Disposition: attachment; filename="' . $filename . '")';
      echo 'header("Content-Length: "' . $filesize .')';

When this is working in another file I want to send the url to a jeroenwijering player like so:

Code:
...
  s1.addVariable("file", encodeURIComponent(http://www.mydomain.com/video/a-lake));
...

I am storing videos above root directory hence why i'm doing it this way.

I tried creating a controller video with function view which output the headers but they just came out as text. I looked at kaging but to no avail.

I tried looking at hooks but dont know if thats right place to look?


  $this->load->view from relative path.
Posted by: El Forum - 09-29-2008, 05:44 AM - Replies (4)

[eluser]Moon 111[/eluser]
Is it possible to execute $this->load->view($path) where $path is a relative path?


  uri->segment object help!!
Posted by: El Forum - 09-29-2008, 04:12 AM - Replies (9)

[eluser]miky4e[/eluser]
hello,

I have a problem with uri->segment() object in my web application.

This is my url

Code:
/index.php/account/d41d8cd98f00b204e9800998ecf8427e

Where account is class Account extends Controller and index() function get uri element... but, doesn't work!

Code:
404 Page Not Found
The page you requested was not found.

This is my error: 404 not found!?!

For simple example, this is my code:
Code:
function index()
    {
        if($this->uri->segment(2) == 'd41d8cd98f00b204e9800998ecf8427e')
        {
            echo "Ok";
        }
    }

Where is the problem???

Thanks Wink

PS. I wanna comparate session_id (in login file) with account/session_id in account class Wink


  AR library : remove cache methods?
Posted by: El Forum - 09-29-2008, 03:45 AM - Replies (2)

[eluser]xwero[/eluser]
Lately i'm beginning to wonder if there is the real benefit when using the cache methods?

A lot of people use the cache methods when they have to get two different things from the same table like the number of rows and the rows themselves but most of the times the num_rows method is sufficient.

Instead of the cache methods i'm starting to use arrays and variables for not having to redefine the sql statement parts.

Code:
$this->db->start_cache();
$this->db->from('table');
$this->db->where(array('id'=>1,'time'=>'12:00:00'));
$this->db->stop_cache();

$this->db->select('number');
$query1 = $this->db->get();

$this->db->select('name');
$query2 = $this->db->get();
$this->db->flush_cache();
// VS
$table = 'table';
$where = array('id'=>1,'time'=>'12:00:00');  

$this->db->select('number');
$this->db->from($table);
$this->db->where($where);
$query1 = $this->db->get();

$this->db->select('name');
$this->db->from($table);
$this->db->where($where);
$query2 = $this->db->get();
Normally i'm not found on copying lines but once the queries are getting more complex i noticed the cache methods are more in the way than helping to reduce the code i have to write. Not adding the flush_cache method caused me a lot of time loss. When using variables and arrays you don't have to flush the DB object values.

What is your view on the cache methods?


  Username and password authentication script
Posted by: El Forum - 09-29-2008, 02:12 AM - Replies (7)

[eluser]bhakti.thakkar[/eluser]
Dear all,
I am a new bie to CI. can some one help me with complete code of validating a username script. if username present in the DB then make entry in the LoginHistory_T table and redirect him to the main.php and if not give him a error message.

My three files (MVC) are:
mlogin.php
login_view.php
login.php

mlogin.php code:

Code:
<?php

    class Mlogin extends Model
    {

        function __Construct()
        {
            parent::Model();
        }
        
        function get_users($username)
        {
            $this->load->database();
            $this->db->select('Username_VC');
            $this->db->from('Users_T');
            $query = $this->db->get();
            return $query->row();
        }
    
        function get_last_ten_entries()
        {
            $this->load->database();
            $query = $this->db->get('Users_T');
            return $query->result();
//            print $query->num_rows();
        }
        
        function check_login_data($username, $password)
        {    

            $query = $this->db->select('Username_VC, Password_VC');
            $query = $this->db->from('Users_T');
            $query = $this->db->where('Username_VC', $username);
//            $query = $this->db->where('Password_VC', $password);
            $query = $this->db->get();
            
            if($query->num_rows() > 0)
            { return $query->result(); }
            else
            { return false;}
        }
    }


    

    function addUsersHistory(){
      $now = date("Y-m-d H:i:s");
      $data = array(
        'Username' => $this->input->xss_clean($this->input->post('username')),
        'RemoteAddr_VC' => $this->input->ip_address(),
        'LoginDate_DT' => $now
      );

      $this->db->insert('LoginHistory_t', $data);
     }


?>

code in login.php

Code:
<?php

class Login extends Controller {

    function Login()
    {
        parent::Controller();    
        $this->load->helper('url');

    }
    
    function index()
    {
        $data['base']       = $this->config->item('base_url');
        $data['css']        = $this->config->item('css');        
        
        $this->load->helper(array('form', 'url'));        // load form
        $this->load->library('validation'); // load validations
              $rules['username'] = 'trim|required|max_length[12]|xss_clean|callback__check_logindata';
              $rules['password'] = 'trim|required|md5';

            // set values for repopulating fields

            $fields['username']='Username';
            $fields['password']= 'Password ';


            $this->validation->set_fields($fields);
              $this->validation->set_rules($rules);
            
    
        if ($this->validation->run() == TRUE)
        {            
            //$this->load->view('checkuser' , $data);
            $this->load->model('Mlogin','',TRUE);
            $password = $this->validation->password;
            $username = $this->validation->username;
            if ($this->Mlogin->check_login_data($username, $password) == FALSE)
            {
                $this->validation->set_message('_check_logindata', 'Username and Password might be incorrect!');
                return FALSE;
            }


//            $this->Mlogin->addHistory();
           // redirect('welcome/thankyou','refresh');



        }
        else
        {
            $this->load->view('login_view' , $data);
        }
    }


     function _check_logindata($username)
        {
          
        $username = $this->input->post('username');
        $password = $this->input->post('password');
            
            $this->load->model('Mlogin');
            if ($this->Mlogin->check_login_data($username, $password) == FALSE)
            {
                $this->validation->set_message('_check_logindata', 'Username and Password might be incorrect!');
                return FALSE;
            }
            else
            {
                return TRUE;
            }
        }

}
?>


there is some mistake somewhere. i get the error message:
Severity: Notice

Message: Undefined property: Mlogin::$db

Filename: models/mlogin.php

Line Number: 31


my DB connection is fine. i printed the number of records in a table and it did print

can some one help me to rectify my code or help me with some sample script link

Million Thanks in advance


  Form that Submits to a Database
Posted by: El Forum - 09-29-2008, 12:56 AM - Replies (19)

[eluser]Jason McCallister[/eluser]
I have been reading the user guide and I have been trying to figure something out. Basically I need a quick and simple tutorial that explains how to create a simple form that submits to a database. I know how to connect to the database, I'm just confused on how to create a form without the scaffolding.

Also any good resources from the community?


  PDO Extension
Posted by: El Forum - 09-29-2008, 12:40 AM - Replies (8)

[eluser]hykoh[/eluser]
Hi,

is there any PDO Database Extension for CI ? I just started to work with CI yesterday, but like to work with PDO and the "real" prepared statements for mySQL. CI has only Pseudo-prepared-statements mh ?


  PostgreSQL where
Posted by: El Forum - 09-28-2008, 11:24 PM - Replies (7)

[eluser]Kfrico[/eluser]

Code:
$sql = "SELECT * FROM "AssocPersonMaster" WHERE "PersonID" = '9788771' or "Status" = 'b'";
$query = $this->db->query($sql);

Parse error: syntax error, unexpected T_STRING in E:\Program Files\Apache Software Foundation\www\pg\system\application\models\modelinsert.php on line 50

why

在sql裡面不能加雙引號嗎?
但是不加雙引號postgresql確無法判別大小寫之分
這該怎麼辦阿?


  Codeigniter that suitable for PHP 6
Posted by: El Forum - 09-28-2008, 10:38 PM - Replies (7)

[eluser]chandrajatnika[/eluser]
I have some problem about my CI application when I install it on PHP 6.
this is some error:

Code:
Deprecated: Assigning the return value of new by reference is deprecated in J:\\Webmaster_File\\Project\\product_database\\system\\codeigniter\\Common.php on line 123

Deprecated: Assigning the return value of new by reference is deprecated in J:\\Webmaster_File\\Project\\product_database\\system\\codeigniter\\Common.php on line 129

Fatal error: Call to undefined function set_magic_quotes_runtime() in J:\\Webmaster_File\\Project\\product_database\\system\\codeigniter\\CodeIgniter.php on line 53

I remove \"Call Time Pass by Reference\" on Common.php by remove \"&\" on object declaration
Code:
$obj =& new Class(); // before
$obj = new Class(); // after

I remark \"set_magic_quotes_runtime()\" statement from CodeIgniter.php, and the last is i create my own \"get_magic_quotes_gpc()\" function by only returning a boolean false.

After that, my application do unfinish looping and my web server got some error.

Could you please help me how to handle this?


  Controller Sub-Folders?
Posted by: El Forum - 09-28-2008, 10:33 PM - Replies (5)

[eluser]Moon 111[/eluser]
My website has two languages so I was going to have an english sub-folder and a hebrew sub-folder inside my controller folder. Is this not allowed?

How should I do this instead?

Thanks,
- Moshe


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

Username
  

Password
  





Latest Threads
Defining extra constants ...
by ramonpuig
59 minutes ago
Error / Shield 1.0.3 + Ci...
by kcs
3 hours ago
Bug with sessions CI 4.5....
by ALTITUDE_DEV
4 hours ago
Validation | trim causes ...
by kenjis
6 hours ago
Integrating Bootstrap 5 i...
by Bosborne
7 hours ago
Asset Minification Packag...
by tarcisiodev1
Yesterday, 05:11 PM
Modify users data as an a...
by luckmoshy
Yesterday, 04:56 PM
Is it possible to go back...
by ejimenezo
Yesterday, 11:49 AM
SQL server connection not...
by davis.lasis
Yesterday, 07:11 AM
Problem with session hand...
by Julesb
Yesterday, 04:13 AM

Forum Statistics
» Members: 85,558
» Latest member: sonamsharma4u
» Forum threads: 77,586
» Forum posts: 376,032

Full Statistics

Search Forums

(Advanced Search)


Theme © iAndrew 2016 - Forum software by © MyBB