Skip to content

Instantly share code, notes, and snippets.

View treffynnon's full-sized avatar
🧟

Simon Holywell treffynnon

🧟
View GitHub Profile
@treffynnon
treffynnon / localhost-virtualhost.xml
Created February 4, 2010 15:19
Apache2: Virtual host example
<VirtualHost *:80>
ServerAdmin name@domain.com
DocumentRoot c:\xampp\htdocs
ServerName localhost
</VirtualHost>
@treffynnon
treffynnon / secure-php-cron.php
Created February 4, 2010 15:19
PHP: Detecting a valid request via a pass key set in a header
<?php
if('my-agent' !== $_SERVER['HTTP_USER_AGENT'] or
$_SERVER['SERVER_ADDR'] !== $_SERVER['REMOTE_ADDR'] or
!isset($_SERVER['HTTP_TASK_KEY']) or
empty($_SERVER['HTTP_TASK_KEY']) or
'my-secret-key' !== $_SERVER['HTTP_TASK_KEY']) {
print 'You do not have permission to execute this script!';
exit();
}
print 'Executing operation.';
@treffynnon
treffynnon / exec-tasks-php.php
Created February 4, 2010 15:19
PHP: Scheduled tasks executed from PHP
<?php
exec('schtasks /Delete /TN taskname /F');
exec('schtasks /Create /RU username /RP password /SC MINUTE /MO 2 /TN taskname /TR “C:\Program Files\wget\wget.exe --header=TASK_KEY:my-secret-key –U my-agent http://www.webaddress.com/script.php -r');
?>
@treffynnon
treffynnon / cron2.bat
Created February 4, 2010 15:19
Windows: Scheduled tasks example
schtasks /Create /RU username /RP password /SC MONTHLY /MO 2 /TN taskname /TR "C:\Program Files\wget\wget.exe http://www.webaddress.com/script.php --spider"
@treffynnon
treffynnon / cron1.bat
Created February 4, 2010 15:19
Windows: Scheduled tasks example
schtasks /Create /RU username /RP password /SC MINUTE /MO 5 /TN taskname /TR "C:\Program Files\wget\wget.exe http://www.webaddress.com/script.php --spider"
@treffynnon
treffynnon / cron3.bat
Created February 4, 2010 15:19
Windows: Scheduled tasks example
schtasks /Create /RU username /RP password /SC MINUTE /MO 2 /TN taskname /TR "C:\Program Files\wget\wget.exe --header=TASK_KEY:my-secret-key -U my-agent http://www.webaddress.com/script.php --spider"
@treffynnon
treffynnon / mass-virtual-hosting.xml
Created February 4, 2010 15:19
Apache2: Mass virtual hosting configuration
# Mass Virtual Hosting
UseCanonicalName Off
LogFormat "%V %h %l %u %t \"%r\" %s %b" vcommon
CustomLog /var/log/apache2/access.log vcommon
VirtualDocumentRoot /mnt/htdocs/%1
<Directory /mnt/htdocs/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
Allow from all
@treffynnon
treffynnon / rewrite.xml
Created February 4, 2010 15:19
mod_rewrite: Default example
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php?url=$1 [QSA,L]
</IfModule>
@treffynnon
treffynnon / t-sql_import.php
Created February 4, 2010 15:19
T-SQL: Import into ODBC via PHP
<?php
/**
* Import a MS SQL T-SQL dump file into
* and ODBC connection via a PHP browser
* script.
*
* I have not tested the script with binary DB fields so
* I cannot confirm whether it works or not.
*
* @author Simon Holywell
@treffynnon
treffynnon / t-sql_dump.sql
Created February 4, 2010 15:19
T-SQL: Dump data command
sp_addumpdevice 'disk', 'pseudoName', 'C:yourFilename.mdb';
GO
DUMP DATABASE yourDatabaseName TO pseudoName;
GO
sp_dropdevice pseudoName;