Skip to content

Instantly share code, notes, and snippets.

View ninetwentyfour's full-sized avatar

Travis Berry ninetwentyfour

View GitHub Profile
@ninetwentyfour
ninetwentyfour / example1.php
Created August 28, 2011 18:39
Create A Ghetto, But Functional, Search Function For CakePHP - blogpost
<div id="search">
<form id="orderform" action="<?php echo $html->url('/users/search'); ?>" method="post" enctype="multipart/form-data">
<label for="searchuser">Search Users:</label><input type="text" name="searchuser" />
Search By:
<input type="radio" name="searchtype" value="User.id" checked> User ID
<input type="radio" name="searchtype" value="User.email" checked> User Email
<input type="radio" name="searchtype" value="Entity.name"> Entity Name
<?php
echo $form->end('Search');
?>
@ninetwentyfour
ninetwentyfour / example1.xml
Created August 28, 2011 18:47
Reasons And Tips For Automated Motion Workflow - blogpost
<styleRun style="10178" offset="0" length="1"/>
<text>Website</text>
@ninetwentyfour
ninetwentyfour / example1.php
Created August 28, 2011 18:59
Upload A Video To Ooyala With PHP - blogpost
<?php
/**
*Publish video to ooyala
*/
function publish(){// this kicks off the massive publish functions
$labels = $_POST['label'];
$file = $_POST['video_file'];
$dir = $file;
$name = explode("/", $dir );
$name = array_reverse($name );//this get just the name of the file and not
@ninetwentyfour
ninetwentyfour / example1.php
Created August 28, 2011 19:02
Upload Videos To MediaSilo With PHP/FTP - blogpost
<?php
//MediaSilo Information
$server = "upload.mediasilo.com";
$ftp_user_name = "YOUR MEDIASILO LOGIN NAME AND HOSTNAME(e.g NAMEHOSTNAME";
$ftp_user_pass = "YOUR MEDIASILO LOGIN PASSWORD";
$dest = "THE WORKSPACE YOU WANT TO UPLOAD TO";
//Video Folder Information
$source_folder = "FULL PATH TO FOLDER. NO TRAILING SLASH (e.g. /var/www/videofolder)";
//Grabs everything in the source folder. You may want to set a file type like, ($source_folder."/*.flv")
@ninetwentyfour
ninetwentyfour / example1.php
Last active June 5, 2022 08:40
Use PHP To Zip Folders For Download - blogpost
<?php
// WARNING
// This code should NOT be used as is. It is vulnerable to path traversal. https://www.owasp.org/index.php/Path_Traversal
// You should sanitize $_GET['directtozip']
// For tips to get started see http://stackoverflow.com/questions/4205141/preventing-directory-traversal-in-php-but-allowing-paths
//Get the directory to zip
$filename_no_ext= $_GET['directtozip'];
// we deliver a zip file
@ninetwentyfour
ninetwentyfour / example1.php
Created August 28, 2011 19:14
If is_page() With Regular PHP - blogpost
<?php
$baseurl = 'http://www.example.com'; //set the base url of the site
$pageYouWant = $baseurl."/the-rest-of-the-url"; //add the rest of the url you want to check against
$currentPage = $baseurl.$_SERVER['REQUEST_URI'];// this gets the current page url
if($pageYouWant==$currentPage) {
//do something
}
?>
@ninetwentyfour
ninetwentyfour / example1.php
Created August 28, 2011 19:20
Remove WordPress’ NoFollow Without A Plugin - blogpost
<?php
function comment_author_link_mine( $comment_ID = 0 ) {
echo get_comment_author_link_mine( $comment_ID );
}
function get_comment_author_link_mine( $comment_ID = 0 ) {
/** @todo Only call these functions when they are needed. Include in if... else blocks */
$url = get_comment_author_url( $comment_ID );
$author = get_comment_author( $comment_ID );
@ninetwentyfour
ninetwentyfour / example1.txt
Created August 28, 2011 19:31
Lightning Fast PHP Server With Nginx, eAccelerator, and Varnish 1 - blogpost
sudo apt-get install nginx
@ninetwentyfour
ninetwentyfour / example10.txt
Created August 28, 2011 19:33
Lightning Fast PHP Server With Nginx, eAccelerator, and Varnish 2 - blogpost
sudo /etc/init.d/php5-fpm restart
@ninetwentyfour
ninetwentyfour / example1.txt
Created August 28, 2011 20:39
Clean URL’s in Nginx - blogpost
## Parse all .php file in the /var/www directory
location ~ \.php$
location ~ \.php$ {
fastcgi_split_path_info ^(.+\.php)(.*)$;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /var/www$fastcgi_script_name;
include fastcgi_params;
fastcgi_param QUERY_STRING $query_string;
fastcgi_param REQUEST_METHOD $request_method;