How to get name of admin folder in prestashop? - prestashop-1.6

$link= PS_ADMIN_DIR;
$admin_folder = substr(strrchr($link, "\ "), 1);
currently i am using this way to get folder name,
But if there are any direct method or any constant please suggest me..
Thanks

To be a little bit more specific : the name of the admin directory is on the filesystem.
When you access a page of the admin directory, a script puts the current directory's path in the _PS_ADMIN_DIR_ constant.
If you forgot the name of the the admin directory you must have a look at the filesystem of your server.
Admin directories are automatically renamed to something like adminXXXX.
If you named it differently you can compare the default directory structure with your actual structure and find the proper directory.
You can also look for files that are only present in the admin directory. The "get-file-admin.php" file for example.
On linux, the following command run from the prestashop root directory will tell you the actual name of the admin directory :
find ./ -name get-file-admin.php

For security reasons, admin folder name is not stored anywhere in your PrestaShop's files or database, so you have to do something like you do to find it.
However, you should use _PS_ADMIN_DIR_ instead of PS_ADMIN_DIR as the second one is not defined directly by PrestaShop and could be undefined.

Related

Prestashop remove /presta on url

As the title says, I want to remove the /presta from my URL.
I can access it now with domain.com/presta but if I change from Preferences > SEO & URL > Base URL as "/", I can't access the site and if I connect to admin panel it's without GUI, just text.
Seems a little bit confusing.
Thanks in advance, sorry for any newbie mistake I've been working on this the whole day and it's my first try on presta.
i think all Prestashop files are inside a folder named "presta" instead of (for example) the httpdocs folder. Change shop domain and ssl domain to your domain name. Set base uri as / and press save. Now move all Prestashop files from the presta folder to the httpdocs folder. The presta folder should be empty, so you can remove it.
Current situation:
You prestashop files are stored in YOURSTORE/presta/
Request situation:
removing the subfolder /presta/ so people can enter the url YOURSTORE/ to acces your prestashop webshop.
What you must do:
copy all your files inside YOURSTORE/presta/ to YOURSTORE.
remove .htaccess (located here (after step 1): YOURSTORE).
Update your prestashop database: go to table ps_shop_url and change value:
physical_uri -> /presta/
To
physical_uri -> /
You should be able to enter your store now by visiting YOURSTORE.com instead of YOURSTORE.com/presta/

How to get application's root directory?

How do I get application's root directory within an action?
The first thing ZF2 does is to change the current dir via chdir(dirname(__DIR__));
This means that every future include is based off of the ROOT PATH of your application and NOT the public folder. Or any other current folder.
Of course this only holds true for PHP-Files.
If you want to define the root path manually, you'd go to /public/index.php and add a line like define('ROOT_PATH', dirname(__DIR__));
As i said before, for INCLUDES this is NOT required though ;) as you're ALWAYS in the root folder when it comes to PHP-Files ;)
getcwd() works best for me, DIR return the module root. Which isn't much use in this case
#Sam:
I don't really understand your question. Basically the current path equals the ZF2-Apps Root. [...] You can always go up-levels, too via ../
Not exactly. When You create module shared within several applications ex. FileUpload Module in vendor, outside application. You would like to upload file to Application subdirectory not shared module :) In this case __DIR__ equals module path not app path and ../ wouldn,t be good solution ;)
I like ROOT_PATH as You have mentioned:
define('ROOT_PATH', dirname(__DIR__));
or even better:
getcwd()

directory path question

What is the difference between:
include("./somepath/class.php");
and
include("somepath/class.php");
There shouldn't be any difference, directory wise, since the former assumes relative directory structure. The only potential pitfall could be if "somepath" were actually a command to be run - some users expect to type a command for a local script file and assume it should run, when you actually have to run "./somepath" to invoke it. This, of course, only pertains to commands not on your $PATH.
I don't see any difference. "." means current directory.
. refers to the current working directory.
Sometimes you want to specify explicitly that what you want is in the current working directory, and that it is not from something in your path variable for example.
For example in PHP "somepath/somefile" is appended after paths specified in include_dir (for example: /home/var/; /home/bin/ ....) directive.
The second variant is more specific it says: search in current directory!

How do I find a specific entry inside a zipped directory using the rubyzip gem?

I have a zip file named test.zip which contains a directory named invoice. Inside the invoice directory there are documents each with different names. I would like to find a specific document named summary.txt which is inside the invoice directory.
I am able to get a handle to test.zip using the following:
zip = Zip::ZipFile.open("/path/to/test.zip")
but when I use
zip.find_entry("summary.txt")
I get nil.
On the other hand, if summary.txt is not inside the the invoices directory, but rather at the root of the zip file itself, the find_entry method as described above seems to work.
It seems that somehow I must navigate down into the invoices directory before searching for summary.txt.
Is this correct? If so, how do I do it? If not, what I am I doing wrong.
You need to specify the full path to the file:
zip.find_entry 'invoices/summary.txt'

Relative path of a given file from a service application in Delphi

I have a problem loading a file, as I'm passing a relative path to the function FileExists(Filename: String) and it's returning false, that is, it does not find the file in the directory that I pass.
I have a file named Template.html in the D:\Programming\Delphi\Projects\SendMail directory, and a service written in Delphi whose .EXE is in the D:\Programming\Delphi\Automation directory. I am passing the relative path: .\..\Projects\SendMail\Template.html to FileExists(), but it's returning that the file does not exist.
I think that has something to do with the relative path of a service and the relative path of the application being different. Can anybody help me with this?
As lorenzog said, try specifying the full path.
You can also try to set the currentdir to your likings.
//sets currentdir to your application.exe dir
SetCurrentDir(ExtractFileDir(ParamStr(0)));
You assume that the current directory of the service is the directory the executable is stored in. Call GetCurrentDir to find out the current directory.
My experience has been that services start with a working folder of %SystemRoot%\System32 no matter where the actual executable is located.
The way that I have got around this limitation is to write a registry key during installation of the service (e.g. HKLM\SOFTWARE\MyCompany\MyApp\INSTALL_PATH) that points to what I would like the working folder to be. Then when the service starts, it grabs the data from the registry and uses that value as the base when creating paths to files.

Resources