Skip to content

Instantly share code, notes, and snippets.

View GoodChancer's full-sized avatar

Good Chancer GoodChancer

View GitHub Profile
@GoodChancer
GoodChancer / param-cookes.js
Created May 15, 2017 20:20
Saving URL parameters as cookies and adding to forms
/*
This script will take the URL parameters of your choice and save them to cookies during a user session,
so if a user changes pages on your site, the data will still be submitted with your forms.
Be sure to include the JS Cookie plugin https://github.com/js-cookie/js-cookie and jquery.
Add the code below to your website footer.
Adjust variable, parameter, and form input names accordingly, add or remove as necessary.
Note: some servers block files with 'cookie' in the name. Be sure to change the filename if you have problems loading the script.
@GoodChancer
GoodChancer / put-data.php
Created April 1, 2017 01:28
Putting weekly music data in database
<?php
require_once($_SERVER['DOCUMENT_ROOT'].'/music/init.php');
$albumCount = 0;
/* Get title and convert to date */
$pageTitle = $parsehub['PageTitle'];
$timeString = str_replace("Week of ","",$pageTitle);
/* Get Artist */
$stmt = $pdo->prepare('SELECT name FROM artist WHERE id = ?');
$stmt->execute([$albumCurrent['artist_id']]);
$artist = $stmt->fetchColumn();
$stmt = $pdo->prepare('SELECT itunes_url FROM artist WHERE id = ?');
$stmt->execute([$albumCurrent['artist_id']]);
$itunesURL = $stmt->fetchColumn();
$stmt = $pdo->prepare('SELECT allmusic_url FROM artist WHERE id = ?');
<?php
/* Get Styles */
$stmt = $pdo->prepare('SELECT style_id FROM album_style WHERE album_id = ?');
$stmt->execute([$albumCurrent['id']]);
$styles = $stmt->fetchAll(PDO::FETCH_COLUMN);
echo '<ul class="styles">';
if (is_array($styles)) {
//Output from file_put_contents('postdata.php', $_POST);
completetGN8rVDxBWdtc65d4635be886e696a3194259d23052412017-03-24T20:19:[email protected]:20:18.717243{"loadJs": false, "sendEmail": true, "webhook": "https://________.com/music/get-status.php", "outputType": "json", "customProxies": "", "maxWorkers": "0", "startTemplate": "new_releases", "rotateIPs": false, "startValue": "{\"want\": [\"Indie Electronic\",\"Indie Folk\",\"Indie Pop\",\"Alternative Singer/Songwriter\",\"Neo-Psychedelia\"]}", "maxPages": "0", "startUrl": "http://www.allmusic.com/newreleases"}{"want": ["Indie Electronic","Indie Folk","Indie Pop","Alternative Singer/Songwriter","Neo-Psychedelia"]}new_releases14http://www.allmusic.com/newreleases
//Output from file_put_contents('postdata2.php', file_get_contents('php://input'));
status=complete&run_token=tEF14GZCoUAj&md5sum=a2fde4fa32e8460ada0b94572418d62a&data_ready=1&custom_proxies=&start_time=2017-03-24T23%3A48%3A08&owner_email=________%40gmail.com&is_empt
if ($itunes['resultCount'] != '0') {
$albumItunesURL = $itunes['results'][0]['collectionViewUrl'].'&ls=1&mt=1';
$artistItunesURL = $itunes['results'][0]['artistViewUrl'].'&ls=1&mt=1';
$albumItunesArt = $itunes['results'][0]['artworkUrl100'];
} else {
$albumItunesURL = 'NULL';
$artistItunesURL = 'NULL';
$albumItunesArt = 'NULL';
@GoodChancer
GoodChancer / generator.php
Created March 4, 2017 08:27
XML Generator
<?php
$json = include('getdata.php');
$i=1;
/* create a dom document with encoding utf8 */
//create a new xmlwriter object
$xml = new XMLWriter();
@GoodChancer
GoodChancer / generator.php
Created March 4, 2017 02:01
XML Generator
<?php
$json = include('getdata.php');
echo $json->Albums[1]->Album; //test
/* create a dom document with encoding utf8 */
//create a new xmlwriter object
$xml = new XMLWriter();
@GoodChancer
GoodChancer / generator.php
Last active March 2, 2017 04:09
Playlist Static
<?php
/* create a dom document with encoding utf8 */
//create a new xmlwriter object
$xml = new XMLWriter();
//using memory for string output
$xml->openMemory();
//set the indentation to true (if false all the xml will be written on one line)
$xml->setIndent(true);
$xml->setIndentString("\t");
<?php
//for temporarily displaying raw XML on php page
header('Content-Type: text/xml');
/* create a dom document with encoding utf8 */
$doc = new DOMDocument('1.0', 'UTF-8');
$doc->formatOutput = true;
$plist = $doc->createElement('plist');