tcpdf not supporting https? - https

when we add to our htaccess file the following lines:
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://www.example.com/$1 [R=301,L]
we receive the following errors:
Warning: getimagesize(/icon/logo_print.jpg): failed to open stream: No such file or directory in /home2/example/public_html/tcpdf/include/tcpdf_images.php on line 171
Warning: imagecreatefromjpeg(/icon/logo_print.jpg): failed to open stream: No such file or directory in /home2/example/public_html/tcpdf/tcpdf.php on line 7039
TCPDF ERROR: [Image] Unable to get the size of the image: /image/1/SB_m.gif
relevant code:
class MYPDF extends FPDI { // extends TCPDF
public function Header() { // Page header
global $dbcmpName;
$html = <<<EOF
<table cellpadding="2" >
<tr>
<td><img src="/icon/logo_print.jpg" alt="$dbcmpName Logo" style="border:none;" /></td>
<td><span class="header1" >$dbcmpName</span>
</td>
</tr>
</table>
EOF;
// output the HTML content:
$this->SetFont('verdana', '', 9);
$this->writeHTML($html, true, false, true, false, '');
}
...
if ( file_exists($_SERVER['DOCUMENT_ROOT'] . '/image/' . $prodFamilly . '/'. $db->f('prd_photo')) ) {
$html .= '
<img src="/image/' . $prodFamilly . '/' . $db->f('prd_photo') . '" alt="' . $imgAlt . '" />
';
}
// output the HTML content:
$pdf->writeHTML($html, true, false, true, false, '');
...
Note: there is a similiar question - TCPDF cache problems when using https
but in this question, they use different way to show the image, without HTML,
and when trying to adapt the proposed answer, I couldnot find the code suggested to change in tcpdf file, probably because we use different version of tcpdf:
// File name : tcpdf.php
// Version : 6.2.13
// Begin : 2002-08-03
// Last Update : 2015-06-18

using tcpdf version 6.2.26 instead of 6.2.13 seems to solve my problem.
They change img URL in version 6.2.25, maybe this is the fix I needed

Related

Unable to open file for reading [ file link ] laravel

I am trying to send a mail to multiple recipients with an attachment of file URL , but while hitting the api in postman it's throwing an error unable to open file for reading [ file link ] , but while I am copying file link and opens in browser it's opening perfectly .
I have checked the file permission also and referred to some of the answers on Stackoverflow but nothing helped me, please help me as soon as possible.
$file_name = 'TimeActivityReport' . "_" . time() . '.pdf';
$storage_path = 'public/TimeActivityReport';
// $storage_path = public_path();
$filePath = $storage_path . '/' . $file_name;
// return $filePath;
$exl = Excel::store(new TimeActivityReportExport($all_total_values,$data,$date_totals), $filePath);
if($exl)
{
$fileurl = asset('storage/TimeActivityReport').'/'.$file_name;
// return $fileurl;
}
// return $fileurl;
return Mail::send([], $emails, function($message)use($fileurl,$emails) {
$message->to($emails,'hello')
->subject('test')
->attach($fileurl,[
'as' => 'checkname.pdf',
'mime' => 'application/pdf'
])
->setBody('check');
});
Try this I tested it on my end and it returned the file
Storage::get('./public/TimeActivityReport/'.$file_name);
You can also test if the file exists using:
Storage::disk('local')->exists('public/TimeActivityReport/'.$file_name);
To attach try:
$fileurl = Storage::path('public/TimeActivityReport/'.$file_name);
resource laravel docs

file_get_contents(): SSL operation failed with code 1. OpenSSL Error messages

In my Laravel project, I am using the laravelgooglemaps api by farhanwazir on my "contact us" page to display a fixed location.
Route for contactus page:
Route::get('/contactus', function () {
$config['center'] = 'California State University, Fullerton';
$config['zoom']='15';
$config['map_height'] = "300px";
$config['map_width'] = "300px";
$config['scrollwheel']= false;
GMaps::initialize($config);
$marker['position'] = 'California State University, Fullerton';
$marker['infowindow_content'] = 'Easywash Centre';
GMaps::add_marker($marker);
$map = GMaps::create_map();
return view('contactus')->with('map', $map); });
In my contactus.blade.php file:
{!! $map['html'] !!}
But sometimes when I load the "contact us" page I get the error:
ErrorException (E_WARNING)
file_get_contents(): SSL operation failed with code 1. OpenSSL Error messages: error:14090086:SSL routines:ssl3_get_server_certificate:certificate verify failed
Can anyone help me understand why I am getting such error and how it can be solved?
Try this:
$arrContextOptions=array(
"ssl"=>array(
"verify_peer"=>false,
"verify_peer_name"=>false,
),
);
file_get_contents($link, false, stream_context_create($arrContextOptions));
Just in case anyone wondering I solved this error by changing https:// to http:// .

Laravel 5.3 response()->download - File(.doc, .docx) becomes unreadable after downloading

Laravel 5.3
When I download a file (.doc, .docx) from my storage folder it becomes unreadable. If I go to the local folder and open the file however it is valid and readable.
I am using the standard download function, using headers and stuff.. Have a look at my code:
$fileNameGenerate = 'example_filename';
$fileArr = [ 'wierd_filename', 'docx' ];
$cvPath = storage_path('app/example_folder/subfolder/wierd_filename.docx');
$headers = array(
'Content-Type: application/' . $fileArr[1],
);
try {
return response()->download($cvPath, $fileNameGenerate . '.' . $fileArr[1], $headers);
} catch (\Exception $e) {
//Error
return redirect()->back()->with('error', trans('locale.file_does_not_exists'));
}
Does anyone know what is wrong here? Thank you!
Update: I removed headers, it doesn't work with or without them.
Here is how the files render in the 2 different cases:
Try this
public function getDownload()
{
//doc file is stored under storagepath/download/info.docx
$file= pathofstorage. "/download/info.docx";
return response()->download($file);
}
I added:
ob_end_clean();
before:
response -> download
and it worked for me.

i18n wants to load an unspecified translation

I'm currently working on an Aurelia project (web framework like Angular2).
I followed the guide on their github account but encountered a problem.
First, the browser returned me this error:
GET http://localhost:9000/src/locale/nl/translation.json?_=1450946571510 404 (Not Found)
Secondly, I'm using two languages in my application: Dutch (nl-BE) and French (fr-BE).
Here is how my folder structure looks like:
src (inside root)
.. locale
..... fr-BE
........ translation.json
..... nl-BE
........ translation.json
Here is what my full main.js file looks like:
import 'bootstrap';
import {I18N} from 'aurelia-i18n';
export function configure(aurelia) {
aurelia.use
.standardConfiguration()
.developmentLogging()
.globalResources('converters/dateFormat')
.plugin('components/index')
.plugin('plugins/index')
.plugin('aurelia-i18n', (instance) => {
instance.setup({
resGetPath: 'src/locale/__lng__/__ns__.json',
lng: 'nl-BE',
attributes: ['t', 'i18n'],
getAsync: true,
sendMissing: false,
fallbackLng: 'fr-BE',
debug: false
});
});
aurelia.start().then(a => a.setRoot());
}
I'm trying to setup a hello world where I have my view and viewmodel set like this:
import {inject} from 'aurelia-framework';
import {I18N} from 'aurelia-i18n';
#inject(I18N)
export class EntryDetails {
constructor(i18n){
this.i18n = i18n;
this.i18n.setLocale('nl-BE').then(() => console.log('test'));
}
}
And my view:
<template>
<span t="hello"></span> <span t="world"></span>
</template>
The problem is not that it's not working. The problem is that I'm getting an error that states my folder nl is missing in my locale folder. But I never specified that anywhere..
That is how i18next resolves translation files.
The lookup order for keys is always:
nl-BE language + country
nl language only
fallback thats defined in options.fallbackLng (en) (string or array of fallback language)
loaded resources:
locale/en/translation.json
locale/nl/translation.json
locale/nl-BE/translation.json
http://i18next.com/translate/#resolve
So you need to have nl/translation.json, even if it is not specified in config. It can be just empty but valid json file with content {}

How to change joomla url suffix

I am using Joomla Sef URLs and its working fine except that i need '.htm' suffix instead of '.html', please help.
currently my URLs appear like :
www.mysite.com/my-page.html
I want it to be like
www.mysite.com/my-page.htm
You will want to use one of the 3rd Party Search Engine Friendly link extensions: http://extensions.joomla.org/extensions/site-management/sef
Here is a patch. Tested on my Joomla 1.5.9 (standard bundled SEF):
Index: includes/router.php
===================================================================
--- includes/router.php (revision 13023)
+++ includes/router.php (working copy)
## -57,8 +57,13 ##
{
if($suffix = pathinfo($path, PATHINFO_EXTENSION))
{
- $path = str_replace('.'.$suffix, '', $path);
- $vars['format'] = $suffix;
+ if ($suffix == 'htm') {
+ $path = str_replace('.'.$suffix, '', $path);
+ $vars['format'] = 'html';
+ } else {
+ $path = str_replace('.'.$suffix, '', $path);
+ $vars['format'] = $suffix;
+ }
}
}
}
## -93,7 +98,8 ##
{
if($format = $uri->getVar('format', 'html'))
{
- $route .= '.'.$format;
+ //$route .= '.'.$format;
+ $route .= '.htm';
$uri->delVar('format');
}
}

Resources