public function get_calendar() { $date_start = date('Y-m-d', $_GET['start']); $date_end = date('Y-m-d', $_GET['end']); $variable = new Result(); $variable->get(); $day = 24 * 60 * 60 * 1000; foreach ($variable as $key => $value) { $title = null; $color = null; switch ($value->result_type_id) { case 1: $title = "รายสัปดาห์"; $color = "#337AB7"; break; case 2: $title = "รายเดือน"; $color = "#f0AD4E"; break; default: $title = "รายวัน"; $color = "#5cb85c"; break; } $data_[] = array("title" => $value->title, "start" => date("Y-m-d", strtotime($value->import_time)), "url" => "reports/views/" . $value->id, "color" => $color); } echo json_encode(@$data_); }
/** * Tries to parse a string and to get the domain name, tld and idn * converted domain name. * * If given string is not a domain name, it will add a default tld. * * Also skips given string if it is longer than 63 characters. * * @throws instance of AbstractException if throwExceptions = true * @param string $unparsedString * @param string $defaultTld * @return void */ public function parse($unparsedString, $defaultTld = 'com') { try { if ($this->loaded === false) { $this->load(); } $matchedDomain = ''; $matchedDomainIdn = ''; $matchedTld = ''; $matchedTldIdn = ''; $matchedGroup = ''; $validHostname = true; $IdnaConverter = new Idna(array('idn_version' => 2008)); preg_match('/^((http|https|ftp|ftps|news|ssh|sftp|gopher):[\\/]{2,})?([^\\/]+)/', mb_strtolower(trim($unparsedString), $this->encoding), $matches); $parsedString = $IdnaConverter->encode(end($matches)); foreach ($this->tldList['content'] as $tldgroup => $tlds) { foreach ($tlds as $tld) { if (preg_match('/\\.' . $tld . '$/', $parsedString, $trash)) { $matchedTld = $tld; $matchedTldIdn = $IdnaConverter->encode($tld); $matchedDomain = substr($parsedString, 0, -strlen('.' . $matchedTld)); $matchedDomain = rtrim($matchedDomain, '.'); $matchedDomain = ltrim($matchedDomain, '.'); if ($matchedTld != 'name' && strpos($matchedDomain, '.')) { $matchedDomain = str_replace('.', '', strrchr($matchedDomain, '.')); } if (strpos($matchedDomain, ' ')) { $matchedDomain = explode(' ', $matchedDomain); $matchedDomain = end($matchedDomain); } $matchedDomainIdn = $IdnaConverter->encode($matchedDomain); $matchedGroup = $tldgroup; break; } if ($tld == $parsedString) { $matchedTld = $tld; $matchedTldIdn = $IdnaConverter->encode($tld); break; } } } if ($matchedDomain == '' && strlen($matchedDomainIdn) <= 63 && $matchedTld == '') { $matchedDomain = $IdnaConverter->decode(preg_replace_callback('/[^a-zA-Z0-9\\-\\.]/', function ($match) use(&$validHostname) { $validHostname = false; }, $IdnaConverter->encode($parsedString))); $matchedDomainIdn = $IdnaConverter->encode($matchedDomain); $matchedTld = $matchedTldIdn = $defaultTld; } elseif ($matchedDomain != '' && strlen($matchedDomainIdn) <= 63 && $matchedTld != '') { $matchedDomain = $IdnaConverter->decode(preg_replace_callback('/[^a-zA-Z0-9\\-\\.]/', function ($match) use(&$validHostname) { $validHostname = false; }, $IdnaConverter->encode($matchedDomain))); $matchedDomainIdn = $IdnaConverter->encode($matchedDomain); } elseif ($matchedDomain == '' && $matchedTld != '') { $validHostname = false; } else { throw \Novutec\DomainParser\AbstractException::factory('UnparsableString', 'Unparsable domain name.'); } $Result = new Result($matchedDomain, $matchedDomainIdn, $IdnaConverter->decode($matchedTld), $matchedTldIdn, $matchedGroup, $validHostname); } catch (\Novutec\DomainParser\AbstractException $e) { if ($this->throwExceptions) { throw $e; } $Result = new Result(); $Result->error = $e->getMessage(); } return $Result->get($this->format); }