Magento admin session not working within a folder - magento

I am trying to use the following code to get Admin session to check whether admin is logged in or not. File created at the level of /app folder.
include('app/Mage.php');
Mage::app();
Mage::getSingleton('core/session', array('name'=>'adminhtml'));
if(Mage::getSingleton('admin/session')->isLoggedIn()){
Mage::getSingleton("core/session")->setAdminLogin("1");
echo "Admin Logged In..";
}
else
{
echo "go away bad boy";
}
This code is working fine at the level of /app.
But when I put this file within a folder at the level of /app, then it works only first time.
Can I have a best solution for this issue ?

Related

How to deploy laravel project on ovh hosting?

For the last month I coded a laravel project on local, using Laragon to have a local server. Now I want to deploy it online, using an ovh hosting ( required by a client ). So I have my ovh hosting, with the "perso" offer.
I used the ftp credentials given by ovh, with FileZilla, and it worked. It gave me something like this :
Then I uploaded all my project in the www folder. Now, when go to the domain, it doesn't display the front page but rather the folder itself, aka this :
For now, I didn't touch the .env file. I deleted the default index.html in the www folder, I know the problem probably come from this. I searched everywhere and found not clear explanation. My knowledge on web hosting is limited, so I'm struggling with this. I know I missed something. Anyone who could help me, would save my life. Thank you !
do not put you project files in the www folder, instead put them in a folder outside that directory 'called laravel for example'.
then copy or move the contents of the 'public' directory to 'www'. (www dir will now contain index.php,...).
edit the two lines in www/index.php that require autoload.php and app.php to reflect the new directory changes:
require __DIR__.'/../vendor/autoload.php';
should be:
require __DIR__.'/../laravel/vendor/autoload.php';
and
$app = require_once __DIR__.'/../bootstrap/app.php';
should be:
$app = require_once __DIR__.'/../laravel/bootstrap/app.php';
The best is to create a new folder in the /www folder with the name of your project.
For exemple: /www/laravel-project
Then you will need to go OVH admin panel, click on your domain and change the folder it is going to by /www/laravel-project/public
You need to go to the public folder of your Laravel project.
saying that your project name is : Laraval_project :
using "filezilla", put 'laravel_project/' under the directory 'www/'.
find the dir named : 'public/' under 'laravel_project/' and copie/pass it in the the parent dir, wich is : 'www/'.
now u have side by side 'laravel_project/' and 'public/' under 'www/'.
in 'public/' folder u'll find four files -> move them all to the parent dir, wich is 'www/'..
edit www/index.php file as Rabah said :
edit the two lines in www/index.php that require autoload.php and
app.php to reflect the new directory changes:
require __DIR__.'/../vendor/autoload.php';
should be:
require __DIR__.'/laravel_projec/vendor/autoload.php';
and
$app = require_once __DIR__.'/../bootstrap/app.php';
should be:
$app = require_once __DIR__.'/laravel_project/bootstrap/app.php';
if ther is a file named : 'www/index.html', rename it :
'index.html.old . enjoy

Laravel TypiCMS redirects to root

I am using TypiCMS Laravel here : github.com/TypiCMS/Base and I am facing the following problem:
I created a new module named "News" by executing command: composer require typicms/news. I also added providers in config/app.php, have publish views and migrations and migrated the database too.
The only problem I am facing is that whenever the url I given, it redirects me to the root directory of my project, that is, http://localhost/mywebsite/public/
Even, if I give invalid route like localhost/mywebsite/public/foobar, instead of showing me error, it again redirects to the root directory.
I have checked the .htaccess and routes.php file and there is not modifications.
Regards:
Adnan
TypiCMS cannot be installed in a subfolder, the root of your site must be http://localhost.

Could not find Maintenance.flag file in root folder magento

I was trying to install an extension in my magento site which was failed in the middle later i could not get access to my admin neither to my site as it shows this error.
http://prntscr.com/68qc3c
this error should be removed maintenance.flag file but this file is not available in my root folder. Please assist me if there is any other way possible?
Thanks
two possible ways are
1 . you can delete manually both session and cache directory from var directory.
path
magento_root/var/
2. or you can delete all files of that extension and reinstall again.
The maintenance.flag file must still be in your root directory, otherwise Magento would not be displaying the 503 error. The way that this is displayed is a result of the index.php file, around line 66:
$maintenanceFile = 'maintenance.flag';
if (file_exists($maintenanceFile)) {
include_once dirname(__FILE__) . '/errors/503.php';
exit;
}
This page cannot even be cached. Re-connect to your FTP server and check for the file in your html directory on the webserver. Alternately, speak with your web hosts & have them remove the file.
As a precaution, you can try deleting your var/cache directory and see if that makes a difference.

How to install or move laravel project on web server

I'm having trouble installing/moving laravel to web server, i downloaded and set laravel on my local linux server but when i moved it to web server ,it shows a blank page.
I uploaded the public folder contents to public_html and other contents outside the public, also i changed the public DIR from paths.php on bootstrap folder as follow: 'public' => __DIR__.'/../public_html/' so what is the exact problem? Please help me with this issue. Is composer a problem? or what?
1) Create a new directory called ‘laravel4′ adjacent to ‘public_html’ so that your remote file structure now looks like this:
[.htpasswds]
[etc]
[laravel4]
[mail]
[public_ftp]
[public_html] etc etc varies depending on server
2) Upload the contents of your local ‘public’ directory to the remote directory ‘public_html’. Note: Be sure not to copy the whole ‘public’ directory, JUST it’s contents.
3) Upload everything else within your local Laravel project to the new remote ‘laravel4′ directory. Check: Now when you view the ‘laravel4′ folder over FTP/SSH/Whatever, you should see all your ‘app’ & ‘bootstrap’ directories along with all the other files and directories, but NOT ‘public’.
4) Edit the remote file ‘public_html/index.php’ and make the following change:
//from:
require __DIR__.'/../bootstrap/autoload.php';
//and
$app = require_once __DIR__.'/../bootstrap/start.php';
//to:
require __DIR__.'/../laravel4/bootstrap/autoload.php';
//and
$app = require_once __DIR__.'/../laravel4/bootstrap/start.php';
5) Edit the remote file ‘laravel4/bootstrap/paths.php’ and make the following change:
//from:
'public' => __DIR__.'/../public',
//to:
'public' => __DIR__.'/../../public_html',
6) That should be it. In my case, that was enough to restructure everything. Routes are working with the default .htaccess file. If you have problems, let me know, or ask on the ever-helpful
Reference: http://myquickfix.co.uk/2013/08/hosting-laravel-4-on-cpanel-type-hosting-public_html/

What are some problems that could cause Magento to redirect to /downloader/ (Installation wizard)

I have a site that has been running fine for awhile. Ran an SVN update after making some changes in the development environment. Now the site keeps redirecting to the Installation Wizard (/downloader/) No matter what I do. Checked and double checked database settings - all seems good. Can anyone tell me what other problems could have this result? I just wish it would give me a freaking error so I could more easily troubleshoot the actual problem.
If you check the index.php file you will see the following...
$mageFilename = 'app/Mage.php';
$maintenanceFile = 'maintenance.flag';
if (!file_exists($mageFilename)) {
if (is_dir('downloader')) {
header("Location: downloader");
} else {
echo $mageFilename." was not found";
}
exit;
}
That is to say, if there is no app/Mage.php file and there is a downloader folder, it will redirect to it.
Check is your app/etc/local.xml file found and readable (644) by the webserver, this should solve the problem.
I deleted both the /var/cache and /var/session directories. It appears to have solved the problem.
wrong permissions may cause that. had this problem when updated magento core while under root, chown to www-data fixed the problem

Resources