Skip to content

Instantly share code, notes, and snippets.

View treffynnon's full-sized avatar
🧟

Simon Holywell treffynnon

🧟
View GitHub Profile
@treffynnon
treffynnon / tSqlImport.php
Created February 4, 2010 15:18
Import a MS SQL T-SQL dump file into and ODBC connection via a PHP browser script.
<?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:18
T-SQL: Setup data dump
sp_addumpdevice 'disk', 'pseudoName', 'C:yourFilename.mdb';
GO
DUMP DATABASE yourDatabaseName TO pseudoName;
GO
sp_dropdevice pseudoName;
@treffynnon
treffynnon / iso3166.php
Created February 4, 2010 15:18
Get ISO list of countries
<?php
//Get ISO list of countries
$iso_xml_zip_file_url = 'http://www.iso.org/iso/';
$iso_xml_zip_filename = 'iso_3166-1_list_en.zip';
$iso_xml_zip_new_filename = 'iso_3166-1_list_en_'.date('Y-m-d').'.zip';
$iso_xml_filename = 'iso_3166-1_list_en.xml';
$download_directory = './temp/';
//setup database variables
$table_name = 'countries';
@treffynnon
treffynnon / flickering_images.php
Created February 4, 2010 15:19
Rotating images
<?php
/*
Original script written by
Simon Holywell (simonholywell.com)
17/3/2006
You may use this script for any purpose. You can
make changes to the code. You may NOT redistribute
the code, link back to my site. All derivatives
must be released and opensource.
@treffynnon
treffynnon / adodb-encrypt.php
Created February 4, 2010 15:19
Wrapper for handling SHA1 encrypted sessions in ADODB
<?php
if (!defined('ADODB_SESSION')) die();
include_once ADODB_SESSION . '/crypt.inc.php';
class ADODB_Encrypt_SHA1 {
function write($data, $key) {
$sha1crypt =& new SHA1Crypt();
return $sha1crypt->encrypt($data, $key);
}
@treffynnon
treffynnon / crypt.php
Created February 4, 2010 15:19
SHA1 crypt functions for ADODB
<?php
class SHA1Crypt{
function keyED($txt,$encrypt_key)
{
$encrypt_key = sha1($encrypt_key);
$ctr=0;
$tmp = "";
for ($i=0;$i<strlen($txt);$i++){
if ($ctr==strlen($encrypt_key)) $ctr=0;
$tmp.= substr($txt,$i,1) ^ substr($encrypt_key,$ctr,1);
@treffynnon
treffynnon / mysql-link.sql
Created February 4, 2010 15:19
Setup the MySQL ODBC connection
@treffynnon
treffynnon / table-list.php
Created February 4, 2010 15:19
Convert MySQL tables to T-SQL
<?php
$conn = mysql_connect('host','user','pass');
mysql_select_db('database',$conn);
$SQL = "SHOW TABLES;";
$result = mysql_query($SQL, $conn);
while($row = mysql_fetch_array($result))
print "SELECT * INTO SQLServerDBName.dbo.{$row[0]}<br />
FROM openquery(MySQL, 'SELECT * FROM `{$row[0]}`');<br />
";
@treffynnon
treffynnon / primary-keys.sql
Created February 4, 2010 15:19
T-SQL: Reset the primary keys
BEGIN TRANSACTION
GO
CREATE TABLE dbo.Tmp_admin_accounts
(
account_id int NOT NULL IDENTITY (1, 1),
username varchar(20) NOT NULL,
passhash char(40) NOT NULL
) ON [PRIMARY]
GO
SET IDENTITY_INSERT dbo.Tmp_admin_accounts ON
@treffynnon
treffynnon / virtualhost.xml
Created February 4, 2010 15:19
Apache2: Virtual host example
<VirtualHost *:80>
ServerAdmin name@domain.com
DocumentRoot c:\xampp\simonholywell.com\pub
ServerName simonholywell.localhost
<Directory c:\xampp\simonholywell.com\pub>
Order allow,deny
Allow from all
</Directory>
</VirtualHost>