function fields() { $res = new response(); $db = $this->params["db"]; $table = $this->params["table"]; //query $result = Doo::db()->fetchAll("SHOW COLUMNS IN {$table} IN {$db}"); foreach ($result as $row) { $data[] = array('field' => $row["Field"], 'type' => $row["Type"], 'null' => $row['Null'], 'key' => $row['Key'], 'default' => $row['Default']); } $res->data = $data; $res->success = true; echo $res->to_json(); }
/** * @access public * @param string $content The content * @param string $type The content type * @param boolean $no_cache Disable caching, default TRUE */ public static function send($content, $type, $no_cache = true) { if (headers_sent()) { die($content); //9* 16072010 USABLE WITH dbg:show(). If headers already sent do nothing with them. } switch (strtolower($type)) { case 'html': header('Content-Type: text/html; charset=' . ENCODING); break; case 'xml': header('Content-Type: text/xml; charset=' . ENCODING); break; case 'javascript': case 'js': header('Content-Type: text/javascript; charset=' . ENCODING); break; case 'json': header('Content-Type: text/x-json; charset=UTF-8'); if (is_array($content)) { $content = response::to_json($content); } break; case 'error': $data = array('success' => false, 'errors' => $content); header('Content-Type: text/x-json; charset=UTF-8'); $content = response::to_json($data); break; case 'noheaders': $no_cache = false; break; case 'text': case 'txt': default: header('Content-Type: text/plain; charset=' . ENCODING); break; } if ($no_cache) { header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // disable IE caching header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); header("Cache-Control: no-cache, must-revalidate"); header("Pragma: no-cache"); } die($content); }
function gearman_status() { $res = new response(); require_once 'Net/Gearman/Manager.php'; $id = $this->params["id"]; $server = Doo::db()->getOne('GearmanJobServers', array('where' => "id = {$id}")); if ($server == false) { $res->message = "invalid id"; $res->success = false; } else { try { $manager = new Net_Gearman_Manager($server->hostname . ":" . $server->port); $res->data = $manager->status(); $res->success = true; } catch (Net_Gearman_Exception $e) { $res->message = $e->getMessage(); $res->success = false; } } echo $res->to_json(); }
/** * Добавить \ Сохранить файл */ protected function sys_set() { $fid = $this->args['_sid']; if ($fid > 0) { $file = $this->get_file($fid); $old_file_name = $file->real_name; } $file = !empty($old_file_name) ? file_system::replace_file('file', $old_file_name) : file_system::upload_file('file'); if ($file !== false) { if (!($fid > 0)) { $file['created_date'] = date('Y-m-d : H:i:s'); } $file['changed_date'] = date('Y-m-d : H:i:s'); $this->set_args($file, true); $this->_flush(); $this->insert_on_empty = true; $result = $this->extjs_set_json(false); } else { $result = array('success' => false); } response::send(response::to_json($result), 'html'); }