", $string); $string = str_replace("<I>", "", $string); $string = str_replace("</i>", "", $string); $string = str_replace("</I>", "", $string); $string = str_replace("<b>", "", $string); $string = str_replace("</b>", "", $string); $string = str_replace("<br>", "
", $string); $string = str_replace("<BR>", "
", $string); $string = str_replace("%%br%%", "
", $string); $string = str_replace("%%BR%%", "
", $string); return $string; } function _formatFloat($float, $size = 2) { #return number_format($float, $size, ",", "."); return number_format($float, $size); } function formatFloat($f) { if ( 0 == ($f - floor($f))) { $f = intval($f); } else { $f = _formatFloat($f); } return $f; } /** * Shorter alias to formatFloat(). */ function fF($f) { return formatFloat($f); } function printScoreData($score_array) { $return = "["; foreach($score_array as $score) { try { $f_score = formatFloat($score); } catch( Exception $e ) { error_log("printScoreData: score data seems to be messed up: " . $e->getMessage()); $f_score = 0; } if ( 0 != $f_score ) { $return .= $f_score; } else { $return .= "null"; } $return .= ","; } rtrim($return, ","); $return .= "]"; return $return; } function getAiringStatusCode($airing_status) { $status = DB::select("SELECT id FROM airing_status WHERE status = ?", array($airing_status)); if ( empty($status) ) { return 4; } return $status[0]->id; } function getSeason( $month = null ){ if ( is_null($month) ) { $month = (int)date("m"); } switch( $month ) { case 1: case 2: case 3: return "Winter"; case 4: case 5: case 6: return "Spring"; case 7: case 8: case 9: return "Summer"; case 10: case 11: case 12: return "Fall"; } } function nextSeason( $month = null ){ if ( is_null($month) ) { $month = (int)date("m"); } $next = $month + 3; if ( $next > 12 ) { $next = $next - 12; } return $next; } function escapeLike($string){ $search = array('%', '_'); $replace = array('\%', '\_'); $string = str_replace($search, $replace, $string); $string = explode(" ", $string); return implode("%", $string); } function compare($str1, $str2) { $str1 = preg_replace("/[^a-z0-9]/", '', strtolower($str1)); $str2 = preg_replace("/[^a-z0-9]/", '', strtolower($str2)); if ( $str1 != $str2 ) { return false; } return true; } function getSeasonFromDate($aired_at) { if ( is_null($ared_at) ) { return array("name" => null, "year" => null); } $aired_from = Carbon::instance($aired_at); return array("name" => getSeason($aired_from->month), "year" => $aired_from->year); } function camo($url) { if ( "" != env("GOCAMO_HMAC") && "" != env("GOCAMO_URL") ) { $phpamo = new \WillWashburn\Phpamo\Phpamo( env("GOCAMO_HMAC"), env("GOCAMO_URL") ); return $phpamo->camo($url); } return $url; }