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

Username/Email:
  

Password
  





Search Forums

(Advanced Search)

Forum Statistics
» Members: 10,159
» Latest member: ylhxboy
» Forum threads: 67,061
» Forum posts: 419,849

Full Statistics

Latest Threads
how to get current class ...
Forum: CodeIgniter 4 Support
1 hour ago
» Replies: 2   » Views: 30
Chrome >= 63 and virtual...
Forum: Lounge
9 hours ago
» Replies: 1   » Views: 50
Underscores in apache vir...
Forum: Lounge
Yesterday, 10:23 AM
» Replies: 2   » Views: 86
Adding Specific Configura...
Forum: General Help
Yesterday, 06:09 AM
» Replies: 2   » Views: 81
How to gracefully degrade...
Forum: General Help
Yesterday, 06:04 AM
» Replies: 1   » Views: 66
Codeigniter & Imap Librar...
Forum: Addins
Yesterday, 04:18 AM
» Replies: 0   » Views: 64
Make table with two recor...
Forum: General Help
Yesterday, 02:53 AM
» Replies: 3   » Views: 107
Community auth problems
Forum: Addins
Yesterday, 12:47 AM
» Replies: 1   » Views: 73
How to show category name...
Forum: General Help
Yesterday, 12:11 AM
» Replies: 0   » Views: 45
Do a second library load
Forum: Libraries & Helpers
12-16-2017, 06:29 PM
» Replies: 1   » Views: 76

 
Tongue Do a second library load
Posted by: [email protected] - 12-16-2017, 10:42 AM - Forum: Libraries & Helpers - Replies (1)

PHP Code:
$this->load->library('uploadlib',array('dir'=>'uploads/biblioteca/','tipos'=>'pdf|doc|docx|txt'));
 
      
$livro
='livro';
$value=$this->upload($livro);
if(!
$value)
    return 
false;
$this->data['error'] = null;
$this->data['upload_data_livro']=$value;
 
      
$this
->load->library('uploadlib',array('dir'=>'images/capas/','tipos'=>'gif|png|jpg')); 

Second time
PHP Code:
$this->load->library('uploadlib',array('dir'=>'images/capas/','tipos'=>'gif|png|jpg')); 
doesn't load the parameters because uploadlib already loaded! how can i fix this? I) want to load the upload lib with the news parameters.
Thanks in advance


  Codeigniter and Ionic framework
Posted by: theedo - 12-16-2017, 06:29 AM - Forum: General Help - No Replies

Hello!

I'm creating an app based on Ionic framework with a PHP Backend. I'm using the Rest Server library for CI.

Now, I've a "logic" problem about the login. I've two input, I send a POST request through AngularJS to my API, here I check all data, I filter the input, check if user exists, if the password is correct and so on. If all is ok, I send to the app a json_encode array with the session that I stored.

This is the code:

PHP Code:
$new_data = array('mail' => $utente->email'uid' => $utente->id'logged_in' => 'yes');
$this->session->set_userdata($new_data);
$final = array(
 
 'status' => 'success',
 
 'session' => $this->session->userdata()
); 

Then, I set a localStorage with the session stored in that. Why that? Because I want that if the user close the app, without clicking on "logout", whene he opens the app is logged in. Now my question is: is secure to store the session in the localStorage?
This is my localStorage after the login:
[Image: 454fb2bd200ad0f5308ded8e633c9e73.png]
I can edit the "uid" value, uid obviously is the user_id. So I think it isn't a secure method to store user session. How can I do that?
Thank you!


  Community auth problems
Posted by: riccardo - 12-16-2017, 03:29 AM - Forum: Addins - Replies (1)

Dear all,
to obtain NMI certification, we upgraded php from 5.6 to 7.2.

With php 5.6, 7.0 all work fine, with that new release we cannot login correctly to our platform.

Also, application wrote all datas into DB, as user logged in but i'm always redirected to home page.

I think it's probably a problem about sessions or cookies, any idea?

Thanks

Riccardo


  [3.1.6] PHP Warning, File: Common
Posted by: rodrigoprazim - 12-15-2017, 02:34 PM - Forum: CodeIgniter 3.x - No Replies

This error is displayed most of the time when I am using the SoapClient.

PHP Warning:  require_once(system/core/Exceptions.php): failed to open stream: Too many open files in system/core/Common.php on line 163


Code:
public function pesquisarAcordosWebservice($id=''){
    if($this->configuracao_model->verConfiguracao('webservice')->row()->status && $this->session->any < 3) {
        if (!empty($ndg)) {
            try {
                $function = 'pesquisarAcordos';
                $dados = [$function => ['id' => str_pad($id, 16, '0', STR_PAD_LEFT)]];
                $client = @new soapclient($this->linkWebserviceProducao().'?wsdl', $this->authWebserviceProducao());
                $options = ['location' => $this->linkWebserviceProducao()];
                $err = $client->__soapCall($function, $dados, $options);
                return $err;
            } catch (Exception $exception) {
                $exception->getMessage();
                return FALSE;
            }
        }
    }
}


  Merge .js files to load only "single merged maxi one"
Posted by: ldetomi - 12-15-2017, 07:28 AM - Forum: Lounge - Replies (1)

Hi,
I don't know if is the right section but here my problem:

Currently I have many many .js files loaded at startup (often small ones but is useful mantain them separated for better organization and maintenance).

In some enterprise platform like LifeRay, is possibile to have a maxi merged-file or load them separated (for debug purposes) simply adding an option to URL like "?js_fast_load=0".

Apart url parameter.... is maybe possible with CodeIgniter to have a feature like this or maybe you have some other suggestions to mantain separated source code, but load in PROD env only a merged one for performances?

Thank you


  [Solved] Expire Session Question
Posted by: wolfgang1983 - 12-15-2017, 01:47 AM - Forum: General Help - Replies (1)

When the user first login email or user name correct I set a custom session token

I when I set the token I would only like that token to last for 5 min then unset it self

How can I make sure that after 5min then only that session data will expire and unset.

PHP Code:
$this->load->helper('string');

$token random_string('alnum'16);

$session = array(
 
  'login_token' => $token
);

$this->session->sess_expiration '14400';// expires in 4 hours
$this->session->set_userdata($session);

redirect(base_url('login/pwd/?token=' $token)); 


PHP Code:
<?php defined('BASEPATH') OR exit('No direct script access allowed');

class 
Login extends CI_Controller {

    public function 
__construct() {
        
parent::__construct();
        
$this->load->library('form_validation');
    }

    public function 
index()
    {

        
$data['title'] = 'Admin Login';

        
$data['error_validation'] = '';
        
        
$this->form_validation->set_rules('validation''Username Or Email''required');

        if (
$this->form_validation->run() == false) {

            if (
form_error('validation')) {
                
$data['error_validation'] = form_error('validation''<p class="text-danger">''</p>');
            }

            
$this->load->view('template/common/header'$data);
            
$this->load->view('template/account/login'$data);
            
$this->load->view('template/common/footer');

        } else {

            
$this->load->helper('string');

            
$token random_string('alnum'16);

            
$session = array(
                
'login_token' => $token
            
);

            
$this->session->sess_expiration '14400';// expires in 4 hours
            
$this->session->set_userdata($session);

            
redirect(base_url('login/pwd/?token=' $token));
        }
    }

    public function 
pwd() {

        
$data['title'] = 'Admin Password Verification';

        if (
$this->session->userdata('login_token') !== $this->input->get('token')) {
            if (
$this->session->userdata('login_token')) {
                
$this->session->unset_userdata('login_token');
            }

            
redirect(base_url('/'));
        }

        
$data['error_password'] = '';

        
$this->form_validation->set_rules('password''Password''required|callback_validatepassword');

        if (
$this->form_validation->run() == false) {

            if (
form_error('password')) {
                
$data['error_password'] = form_error('password''<p class="text-danger">''</p>');
            }

            
$this->load->view('template/common/header'$data);
            
$this->load->view('template/account/password'$data);
            
$this->load->view('template/common/footer');

        } else {

            if (
$this->session->userdata('login_token')) {
                
$this->session->unset_userdata('login_token');
            }

            
redirect(base_url('dashboard'));
        }

    }

    public function 
validatepassword() {

    }


  session does not work in mobile application
Posted by: gabrielbaroni - 12-14-2017, 07:01 PM - Forum: Libraries & Helpers - Replies (2)

Hi guys,
What could be happening?

i can access my site(restrict area protected with sessions) through my computer but i can't access with mobile 

i'm not know more what to do with this problem


plz help me  Huh


  Handle mysql errors using query builder
Posted by: geabenitez - 12-14-2017, 06:11 PM - Forum: Libraries & Helpers - Replies (4)

How do I handle errors when using the query builder?


  Help with routes
Posted by: canado - 12-14-2017, 03:45 PM - Forum: CodeIgniter 4 Support - No Replies

I am trying all possibilities but I am stuck to one controller and one method only.

I have 2 controller, Home and Report. Only index on home is working correctly

Here is part of my route file

PHP Code:
$routes->setDefaultNamespace('');
$routes->setDefaultController('Home');
$routes->setDefaultMethod('index');
$routes->setTranslateURIDashes(false);
$routes->set404Override();
$routes->setAutoRoute(true);

/**
 * --------------------------------------------------------------------
 * Route Definitions
 * --------------------------------------------------------------------
 */

// We get a performance increase by specifying the default
// route since we don't have to scan directories.
$routes->add('/''Home::index');

$routes->add('reportapi''Report::index'); 




Here is my .htaccess


Code:
# ----------------------------------------------------------------------
# Environment Name
# ----------------------------------------------------------------------

# Sets the environment that CodeIgniter runs under.
# SetEnv CI_ENV development

# ----------------------------------------------------------------------
# UTF-8 encoding
# ----------------------------------------------------------------------

# Use UTF-8 encoding for anything served text/plain or text/html
AddDefaultCharset utf-8

# Force UTF-8 for a number of file formats
<IfModule mod_mime.c>
   AddCharset utf-8 .atom .css .js .json .rss .vtt .xml
</IfModule>

# ----------------------------------------------------------------------
# Rewrite engine
# ----------------------------------------------------------------------

# Turning on the rewrite engine is necessary for the following rules and features.
# FollowSymLinks must be enabled for this to work.
<IfModule mod_rewrite.c>
Options +FollowSymlinks
RewriteEngine On

# If you installed CodeIgniter in a subfolder, you will need to
# change the following line to match the subfolder you need.
# http://httpd.apache.org/docs/current/mod/mod_rewrite.html#rewritebase
RewriteBase /

# Redirect Trailing Slashes...
   # RewriteRule ^(.*)/$ /public/api/$1 [L,R=301]

# Rewrite "www.example.com -> example.com"
RewriteCond %{HTTPS} !=on
RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
RewriteRule ^ http://%1%{REQUEST_URI} [R=301,L]

# Checks to see if the user is attempting to access a valid file,
   # such as an image or css document, if this isn't true it sends the
   # request to the front controller, index.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]

# Ensure Authorization header is passed along
   RewriteCond %{HTTP:Authorization} .
   RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
</IfModule>

<IfModule !mod_rewrite.c>
   # If we don't have mod_rewrite installed, all 404's
   # can be sent to index.php, and everything works as normal.
   ErrorDocument 404 index.php
</IfModule>

# ----------------------------------------------------------------------
# Gzip compression
# ----------------------------------------------------------------------

<IfModule mod_deflate.c>

# Force deflate for mangled headers developer.yahoo.com/blogs/ydn/posts/2010/12/pushing-beyond-gzipping/
<IfModule mod_setenvif.c>
<IfModule mod_headers.c>
SetEnvIfNoCase ^(Accept-EncodXng|X-cept-Encoding|X{15}|~{15}|-{15})$ ^((gzip|deflate)\s*,?\s*)+|[X~-]{4,13}$ HAVE_Accept-Encoding
RequestHeader append Accept-Encoding "gzip,deflate" env=HAVE_Accept-Encoding
</IfModule>
</IfModule>

# Compress all output labeled with one of the following MIME-types
# (for Apache versions below 2.3.7, you don't need to enable `mod_filter`
# and can remove the `<IfModule mod_filter.c>` and `</IfModule>` lines as
# `AddOutputFilterByType` is still in the core directives)
<IfModule mod_filter.c>
AddOutputFilterByType DEFLATE application/atom+xml \
                             application/javascript \
                             application/json \
                             application/rss+xml \
                             application/vnd.ms-fontobject \
                             application/x-font-ttf \
                             application/xhtml+xml \
                             application/xml \
                             font/opentype \
                             image/svg+xml \
                             image/x-icon \
                             text/css \
                             text/html \
                             text/plain \
                             text/x-component \
                             text/xml
   </IfModule>
</IfModule>

It should be straight forward so I don't know what else I have to change edit or check.
Thanks


  Session issue
Posted by: yinkoh - 12-14-2017, 09:55 AM - Forum: Issues - Replies (5)

Hello,

I'm getting confused with a session issue...

I'm using a parent controller (MY_Controller) for all others controllers. Each of them is correctly initiated with parent::__construct() and everything is going well.

Right now, I'm doing the backoffice part of my site and so, I need to store a flag for identified users.

PHP Code:
class MY_Controller extends CI_Controller
{
 public function 
__construct()
 {
 
 parent::__construct();
 
 $this->load->library->('session');
 
 }

PHP Code:
class Backoffice extends MY_Controller
{
 public function 
__construct()
 {
 
 parent::__construct();
 
 }

 public function 
index()
 {
 
 if ( ! $this->session->has_userdata('is_logged') )
 
   $this->load->view('login');
 
 else
    $this
->load->view('admin');
 
 }

 public function 
login()
 {
 
 if $this->input->post('user') == 'user' && $this->input->post('passwd') == 'passwd' )
 
  $this->session->set_userdata('is_logged' => 1);
 
 }


My problem is that session always gets empty unless I do not use the CI Session library and therefore uses $_SESSION from native php.

I just dont get what part is wrong in my code.


Ps: I've tried using both files or database driver in application/config/config.php but without any changes.



  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2017 MyBB Group.