Cant access user object in joomla 3.9.3 - joomla

I built a small website using Joomla 3.4.0./ Wampserver 2.4 on Windows 8.1 Pro.
Now I've upgraded the computer to Windows 10 Pro and Wamp 3.1.7 (64 bit). I've rebuilt the website with latest version of Joomla 3.9.3 from scratch, and its working fine EXCEPT all those custom modules which access the user object. I havent changed anything yet. I'm getting error as below:
( ! ) Warning: require_once(C:/wamp64/www/includes/defines.php): failed to open stream: No such file or directory in C:\wamp64\www\clib\custom\userdnld.php on line 7
Call Stack
#
Time Memory Function Location
1 0.0007 402200 {main}( ) ...\userdnld.php:0
( ! ) Fatal error: require_once(): Failed opening required 'C:/wamp64/www/includes/defines.php' (include_path='.;C:\php\pear') in C:\wamp64\www\clib\custom\userdnld.php on line 7
Call Stack
#
Time Memory Function Location
1 0.0007 402200 {main}( ) ...\userdnld.php:0
My custom module begins with code as under:
<?php
$mf1="";
define( '_JEXEC', 1 );
define( 'DS', DIRECTORY_SEPARATOR );
define( 'JPATH_BASE', $_SERVER[ 'DOCUMENT_ROOT' ] );
require_once( JPATH_BASE . DS . 'includes' . DS . 'defines.php' );
require_once( JPATH_BASE . DS . 'includes' . DS . 'framework.php' );
require_once( JPATH_BASE . DS . 'libraries' . DS . 'joomla' . DS . 'factory.php' );
$mf1 = JFactory::getApplication('site');
date_default_timezone_set("Asia/Calcutta");
$user = JFactory::getUser();
$uname=$user->name;
$uid=$user->id;
$date= JFactory::getDate();
?>
When I'm accessing from localhost, it works as expected, but not when I access from any machine on LAN.

It could be a permissions issue. Try changing permissions of the entire local site to 777 (since you are local this isn't an issue).
chmod -R 777 /your/website/root
Just be sure to secure the site's permissions after testing.

Related

passing image path from storage in Laravel failed

I have stored my images in storage/app/public/images.
and i have done the storage:link.
now i want to get a path for an image that exists in /images and i want to send it with an API.
i do the below to pass it to HTTP::attach():
$path = storage_path('images' . DIRECTORY_SEPARATOR . $new_file);
and then:
$response = Http::attach('new_file', file_get_contents($path))->post('http://localhost/imageresizer/service.php', $sizes);
when i dd($path), everything seems OK and i get the path i expect.
but there's the below error when i log::debug:
file_get_contents(C:\laragon\www\myblog\storage\images\SVoGGKjERVMYxy9qDciAhgOse9kzQsIuvBg64hjE.jpg): failed to open stream: No such file or directory
what's the problem with file_get_contents ?
If your file is in storage/app/public/images, you'll want to use:
$path = storage_path('app/public/images/' . $new_file);
NB the additional 'app/public/'.

TCPDF ERROR joomla virtuemart does not create the invoice

I use joomla 3.9.6, virtuemart 3.4.2, and tcpdf 1.0.7
When i try to view the invoice(pdf) or when i change order status to confirmed i get the TCPDF ERROR: Unable to create output file: \vmorders\invoices\invoice_190522TIXG01.pdf
i already have created the folders vmorders\invoices and gave it the proper permissions. (the site runs locally with wamp)
Php Error log
[22-May-2019 16:11:21 UTC] PHP Warning: fopen(): remote host file access not supported, file://\vmorders\invoices\invoice_190522TIXG01.pdf in C:\wamp64\www\byzantinemusic\libraries\vendor\tecnickcom\tcpdf\include\tcpdf_static.php on line 1854
I think i have found the solution. Edit "libraries\vendor\tecnickcom\tcpdf\include\tcpdf_static.php". At line 1850 remove code
$filename = 'file://'.$filename;
and substitute with this
$absPath = getcwd();
$filename = str_replace("\\administrator","",$absPath) .$filename;
For Virtuemart 3.6.10:
Edit "libraries\vendor\tecnickcom\tcpdf\include\tcpdf_static.php".
At line 1817 remove code:
$filename = 'file://'.$filename;
and replace with:
$filename = $filename;
$absPath = getcwd();
$filename = str_replace("\\administrator","",$absPath)."/".$filename;

Make directory inside directory Laravel 5.4

I am trying to make a directory inside a directory using the following code:
Storage::makeDirectory('app/public' . $data['code'] . '/' . 'themes', true);
So the structure will be :
Folder 1 :
app/public/123
Folder 2:
app/public/123/themes
I have been trying for the last 2 hours. I hope somebody can help. Thanks !
You can create the directories recursively by calling makeDirectory() method
overFile` object
$result = File::makeDirectory('/path/to/directory', 0775, true);
In Your case, To create the themes directory inside storage directory
Storage::makeDirectory('themes', 0775, true);
To create a file inside the public directory
$result=File::makeDirectory('app/public/' . $data['code'] . '/' . 'themes',0755, true);
dd($result);
The problem was the path structure.
The following code worked :
Storage::makeDirectory('public/' . $data['code'] . '/' . 'themes');
In your app check what the path given in config/filesystem.php on line 44. So when you trying to create directory or a file check the storage directory

How to clear user cache in APCu?

I have tried to clear the user cache using this PHP code and access it from the browser:
<?php
apc_clear_cache();
apc_clear_cache('user');
apc_clear_cache('opcode');
echo json_encode(array(
'success' => true,
));
but it doesn't work.
(I am using these tools to see if it's working or not https://rtcamp.com/tutorials/php/zend-opcache/ )
Also when the user cache gets full, it doesn't restart from 0. The APCu just stops working.
I have tried to set apc.user_ttl=0, but APCu doesn't recognize it.
My settings are:
extension=apcu.so
apc.enabled=1
apc.shm_size=10240M
apc.ttl=7200
apc.enable_cli=1
apc.gc_ttl=3600
apc.entries_hint=4096
apc.slam_defense=0
apc.enable_cli = 1
apc.user_ttl=0
apc.serializer=igbinary
<?php
if (extension_loaded('apc')) {
echo "APC-User cache: " . apc_clear_cache('user') . "\n";
echo "APC-System cache: " . apc_clear_cache() . "\n";
}
if (extension_loaded('apcu')) {
echo "APCu cache: " . apcu_clear_cache() . "\n";
}
if (function_exists('opcache_reset')) {
// Clear it twice to avoid some internal issues...
opcache_reset();
opcache_reset();
}
The tool you are using is for Opcache, it doesn't know about APCu.
The script you need to look at the status of APCu is:
PHP 7: https://github.com/krakjoe/apcu/blob/master/apc.php
PHP 5: https://github.com/krakjoe/apcu/blob/PHP5/apc.php
If you believe you have found a bug, please report it on github.

Using Laravel core in scripts built without it

I have built a Laravel 3 application, it involves a lot of per-user content management.
For prototype and internal testing I got away with plain configuration of KCFinder, now we're about to start a closed beta.
Firstly, I must lock the KCFinder behind Laravel applications Auth system.
Secondly, I must configure the KCF with a per-user settings.
While it may seem like those are two questions, I doubt they are.
My Laravel is installed in /srv/http/, KCFinder in /srv/http/public/php/kcfinder/.
KCFinder exposes two incoming files - browse.php and upload.php. These files include core/autoload.php, that ultimately ties the KCF together.
I tried requiring Laravel's public/index.php inside it, then tried to access something KCF (/php/kcfinder/browse.php) through browser. Got redirected to a mix of the request path and Laravel applications root route: /php/kcfinder/browser.
How could I prevent the Routing from Laravel and be able to use Laravel inside the KCF scope?
P.S. I did try to go the Bundle way, but apparently KCF is so poorly written that it appears that in order to Bundle it up, I'll have to rewrite everything there.
I managed to do it with a very, very dirty hack.
In /srv/http/public/php/kcfinder/core/autoload.php I appended the lines:
require '../../../paths.php';
require path('sys').'core.php';
\Laravel\Bundle::start(DEFAULT_BUNDLE);
$KCFinderRoot = addslashes(realpath(dirname(__FILE__). '/../') . DS);
\Laravel\Autoloader::map(array(
'browser' => $KCFinderRoot . 'core/browser.php',
'uploader' => $KCFinderRoot . 'core/uploader.php',
'type_img' => $KCFinderRoot . 'core/types/type_img.php',
'type_mime' => $KCFinderRoot . 'core/types/type_mime.php',
'gd' => $KCFinderRoot . 'lib/class_gd.php',
'input' => $KCFinderRoot . 'lib/class_input.php',
'zipFolder' => $KCFinderRoot . 'lib/class_zipFolder.php',
'dir' => $KCFinderRoot . 'lib/helper_dir.php',
'file' => $KCFinderRoot . 'lib/helper_file.php',
'httpCache' => $KCFinderRoot . 'lib/helper_httpCache.php',
'path' => $KCFinderRoot . 'lib/helper_path.php',
'text' => $KCFinderRoot . 'lib/helper_text.php',
));
if (!\Laravel\Auth::check())
{
die('no user :(');
}
Wherever KCF had some file inclusions, I had to squeeze in $KCFinderRoot, in some methods even requiring to global them before.
In KCF's config I added:
// ...
'uploadURL' => "/useruploads/" . sha1(Auth::user()->id . Auth::user()->email),
'uploadDir' => path('public') . "useruploads/" . sha1(Auth::user()->id . Auth::user()->email),
// ...
The end result works like I wanted it to, except I have no idea how "smart" this is.
P.S. In the following days I'm going to try to bundle, IoC this up while leaving KCF files intact.

Resources