cURL library no longer works with current CodeIgniter? - codeigniter

I would like to know please how to correct the following error, or what an alternative solution would be.
Update 1 - In my php.ini from extension=php_curl.dll is uncommented (I've rebooted the server too), however Curl does not appear anywhere in PHPINFO().
Update 2 - Furthermore, I'm certain I'm looking at the right php.ini because it's the one mentioned inPHPINFO() as Loaded Configuration File.
I'm trying to perform simple cURL calls from within CodeIgniter using Phil Sturgeon's library.
I'm using CodeIgniter 2.1.3.
I get the following error when performing the first example straight from the official README.
Here is my controller class:
<?php
class Test extends CI_Controller {
function __construct() {
parent::__construct();
}
function index() {
$this->load->library('curl');
// Simple call to remote URL
echo $this->curl->simple_get('http://google.com/');
}
}
/* End of file test.php */
/* Location: ./application/controllers/test.php */

Did you first install the php curl extension.
Please visit http://php.net/manual/en/curl.setup.php for instructions on doing this.
Here is a guide for windows http://devilsworkshop.org/tutorial/enabling-curl-on-windowsphpapache-machine/702/
After doing this, make sure you restart your Apache web server

I installed the most recent wampserver 2.2 over my (few months old) wampserver installation (and chose 32bit this time instead of 64bit), and curl seems to be working perfectly now.

Related

CodeIgniter 4 - No direct script access allowed

After installing and configuring CI 4 I can see the home controller and the debug bar as normal (I'm in development mode).
There is a problem with error reporting. If I try to deliberately write some wrong PHP code, CodeIgniter overrides the normal PHP behaviour and hides the errors (in development mode!!).
Here's an example of deliberately adding a PHP error to the home controller:
<?php namespace App\Controllers;
class Home extends BaseController
{
public function index()
{
this is an error!! ()
return view('welcome_message');
}
}
Here's the output (which is not helpful with real errors):
No direct script access allowed
How can I set CodeIgniter 4 to show PHP errors? (the error is not even logged anywhere inside the server)
this problem happened when u delete this folder (app/view/errors) from view

Why wont my Codeigniter model load on Lamp?

My model is:
/application/models/tester.php
The code inside is:
class Tester extends CI_Model
{
function __construct()
{
parent::__construct();
$this->load->database();
}
}
And here's the usage:
class Hauth extends CI_Controller
{
public function index()
{
$this->load->view('hauth/home');
}
public function login($provider)
{
// Load models
$this->load->model('Tester');
// Load helpers
$this->load->helper('url');
log_message('debug', "controllers.HAuth.login($provider) called");
It works perfectly on my local WAMP server but I get this error on the LAMP production envrionment:
An Error Was Encountered
Unable to locate the model you have specified: Tester
I've looked at a dozen StackOverflow questions that appear to be similar but I've tried all of the solutions posted. As far as I can tell, I've followed the CI manual to the letter. I figured that perhaps file names were an issue WAMP vs LAMP so I confirmed the case of the file names via FTP. Thought it might be a naming conflict, so I renamed them "tester". Again, works perfect on local, but not on live.
I found the problem. Turns out I accidentally used a zip of Codeigniter 3.0-dev. When I moved my application files over to the latest stable version, everything instantly worked.

Laravel Controller not working

I'm very new to the Laravel framework and am trying to load a simple controller in my browser to slowly get the hang of things.
I have a file that's titled users.php inside of the the laravel/app/controllers/ folder and it looks like this:
class UsersController extends BaseController
{
public $restful = true;
public function action_index()
{
echo 'hi';
}
}
In the routes.php file, I have
Route::get('users', 'UsersController#index');
But, when I go to
http://localhost:8888/laravel/public/users
I'm greeted with a message that says "ReflectionException
Class UsersController does not exist"
I'm not sure if this is because I didn't install the mcrypt extension of PHP. But, when I checked the php.ini file on MAMP, it said that it was enabled. Upon entering
which PHP
in my terminal, it said /usr/bin/php. So, it might not be using the correct version of PHP.
I'm not entirely sure if this is a routes problem or if it's stemming from an absence of a vital PHP extension.
Thanks a bunch!
You need to use the Route::controller method to reference your Controller:
Route::controller('test', 'TestController');
...and rename your file (as Cryode mentions ) to be TestController.php.
Note - if you want to use the filename as test.php, then you will need to use composer to update the autoload settings.
Finally, the format of names for Controller methods changed in Laravel 4, try renaming the method
public function action_index() {}
to be
public function getIndex() {}
the get represents a HTTP GET request... the same applies for post (HTTP POST) and any (GET or POST.. )
I'm not familiar with that part of Laravel's source, so I'm not entirely certain that this is the issue, but your controller file name should match the controller class name, including capitalization.
So users.php should be UsersController.php. Now, when I do this myself on purpose, I get a "No such file or directory" error on an include() call, so that's why I'm not certain that's the sole cause of your problem. But it may be a start.

google calendar with codeigniter

I'm trying to integrate Google Calendar in my php application (I use CodeIgniter for this).
I have a problem with my controller calendar.php.
<?php
session_start();
Class Calendar extends Controller {
function Calendar(){
echo 'start';
parent::Controller();
echo 'okkkkkkkk';
require_once '/home/me/framework/ZendGdata/library/Zend/Loader.php';
Zend_Loader::loadClass('Zend_Gdata');
Zend_Loader::loadClass('Zend_Gdata_AuthSub');
Zend_Loader::loadClass('Zend_Gdata_ClientLogin');
Zend_Loader::loadClass('Zend_Gdata_Calendar');
}
but there is a problem with parent::Controller() because 'okkkkkk' is not printed.
Could anyone help me please?
Change
parent::Controller();
to
parent::__construct();
parent::Controller() doesn't work in CI because as of CI 2.1.2, the constructors are declared using PHP's __construct() method.
As a sidenote, it seems you are using an older version of CI. CI 2.o onwards, the base controller class is called CI_Controller as opposed to just Controller. You should look into updating your project by replacing the system folder.
You can find the full working code in this following link https://github.com/omerkamcili/ci_google_calendar_api.
After down loading the code create your service account, OAuth client Id's in the following link http://console.developers.google.com.
Then replace the client_id,client_secret,redirect_uri's in your project file in the following path -> /project_folder/application/config/client_secret_846685841138-t0a5b9d2i655e7km54md8j440jcg5rr5.apps.googleusercontent.com.json file
Finally download and replace the google-api-php-client in the following file path /project_folder/application/third_party/google-api-php-client

Setting up Codeigniter HMVC with tank auth

I am having trouble getting a working Codeigniter version 2.0.3 with hmvc and tank auth(set up as a module) setup properly. I have installed CI properlly and then install HMVC with these directions https://bitbucket.org/wiredesignz/codeigniter-modular-extensions-hmvc/wiki/Home
I get to my welcome controller/view as example just fine which means the HMVC is working. Next I try to add tank auth to the project by adding it to a folder in the modules folder. It has the proper controller/view/model etc.. setup within the tank auth. I even added in routes something like
$route["auth"]="auth/login";
I also extended the controller within the auth module to MX_Controller like as directed. Also in the constructor I have :
$this->load->helper(array('form', 'url'));
$this->load->library('form_validation');
$this->load->library('security'); <--failing to load this
$this->load->library('tank_auth');
$this->lang->load('tank_auth');
$this->form_validation->CI =& $this;
It seems to be redirecting fine to the module however it comes up with an error saying ::
An Error Was Encountered
Unable to load the requested class: security
What am I doing wrong? Does any one have a working CI installation with HMVC and tank auth as a module so I can see how its done? I'm new to HMVC, thanks
I found the same problem, but i solved by simple adding a comment to the
$this->load->library('security');
so it will look like this:
//$this->load->library('security');
since security its now part of the codeigniter core, i guess its already loaded by default, and everything seems to be working pretty good
it is in Helper now according to CodeIgniter 3.0 user guide
try:
$this->load->helper('security');
I fix this, by creating Security.php file in application/libraries directory with the following code:
require_once(BASEPATH.'core/Security.php');
class Security extends CI_Security { }
I found a solution, I simply took the security.php file from codeigniters system/core folder and dropped it into system/libraries.
move the file security.php from system/core to system/libraries
then edit core/codeigniter.php line number 204 from $SEC =& load_class('Security', 'core'); to $SEC =& load_class('Security', 'libraries');
Security.php is present in "codeigniter/system/core/Security.php"
so provide this path your problem gets solved easily
load->library('../core/security');
I Read CodeIgniter 3.X User Guide and I was found that "Security" is available as a 'helper' Now.
So you need to change this;
$this->load->library('security');
into
$this->load->helper('security');
XSS Filtering
The Input class has the ability to filter input automatically to prevent cross-site scripting attacks. If you want the filter to run automatically every time it encounters POST or COOKIE data you can enable it by opening your application/config/config.php file and setting this:
$config['global_xss_filtering'] = TRUE;
You need to read a CodeIgniter 3.0 User Guide there are so many changes and implementation or please Refer change log.

Resources