How to create and set content type in Vcard generate file in PHP - vcf-vcard

I have been working to generate vcard file in php just simple way.
my code like following :
header('Content-Type: text/x-vcard;charset=utf-8;');
header('Content-Disposition: inline; filename= "'.$file.'"');
header("Pragma: no-cache");
and generated file is something like this:
BEGIN:VCARD
FN:Elke Schöne;
ADR;INTL;HOME:;;;Leipziger Straße 3;Markranstädt;04420;
EMAIL;INTERNET:praxis.elkeschoene#t-online.de
TEL;FAX;HOME:+49 34205 83980
TEL;HOME:+49 34205 88249
URL;WORK:www.praxis-schoene.de
REV:20161207
END:VCARD
But when i open this file in Windows Contact then name "Schöne" is not encoded and display with special character, but it works fine in Thunderbird contact.
can anybody help me..

You can add the charset:
FN;CHARSET=Windows-1252:Elke Schöne
The semi colon at the end of the lines is not needed on vcard.

Related

How to access pdf file outside of public_html in joomla site?

Actually i want to edit a module to fetch PDF file outside from public_html.
I already tried to change permission of that file from which i want to fetch PDF to 777.
I am trying to fetch PDF by following codes
$baseurl = JURI::base();
$outside_baseurl = $baseurl.'../pdf/name.pdf';
Shows this error
Cannot access file!
https://mysitedomain.com/../pdf/name.pdf
It's really not safe to access a file outside the scope of your public folder in the open like that. It has the potential to open serious security holes. If you are trying to do this to modify or use the PDF file for something inside PHP, you should be able to. If you are trying to send it to a user for download or preview, you might wanna try fpassthru(). Something like the example below.
<?php
$path = 'path/to/file.pdf';
$public_name = basename($path);
$finfo = finfo_open(FILEINFO_MIME_TYPE);
$mime_type = finfo_file($finfo, $path);
header("Content-Disposition: attachment; filename=$public_name;");
header("Content-Type: $mime_type");
header('Content-Length: ' . filesize($path));
$fop = fopen($path, 'rb');
fpassthru($fop);
exit;
This should serve your purpose.

SoapUI Auth Header with special characters

I am using SoapUI and encountered that if I add umlauts into the password, it does not work as expected.
Here is an example: Lets assume as username "täst" and as password "!23Öüok". SoapUI will create the following Base64 encoded String: "Authorization: Basic dD9zdDohMjM/P29r[\r][\n]". Decoding "dD9zdDohMjM/P29r" will result into this "t?st:!23??ok".
Is there any SoapUI specific setting or anything that I am missing? I think the Base64 encoded String should be like this: "dMOkc3Q6ITIzw5bDvG9r"
I believe that you need to have have encoding as UTF-8 in order to see the desired value.
Go to SOAPUI_HOME/bin
Have a backup of soapui.bat file
Close soapui tool if it is running
Open soapui.bat in a text editor of your choice
Find line set JAVA_OPTS=%JAVA_OPTS% -Dsoapui.ext.libraries="%SOAPUI_HOME%ext"
Add below line after the above line
set JAVA_OPTS=%JAVA_OPTS% -Dfile.encoding=UTF-8
Save the file
Restart soapui, make sure that is reflected in System Properties
This should help you to see the desired output.
Note that if you are using testrunner.bat to execute the tests, incorporate the above suggested change into this file as well.

nodejs npm libraries to access and modify microsoft word documents

Do you know if it is possible to search specific text like "xAx" into a Microsoft Word file (.doc or .docx) hosted on a website, replace it with some other text input by the user and make the file available for download using nodejs?
Is there a npm library that can do that?
If not it is possible to manipulate a PDF file instead? Please note that I do not want to create the document but manipulate a template file in the server.
Thank you for your help.
There is project https://github.com/open-xml-templating/docxtemplater which serves for replacing {placeholders} in a .docx files.
Also supports loops and images, check out demo (examples) on http://javascript-ninja.fr/docxtemplater/v1/examples/demo.html
If odt is an option (these files are open directly by MS Word besides Open and Libre Office and can be set with extension .doc so end users do not freak out) you can use HTML52PDF.
For example something like the following code will replace a string of text by a link:
require_once 'path/to/CreateDocument.inc';
$doc = new Html52pdf\createDocument(array('template' => 'template.odt'));
$format = '.odt';//.pdf, .doc, .docx, .odt, .rtf
//replace natural text
$doc->replace(array('replace me, please' => array('value' => 'external link')), array('format' => array('','')));
$doc->render('replaced_content' . $format);

PHPMailer giving rtf file .txt extension

First time using PHPMailer within Yii and i've got the files to attach fine in email form using .doc, .rtf and .txt. I then tried to add the optional name to the file rather than the uploaded name and my rtf file was sent as a .txt file. Not sure why? Wondered if anyone could point me int he right direction.
$mail = new YiiMailer();
//$mail->clearLayout();//if layout is already set in config
$mail->setFrom('email#example.com', 'Me!');
$mail->setTo(Yii::app()->params['adminEmail']);
$mail->setSubject('Mail subject');
$mail->setBody('Simple message');
$mail->AddAttachment($dest . '/' . $file->tmp_name . '.' .$file->extension, $file->name);
Thanks in advance
Jonnny
Seems that if I pass all the arguments to the AddAttachment() it sends the RTF as a .doc file.
$mail->AddAttachment($dest . '/' . $file->tmp_name . '.' .$file->extension, $file->name, 'base64', $file->mime_type);
Jonnny

php using "Content-Disposition:attachment; and Content-type:application/octet stream, gives "/n"

$file_name="test.key"; $key="1111111";
header("Content-disposition: attachment; filename=$file_name");
header("Content-type: application/octet-stream"); echo trim($key);
the above listed is my piece of code but when this is called, when opening the document, I am having to new lines before "11111111".
May I know, how to avoid new line space, is this an issue or am I using wrong headers,
Here the scenario is I'll get the key from the database and give that key as a download option.
Thanks in advance