Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added functionality and small fixes #2

Merged
merged 5 commits into from
Aug 13, 2012
Merged

Conversation

bsevere
Copy link
Contributor

@bsevere bsevere commented Aug 10, 2012

Hi,

I am preparing the digital strategy implementation for the Dept. of Commerce and we are using your report generator. Thank you for the tool as it has accelerated our deployment.

I have forked your code and have added a few enhancements that were requested by our DS POC and fixed a couple small issues. These are the changes I have made:
Changed output filenames from ‘digital-strategy’ to digitalstrategy’ (removed hyphen).
Added constant for reports directory.
Added functionality to write to reports directory if it is defined.
Read in existing JSON file from reports directory if present.
Remove “/” from $local_path variable in dgs_zip() to fix “Cannot use absolute pathnames for this command” error.
Fixed unordered HTML report items.
Fixed generate.php to write to /tmp instead of DGS_BASE_DIR/tmp.

This code still points to the Digital-Strategy repo to create the agency and item lists. I have sent a pull request for that as well to fix the missing agency IDs.

I would very much like to combine our efforts on this for the benefit of the entire FED community. Please let me know if you have any questions about the changes made.
Thanks,

Bill Severe

@ro281815
Copy link

Hi Bsevere,

I've been trying to run your project (and the master project) for hours now and I can't make it work.

I'm using IIS 7 and PHP 5.3.13.

What environment are you successfully able to run this code on?

The zip file is empty after I hit Generate; and the error log says the following:

PHP Warning: mkdir() [function.mkdir]: No such file or directory in C:\inetpub\wwwroot\bsevere\includes\generate.php on line 63

PHP Warning: file_put_contents(/tmp/451668edcbf94d76691b9d3ed988a313/digitalstrategy.json) [function.file-put-contents]: failed to open stream: No such file or directory in C:\inetpub\wwwroot\bsevere\includes\generate.php on line 69

PHP Warning: file_put_contents(/tmp/451668edcbf94d76691b9d3ed988a313/digitalstrategy.xml) [function.file-put-contents]: failed to open stream: No such file or directory in

C:\inetpub\wwwroot\bsevere\includes\generate.php on line 74
PHP Warning: file_put_contents(/tmp/451668edcbf94d76691b9d3ed988a313/digitalstrategy.html) [function.file-put-contents]: failed to open stream: No such file or directory in

C:\inetpub\wwwroot\bsevere\includes\generate.php on line 77
PHP Warning: filesize() [function.filesize]: stat failed for /tmp/451668edcbf94d76691b9d3ed988a313/DOL-report.zip in C:\inetpub\wwwroot\bsevere\includes\generate.php on line 86

PHP Warning: readfile(/tmp/451668edcbf94d76691b9d3ed988a313/DOL-report.zip) [function.readfile]: failed to open stream: No such file or directory in C:\inetpub\wwwroot\bsevere\includes\generate.php on line 89

PHP Warning: rmdir(/tmp/451668edcbf94d76691b9d3ed988a313) [function.rmdir]: No such file or directory in C:\inetpub\wwwroot\bsevere\includes\functions.php on line 116

Thanks for any help!
R.

@bsevere
Copy link
Contributor Author

bsevere commented Aug 10, 2012

The script is trying to mkdir but it does not have the proper permissions. Look at includes/generation.php:line 54. If that line reads:
$dir = DGS_BASE_DIR . '/tmp/' . md5( time() );
change it to:
$dir['tmp'] = '/tmp/' . md5( time() );

Also make sure that you set world write permissions on /tmp as per the readme. (chmod 0777 /tmp/)

Bill

@ro281815
Copy link

Thanks Bill,

I'm running windows 7, I had set the permissions for that folder to be Full Control for the groups using IIS.

The first error message I saw said that DGS_BASE_DIR was an undefined constant in generator.php

I'm not familiar at all with php so I don't know if it's a configuration issue on IIS or if it's a problem with the version of php I am using.

What version of php are u running?

Thanks so much for your time,
Rodyna

On Aug 10, 2012, at 6:52 PM, bsevere notifications@github.com wrote:

The script is trying to mkdir but it does not have the proper permissions. Look at includes/generation.php:line 54. If that line reads:
$dir = DGS_BASE_DIR . '/tmp/' . md5( time() );
change it to:
$dir['tmp'] = '/tmp/' . md5( time() );

Also make sure that you set world write permissions on /tmp as per the readme. (chmod 0777 /tmp/)

Bill


Reply to this email directly or view it on GitHub.

@bsevere
Copy link
Contributor Author

bsevere commented Aug 10, 2012

Sorry, I should have picked up that you are running Windows. I am running an older version of PHP (5.2.13). That should not matter as I think your issues are mostly permissions. There may also be an issue with the paths (the code is written for a *nix filesystem). Check the contents of the data folder. If there are no contents then you will need to allow Everyone read/write/execute access to that folder. That is the Windows equivalent to chmod 0777. Do the same for C:\tmp. If that folder does not exist you can point it to C:\temp, or whatever your temp directory is.

@ro281815
Copy link

The data folder has files in it.

When I create a folder called 'tmp' at the same level as index.php the script runs but the zip folder is still empty.

Generate.php throws errors about DGS_BASE_DIR being an unknown constant.

At this point I'm going to try just hard coding the XML and json files since the deliverable is Thursday. And then try to figure out why it won't generate.

Would you mind sending me an example JSON file and XML file?

Thanks so much for your help Bill.

Rodyna

Sent from my iPhone

On Aug 10, 2012, at 7:32 PM, bsevere notifications@github.com wrote:

Sorry, I should have picked up that you are running Windows. I am running an older version of PHP (5.2.13). That should not matter as I think your issues are mostly permissions. There may also be an issue with the paths (the code is written for a *nix filesystem). Check the contents of the data folder. If there are no contents then you will need to allow Everyone read/write/execute access to that folder. That is the Windows equivalent to chmod 0777. Do the same for C:\tmp. If that folder does not exist you can point it to C:\temp, or whatever your temp directory is.


Reply to this email directly or view it on GitHub.

@bsevere
Copy link
Contributor Author

bsevere commented Aug 13, 2012

The zip folder is emptied after the zip is created and the download headers are sent. The issue with DGS_BASE_DIR is most likely coming from line 54 of includes/generation.php as I mentioned earlier. To fix you will need to open that file and make the change below.

$dir = DGS_BASE_DIR . '/tmp/' . md5( time() );
change it to:
$dir['tmp'] = '/tmp/' . md5( time() );

The JSON and XML files are available here: https://github.com/GSA/digital-strategy.

Bill

@benbalter benbalter merged commit 61f3814 into GSA:master Aug 13, 2012
@benbalter
Copy link
Contributor

Merged the pull request. @bsevere thanks for taking the time to put this together.

Resolved @ro281815's windows compatibility issue by changing the temp. directory to use PHP's default temp directory, rather than assuming /tmp exists (which would only exist on unix systems). The reason the zip is empty is because PHP cannot find or write to the temp. folder, thus cannot round up the files to generate the zip.

Also tweaked the way the script loads configs (making it easier to customize outside of Git, which should resolve the undefined constant issue. Per the Readme, you'll need to copy config/config.sample.php to config/config.php (if you don't it will err out and remind you to).

All the changes should be in the "master" branch, and labeled generator version 1.1. Will go back and tag the 1.0 for history sake.

Thanks again to both for the feedback and for the code. Truly a model of what government should be doing.

-Ben

(cc @gbinal)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants