Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6944688
commit 6d791bf
Showing
5 changed files
with
102 additions
and
82 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
<?php | ||
/** | ||
* Created by PhpStorm. | ||
* User: Davis | ||
* Date: 1/2/2016 | ||
* Time: 5:39 PM | ||
*/ | ||
require_once(__DIR__ . '/php/shittalk_functions.php'); | ||
|
||
$file = "cfg/shittalk.cfg"; | ||
$myfile = fopen($file, "r") or die("Unable to open file!"); | ||
|
||
$fileContents = fread($myfile, filesize($file)); | ||
fclose($myfile); | ||
|
||
$del = convert_smart_quotes(get_delimited($fileContents)); //an array of everything between quote marks. need to parse this | ||
|
||
//UNCOMMENT FOR THIS TO RUN - IMPORTS OLD BINDS | ||
//if (!empty($del)) { | ||
// for ($i = 0; $i < count($del); $i++) { | ||
// | ||
// if (strpos($del[$i], 'say ') !== false) { //if "say " is the first part of the string | ||
// $fixedBind = str_replace('say ', '', $del[$i]); | ||
// createShittalkRow($fixedBind); | ||
// | ||
// } | ||
// } | ||
//} | ||
|
||
function createShittalkRow($text) | ||
{ | ||
$text_escaped = mysql_escape_mimic(strip_double_quotes($text)); | ||
$today = mysql_escape_mimic(date("Y-m-d H:i:s")); | ||
|
||
$sql = "INSERT INTO `shittalkDB` | ||
(`text`, `date_created`, `custom`) | ||
VALUES ('$text_escaped', '$today', 0);"; | ||
$result = mySqlQuery($sql); | ||
|
||
return $result; | ||
} | ||
|
||
function get_delimited($str, $delimiter = '"') | ||
{ | ||
$escapedDelimiter = preg_quote($delimiter, '/'); | ||
if (preg_match_all('/' . $escapedDelimiter . '(.*?)' . $escapedDelimiter . '/s', $str, $matches)) { | ||
return $matches[1]; | ||
} | ||
} | ||
|
||
function convert_smart_quotes($string) | ||
{ | ||
$search = array( | ||
'“', | ||
'”', | ||
'“', | ||
'”', | ||
chr(147), | ||
chr(148), | ||
'‘', | ||
'’', | ||
"‘", | ||
"’", | ||
chr(145), | ||
chr(146), | ||
chr(151), | ||
'—', | ||
'—', | ||
'–', | ||
chr(133)); | ||
|
||
$replace = array( | ||
'"', | ||
'"', | ||
'"', | ||
'"', | ||
'"', | ||
'"', | ||
"'", | ||
"'", | ||
"'", | ||
"'", | ||
"'", | ||
"'", | ||
'-', | ||
'-', | ||
'-', | ||
'-', | ||
'...'); | ||
|
||
return str_replace($search, $replace, $string); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters