本文整理汇总了PHP中formatJSEND函数的典型用法代码示例。如果您正苦于以下问题:PHP formatJSEND函数的具体用法?PHP formatJSEND怎么用?PHP formatJSEND使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了formatJSEND函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: Load
public function Load()
{
if (!file_exists(DATA . "/settings.php")) {
saveJSON('settings.php', array($this->username => array('codiad.username' => $this->username)));
}
$settings = getJSON('settings.php');
echo formatJSEND("success", $settings[$this->username]);
}
开发者ID:practico,项目名称:Codiad,代码行数:8,代码来源:class.settings.php
示例2: Run
public function Run()
{
$filepath = "{$this->root}/{$this->get['filepath']}";
$tmpfname = tempnam("/tmp", "shipshape-results-");
$fp = fopen($tmpfname, "w");
fclose($fp);
$ret = runShellCommand("shipshape --categories='go vet,JSHint,PyLint' --json_output={$tmpfname}" . " {$this->escapeShellArg($filepath)}");
echo formatJSEND('success', json_decode(file_get_contents($tmpfname)));
unlink($tmpfname);
}
开发者ID:iFromzForks,项目名称:appengine-codiad,代码行数:10,代码来源:class.shipshape.php
示例3: Run
public function Run()
{
$filepath = "{$this->root}/{$this->get['filepath']}";
// Truncate the output json file.
$fp = fopen("/tmp/shipshape-results.json", "w");
fclose($fp);
$ret = runShellCommand("shipshape --categories='go vet,JSHint,PyLint'" . " --json_output=/tmp/shipshape-results.json" . " {$this->escapeShellArg($filepath)}");
if ($ret->exit_code != 0) {
// If for any reason shipshape command failed, we don't want to show error message.
// The reason could be simply that there is no reference at the requested position.
echo formatJSEND('success', 'Running shipshape failed.');
return;
}
echo formatJSEND('success', json_decode(file_get_contents('/tmp/shipshape-results.json')));
}
开发者ID:JeckoHeroOrg,项目名称:appengine-codiad,代码行数:15,代码来源:class.shipshape.php
示例4: GetUserCount
public function GetUserCount()
{
/* Array */
$cur_users = array();
foreach ($this->actives as $data) {
if (is_array($data) && isset($data['username']) && $data['username'] != $this->username && $data['path'] == $this->path) {
$cur_users[] = $data['username'];
}
}
/* Prepare the return data. */
/* Array */
$data = array();
$data['count'] = count($cur_users);
echo formatJSEND("success", $data);
}
开发者ID:practico,项目名称:Codiad-FileUse,代码行数:15,代码来源:class.fileuse.php
示例5: Execute
public function Execute()
{
$macrolist = $this->Load();
$command = $macrolist[$this->id]['c'];
if (!$this->isAbsPath($this->path)) {
$this->path = WORKSPACE . '/' . $this->path;
}
if (is_file($this->path)) {
$command = str_replace('%FILE%', $this->path, $command);
$command = str_replace('%FOLDER%', dirname($this->path), $command);
$command = str_replace('%NAME%', basename($this->path), $command);
} else {
$command = str_replace('%FOLDER%', $this->path, $command);
$command = str_replace('%NAME%', basename($this->path), $command);
}
shell_exec($command);
echo formatJSEND("success", null);
}
开发者ID:practico,项目名称:Codiad-Macro,代码行数:18,代码来源:class.macro.php
示例6: pull
public function pull()
{
$cli_params = array();
$cli_params[] = "--non-interactive";
if ($this->username != '') {
$cli_params[] = "--username " . $this->username;
}
if ($this->password != '') {
//Need to clean up the password so it can be passed to the cli, If anyone find's or thinks of more let me know [email protected]
$this->password = str_replace(array("*", "^", "&", '"'), array('\\*', '\\^', '\\&', '\\"'), $this->password);
$cli_params[] = "--password " . $this->password;
}
if ($this->svnrepo) {
if (!$this->isAbsPath($this->path)) {
if (!file_exists(WORKSPACE . '/' . $this->path)) {
$this->command_exec = "cd " . WORKSPACE . " && svn co \"" . $this->svnrepo . "\" " . $this->path . " " . implode(" ", $cli_params);
} else {
die(formatJSEND("success", array("message" => "Folder already exists")));
}
} else {
if (!file_exists($this->path)) {
$this->command_exec = "cd " . WORKSPACE . " && svn co \"" . $this->svnrepo . "\" " . $this->path . " " . implode(" ", $cli_params);
} else {
die(formatJSEND("success", array("message" => "Folder already exists")));
}
}
if ($this->newproject) {
$this->projects = getJSON('projects.php');
$this->projects[] = array("name" => $this->name, "path" => $this->path);
saveJSON('projects.php', $this->projects);
}
$this->ExecuteCMD();
echo formatJSEND("success", array("message" => "Repo cloned"));
} else {
echo formatJSEND("error", array("message" => "No Repo specified"));
}
}
开发者ID:practico,项目名称:Codiad-SVN,代码行数:37,代码来源:class.svn.php
示例7: pull
public function pull()
{
if ($this->gitrepo) {
if (!$this->isAbsPath($this->path)) {
if (!file_exists(WORKSPACE . '/' . $this->path)) {
mkdir(WORKSPACE . '/' . $this->path);
$this->command_exec = "cd " . WORKSPACE . '/' . $this->path . " && git init && git pull " . $this->gitrepo . " " . $this->gitbranch;
} else {
die(formatJSEND("success", array("message" => "Folder already exists")));
}
} else {
if (!file_exists($this->path)) {
mkdir($this->path);
$this->command_exec = "cd " . $this->path . " && git init && git pull " . $this->gitrepo . " " . $this->gitbranch;
} else {
die(formatJSEND("success", array("message" => "Folder already exists")));
}
}
$this->ExecuteCMD();
echo formatJSEND("success", array("message" => "Repo cloned"));
} else {
echo formatJSEND("error", array("message" => "No Repo specified"));
}
}
开发者ID:practico,项目名称:Codiad-GitAdmin,代码行数:24,代码来源:class.git.php
示例8: formatJSEND
}
} else {
// Set the session username.
$_SESSION['user'] = $User->username;
}
// Set the session language, if given, or set it to english as default.
if (isset($_POST['language'])) {
$_SESSION['lang'] = $_POST['language'];
} else {
$_SESSION['lang'] = "en";
}
// Set the session theme and project.
$_SESSION['theme'] = $_POST['theme'];
$_SESSION['project'] = $_POST['project'];
// Respond by sending verification tokens on success.
echo formatJSEND("success", array('username' => $User->username));
header("Location: " . $_SERVER['PHP_SELF'] . "?action=verify");
}
} elseif ($count > 1) {
// We returned too many results. Error as such.
die(formatJSEND("error", "A server error occurred: LDAP filter result is non-unique. Please ensure this is a unique identifier within its context.\n\t\t\t\t\t If the problem persists, please contact the webmaster. If you are the webmaster, please check the LDAP filter used."));
} else {
// Invalid login.
die(formatJSEND("error", "Incorrect user name or password."));
}
} else {
// The server is having issues connecting to the LDAP server. Error as such.
die(formatJSEND("error", "An error occurred: Cannot connect to LDAP server. Please contact the webmaster. \n If you are the webmaster, please contact your LDAP server administrator or check if your LDAP server is running."));
}
}
}
开发者ID:smdion,项目名称:Codiad-LDAPExternalAuth,代码行数:31,代码来源:ldap.php
示例9: ListBranches
public function ListBranches()
{
$repo = Common::GetProjectRoot();
$ret = runShellCommand("git -C {$this->escapeShellArg($repo)} branch --no-color " . " | awk -F ' +' '! /\\(no branch\\)/ {print \$2}' ");
if ($ret->exit_code != 0 || count($ret->output) == 0) {
echo formatJSEND('error', 'No branches in this project.');
return;
}
$branches = $ret->output;
$currentBranch = $this->GetCurrentBranchName();
$result = new stdClass();
$result->current_branch = trim($currentBranch);
$result->branches = $branches;
echo formatJSEND('success', $result);
}
开发者ID:iFromzForks,项目名称:appengine-codiad,代码行数:15,代码来源:class.review.php
示例10: Check
public function Check()
{
$local = $this->getLocalVersion();
$remote = $this->getRemoteVersion("check", $local[0]['version']);
$nightly = true;
$archive = Common::getConstant('ARCHIVEURL', $this->archive);
$latest = '';
foreach ($remote as $tag) {
if ($latest == '') {
$latest = $tag["name"];
$archive = $tag["zipball_url"];
}
if ($local[0]['version'] == $tag["commit"]["sha"]) {
$local[0]['version'] = $tag["name"];
$nightly = false;
break;
}
}
$search = array("\r\n", "\n", "\r");
$replace = array(" ", " ", " ");
$message = '';
$merge = '';
$commits = json_decode(file_get_contents(Common::getConstant('COMMITURL', $this->commits)), true);
foreach ($commits as $commit) {
if ($local[0]['version'] != $commit["sha"]) {
if (strpos($commit["commit"]["message"], "Merge") === false) {
$message .= '- ' . str_replace($search, $replace, $commit["commit"]["message"]) . '<br/>';
} else {
$merge .= '- ' . str_replace($search, $replace, $commit["commit"]["message"]) . '<br/>';
}
} else {
break;
}
}
if ($message == '') {
$message = $merge;
}
return "[" . formatJSEND("success", array("currentversion" => $local[0]['version'], "remoteversion" => $latest, "message" => $message, "archive" => $archive, "nightly" => $nightly, "name" => $local[0]['name'])) . "]";
}
开发者ID:codiad,项目名称:codiad,代码行数:39,代码来源:class.update.php
示例11: die
//////////////////////////////////////////////////////////////////
// Change Password
//////////////////////////////////////////////////////////////////
if ($_GET['action'] == 'password') {
if (!isset($_POST['username']) || !isset($_POST['password'])) {
die(formatJSEND("error", "Missing username or password"));
}
if (checkAccess() || $_POST['username'] == $_SESSION['user']) {
$User->username = $_POST['username'];
$User->password = $_POST['password'];
$User->Password();
}
}
//////////////////////////////////////////////////////////////////
// Change Project
//////////////////////////////////////////////////////////////////
if ($_GET['action'] == 'project') {
if (!isset($_GET['project'])) {
die(formatJSEND("error", "Missing project"));
}
$User->username = $_SESSION['user'];
$User->project = $_GET['project'];
$User->Project();
}
//////////////////////////////////////////////////////////////////
// Verify User Account
//////////////////////////////////////////////////////////////////
if ($_GET['action'] == 'verify') {
$User->username = $_SESSION['user'];
$User->Verify();
}
开发者ID:mirzavu,项目名称:clothfarm,代码行数:31,代码来源:controller.php
示例12: Project
public function Project()
{
$revised_array = array();
foreach ($this->users as $user => $data) {
if ($this->username == $data['username']) {
$revised_array[] = array("username" => $data['username'], "password" => $data['password'], "project" => $this->project);
} else {
$revised_array[] = array("username" => $data['username'], "password" => $data['password'], "project" => $data['project']);
}
}
// Save array back to JSON
saveJSON('users.php', $revised_array);
// Response
echo formatJSEND("success", null);
}
开发者ID:codiad,项目名称:codiad,代码行数:15,代码来源:class.user.php
示例13: GetDebuggee
public function GetDebuggee($repo_name, $revision_id)
{
$token = $this->GetAccessToken();
$project_num = $this->GetCloudProjectNum();
// Call API to get a list of all (active) debugees.
$opts = array('http' => array('header' => "Authorization: Bearer {$token}\r\n"));
$resp = $this->FileGetContents("{$this->gapi_prefix}/debuggees?project={$project_num}", $opts);
if ($resp['code'] !== '200') {
throw new Exception('Cannot list debuggees for this Google Cloud project.', $resp['code']);
}
$resp_json = json_decode($resp['body']);
// Debuggees may disappear even if an application is currently deployed,
// e.g, if an application has gone offline.
if (empty($resp_json->debuggees) || !is_array($resp_json->debuggees) || count($resp_json->debuggees) === 0) {
throw new Exception('No debuggee exists in this Google Cloud project.');
}
// Try to find a best match with the (numeric) project id, repo name, and revision id.
foreach ($resp_json->debuggees as $debuggee) {
// 'sourceContexts' may not always exist.
if ($debuggee->project === $project_num && !empty($debuggee->sourceContexts)) {
foreach ($debuggee->sourceContexts as $context) {
if (!empty($context->cloudRepo->repoId->projectRepoId)) {
$repo = $context->cloudRepo->repoId->projectRepoId;
if ($repo->repoName === $repo_name && $context->cloudRepo->revisionId === $revision_id) {
// Found a perfect match. Return its id. Return the entire debuggee list together
// anyway so that users may manually select one if they wish to.
echo formatJSEND('success', array('id' => $debuggee->id, 'list' => $resp_json->debuggees));
return;
}
}
}
}
}
// Did not find a matching debuggee. Return the entire debuggee list anyway.
echo formatJSEND('success', array('list' => $resp_json->debuggees));
}
开发者ID:iFromzForks,项目名称:appengine-codiad,代码行数:36,代码来源:class.debugger.php
示例14: Update
public function Update($type, $name)
{
function rrmdir($path)
{
return is_file($path) ? @unlink($path) : @array_map('rrmdir', glob($path . '/*')) == @rmdir($path);
}
function cpy($source, $dest, $ign)
{
if (is_dir($source)) {
$dir_handle = opendir($source);
while ($file = readdir($dir_handle)) {
if (!in_array($file, $ign)) {
if (is_dir($source . "/" . $file)) {
if (!file_exists($dest . "/" . $file)) {
mkdir($dest . "/" . $file);
}
cpy($source . "/" . $file, $dest . "/" . $file, $ign);
} else {
copy($source . "/" . $file, $dest . "/" . $file);
}
}
}
closedir($dir_handle);
} else {
copy($source, $dest);
}
}
if (file_exists(BASE_PATH . '/' . $type . '/' . $name . '/' . rtrim($type, "s") . '.json')) {
$data = json_decode(file_get_contents(BASE_PATH . '/' . $type . '/' . $name . '/' . rtrim($type, "s") . '.json'), true);
if (substr($data[0]['url'], -4) == '.git') {
$data[0]['url'] = substr($data[0]['url'], 0, -4);
}
$data[0]['url'] .= '/archive/master.zip';
$ign = array(".", "..");
if (isset($data[0]['exclude'])) {
foreach (explode(",", $data[0]['exclude']) as $exclude) {
array_push($ign, $exclude);
}
}
if (file_exists(BASE_PATH . '/' . $type . '/_' . session_id()) || mkdir(BASE_PATH . '/' . $type . '/_' . session_id())) {
if (file_put_contents(BASE_PATH . '/' . $type . '/_' . session_id() . '/' . $name . '.zip', fopen($data[0]['url'], 'r'))) {
$zip = new ZipArchive();
$res = $zip->open(BASE_PATH . '/' . $type . '/_' . session_id() . '/' . $name . '.zip');
// open downloaded archive
if ($res === true) {
// extract archive
if ($zip->extractTo(BASE_PATH . '/' . $type . '/_' . session_id() . '') === true) {
$zip->close();
$srcname = $name;
if (substr($srcname, -6) != "master") {
$srcname = $srcname . '-master';
}
cpy(BASE_PATH . '/' . $type . '/_' . session_id() . '/' . $srcname, BASE_PATH . '/' . $type . '/' . $name, $ign);
} else {
die(formatJSEND("error", "Unable to open " . $name . ".zip"));
}
} else {
die(formatJSEND("error", "ZIP Extension not found"));
}
rrmdir(BASE_PATH . '/' . $type . '/_' . session_id());
// Response
echo formatJSEND("success", null);
} else {
die(formatJSEND("error", "Unable to download " . $repo));
}
} else {
die(formatJSEND("error", "Unable to create temp dir "));
}
} else {
echo formatJSEND("error", "Unable to find " . $name);
}
}
开发者ID:codiad,项目名称:codiad,代码行数:72,代码来源:class.market.php
示例15: array
// Save array back to JSON and set the session username.
$User->users[] = array('username' => $User->username, 'password' => null, 'project' => "");
saveJSON("users.php", $User->users);
$_SESSION['user'] = $User->username;
} else {
// Deny login and send message, the user doesn't exist within users.php.
die(formatJSEND("error", "User " . $User->username . " does not exist within Codiad."));
}
} else {
// Set the session username.
$_SESSION['user'] = $User->username;
}
// Set the session language, if given, or set it to english as default.
if (isset($_POST['language'])) {
$_SESSION['lang'] = $_POST['language'];
} else {
$_SESSION['lang'] = "en";
}
// Set the session theme and project.
$_SESSION['theme'] = $_POST['theme'];
$_SESSION['project'] = $_POST['project'];
// Respond by sending verification tokens on success.
echo formatJSEND("success", array('username' => $User->username));
header("Location: " . $_SERVER['PHP_SELF'] . "?action=verify");
} else {
// Invalid login.
die(formatJSEND("error", "Invalid user name or password."));
}
}
}
}
开发者ID:QMXTech,项目名称:Codiad-SQLExternalAuth,代码行数:31,代码来源:SQL.php
示例16: die
}
}
//////////////////////////////////////////////////////////////////
// Rename Project
//////////////////////////////////////////////////////////////////
if ($_GET['action'] == 'rename') {
if (!checkPath($_GET['project_path'])) {
die(formatJSEND("error", "No Access"));
}
$Project->path = $_GET['project_path'];
$Project->Rename();
}
//////////////////////////////////////////////////////////////////
// Delete Project
//////////////////////////////////////////////////////////////////
if ($_GET['action'] == 'delete') {
if (checkAccess()) {
$Project->path = $_GET['project_path'];
$Project->Delete();
}
}
//////////////////////////////////////////////////////////////////
// Return Current
//////////////////////////////////////////////////////////////////
if ($_GET['action'] == 'current') {
if (isset($_SESSION['project'])) {
echo formatJSEND("success", $_SESSION['project']);
} else {
echo formatJSEND("error", "No Project Returned");
}
}
开发者ID:codiad,项目名称:codiad,代码行数:31,代码来源:controller.php
示例17: GetLocalRefs
public function GetLocalRefs()
{
$filepath = $this->escapeShellArg(str_replace($this->project . '/', '', $this->get['filepath']));
$fileTicket = $this->escapeShellArg($this->GetFileTicket($filepath));
$dirtyBuffer = $this->escapeShellArg("{$this->root}/{$this->get['filepath']}");
$cursor = $this->get['cursor'];
$ret = runShellCommand("/opt/kythe/tools/kythe --json" . " -api http://localhost:" . KYTHE_SERVER_PORT . " refs --dirty {$dirtyBuffer} {$fileTicket}");
if ($ret->exit_code != 0 || count($ret->output) == 0) {
// If for any reason kythe command failed, we don't want to show error message.
// The reason could be simply that there is no reference at the requested position.
echo formatJSEND('success');
return;
}
$kythe_refs = json_decode($ret->output[0]);
// Go through the kythe's response and build three maps which are addressable by tickets.
$refs_target = array();
$refs_source = array();
$nodes = array();
$matchedLocationTickets = array();
foreach ($kythe_refs->reference as $reference) {
if (!isset($refs_target[$reference->target_ticket])) {
$refs_target[$reference->target_ticket] = array();
}
if (!isset($refs_source[$reference->source_ticket])) {
$refs_source[$reference->source_ticket] = array();
}
$refs_target[$reference->target_ticket][] = $reference;
$refs_source[$reference->source_ticket][] = $reference;
}
foreach ($kythe_refs->node as $node) {
$nodes[$node->ticket] = $node;
if ($this->LocationMatches($node, $cursor)) {
$matchedLocationTickets[] = $refs_source[$node->ticket][0]->target_ticket;
}
}
$ref_locations = array();
// Go through all the nodes in the file. If the location of the node
// matches that of the cursor, then use the node's ticket to find all of
// the references which target ticket is the same as node's ticket.
// For those references get the location of the nodes whose tickets are
// the same as the reference's source.
foreach ($matchedLocationTickets as $t) {
foreach ($refs_target[$t] as $target_ref) {
$ref_locations[] = $this->GetLocation($nodes[$target_ref->source_ticket]);
}
}
echo formatJSEND('success', $ref_locations);
}
开发者ID:iFromzForks,项目名称:appengine-codiad,代码行数:48,代码来源:class.kythe.php
示例18: MarkFileAsFocused
public function MarkFileAsFocused()
{
foreach ($this->actives as $active => $data) {
if (is_array($data) && isset($data['username']) && $this->username == $data['username']) {
$this->actives[$active]['focused'] = false;
if ($this->path == $data['path']) {
$this->actives[$active]['focused'] = true;
}
}
}
saveJSON('active.php', $this->actives);
echo formatJSEND("success");
}
开发者ID:codiad,项目名称:codiad,代码行数:13,代码来源:class.active.php
示例19: checkSession
public static function checkSession()
{
// Set any API keys
$api_keys = array();
// Check API Key or Session Authentication
$key = "";
if (isset($_GET['key'])) {
$key = $_GET['key'];
}
if (!isset($_SESSION['user']) && !in_array($key, $api_keys)) {
echo formatJSEND('error', 'Session expired. Please refresh your page.');
exit(1);
}
}
开发者ID:iFromzForks,项目名称:appengine-codiad,代码行数:14,代码来源:common.php
示例20: session_write_close
$_GET['no_return'] = 'true';
require_once '../project/controller.php';
}
// Release a lock on '$_SESSION'. No one writes to it.
session_write_close();
//////////////////////////////////////////////////////////////////
// Handle Action
//////////////////////////////////////////////////////////////////
$debugger = new CloudDebugger();
try {
switch ($action) {
case 'get_debuggee':
$debugger->GetDebuggee($_GET['repo_name'], $_GET['revision_id']);
break;
case 'set_breakpoint':
$debugger->SetBreakpoint($_POST['debuggee_id'], $_POST['path'], $_POST['line'], $_POST['cond'], $_POST['exprs']);
break;
case 'get_breakpoint':
$debugger->GetBreakpoint($_GET['did'], $_GET['bid'], $_GET['ignore_err']);
break;
case 'delete_breakpoint':
$debugger->DeleteBreakpoint($_GET['did'], $_GET['bid']);
break;
default:
exit('{"status":"error","message":"Unknown Action"}');
}
} catch (Exception $e) {
// If a response code is set, print it too.
$code = empty($e->getCode()) ? '' : " [code: {$e->getCode()}]";
echo formatJSEND('error', $e->getMessage() . $code);
}
开发者ID:iFromzForks,项目名称:appengine-codiad,代码行数:31,代码来源:controller.php
注:本文中的formatJSEND函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论