/** * (non-PHPdoc) * @see \Bootstrap\Button::getHtml() */ public function getHtml() { if (sizeof($this->params) > 0) { $this->data('params', base64_encode(\Koldy\Json::encode($this->params))); } return parent::getHtml(); }
/** * (non-PHPdoc) * @see \Bootstrap\HtmlElement::getHtml() */ public function getHtml() { if ($this->searchEnabled) { $search = '<form class="form-inline x-remote-search-form" role="form">' . '<div class="form-group">' . '<label class="sr-only" for="search">Search</label>' . '<input type="search" class="form-control input-sm animate-width" id="search" placeholder="Search" style="width:80px;">' . '<button type="reset" class="btn btn-xs btn-link">' . \Bootstrap::icon('remove-circle') . '</button>' . '</div>' . '</form>'; $this->panel->addHeaderElement($search); } if ($this->collapsible !== null) { $this->panel->collapsible($this->collapsible); } $footer = '<div class="row">' . '<div class="col-md-6 x-remote-table-info"></div>' . '<div class="col-md-6 x-remote-table-pagination text-right"></div>' . '</div>'; $this->panel->footer($footer); $this->table->data('url', $this->url === null ? $_SERVER['REQUEST_URI'] : $this->url); $this->table->data('page', $this->startPage); $this->table->data('limit', 10); $this->table->data('field', $this->sortField === null ? $this->table->getPrimaryKey() : $this->sortField); $this->table->data('dir', $this->sortDirection); $this->table->data('extra-params', base64_encode(Json::encode($this->extraParams))); $this->panel->content($this->table); return $this->panel->getHtml(); }
public function __toString() { return \Koldy\Json::encode($this->getData()); }
/** * Process the request * @param string $os 'Android','iOS' or 'Windows' * * TODO: This logic shouldn't be in the model */ public static function processRequest($os) { if (!isset($_POST['PACKAGE_NAME'])) { Log::warning('Package name is not set! UAS=' . Request::userAgent() . ' POST=' . Json::encode($_POST)); } $time = time(); $ip = $_SERVER['REMOTE_ADDR']; $host = gethostbyaddr($ip); $country = null; $provider = null; if ($host != $ip && strpos($host, '.') !== false) { $country = strtolower(substr($host, strrpos($host, '.') + 1)); if (strlen($country) != 2) { $country = null; } $provider = \Provider::normalizeHostName($host); } Log::notice("Got request time={$time} host={$host} country={$country}"); $values = array('created_at', 'package_name', 'app_version_code', 'app_version_name', 'brand', 'phone_model', 'product', 'stack_trace', 'android_version', 'file_path', 'total_mem_size', 'available_mem_size', 'user_comment', 'user_app_start_date', 'user_crash_date', 'installation_id', 'report_id', 'user_email'); $data = array(); $vals = $_POST; foreach ($values as $key) { $key = strtoupper($key); if (isset($vals[$key])) { $data[$key] = trim($vals[$key]); unset($vals[$key]); } } if (isset($data['user_email']) && ($data['user_email'] == 'N/A' || trim($data['user_email']) == '')) { $data['user_email'] = null; } $data['created_at'] = gmdate('Y-m-d H:i:s'); $data['country'] = $country; $data['provider'] = $provider; $data['os'] = $os; $secureCount = 0; do { $submit = static::create($data); if ($submit === false) { Db::getAdapter()->close(); Log::info("Failed to insert crash submit report for time={$time}, waiting 5 seconds"); set_time_limit(60); sleep(5); Db::getAdapter()->reconnect(); Log::info("Retry {$secureCount} insert crash submit report for time={$time}"); } } while ($submit === false && $secureCount++ < 3); if ($submit !== false) { foreach ($vals as $metaName => $metaValue) { if ($metaValue !== null) { $metaValue = trim($metaValue); if (strlen($metaValue) > 0) { $secureCount = 0; do { $dbMeta = $submit->insertMeta(strtolower($metaName), trim($metaValue)); if ($dbMeta === false) { Db::getAdapter()->close(); Log::info("Failed to insert submit meta for meta={$metaName} time={$time}, waiting 5 seconds"); set_time_limit(60); sleep(5); Db::getAdapter()->reconnect(); Log::info("Retry {$secureCount} meta insert for meta={$metaName} time={$time}"); } } while ($dbMeta === false && $secureCount++ < 2); } } } } \Email\Trigger::processRequest($_POST); Log::notice("Done request time={$time}"); }