Tacoen's shared code-snipsets
define("DEBUG", 1); define("DIR", "D:/zararadio/"); define("DIR_CONF", DIR."bin/"); define("DIR_TPL", DIR."template/"); define("DIR_SEQ", DIR."sequences/"); define("DIR_PLS", DIR."playlist/"); define("DIR_VOC", DIR."voice/"); define("DIR_ADS", DIR."ads/"); define("DIR_ADS", DIR."text/"); define("DIR_AUTO", DIR."auto/"); $whari = array( "minggu", "senin", "selasa", "rabu", "kamis", "jumat", "sabtu"); $hh = $whari[date("w",time())]; $jj = date("H",time()); $mmdd = date("m-d",time()); // what to queries $q0 = "*:*"; $q1 = "$hh:*"; $q2 = "*:$jj"; $q3 = "$hh:$jj"; if ($jj < 6) { $q4= "subuh"; } if (($jj >= 6) & ($jj < 10)) { $q4= "pagi"; } if (($jj >= 10) & ($jj < 14)) { $q4= "siang"; } if (($jj >= 14) & ($jj < 18)) { $q4= "sore"; } if (($jj >= 18) & ($jj <= 23)) { $q4= "malam"; } $q5 = "$mmdd:*"; $q6 = "$mmdd:$jj"; $object = array ( "ads0" => DIR_ADS, "ads1" => DIR_ADS, "ads2" => DIR_ADS, "ads3" => DIR_ADS, "ads4" => DIR_ADS, "pls0" => DIR_PLS, "pls1" => DIR_PLS, "pls2" => DIR_PLS, "pls3" => DIR_PLS, "pls4" => DIR_PLS, "seq0" => DIR_SEQ, "seq1" => DIR_SEQ, "seq2" => DIR_SEQ, "seq3" => DIR_SEQ, "seq4" => DIR_SEQ, "voc-talk" => DIR_VOC, "voc-open" => DIR_VOC, "voc-close" => DIR_VOC, "text" => DIR_TXT, "lock" => "" ); function pre_check($f,$o) { global $object; $ext = array ("lst","mp3","rot","seq"); if ($f) { foreach ($ext as $e) { $fi = $object[$o]."$f.$e"; if (file_exists($fi)) { $fc=$fi; } } return $fc; } } function make_values($I) { global $object, $q0, $q1, $q2, $q3, $q4, $q5, $q6; $values = array(); // Main function, make variable foreach (array_keys($object) as $o) { $values["$$o"] = pre_check($I["$q6"][$o],$o); /* 12-25:jam */ if (is_null ($values["$$o"])) { $values["$$o"] = pre_check($I["$q5"][$o],$o); } /* 12-25:* */ if (is_null ($values["$$o"])) { $values["$$o"] = pre_check($I["$q3"][$o],$o); } /* full */ if (is_null ($values["$$o"])) { $values["$$o"] = pre_check($I["$q2"][$o],$o); } /* jam */ if (is_null ($values["$$o"])) { $values["$$o"] = pre_check($I["$q1"][$o],$o); } /* hari */ if (is_null ($values["$$o"])) { $values["$$o"] = pre_check($I["$q4"][$o],$o); } /* siang/sore */ if (is_null ($values["$$o"])) { $values["$$o"] = pre_check($I["$q0"][$o],$o); } /* default values */ } return $values; } // Load configurations $values = make_values(parse_ini_file(DIR_CONF."claudio.ini",true)); if (DEBUG) { print_r($values); } $template = array ( "open.lst","close.lst","restart.lst", "apc.seq","auto1.lst","auto2.lst","auto3.lst", "ts1.seq","ts2.seq","ts3.seq", ); function parse_template($temp) { global $object, $q0, $q1, $q2, $q3, $q4, $q5, $q6, $values; foreach (array_keys($object) as $o) { if ($values["$$o"]) { $temp = preg_replace("/%".$o."%/i", "-1\t".$values["$$o"], $temp); } else { $temp = preg_replace("/%".$o."%/i", "", $temp); } } $temp = preg_replace("/^-1\t*[\n|\r]/", "", $temp); $temp = preg_replace("/(^[\r\n]*|[\r\n]+)[\s\t]*[\r\n]+/", "\n", $temp); $temp = preg_replace("/(^[\r\n]*|[\r\n]+)[\s\t]*[\r\n]+/", "", $temp); $temp = preg_replace("/\//","\\",$temp); /* win32 slash */ // count $c = explode("\n",$temp); $counter = count($c)-1; $finetemp = $counter . "\n" .$temp; return $finetemp; } foreach ($template as $tpl) { $temp = ""; if (file_exists(DIR_TPL.$tpl)) { $T = file(DIR_TPL.$tpl); $temp = implode ($T); $temp = $temp."\n"; $temp = parse_template($temp); if ($temp) { echo "$tpl\n\n$temp\n---------------\n"; } } } // Unfinished: Write $temp to new files //
#!/bin/bash PACK=$1 # #usage syntax : fog [game-id] # REPOS="/var/www/fog/.repos" wget -c http://www.freegamesforyourwebsite.com/download.php?g=$PACK -O $REPOS/$PACK.zip unzip -j $REPOS/$PACK.zip -d /var/www/fog/$PACK chown myfog:myfog /var/www/fog/$PACK -R