Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Move php to own directory

  • Loading branch information...
commit 8564e0701eaff40a488f61fa34451f8e7490891d 1 parent 82376e4
@remy remy authored
Showing with 12 additions and 6 deletions.
  1. +7 −4 php/app.php
  2. +2 −1  php/index.php
  3. +3 −1 php/sprocketize.php
View
11 php/app.php
@@ -156,6 +156,7 @@
$sql = sprintf('select * from ownership where name="%s"', mysql_real_escape_string($name));
$result = mysql_query($sql);
$ok = false;
+ $created = false;
header('content-type: application/json');
@@ -163,9 +164,11 @@
// store and okay (note "key" is a reserved word - typical!)
$key = $bcrypt->hash($key);
$sql = sprintf('insert into ownership (`name`, `key`, `email`, `last_login`, `created`, `updated`) values ("%s", "%s", "%s", NOW(), NOW(), NOW())', mysql_real_escape_string($name), mysql_real_escape_string($key), mysql_real_escape_string($email));
- $ok = mysql_query($sql);
- if ($ok) {
- echo json_encode(array('ok' => true, 'created' => true));
+ $result = mysql_query($sql);
+ if ($result) {
+ $ok = true;
+ $created = true;
+ // echo json_encode(array('ok' => true, 'created' => true));
} else {
echo json_encode(array('ok' => false, 'error' => mysql_error()));
}
@@ -205,7 +208,7 @@
)));
$hash = session_hash($data);
setcookie('session', $hash . $data, time() + 60 * 60 * 24 * 30, '/', null, false, true);
- echo json_encode(array('ok' => true, 'created' => false));
+ echo json_encode(array('ok' => true, 'created' => $created));
}
exit;
}
View
3  php/index.php
@@ -39,6 +39,7 @@
'home' => $home,
'revision' => $revision,
'code_id' => $code_id,
+ 'url' => $_SERVER['REQUEST_URI'],
'code_id_path' => $code_id_path,
'code_id_domain' => $code_id_domain,
'json_template' => json_encode(array(
@@ -51,7 +52,7 @@
'production?' => IS_PRODUCTION,
'analytics_id' => ANALYTICS_ID,
'embed' => $embed,
- 'tips' => file_get_contents('tips.json'),
+ 'tips' => file_get_contents('../public/tips.json'),
'list_history' => $embed ? '' : $list_history,
'jsbin' => json_encode(array(
'root' => ROOT,
View
4 php/sprocketize.php
@@ -8,7 +8,9 @@
$request_uri = substr($_SERVER['REQUEST_URI'], $pos);
$filePath = '/' . preg_replace('/\?.*/', '', $request_uri);
-
+
+chdir('../public');
+
// prepare sprocket
$sprocket = new Sprocket($filePath, array(
'contentType' => 'application/x-javascript',
Please sign in to comment.
Something went wrong with that request. Please try again.