diff --git a/php/app.php b/php/app.php index 597dd825..208b96bc 100644 --- a/php/app.php +++ b/php/app.php @@ -156,6 +156,7 @@ if (!$action) { $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 @@ if (!$action) { // 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 @@ if (!$action) { ))); $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; } diff --git a/php/index.php b/php/index.php index f021cc91..a17d98d2 100644 --- a/php/index.php +++ b/php/index.php @@ -39,6 +39,7 @@ echo $mustache->render($view, array( '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 @@ echo $mustache->render($view, array( '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, diff --git a/php/sprocketize.php b/php/sprocketize.php index 0eeb463f..edb0050a 100644 --- a/php/sprocketize.php +++ b/php/sprocketize.php @@ -8,7 +8,9 @@ if ($pos !== false) $pos = strlen(PATH); $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',