Wednesday, January 30, 2008

Warning: I am able to write to the configuration file: Windows, Helm, Zen Cart/OS Commerce, and File Properties

Ok, so I am not too proud to admit that I am moving from a linux box to a Windows environment for many of my projects. Suffice it to say that it was not originally my idea and it ends up being a complex situation of cost and performance. In my defense, the windows hosting that I am using has newer versions of php and mysql and is a clustered, load balanced system as opposed to the single linux box. I was kicked off the linux box for having too many domains and taking up too much processing power, but that is another post I will make later.

In any case, I was porting over my Zen Cart installations to the windows environment. And everything went fairly smooth until I ran into the
"Warning: I am able to write to the configuration file:"

As I did research, i found this was supposed to be an easy fix of setting the file permissions to 644 or 444. Well low and behold, this was actually not that easy in my situation: I tried to set these permissions through dreamweaver, filezilla ftp, and then even through the IE Ftp interface... and still no luck. I went in through helm and tried to use the file manager, but it does not allow for setting file permissions.

I ended up putting in a ticket to my hosting company to see if they can help. Apparently all you need to do is look at the file from the OS, right click on it and then set to read only- and voila you should be fine. Well, I realized I did not want to have to rely on my hosting company for changes to these files every single time I want to update or change configuration (which would not be often, but I have a few other installations of zen cart I wanted to do on this server).

As I was waiting for response, I came up with the idea to try to set the file permissions through php or asp. I set out on a quest and found some code which I altered ever so slightly to get to work on my system... Here it is. Just make a setfilepermissions.asp page on your server. This page will just do one thing and this is to set the filepermissions to readonly. You will have to alter the code to make it dynamic or set the file back from read-only.

If you do add or change it, please post it here. Thanks!


......................................


response.write "i am in here"


Dim strSaveFilename
'As String

Dim scrFSO
'As Object 'Scripting.FileSystemObject
Dim scrFile
'As Object 'Scripting.File

'i used absolute path which worked for me
strSaveFilename = "c:\domains\your domain here\wwwroot\includes\configure.php"


' Set up Scripting variables
Set scrFSO = CreateObject("Scripting.FileSystemObject")
Set scrFile = scrFSO.GetFile(strSaveFilename)

' Set file to be read-only
scrFile.Attributes = 1 'ReadOnly

' De-reference variables
Set scrFSO = Nothing
Set scrFile = Nothing

response.write "
done setting permissions!"

Labels: , , , , , , , , , , ,

Saturday, January 12, 2008

Opera 8.65 on Windows Mobile 6 on Samsung i760

I just recently got my Samsung i760. This is my first smartphone and I am so happy to finally be a part of the convergence revolution. I have one device which allows me texting capabilities, instant messaging, web browsing, digital camera, games, and even music. Although it can be a little difficult to do everything you can do on a laptop, I am also able use remote desktop and logmein.com to control other computers and servers. This was part of my rationale for going with Samsung smartphone versus the Apple iPhone. Well, I guess I should also mention that I had a 100 credit to upgrade my phone from Verizon along with a 50 rebate and another 100 discount for signing up for the wireless broadband plan. In the end, it was a great deal that I could not pass up.

Well so I realized very quickly that windows mobile internet explorer has some severe limitations as far as what I am accustomed to on my desktop. Which I probably should not complain about since a few years ago it was a stretch to have internet browsing on your phone.

In any case, I did some research and found minimo (zilla) as an option for my phone with tabbed browsing and perhaps some other nice little features. Well it turns out Minimo didn't like my phone too much and the number of error reports generated was a bit disconcerting so I kept looking. I am sure that they will work them out, but I was looking for something more stable

Labels: , , , , , ,

My New Photography Site

I decided last night to start creating a site for my photography. I have been taking photographs regularly for about 10 years now. I have took several courses while I was in High School at Ransom Everglades and again in College where I was at University of Pennsylvania.

Mauricio Zuniga's Photography Site is just a small spot where you can browse through the various photographs that I have taken. The site is built from scratch except I used the help of phpFlickr as the starting point. As I keep working on the site and I will update with how I accomplished my own Php Flickr Gallery.

Thank you for looking

Labels: , , , , , ,

Email Elements on Web Page - AJAX Solution

So yesterday I had to quickly come up with a solution to send out an email of a web page that was already rendered. I could go back through all the php server side code and try to hold all of the information in a cache variable that would then also email out the rendered html. This provided me with many complications and issues as I would then have scope to worry about in certain situations and some of the functions had been expressly written to spit out html as they run.

If you have read this far, then you understand the plight..
I came up with the following solution: I decided to try and create an AJAX solution. This is what I did:

Create a div container in your html. This Div Container should encompass everything yould like to appear in your email.


<DIV id="Email">

INSERT YOUR HTML IN HERE

<DIV>


now before this Div element, you will need to declare a form. Here you can declare where your destination ajax call ill be (ajaxsendemail.php), what to call on submit. We are disabling submit via html via return false. You can also see from this code that we have a button which will trigger the call to send the email.



<form id="emailForm" name="emailForm" method="post" action="ajaxsendemail.php" onsubmit="sendEmail(); return false;">

<input name="Send Email" type="button" value="Send Email" id="Send Email" onclick="sendEmail();"/>

<input type="text" name="to" id="to" value="recipient@email.com"/>

<input type="text" name="subject" id="subject" value="Email" />

<textarea>


<DIV id=/"Email">

INSERT YOUR HTML IN HERE

</DIV>


</form>



What you will need to know now is that we will be taking the html contents in the div container we created, then via ajax, we will send this html code through a post method to a php script which will then send the email to your desired destination. Please note that you will need the zxml javascript library:
Which the latest version that I have is here: zxml.js. Please be sure to check (and let me know) if there is an updated version.

So first, we will need to include some javascript on our page, preferably before the div container.

<script type="text/javascript" src="zxml.js"></script>

<script type="text/javascript" >



function sendEmail(){



var oForm = document.emailForm;

var sBody = getRequestBody(oForm);



var oXmlHttp = zXmlHttp.createRequest();

//alert(sBody);

oXmlHttp.open("post", oForm.action, true);

oXmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");

oXmlHttp.onreadystatechange = function () {

if (oXmlHttp.readyState == 4) {

if (oXmlHttp.status == 200) {

//saveResult(oXmlHttp.responseText);

alert(oXmlHttp.responseText);

} else {

saveResult("An error occurred: " + oXmlHttp.statusText);

alert('error code');



}

}

};

oXmlHttp.send(sBody);

}



function getRequestBody(oForm) {

var aParams = new Array();



for (var i=0 ; i < oForm.elements.length; i++) {

var sParam = encodeURIComponent(oForm.elements[i].name);

sParam += "=";

sParam += encodeURIComponent(oForm.elements[i].value);

aParams.push(sParam);

}

//email body

var sParam = encodeURIComponent('emailBody');

sParam += "=";

sParam += encodeURIComponent(document.getElementById("Email").innerHTML);

aParams.push(sParam);



return aParams.join("&");

}

</script>



Simply speaking, getRequestBody() takes all the form elements that you have made and then creates a Post Body request. In here I have added a bit of code which simply takes the div element (called Email) and creates another Post Variable from this element. You could do this for multiple elements in your document. The send email, instantiates the ajax transport method and calls the getRequestBody to create the post body, which is sent in the command oXmlHttp.send(sBody); . I simply created an alert to let you know what happened with the Ajax call (was the email successful?).

Now we have to take a look at the php code which handles the actual email.
ajaxsendemail.php

<?php

$to = $_POST['to'];

$subject = $_POST['subject'];

$body = '<style type="text/css">

<!--

body,td,th {

font-family: Arial, Helvetica, sans-serif;

}

-->

</style>'.stripslashes($_POST['emailBody']);

$headers = 'MIME-Version: 1.0' . "\r\n";

$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";

$headers .= 'From: Orders@NitroPrint.com <Orders@NitroPrint.com>' . "\r\n";


if (mail($to, $subject, $body, $headers)) {

echo("Message successfully sent!");

} else {

echo("Message delivery failed...");

}

?>




that pretty much takes care of it... I hope you will find this useful. If you have the time, please click through one of our fine sponsors.
In addition, if you have any difficulties or suggestions, please let me know.

Labels: , , , , , ,

#1 on Google


I am happy to report that this week, after hard work and some fairly inventive programming, we were able to take South Wind from #8 on Google to #1. I will not give away too much, but this was a great accomplishment for Ceiling-Fans.biz and myself. We had been bouncing around from #3 to #8, but the index placed us at #1 this week for ceiling fans.

So how did we accomplish this? I cannot tell you, but there are no black-hat approaches. So this is proof that if ou use ethical and fair methods, you can get the #1 on Google, #1 on MSN, and top 3 on Yahoo.

I cannot take all the credit for this myself: there has been a lot of work and effort taken to ensure that we are #1. But if you are new to Search Engine Optimization be sure to use these tips:

1) Create legitimate content - don't try to fool the engines.
Even if you can figure out how to fool the engines, this won't last long. Eventually this will catch up with you. Algorithms are updated often and if you are using a 'black hat' approach, your relevance will drop.

If you have good articles and content, you will bring users back and create a resource that will benefit users and the search engines when they link to you.

2) Use legitimate linking strategies.
A link on the internet is a vote on a search engine. These votes have different weight though. If you have a vote (a link) from an Authority site, this will benefit you much more than a random link from a link farm. For instance, if WebMd.com links to your Independent Doctor's Office Web Page, this link will have more weight than one coming from abcdwebspacelinks.tripod.com.

The more inbound and relevant links, the better.

You might know all this already... but did you know this?
3) Make your Url's friendly for users and search engines. Always try to put relevant information in your Url's.

For instance, for our new site, we were sure to include the function of what the page does such as SaveOnAtoZ.com/ComparePrices.php?keywords=Apple Iphone. For A Contact Us page, use ContactUs.html or Contact-Us.html. By the way, you can always use a dash, this is usually represented or treated as a space by the search engines.

for Nitroprint, we made the flyers page named Flyers.php. Although this might come as no surprise, you would be surprised how many times I have seen pages that are just called form, product, something generic, or an abbreviation (avoid abbreviations in your filenames such as CPrices for Compare Prices, etc). The url is another opportunity to tell the search engine (and the user) what is on that page. Be sure to use this to its best effect.

4) Use More Text / less Javascript/Flex/Flash
Although Ajax, Flex, and new web 2.0 technologies are the rage, don't forget about the basics. If a search engine cannot read your page, then it will not be indexed properly. These technologies are rarely handled properly by search engine spiders, so use them for advanced or secondary functionality.

In summary, you can use these basic principles to get you to your top 10 search engine placement. Start exchanging links with relevant sites and creating a good site people will want to visit. Keep track of your results with a tool such as statcounter.com. With some patience and tenacity, you will be able to rise in page rank and get that top 10 placing.


Mauricio
If you would like to hire me for your web project, you may find me here: www.CustomInternetSoftwareDevelopment.com

server crash!!

So I run a few different websites with a few different companies. I have been buying up web domains or what I'd like to call virtual estate. But that is neither here nor there really... as I would like to be spending my time doing research on great domain names to buy up. Unfortunately at about 4:00 am I was going up to bed after a long night of watching bad movies and configuring domains. I noticed something was wrong with the server. I tried to login remotely and no dice... This is my personal server, where I do most of my development and host a few smaller sites. Luckily the financial impact is somewhat minimal at this point, but the frustration has taken it out of me.

As it turned out the server was toast, something happened to the boot sector and the OS, which had been suffering from another semi crash a few weeks ago, had decided to give way. It took me quite a long time to fix it as I was actually gullible enough to believe that I would be to able to repair the os properly. Well, I ended up re-installing SBS2k3... and now as I think back, I would recommend that if at all possible, go with Windows Server Standard Edition 2k3. Too much overhead with what I have deemed useless gadgets and services that are great for a small to midsize company, but not ideal if all you want to do is host a website and SQL Server. Why did I sign up for SBS then? It was a deal with the server.

So the quick lesson... code in php, use XAMP ;).

Just kidding - that's my preference, but I have a few clients that work with SQL Server/MSDE (and a few legacy systems I developed in classic ASP) - so that's not really a choice.

Anyhow, with all the frustration and and work to completely reinstall I came up with a few tips that might help - especially if you are trying to salvage your data:

- try to install a new os on a different partition. Do not create a new partition at this point. It is possible, but not likely you will succeed in creating a new partition AND save all your data. Didn't you make multiple partitions when you installed the system? Oh.. well, this is a good reason why you might want to do that.

- if you do not have a new partition to work on, or you really want to try to repair your system, try to the system repair with windows. Take out your cd-rom, insert it and boot with it. Do not press f2 on load up for the automated system restore... you will have to let the blue screen load until it prompts you if you want to (R)epair. You wan to try to repair your system (keep your eye on the screen).

This will overwrite all your major system files and try to restore your system from initial installation. If this is successful, you might get your system to boot, but you will then have to reapply pretty much all patches, service packs, and perhaps reinstall several applications.

I am no expert , more of a crazy mad scientist, so don't blame me if you mess your system up even further.

- upon finally loading the system, I was able to reinstall SQL server. If you know this trick, move on. But you can always go to databases, right click on databases- and choose the actino "attach database" file directly from enterprise manager. The system will prompt you for the location of hte data files. You can take the databases from your crashed os, and just attach them again. Although if you have sustained system damage, you might want to consider moving the files to a clean location.

- if you have mysql as well... also on the server... you can take the datafiles folder and copy and paste all those datafiles into your new mysql datafiles folder. Mysql Admin should recognize them the next time it checks the folder.

This saved me quite a bit of time as to how I was going to get the latest data from the databases since my db backups were not as current as they could have been.

- I was also able to reinstall FTPZilla Server to the same exact folder it was installed in previously, and this saved me from having to reconfigure.

- also had quite a bit of trouble getting php to work. I had it previously downloaded and tried to use the files I had previously. I took the latest version from Php.net and it worked fine. Normally, I like to archive versions I have worked with in the past for easy installation and recovery such as this case. Pros: For the installation of MySql, this was really handy. I tried searching online, and I am not sure what MySQL is doing, but they are making it seem harder and harder to find the open source free versions. After looking on my archive drive, I got it installed in 2 minutes. On the other hand, Sometimes trying to use older versions doesn't work in your favor to save time, as in the case of PHP.

- Now I'm running all sorts of checks, defrags, and drive analyses... but the server is back up and running. Hoping for a better Day tomorrow.

Labels: , , , , , , , , ,

Can't See Database Tables in Dreamweaver?

This took me a really long time to figure out. For some reason I couldn't see the tables in an asp/sql server setup that I had in dreamweaver.

I prefer to use ftp connections in dreamweaver, but I know you probably shouldn't. What you have to do is make sure that you are connected within the same network. Cross network connections via sql server are not as likely to work. I had my sql server for development set up on another network as I had some sites hosted on that server and my roommate likes to play wow. So I decided to get a second connection. But that is neither here nor there... make sure the computer is connected to the same network and save yourself the trouble of trying to figure out which ports are open and closed.

Then create a new ftp connection.

Where you set your HostDirectory and URLPrefix are Very important for these kinds of setups. Your HostDirectory should point to the exact root web directory. For instance if you connect to your host and then there is an html folder, you probably want to enter "/html/" in your HostDirectory setting.

Then, make sure that your url prefix matches up to where you can access the website: http://192.168.2.21

If these two match up to the correct locations, then you should now be able to see the tables in dreamweaver. The reason is that dreamweaver places some scripts in your root folder as well as the connection files. It uses those files to then communicate with the sql server connection and then send you back the information to your interface. If dreamweaver cannot talk to these scripts, you will not be able to see the tables in your database.

Hope this saves you some time! Thanks for reading ... now please click on a google ad :)

Labels: , , , , , ,

Nusoap php class and Godaddy.com hosting - CURL Settings!

I spent way too many hours trying to figure out how to get nusoap class to work on one of my godaddy accounts. It is actualy fairly simple, but not all too clear at first. It ends up being that nusoap.php classes are dependent on curl. Although curl is in fact instated on Godaddy, it isn't clear at first that you will need a proxy in order to get curl to work for you. If you start searching deep in the godaddy help, you will find examples on how to use curl, but it wasn't obvious (to me at least) that

in most cases, all you need to do is add this bit of code.

curl_setopt ($ch, CURLOPT_PROXYTYPE, CURLPROXY_HTTP);
curl_setopt ($ch, CURLOPT_PROXY,"http://proxy.shr.secureserver.net:3128");


this is a full example using curl
$URL="https://www.paypal.com";
if (isset($_GET["site"])) { $URL = $_GET["site"]; }
$ch = curl_init();
echo "URL = $URL
\n";
curl_setopt($ch, CURLOPT_VERBOSE, 1);
//curl_setopt ($ch, CURLOPT_HTTPPROXYTUNNEL, TRUE);
curl_setopt ($ch, CURLOPT_PROXYTYPE, CURLPROXY_HTTP);
curl_setopt ($ch, CURLOPT_PROXY,"http://proxy.shr.secureserver.net:3128");
curl_setopt ($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt ($ch, CURLOPT_URL, $URL);
curl_setopt ($ch, CURLOPT_TIMEOUT, 120);
$result = curl_exec ($ch);
echo "

\n";
echo 'Errors: ' . curl_errno($ch) . ' ' . curl_error($ch) . '

';
echo "

\n";
curl_close ($ch);
print "result - $result";
echo "

\n";


now to get nusoap working...
go into nusoap.php
search for curl in text

you will find where curl options are set in this document,
just add the two lines of code

curl_setopt ($ch, CURLOPT_PROXYTYPE, CURLPROXY_HTTP);
curl_setopt ($ch, CURLOPT_PROXY,"http://proxy.shr.secureserver.net:3128");

now nusoap class show work for you on godaddy.com. Hope it saves you a few hours. Now please be kind and visit http://www.ChaoSearch.com comparison engine or at least click a google ad :).

Labels: , , , , , , ,

Crossbrowser Show/Hide Div Tag

i had a lot of difficulty to get some code I found to work on both ie and firefox.

After a bit of testing and debugging I found that certain css attributes were not working properly in firefox. Not sure if the attributes were not standard - im no css expert, but be careful on whether you use the display property or the visibility property. It seems that Firefox seems to prefer the visibility property. .


this is the javascript i ended up with to show and hide a div tag (and css properties on the div).


Again be sure you are using visibility tag. Others may have been able to work with css display property... but this worked for me.


function ShowContent(d) {


if (document.getElementById) { // DOM3 = IE5, NS6

document.getElementById(d).style.visibility = "";

} else {

if (document.layers) { // Netscape 4

document.d.visibility= "";

} else { // IE 4

document.all.d.style.visibility = "";

}

}


//if(d.length < 1) { return; }

//document.getElementById(d).style.visibility = "";

}


 


function HideContent(d) {

document.getElementById(d).style.visibility = "hidden";

//alert(d);

if (document.getElementById) { // DOM3 = IE5, NS6

document.getElementById(d).style.visibility = "hidden";

} else {

if (document.layers) { // Netscape 4

document.d.visibility= "hidden";

} else { // IE 4

document.all.d.style.visibility = "hidden";

}

}


//if(d.length < 1) { return; }


}


now for the div tag


<div id="dynamicDiv" style="visibility:hidden; position:absolute; background-color: white;" >

insert your content in here

</div>


then just call the HideContent('dynamicDiv') and ShowContent('dynamicDiv') from click event or create an href link like so:


<a href="javascript:ShowContent('dynamicDiv')">Show The Div</a>


<a href="javascript:HideContent('dynamicDiv')">Hide The Div</a>


hope that helps!

Mz

Labels: , , , , , ,

SQL Server MSDE Separate Instance ASP.NET & DSN Connections

Today I ran into an issue where I had a bit of difficulty connecting ASP.net to SQL Server MSDE Named Instance. The problem is that the website previously did not need to specify a named instance of MSDE/SQL Server. I was able to address the connection over asp rather easily, but there was a bit of development already done in ASP.NET and I was not very familiar with the ASP.NET setup.

A little bit of background on myself... I'm a newbie to .NET, but I am always willing to learn. I've been coding in VBscript (ASP), SQL, PHP, XML/HTML, and Javascript for quite some time. I've even had the opportunity to work on some actionscript / flex projects incorporating calls between dhtml and simple flex applications. So you may laugh at how basic this little bit of info is, or (I hope) you may actually find a useful tidbit of knowledge.

I had been handed over a web site from a previous programmer/software company and I had to figure out a way to deploy the website rather quickly. We went with a Dedicated Machine on Win2k3 Web Edition. I knew that a lot of the other O/S I ran in the past had issues with too many unneeded services (Win2k3 SBS I'm looking at you!). So to help client keep costs low and through previous experience (and knowledge about web traffic) and requirements of site, I decided that using MSDE would be a sufficient solution for the database.

I am familiar with SQL Server Enterprise Manager and SQL Server Query Tool. In using MSDE, I didn't think through that I wouldn't have a GUI if I used MSDE. This lead me through the maze of what is IT and Dev...

So yeah, I called some friends and apparently you can run MSDE and just install SQL Server Tools on a machine to get GUI access. Lucky for my client (and me), I have a legitimate copy of SQL Server I bought for my business. But here's the kicker... Web Edition 2k3 doesn't allow you (due to its licensing) to install SQL Server on the same machine. So now I was back to square one. Eventually I figured out how to use SQL Server 2005 Express Edition to serve as the gui for the MSDE DB I had already created. Don't ask me why, but I didn't feel like porting over to a new instance of 2005 by this point.

Guess what though... you cannot import (at least I haven't figure out yet) data the same way you can with Enterprise Manager. The functionality is significantly limited from Enterprise Manager for importing and exporting data. I have tried to connect to MSDE Instance via tcp ip, but I think my isp seems to be blocking port 1433/1434 udp... but that is a topic for another post I suppose.

so the basics...
1) check web.config file where you have the dsn / application connection string stored. It seemed that ASP.NET was not connecting. After a bit of debugging I realized that it should be connecting to a different instance of SQL Server.

2) in the web config - this can also be edited through IIS - ASP.NET tab...

previously looked something like this:
add key= "DSN16" value="server=LOCALHOST;database=DBNAME;uid=sa;pwd=XC123XC123x;"/

3) Now change it to
add key= "DSN16" value="Server=COMPUTERNAME\INSTANCENAME;Database=DBNAME;uid=sqlserverlogin;pwd=XC123XC123x;"/

One thing I would recommend is that you try to login with SQL Server only credentials when you are logging in through Enterprise Manager or SQL Server Manager 2005. It took me a long time to figure this out, but if you know that you can login with the SQL Server only credentials, they should hypothetically work when ASP.NET is using these credentials to talk to SQL Server.

Oh yeah, another thing is that I had to look up on SQL Server properties to give me a clue to use COMPUTERNAME\INSTANCENAME. Since I had to figure it out on my own and I couldn't find the info online ... I did find about connections with named instances, but without realizing that the credentials i was using weren't SQL server credentials... well it was useless. until I switched to SQL server only credentials, then it worked.

hope this helps and saves you a bit of time. Now please click on a google ad.
thanks,
Mauricio

Labels: , , , , , , , ,

My Current Web Project : Mashup Galore on SAVEonAtoZ.com

Look through multiple search engines, price comparison Engines, and other resources we can find.
Save Money On Everything: SAVEOnAtoZ.com

I am always working on adding new resources to help you find a better price including multiple comparison sites, meta search engines... its like meta^2.

The mashup features results from Amazon, Ebay, Half, Google Base, MSN, Shopzilla, Nextag and a few more resources as well. You can compare side by side in your shopping list and bookmark them for later. I have spent a lot of time on this project just learning how to use APIs and pulling the results from different locations, so I hope my efforts are not in vain.

I hope it saves everyone an incredible amount of money!
thanks for looking and please take some time to visit SAVEonAtoZ
thanks!
Mz

Labels: , , , , , , , , , , , , , , , , , ,

PDF Thumbnails through PHP, ImageMagick, Ghostscript - the Commandline solution

I had run into all sorts of issues with trying to deploy the imagemagick library in php. I was able to get it working fine on my xamp installations, but when I would try to get it working on IIS, I would run into issues.

GD worked fine, but unfortunately we deal with many complex image types. Some of them are only accessible to imagemagick such as PDFs.

And even worse, trying to get it running on an already live server was proving to be extremely difficult as I had to mess with the php.ini and reboot iis and perhaps the machine just to test certain changes - obviously this is not ideal with a server that is already hosting traffic.

After much frustration I came up with the idea that I could just remote php and ImageMagick via commandline. It has already prooved to be very powerful for me. This method might have a few drawbacks in terms of processing power, but its a lot better than remoting Photoshop or similar program.



Ingredients I used for Thumbnailing - you may try and substitute to see if it works for you.
Win2k3 Server, IIS, PHP5x, ImageMagick (any flavour i think), Ghostscript

Hopefully you have remote desktop/admin access otherwise this might not work for you... but maybe you can convince your provider to do this for you?

1) Download and install everything, you should already have PHP installed and working.

2) Install Imagemagick, Install Ghostscript which is necessary to render the PDF thumbnails.

3) but you will need to change a few settings.

one key one is changing permissions on IUSER_XXXXX on %system path%/system32/cmd.exe

you have to actually right click on the cmd.exe file and set the permissions on this file specifically.

4) make sure you have executable permissions in IIS for the website

5) i created a temp directory for easy testing such as
c:\temp\

6) I gave this directory full permissions for testing and also shared it on the network so it could be modified... this is temporary to see if mechanism works.

7) I then created this script... I will leave all the commenting so you can see more or less everything I tried and went through to get it to work...



/ < ? PHP

// MZs IMAGE MAGICK PDF THUMBNAILING MECHANISM
// REQUIRED INGREDIENTS :
// IMAGE MAGICK
// GHOSTSCRIPT
// !!!! NOTE TO RUN EXEC() ON IIS6.win2k6 I had to enable permissions on system32/cmd.exe for INETUSR_XXXXX
//
///
//

function CreateThumbnail($sourcefile, $destfile, $percentage=25 ) {
//$percentage = "25%";
//create command to send out
//exec(,$output,$return);
$command = "convert.exe -colorspace cmyk ".$sourcefile." -thumbnail ".$percentage."%x".$percentage."% ".$destfile;
//$command = 'start /B "convert" "convert.exe -colorspace cmyk '.$sourcefile.' -thumbnail 25%x25% '.$destfile.'"';
//$command = "dir";
echo $command;

$ret = exec($command, $output);
//echo $ret;
//echo sizeof($output[0]);
//echo $output[1].'
';
//echo $output[2].'
';
//echo 'the output'.$output.'
';

return true;
}


$sourcefile = "e:\\test\\1.pdf";
$destfile= "e:\\test\\1.pdf";


if ( $_GET['sourcefile'] ) {
$sourcefile = $_GET['sourcefile'];
}

if ($_GET['destfile'] ) {
$destfile = $_GET['destfile'];
} else {
$destfile = 'thumb-'.$sourcefile;
}

if ($_GET['percentage'] ) {
$percentage = $_GET['percentage'];
} else {
$percentage = 40;
}

CreateThumbnail($sourcefile,$destfile, $percentage) ;


?>


I still have a lot more to write, so I'll keep upating the blog as I make the script better.

you can pass in variables into the script such as thumbnail.php?sourcefile=sourcefile.pdf&destfile=destfile.jpg&percentage=25
and it creates a jpg thumbnail 25% the size of the

Labels: , , , ,