“RIPS is a static code analysis tool to automatically detect vulnerabilities in PHP applications.
By tokenizing and parsing all source code files RIPS is able to transform PHP source code into a program model and to detect sensitive sinks (potentially vulnerable functions) that can be tainted by user input (influenced by a malicious user) during the program flow.
Besides the structured output of found vulnerabilities RIPS also offers an integrated code audit framework for further manual analysis. ”
TNT Search is a fully featured full text search engine written in PHP.
1 2 3 4 5 6 7 8 9 10 11 |
//don't forget to load the Facade use TNTSearch; //indexing $indexer = TNTSearch::createIndex('articles.index'); $indexer->query('SELECT id, article FROM articles;'); $indexer->run(); //searching TNTSearch::selectIndex("articles.index"); $res = TNTSearch::searchBoolean('search string', 10); |
“Gravity Forms for WordPress is a full featured contact form plugin that features a drag and drop interface, advanced notification routing, lead capture, conditional logic fields, multi-page forms, pricing calculations and the ability to create posts from external forms.”
There are multiple options how to handle the confirmation page. Gravity form allows you to send query parameters to the page it is redirecting to.
You can send all form information in the clear, via query variables, but that looks really messy. Its better to use something like this .. lead_id={entry_id} and query form information on the actual confirmation page.
This will output the submitted form data as an array, with all fields linked by field id.
1 2 |
$lead_id = intval( $_GET['lead_id'] ); $lead = RGFormsModel::get_lead($lead_id); |
When you are reusing the field data for your own purposes, its easier to deal with field names than with fields ids. So we get the form meta data
1 2 3 4 5 6 7 8 9 10 |
$form = RGFormsModel::get_form_meta( $lead['form_id'] ); foreach( $form['fields'] as $field ) { $values[$field['id']] = array( 'id' => $field['id'], 'label' => $field['label'], 'value' => $lead[ $field['id'] ], ); } |
and extend the lead array.
1 2 3 4 5 6 |
foreach($lead as $key => $val){ if(is_numeric($key)){ $lead_key = str_replace(" ", "_", strtolower($values[$key]['label'])); $lead[$lead_key] = $val; } } |
Before you needed to know the actual field id to get its value. Now you can use the generated lead key to get that value.
1 2 |
$field_key = 10; echo $lead[$field_key]; |
1 2 |
$field_key = "e-mail"; echo $lead[$field_key]; |
Much easier to reuse and remember :)
Crunz is a framework-agnostic package to schedule periodic tasks (cron jobs) in PHP using a fluent API.
Sometimes we need to debug a WordPress plugin, even though the website is live.
This would display the errors for anyone.
1 |
define('WP_DEBUG', true); |
Gladly WordPress provides options to do this more subtle.
1 2 3 4 5 6 7 8 9 10 11 |
// Turns WordPress debugging on define('WP_DEBUG', true); // Tells WordPress to log everything to the /wp-content/debug.log file define('WP_DEBUG_LOG', true); // Doesn't force the PHP 'display_errors' variable to be on define('WP_DEBUG_DISPLAY', false); // Hides errors from being displayed on-screen @ini_set('display_errors', 0); |
“Snappy is a PHP5 library allowing thumbnail, snapshot or PDF generation from a url or a html page. It uses the excellent webkit-based wkhtmltopdf and wkhtmltoimage available on OSX, Linux, Windows.”
TWIG is always part of my development process, allowing me to easily update handling and apply changes for my customers.
Nice to see Timber (TWIG integration for WordPress) reach version 1.0.
Wolfram Alpha‘s computational knowledge engine or answer engine developed by Wolfram Research, which can be consumed as a service as well. Users submit queries and computation requests. Wolfram Alpha then computes answers and relevant visualizations from a knowledge base of curated, structured data that come from other sites and books. 2000 non-commercial API calls per month are free.
They provide a nice set of API Language Libraries to get you started.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
<?php $appID = 'PLACE_YOUR_APP_ID_HERE'; if (!$queryIsSet) die(); $qArgs = array(); if (isset($_REQUEST['assumption'])) $qArgs['assumption'] = $_REQUEST['assumption']; // instantiate an engine object with your app id $engine = new WolframAlphaEngine( $appID ); // we will construct a basic query to the api with the input 'pi' // only the bare minimum will be used $response = $engine->getResults( $_REQUEST['q'], $qArgs); // getResults will send back a WAResponse object // this object has a parsed version of the wolfram alpha response // as well as the raw xml ($response->rawXML) // we can check if there was an error from the response object if ( $response->isError() ) { ?> <h1>There was an error in the request</h1> </body> </html> <?php die(); } ?> |
“Responsive FileManager is a free open-source file manager and image manager made with jQuery, CSS3, PHP and HTML5 that offers a nice and elegant way to upload and insert files, images and videos.
You can use it as external plugin for TinyMCE, CKEditor and CLEditor or as a stand-alone file manager to manage and select files.”
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
tinymce.init({ selector: "textarea",theme: "modern",width: 680,height: 300, plugins: [ "advlist autolink link image lists charmap print preview hr anchor pagebreak", "searchreplace wordcount visualblocks visualchars insertdatetime media nonbreaking", "table contextmenu directionality emoticons paste textcolor responsivefilemanager code" ], toolbar1: "undo redo | bold italic underline | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | styleselect", toolbar2: "| responsivefilemanager | link unlink anchor | image media | forecolor backcolor | print preview code ", image_advtab: true , external_filemanager_path:"/filemanager/", filemanager_title:"Responsive Filemanager" , external_plugins: { "filemanager" : "/filemanager/plugin.min.js"} }); |
MediaStreamRecorder.js is a cross-browser implementation to record audio & video streams via WebRTC. The lib allows you to submit/upload recorded blobs in realtime to your server.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
<script src="https://cdn.webrtc-experiment.com/MediaStreamRecorder.js"> </script> <script> var mediaConstraints = { audio: true, video: true }; navigator.getUserMedia(mediaConstraints, onMediaSuccess, onMediaError); function onMediaSuccess(stream) { var multiStreamRecorder = new MultiStreamRecorder(stream); multiStreamRecorder.video = yourVideoElement; // to get maximum accuracy multiStreamRecorder.audioChannels = 1; multiStreamRecorder.ondataavailable = function (blobs) { // blobs.audio // blobs.video }; multiStreamRecorder.start(3 * 1000); } function onMediaError(e) { console.error('media error', e); } </script> |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
<?php foreach(array('video', 'audio') as $type) { if (isset($_FILES["${type}-blob"])) { $fileName = $_POST["${type}-filename"]; $uploadDirectory = "uploads/$fileName"; if (!move_uploaded_file($_FILES["${type}-blob"]["tmp_name"], $uploadDirectory)) { echo("problem moving uploaded file"); } echo($uploadDirectory); } } ?> |