You are here:  » Feed Automation Problem.


Feed Automation Problem.

Submitted by sbedigital on Thu, 2013-08-01 11:30 in

Hi Dave,

Just test out your latest version of PT and I am facing bit on an issue here. Although it is not recommended, I am running on WINDOWS SERVER 2012 with Plesk 11 and IIS8. I am using PHP5.4

As per instruction I have installed UNZIP.EXE, GZIP.EXE and WGET.EXE from gunWin32 website. I have granted the relavent users full access to the files and folders. I have set my php configuration to following using plesk:

Safe_Mode = off
Open_Basedir = none
Allow Url_fopen = True

I have done following test:

1. I have set my php to run as CGI tested with a sample feed URL from affiliatewindow, the result I get Bad Gateway Error
2. I have changed my php to run as FastCGI - I can automation script can download the feed but when unzipped file is empty. However When I have set the "Unzip?" option to NO in the automation area in admin, I can feed is downloaded with data in it (by looking at the file size). When i put unzip option to YES I get empty file.

What could be the problem? Sorry I need the Windows enviorment because I have some other sites needs ASP.net

Noor

Submitted by support on Thu, 2013-08-01 12:40

Hello Noor,

Can you check that the location of the unzip programs matches the $config_unzipProgram settings in config.advanced.php - noting the difference in slash direction between Linux and Windows - and something that just occurred to me is that the the back-slashes would then need to be escaped; so for example if you have

c:\Program Files\gnuwin32\unzip.exe
c:\Program Files\gnuwin32\gzip.exe

...then the configuration would be:

  $config_automationUnzipPrograms["unzip"] = "c:\\Program Files\\gnuwin32\\unzip.exe";
  $config_automationUnzipPrograms["gzip"] = "c:\\Program Files\\gnuwin32\\gzip.exe";

...the double back-slash might just be all it is...

Hope this helps!

Cheers,
David.
--
PriceTapestry.com

Submitted by sbedigital on Thu, 2013-08-01 13:10

Here is my settings:

 $config_automationHandler = "php";
  $config_automationUnzipPrograms = array();
  $config_automationUnzipPrograms["unzip"] = "C:\\gnuwin32\\bin\\unzip.exe";
  $config_automationUnzipPrograms["gzip"] = "C:\\gnuwin32\\bin\\gzip.exe";
  $config_CRONPrograms = array();
  $config_CRONPrograms["php"] = "C:\\Program Files (x86)\\Parallels\\Plesk\Additional\\PleskPHP54\\php.exe";
  $config_CRONPrograms["wget"] = "C:\\gnuwin32\\bin\\wget.exe";

Another strange thing is onthe "Support Info" page in the admin area my Install Path is equal to C:\Inetpub\vhosts\example.co.uk\httpdocs\admin\support.php and I am pretty sure it should be C:\Inetpub\vhosts\example.co.uk\httpdocs. It shoould refer to the main installation folder rather than the support.php file. Does that have any roles invloved in this error?

And what other possible values I can try for $config_automationHandler. I have tried curl, although the feed download was faster, but ended up with same result.

In a nutshell, I think I am getting as far as downloading comressed file from the datafeed server, but there something stopping feed being uncompressed.

Noor

Submitted by sbedigital on Thu, 2013-08-01 13:19

Dave Just had an idea. On my server I use Plesk 11. I notice that the plesk's built in FILE BOWSER / UPLOADER has a built in file extractor. So if upload test.zip using the FILE BROWSER, I vcan therefore extract the file. Surly its using a unzip or gzip binary from somewhere - do you have any idea? My point is, if know the location of that binary, I can append that in my config.advance.php file to see that makes any difference.

Also just notice this on Support Info Page:

Option 1 cd C:\Inetpub\vhosts\example.co.uk\httpdocs\admin\support.phpscripts;C:\Program Files (x86)\Parallels\plesk\Additional\PleskPHP54\php.exe cron.php

notice the first part of the command referring to support.phpscripts is that normal?

Noor

Submitted by support on Thu, 2013-08-01 13:29

Hello Noor,

Regarding admin\support.php appearing in the Install Path and derived Cron Option 1 these are because the way the paths are derived look for the linux variant of "admin/support.php" so to correct this for Windows, in admin/support.php look for the following code at line 32:

  $baseHREF = str_replace("admin/support.php","",$baseHREF);

...and REPLACE with:

  $baseHREF = str_replace(array("admin/support.php","admin\\support.php"),"",$baseHREF);

A little later today I'll have access to a Windows machine so I'll give it a go with gnuwin32 scripts and see why they might not be executing, but in the mean time, Affiliate Window feeds are available in .gz (format) so one options would be to revert to PHP's internal gzip functions. To do this, edit your includes/automation.php and look for the automation_unzip_gzip function (beginning at line 160) and REPLACE with the following version

  function automation_unzip_gzip($tmp)
  {
    $gfp = gzopen($tmp,"r");
    if (!$gfp) return FALSE;
    $fp = fopen($tmp.".ungzipped","w");
    if (!$fp) return FALSE;
    while(!gzeof($gfp)) fwrite($fp,gzread($gfp,2048));
    fclose($fp);
    gzclose($gfp);
    unlink($tmp);
    rename($tmp.".ungzipped",$tmp);
    return TRUE;
  }

(if you're not sure, let me know and I'll email the mods for you)

Hope this helps!

Cheers,
David.
--
PriceTapestry.com

Submitted by sbedigital on Thu, 2013-08-01 19:43

Ok that downloading and unzipping is sorted with your mods for php's built in gzip decompression methods. Now for some reason cron job not executing the the command properly. I have tried to use option 2 C:\gnuwin32\bin\wget.exe http://example.co.uk/scripts/cron.php using plesk's gui. When run the command plesk reports it has successfully executed, but when I check in the PT installation there are no feeds.

I have tried both option in plesk and running using the command line. For strange reason this what happens:

If I use C:\gnuwin32\bin\wget.exe http://example.co.uk/scripts/cron.php .. I get cron.php downloaded to my HDD.

If I use php.exe http://example.co.uk/scripts/cron.php .. I get "Could not open file ..." message.

I have checked all the file permission and everything.

I don't know what else can be done. Strangely enough, cron scheduler did not send me any e-mails either even I did leave that option on for debugging reason.

Submitted by support on Fri, 2013-08-02 08:31

Hello Noor,

Could you have a go with the PHP version, but with the full path to PHP in the CRON command, e.g.

C:\Program Files (x86)\Parallels\Plesk\Additional\PleskPHP54\php.exe C:\Inetpub\vhosts\example.co.uk\httpdocs\scripts\cron.php

(replace example.co.uk with your domain name)

However, if still no joy, it is sometimes the case that PHP is not configured to change directory internally to the same folder as the script, so to work around that if it's not possible to change a change directory command as part of the CRON job, if you edit your scripts/cron.php and add the following line at the very top (after the opening
PHP tag)

  chdir("C:\\Inetpub\\vhosts\\example.co.uk\\httpdocs\\scripts\\");

(replace example.co.uk with your domain name)

That should do the trick...

Cheers,
David.
--
PriceTapestry.com

Submitted by sbedigital on Sun, 2013-08-11 17:55

Yes the later solution did the trick. Since I have plan to use the script more than one domain, I just wonder whether you can make the CHDIR part little bit dynamic by scritp to detect the script folder automatically arther than me (end user) having to modify the CHDIR location manually.

Also just for other users running on Windows Server using IIS, I have found that on Windows Server command line enviornment you can not use any special characters or spaces. For example if you have php.exe location in C:/Program Files (x86)/Parallels/Additional/PHP54/php.exe and try to excute the program using Powershell or default command line, you will get an error with file not found message. To get around the that I have experimented 2 solutions:

1. Instead of using C:/Program Files (x86)/Parallels/Additional/PHP54/php.exe you can Use C:/Progra~2/Parallels/Additional/PHP54/php.exe. Take note of Progra~2 It's not a mistake.

2. Make PHP.EXE a global excutable in your system's Environmental Variables (Control Panel --> System and Security --> System --> Advance System Setting). Once properly setup, all you need to type is php.exe note that this method does NOT require the full path of the PHP binary.

I have now adopted the later solution just shear simplicity of it.

thank you for your prompt action as usuall five star support.

noor

Submitted by support on Mon, 2013-08-12 07:57

Hello noor,

Sure - have a go with:

  chdir(dirname(__FILE__));

Cheers,
David.
--
PriceTapestry.com