/** * The mysql connection. * @return resource */ public static function mysql() { if (is_null(self::$mysql)) { self::$mysql = new mysqli('localhost', 'portal', 'V0iiYF9C', 'portal_dev'); if (!self::$mysql) { throw new Portal_MySQL_Exception(mysqli_connect_error()); } } return self::$mysql; }
REST::fatal(REST::HTTP_BAD_REQUEST, 'Missing (one of) required parameters "email" and "password"'); } $dn = Portal_User::csa_dn(); if (empty($dn)) { REST::fatal(REST::HTTP_NOT_FOUND); } $escemail = Portal_MySQL::escape_string($_GET['email']); $md5password = md5($_GET['password']); $escdn = Portal_MySQL::escape_string($dn); Portal_MySQL::real_query(<<<EOS DELETE FROM `User` WHERE `user_dn` = {$escdn} AND `user_email` <> {$escemail}; EOS ); Portal_MySQL::real_query(<<<EOS UPDATE `User` SET `user_dn` = {$escdn} WHERE `user_email` = {$escemail} AND `user_password` = '{$md5password}'; EOS ); if (!Portal_MySQL::mysql()->affected_rows) { Portal_User::unauthorized(); } $url = REST::htmlspecialchars(Portal::portalURL()); REST::fatal(REST::HTTP_OK, <<<EOS <p>Registration complete.</p> <p>You can now start <a href="{$url}">using the GridApps web service</a>.</p> EOS );
REST::fatal(REST::HTTP_BAD_REQUEST, "Content-Length header doesn't match actual content length."); } $is_shared = @$_GET['shared'] == '1' ? 1 : 0; try { Portal_MySQL::real_query(<<<EOS INSERT INTO `Database` ( `name`, `version`, `user_id`, `is_shared`, `checksum`, `type` ) VALUES ( {$dbname}, {$dbversion}, {$user_id}, {$is_shared}, '{$checksum}', {$typeId} ); EOS ); } catch (Portal_MySQL_Exception $e) { unlink($tmpfilename); REST::fatal(REST::HTTP_CONFLICT, "Can't overwrite existing file: name={$dbname}, version={$dbversion}, type={$_POST['type']}"); } $insert_id = Portal_MySQL::mysql()->insert_id; if (!rename($tmpfilename, Portal_DB::DATABASE_DIR . $insert_id)) { unlink($tmpfilename); Portal_MySQL::real_query("DELETE FROM `Database` WHERE `database_id` = {$insert_id}"); REST::fatal(REST::HTTP_INTERNAL_SERVER_ERROR, "Couldn't store uploaded file."); } chmod(Portal_DB::DATABASE_DIR . $insert_id, 0660); } $extension = Portal_DB::databaseTypeExtension($typeId); $htmlurl = "{$insert_id}.{$extension}"; $fullurl = REST::urlbase() . $_SERVER['REDIRECT_URL'] . $htmlurl; $content_type = REST::best_content_type(array(REST::best_xhtml_type() => 1.0, 'text/plain' => 0.5), 'text/plain'); if ($content_type == 'text/plain') { REST::header(array('status' => REST::HTTP_CREATED, 'Location' => $fullurl, 'Content-Type' => 'text/plain; charset=US-ASCII')); echo $fullurl; exit;