How can I validate CSS within a script? [closed] - php

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 6 years ago.
Improve this question
Is there a library out there which will validate CSS?
The only tools I can find to do so are web sites. If one of these sites has an API, that would fit the bill, too.
I have a script that serves as a CSS compiler. It sets various variables according to settings for a theme, and generates and writes a CSS file. Before committing to writing the CSS file, I'd like to validate it to make sure there aren't any invalid entries.
PHP would be convenient, but Python, Perl, Ruby, Java, or anything executable from a shell would be fine.
Ideally, there's something out there that I can use as part of a sequence like:
$css_file=theme_compile('theme-name');
if(!validate_css($css_file)){
echo "css file contained invalid entry 'width:px'";//just an example, of course
}
else{
file_put_contents('/path/css_file',$css_file);
}

W3C has an API:
http://jigsaw.w3.org/css-validator/api.html
You can also download the validator and run it locally:
http://jigsaw.w3.org/css-validator/DOWNLOAD.html
You need to be able to run java from your script.

Python library:
http://cthedot.de/cssutils/

There is a pear package called Services_W3C_CSSValidator which does this.
You can download the PHP class directly from the github if you prefer.
Its very simple to use.
require_once 'Services/W3C/CSSValidator.php';
$v = new Services_W3C_CSSValidator();
$result = $v->validateFile('pear_manual.css'); // XML
It includes all features available at http://jigsaw.w3.org/css-validator

Related

Php code protection libraries [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 6 years ago.
Improve this question
There are many code protection libraries in php, however they require installation of additional php modules, which I can not afford because the application will be running on servers I do not own. So I thought I could make my own.
What I want to do:
$source = file_get_contents("encryptedPhpFile.php");
$source = decrypt($source, "mySecretKey");
//$source now contains decrypted source code which needs to be included
//I cant use eval($source); because that code also contains
//html/css/opening and closing php tags ... which eval() does
//not know how to render
//I cant write the source into temporary file and then include
//that file because as soon as I write decrypted source to a disk,
//it is exposed and it can be copyed
What can I do? Any suggestions?
These libraries are modules for a reason. You will not be able to fully simulate them in "code space". Your attempts will be clumsy (not your fault) and make your codebase far less pleasing/maintainable.
You should instead focus your efforts on obtaining permission to install them, migrating to a host that lets you control your server to a useful degree, or getting your own server up and running.
Again and again.
We cannot protect PHP source code. PHP was not meant to be 'protected'. Even compiling code to binary is prone to reverse engineering. In your example, when you decrypt source with secret key (how secret - there he is) you do what? Eval it? Replace eval with echo.
Write license & do legal job with lawyer. Organize business model so your customers would want to pay you so they could get updates & support.
Regarding code protection libraries (paid ones): there are free online services that automatically decode them for you...

Generate a DOC for a REST API [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 5 years ago.
Improve this question
I have generated my REST API, and now I have to write a documentation for the API.
As the API is mainly generated by a third-party plugin it's not possible to generate the DOC automatically.
So what the best tool (to save time) to manually write a DOC?
PS: I do have github account, I wonder if the user pages can fit this need.
You might want to take a look at TechWriter for Web Services. It also supports generating documentation for REST APIs.
You can spent sometime to put DocBlock into all function/class you have built
A tool like PHPDOC is available for you to compile DocBlock into documentation and regenerate whatever you need (into your desired format).
Not to mention, is stored as static HTML

PHP and Javascript Documentation Generator [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 5 years ago.
Improve this question
I'm in the process of generating API docs for an in-house web app that's undergoing some expansion. It's a DHTML project, with a mix of both some OO and mostly procedural PHP, and purely procedural Javascript. At the moment, it's pretty much all documented for the appropriate doc generators (phpdocumentor and jsdoc), but the two were never "connected". I could go through and add manual link statements to the doc blocks, but managing all those links (like "../jsdoc/filename.html#function) is a real pain.
Any suggestions for documentation generators that handle both PHP and JavaScript, and allow something like #see functionName between languages?
If worst comes to worst, I can hack together a script to rewrite LINK URLs from some magic syntax (i.e. js: and php:), but I'd really rather have something that will allow a unified tree view of everything.
Thanks,
Jason
After looking at a number of options, I wrote a PHP script that parses JS files, pulls out the doc blocks and function definitions, and then writes it to a file that phpdoc can process. It just needs one line added to phpDocumentor.ini so it will parse .js files.
The blog post talking about it is at:
http://blog.jasonantman.com/2010/08/documentation-generation-for-web-apps-php-and-javascript/
And the script is at:
http://svn.jasonantman.com/misc-scripts/

Coverting DOC to PDF programmatically [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 7 years ago.
Improve this question
I'm looking for a library to help me convert DOC files to PDF using PHP.
I'm also open to using an external website if this functionality already exists elsewhere, as long as this website has a programmatic API and is free.
Any suggestions how to approach this?
I haven't looked at PHP in a very long time, but if you can make web service calls from it then try this product. It provides excellent conversion fidelity. It also supports additional formats including Infopath, Excel, PowerPoint etc and has Watermarking support as well.
Please note that I have worked on this product so the usual disclaimers apply.
Late but possibly useful as a general reference particularly in light of the "external website" option you mentioned - Docmosis provides a web-service api for creating doc + pdf + odt + other formats from any application that can invoke a REST web service (or HTTP post).
You can change the file extension of the word file to pdf,by using below code
$filename = preg_replace('".docx$"', '.pdf', $filename);

DocBook to DokuWiki [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 5 years ago.
Improve this question
Is there a straightforward way to take docbook content and convert it into DokuWiki content? So far I've only found the DokuWiki plugin that will interpret docbook content and output it in XHTML, but this happens on every page load.
I would like to find a way to convert docbook content directly to DokuWiki's native formatting syntax so I only have to interpret it once. Any ideas?
Another option will be to
Use 'docbook2html' - [DocBook tools] to convert docbook to HTML, and then
use something like this Perl Module to convert the HTML to wiki markup. http://metacpan.org/pod/HTML::WikiConverter
I'm not familar with the tool you mentioned, but I have some thoughts on general strategies you might employ.
If you're happy with the output from the DocuWiki plugin you could write some sort of script in perl, sh, ruby, etc. that executes the plugin and stores the content to be served up statically in the future.
It appears that DocuWiki is simply calling the xsltproc program and serving up the output. If the plugin is working then you should be able to call xsltproc directly from the command line or your own script. Take a look at these lines from DocuWiki
exec("$xsltproc -o $tmpXhtmlFile $docbookXsl $tmpDocbookFile 2>&1", $errors);
$returnXhtml = shell_exec("$xsltproc " . DOKU_PLUGIN . "/docbook/xhtmlCleaner.xsl $tmpXhtmlFile");
Once you have option 1 or 2 working. Setup a cron job or hook in your revision control system to watch for changes to the original docbook source and call the script to regenerate the static version.
One small (but possibly important) note: DokuWiki contains a caching mechanism which saves the outputted HTML file. This means that normally the plugin would be executed very infrequently (ie. only the first time a particular revision of the page is viewed).

Categories