Call to undefined function money_format()

Here’s the reason why it may not work, probably you are having windows platform

“The function money_format() is only defined if the system has strfmon capabilities. For example, Windows does not, somoney_format() is undefined in Windows. ”

found the above statement on php.net

curl not working with https

Today i was facing this issue. I had implement rpxnow for open ID on a website a. which used CURL for xml services.

The implementation was working fine on our server. But when client moved teh code to their server it stopped working.

First i checked that CURL is enabled on their server, but CURL was working perfectly fine for urls like “http://www.google.com”. Then i found that the issue was with the “https” sites.

So this is what solved my issue:

Add the below code to your curl options:

curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 2);

This solved my problem.

Regards,

samsami2u

http://www.avidindiainc.com

xml parser in php

There is a build in function in php using which you can parse xml file to an array. I have an example created for the same, and it goes as mentioned below:

$xmlString = $raw;
$xmlParser = xml_parser_create();
xml_parse_into_struct($xmlParser, $xmlString, $values, $main);
xml_parser_free($xmlParser);

print_r(‘<pre>’);
echo “<b>Main array</b><br>”;
print_r($main);
echo “<br>”;
echo “<b>Values array</b><br>”;
print_r($values);
print_r(‘</pre>’);

Thanks,

Sachin (http://www.avidindiainc.com)

Call to undefined function curl_init()

Most likely curl support is not enabled.

You can check by creating a .php file with a phpinfo(); command in it. Browse to this and search/look for curl on the resulting page. If support is enabled, there will be a listing for it.

If this is with a hosting company, you will need to have them install/enable it. If this is a Windows based system, CURL can be enabled by uncommenting the curl extension line in the php.ini file – extension=php_curl.dll and restarting the web server. If this is Unix/Linux, PHP must be compiled with CURL support and the libcurl library must be installed.

Convert ppt to pdf in php linux

There is an opensource available for converting PowerPoint document (PPT) to Portable Document Format (PDF). And you can find it at http://www.artofsolving.com/opensource/jodconverter.

In this post i will illustrate you how to convert ppt to pdf format and many other formats.

First of all its a java based convertor and converts the following documents.

From (any of) To (any of)
Text Formats
OpenDocument Text (*.odt)
OpenOffice.org 1.0 Text (*.sxw)
Rich Text Format (*.rtf)
Microsoft Word (*.doc)
WordPerfect (*.wpd)
Plain Text (*.txt)
HTML1 (*.html)
Portable Document Format (*.pdf)
OpenDocument Text (*.odt)
OpenOffice.org 1.0 Text (*.sxw)
Rich Text Format (*.rtf)
Microsoft Word (*.doc)
Plain Text (*.txt)
HTML2 (*.html)
MediaWiki wikitext (*.wiki)
Spreadsheet Formats
OpenDocument Spreadsheet (*.ods)
OpenOffice.org 1.0 Spreadsheet (*.sxc)
Microsoft Excel (*.xls)
Comma-Separated Values (*.csv)
Tab-Separated Values (*.tsv)
Portable Document Format (*.pdf)
OpenDocument Spreadsheet (*.ods)
OpenOffice.org 1.0 Spreadsheet (*.sxc)
Microsoft Excel (*.xls)
Comma-Separated Values (*.csv)
Tab-Separated Values (*.tsv)
HTML2 (*.html)
Presentation Formats
OpenDocument Presentation (*.odp)
OpenOffice.org 1.0 Presentation (*.sxi)
Microsoft PowerPoint (*.ppt)
Portable Document Format (*.pdf)
Macromedia Flash (*.swf)
OpenDocument Presentation (*.odp)
OpenOffice.org 1.0 Presentation (*.sxi)
Microsoft PowerPoint (*.ppt)
HTML2 (*.html)
Drawing Formats
OpenDocument Drawing (*.odg) Scalable Vector Graphics (*.svg)
Macromedia Flash (*.swf)

JODConverter can be used in many different ways

  • As a Java library, embedded in your own Java application
  • As a command line tool, possibly invoked from your own scripts
  • As a simple web application: upload your input document, select the desired format and download the converted version
  • As a web service, invoked from your own application written in your favourite language (.NET, PHP, Python, Ruby, …)

JODConverter is open source software released under the terms of the LGPL and can be downloaded from SourceForge.net.

Here I will be illustrating how to make it work on a windows platform as I have still done it on windows platform. If anyone needs to install it on linux platform they can got to http://www.artofsolving.com/opensource/jodconverter/guide for more details.

Firstly you will need following softwares that need to be installed on your system.

  1. A Java runtime environment version 1.4 or higher
  2. OpenOffice.org v2.0.3 or higher; the latest stable version is usually recommended. (StarOffice 8, NeoOffice being based on OpenOffice.org should also work.)
  3. Apache-Tomcat server incase you want to make it work as web application.

Install java runtime environment, open office for windows and apache-tomcat (if you want to run it as web application).

Now if you want to use directly from command line, open command line (Start->Run->cmd) and make open office to listen to the 8100 post through command “soffice –accept=”socket,host=localhost,port=8100;urp;StarOffice.ServiceManager””

Then to convert the documents with command you need to download the following file, unpack and execute the jodconverter-cli-2.2.0.jar JAR with java.

http://sourceforge.net/project/downloading.php?group_id=91849&use_mirror=internode&filename=jodconverter-2.2.1.zip&80467754 if this link doesn’t work please try other mirror.

To convert a single file, go to the directory or the folder you have unpacked the above file, specify input and output files as parameters

java -jar lib/jodconverter-cli-2.2.0.jar document.doc document.pdf

Okay, to make it work as web application please you need to install tomcat-apache. Next download the following file and extract it.

http://sourceforge.net/project/downloading.php?group_id=91849&use_mirror=internode&filename=jodconverter-webapp-2.2.1.zip&68028801 here also if this link doesn’t work, please try other mirror.

Go to the webapps directory/folder of your apache-tomcat installation. In my case its C:\Program Files\Apache Software Foundation\Tomcat 6.0\webapps and copy the files

jodconverter-webapp-2.2.1.war and src directory/folder there, rename jodconverter-webapp-2.2.1.war to converter

now start the apache-tomcat server and run the following link http://localhost:8080/converter/.

also to make listening the port 8100 for openoffice you can do the following.

Creating a Windows Service lets you have an OpenOffice.org instance always running as a service and listening for connections. That’s what you usually want to do on a server machine.

Here’s how to create a Windows Service using the SRVANY utility that you can download for free as part of the Resource Kit. (This was done on an XP SP2, YMMV.)

1.  OpenOffice.org is already installed and started at least once under the current user

2.  Download and install the Windows Server 2003 Resource Kit Tools

3.  Read How To Create a User-Defined Service

4.  Create a service named OpenOfficeUnoServer following the instructions above;

Command Prompt>”C:\Program Files\Windows Resource Kits\Tools\Instsrv.exe” OpenOfficeUnoServer “C:\Program Files\Windows Resource Kits\Tools\Srvany.exe”

This will create some registry keys for a new service called “OpenOfficeUnoServer“.

5.  Modify the registry keys
Open the registry editor (use the start/execute/regedit.exe or regedit32.exe) and locate the following registry key:

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\OpenOfficeUnoServer

Create a subkey named “Parameters” and create two string values (update the paths to your local settings):

  • Application, with a value of  C:\Program Files\OpenOffice.org 2.2\program\soffice.exe (the path of ‘soffice.exe’)
  • AppParameters, with a value of  -headless -accept=socket,port=8100;urp;StarOffice.ServiceManager

6.  From Control Panel / Administrative Tools / Services open the Properties for the new service and change the Log On account to be Local Service which is a more secure option than SYSTEM

7.  If we stop here the service will start but not actually work. That’s because the service runs as a special account and OpenOffice.org will try to show the license agreement dialog as if it was a new user instead of starting the application. To avoid this, you need to edit share\registry\data\org\openoffice\Setup.xcu (it’s an XML file) inside the OpenOffice.org installation directory and replace this bit.

<prop oor:name=”ooSetupInstCompleted”>
<value>false</value>
</prop>
<prop oor:name=”ooSetupShowIntro”>
<value>true</value>
</prop>

with this other one (ideally you should replace the date with the one when you accepted the license)

<prop oor:name=”ooSetupInstCompleted” oor:type=”xs:boolean”>

<value>true</value>

</prop>

<prop oor:name=”LicenseAcceptDate” oor:type=”xs:string”>

<value>2006-07-25T17:34:04</value>

</prop>

<prop oor:name=”FirstStartWizardCompleted” oor:type=”xs:boolean”>

<value>true</value>

</prop>

8.  Start your new service (e.g. from Control Panel / Administrative Tools / Services). You may need to unblock the new service at the firewall level
9.  From a command prompt do
        Command Prompt> netstat -anp tcp

this should show a listening on port 8100. Chances are that the service will only listen on the 127.0.0.1 interface; this means you can only connect from the same machine and it’s good from a security point of view. However, if you want to be able to connect from other machines as well you need to change the accept string to "socket,host=0.0.0.0,port=8100;...." in the AppParameters registry value

2. From Command Prompt

From the command prompt C:\Program Files\OpenOffice.org 2.2\program>

type soffice -accept=”socket,host=<HOST NAME>,port=8100;urp;StarOffice.ServiceManager” and press Enter to start the OpenOffice Service Manager.

eg: C:\Program Files\OpenOffice.org 2.2\program>soffice -accept=”socket,host=<HOST NAME>,port=8100;urp;StarOffice.ServiceManager”

Note: i) The port number can be given according to your preference.

ii) HOST NAME can be either localhost or the ip address