Wrong controller function getting called - codeigniter

I'm building a small HR management system for my company, and am facing a weird issue with GoDaddy hosting. As if the pain that comes with figuring out the index.php? part was not enough, now I'm not able to log in as an HR. The error I get is that:
Parse error: syntax error, unexpected '[' in /home/content/37/11019837/html/hrms/application/controllers/hr.php on line 58
Now the line it refers to is part of a file upload function, and goes like this:
$path = $this->upload->data()['full_path'];
. . . which is simply saving the uploaded file path to $path. BUT, this is part of the uploading function and shouldn't even be accessed while logging in. Once I hit "Log in", the URL says http://www.example.com/hrms/index.php?/hr/dashboard which means the following function will be called:
public function dashboard()
{
$data['page_title'] = 'HR Area';
$this->load->view('hr/header.php', $data);
$this->load->view('hr/navigation.php');
$this->load->view('hr/footer.php');
}
A parting note: The app is working without hiccups on the local server, so I'm not sure why it's hopping functions on GoDaddy servers. Can someone throw some light?

Try this:
$path = $this->upload->data();
$path1 = $path['full_path'];

Related

codeigniter array session issue after move site one server(godaddy) to another server(bluehost)

There is issue in session. This is my array.
print_r($this->session->userdata("user_data"));
Array
(
[useremail] => myid#gmail.com
[user_id] => 1
[is_login] => 1
)
I want to get the useremail . so I am writing this code.
print_r($this->session->userdata("user_data")['useremail']);
It gives the error . Parse error: syntax error, unexpected '['
If I am writing the code like this :
$dataval = $this->session->userdata("user_data");
print_r($dataval['useremail']);
Then it it working fine .
Please help me what is issue ?
It is because you (probably) moved from newer php version (5.4+) to older version (5.2).
Accessing array items directly by calling function name is only available on php 5.4 and newer: array dereferencing.
Only solution is to use temporary variable (like your $dataval). Or you can switch to newere php version, if the bluehost allows it.

Directory_map works only on C:

Directory_map works only on C: harddisk.
I want to use it on a server "P:" or "Q:" but that's not working currently.
I have full permission so I guess the problem is not about it.
$path = "C:\Users\Public\Documents\";
$map = directory_map(realpath($path), TRUE);
var_dump($map);
// WORKS
$path = "P:\INTRANET";
// DOESN'T WORKS
And the same things happend with get_filenames function ...
Ok so, I found a pretty nice solution here :
http://www.dynamicdrive.com/forums/showthread.php?27880-Using-function-opendir-on-a-network-drive #DaveRandom comment.
You can also see his contribution about that in php manual http://php.net//manual/fr/function.opendir.php
In fact, to use function (in codeigniter or php ) in a network drive, you had to map it.

how to read yii session in codeginiter controller. I am new to both the frameworks

Following is the code I have used :-
require(realpath(dirname(__FILE__).'/../../../email/apps/common/framework/YiiBase.php'));
$config = require(realpath(dirname(__FILE__).'/../../../email/apps/customer/config/main.php'));
Yii::createWebApplication($config);
var_dump(Yii::app()->User->id);
i am getting following error:-
Message: include(): Failed opening 'Yii.php' for inclusion (include_path='.:/usr/share/php:/usr/share/pear')
Filename: framework/YiiBase.php
Line Number: 428
Be kind write full absolute path for the script that executes the code and location of the files YiiBase.php and main.php.
Solution from the creator of Yii says:
require_once('path/to/yii.php');
Yii::createWebApplication($config);
// you can access Yii::app() now as usual
$session = Yii::app()->session;
//....use session as you wish
My file that can help you start is:
// change the following paths if necessary
$yii=dirname(__FILE__).'/../yii/yii.php';
$config=dirname(__FILE__).'/protected/config/main.php';
// remove the following lines when in production mode
defined('YII_DEBUG') or define('YII_DEBUG',true);
// specify how many levels of call stack should be shown in each log message
defined('YII_TRACE_LEVEL') or define('YII_TRACE_LEVEL',3);
require_once($yii);
Yii::createWebApplication($config);
NOTE
Its is not recommended you use YiiBase. Use either yii or yiilite. YiiBase serves as base class and is not intended to be used directly (to the best of my kowledge). Also check paths if they real point to the file!

Require path is not being accepted [closed]

This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center.
Closed 10 years ago.
Warning:
require_once(/var/www/html/test_lms/include/mysql.processing.php):
failed to open stream: No such file or directory in
/var/www/html/test_lms/include/IMEXporter.class.php on line
513
Fatal error: require_once(): Failed opening required
'/var/www/html/test_lms/include/mysql.processing.php'
(include_path='.:/usr/local/lib/php') in
/var/www/html/test_lms/include/IMEXporter.class.php on line
513
PHP from IMEXporter.class.php LINE 513 that is throwing the error
require_once dirname(__FILE__) . "/mysql.processing.php";
The file is there.
The file is chmod 777.
The two files are both owned by the same user and group.
Why is php doing this to me?
The problem could be that mysql.processing.php itself is broken and even though php finds the file it refuses to retrieve it and instead throws a Derp! cant find file. Derp.. Kind of stupid to mislead me like that but its a possibility. I'm checking over my code now.
Nope, I tried erasing the entire script of mysql.processing.php and wrote
echo "Hello you impudent php";
and it still wont find the file. So its not a file broken issue. Also I fixed the file case issue. From uppercase P to lowercase and it still wont go for it. I tried to include a file by the name of test.php and it wont find that one either..
You are having case sensitivity issue. Most likely you moved form windows environment to Linux
If your file is mysql.processing.PHP require_once dirname(__FILE__) . "/mysql.processing.php would work on a windows + apache server but fail on Linux + apace
use the following to get the actual file name
var_dump(scandir(__DIR__));
Please run this simple test
error_reporting(E_ALL);
$name = "mysql.processing.php";
$file = __DIR__ . "/mysql.processing.php";
$dir = scandir(__DIR__);
$func = array("file_exists","is_file","is_readable");
echo "<pre>";
foreach ( $func as $fun ) {
if (! $fun($file)) {
echo $fun, " - Failed ", PHP_EOL;
} else {
echo $fun, " - Failed ", PHP_EOL;
}
}
if (! in_array(basename($file), $dir)) {
echo basename($file), " in_array Error", PHP_EOL;
} else {
echo basename($file), " in_array OK", PHP_EOL;
}
if (! in_array($name, $dir)) {
echo $name, " in_array Failed", PHP_EOL;
} else {
echo $name, " in_array Ok", PHP_EOL;
}
if ($name !== basename($file)) {
echo $name, " basename Failed", PHP_EOL;
} else {
echo $name, " basename OK", PHP_EOL;
}
Well, in the error message the capitalization on the filename is not the same as in the require line you posted... are you sure it's not a typo?
Okay here was the problem. Remember when I mentioned that my mysql.processing.php file could be broken? Well that was half the issue. Apparently php require returns the error failed to open stream: No such file or directory.. etc if it:
1) Cannot find the file.
2) It finds the file, but it cannot open it.
The error message is misleading and leads you to believe it is a path issue. Sometimes it is, but cases like mine, its just a syntax issue with the returned file. Now for the second half. I made the corrections to all my syntax errors on the mysql.processing.php but it still was not working.. So I just did a reboot of my server and now it works.
The second half of the problem is that php has a nasty tendency to cache php files. Often you can start editing a php script, fixing solutions etc etc and not make any progress because php wont immediately take into effect your changes. This can lead you into stumbling around from one solution to the next, constantly changing your script and it can feel like you are in a maze.
There are ways to stop php from caching specific files. But the problem was php itself, with its misleading error report, and two with its caching of problems and excluding solutions.
Maybe the problem is that your php are not in the same folder, you cannot include a .php from a URL or another folder. You can include a php if it is on the same path or in a subfolder that is on your path. Sorry for my english but I think that you're going to understand what I'm saying.

Write permissions with Codeigniter + Simplepie

I am trying to create a simple RSS parser using the two frameworks. However I am getting PHPerrors when trying to write to my cache directory:
set_cache_location(APPPATH.'cache/rss');
I am running windows 7 with XAMPP using the latest version of Simplepie from github
error:
A PHP Error was encountered
Severity: User Warning
Message: C:\xampp\htdocs\geekurls/system/application/cache/rss is not writeable. Make sure you've set the correct relative or absolute path, and that the location is server-writable.
Filename: libraries/simplepie.php
Line Number: 1732
Tried like the below comment said and tried making a test file but to no luck
$file = APPPATH."cache/rss/testFile.txt";
$handle = fopen($file, 'w') or die("fail");
fclose($handle);
A simple checks to find out what might be happening,
Try creating a file in this directory using standard php - this could help solve permission problems.
$this->load->helper('file');
$data = 'Some file data';
if ( ! write_file('./path/to/file.php', $data))
{
echo 'Unable to write the file';
}
else
{
echo 'File written!';
}
Also how about using the default cache?
http://simplepie.org/wiki/faq/i_m_getting_cache_error_messages

Resources