hackalive
Members-
Posts
652 -
Joined
-
Last visited
Everything posted by hackalive
-
Hi guys I am encoding JSON in PHP but want to know how to escape ' and " thats in the content? Thanks
-
My point is I dont want this :{ I want : { like that adda break between : and {
-
Hi guys I have this code I am using function indent($json) { $result = ''; $pos = 0; $strLen = strlen($json); $indentStr = ' '; $newLine = "\n"; $prevChar = ''; $outOfQuotes = true; for ($i=0; $i<=$strLen; $i++) { // Grab the next character in the string. $char = substr($json, $i, 1); // Are we inside a quoted string? if ($char == '"' && $prevChar != '\\') { $outOfQuotes = !$outOfQuotes; // If this character is the end of an element, // output a new line and indent the next line. } else if(($char == '}' || $char == ']') && $outOfQuotes) { $result .= $newLine; $pos --; for ($j=0; $j<$pos; $j++) { $result .= $indentStr; } } // Add the character to the result string. $result .= $char; // If the last character was the beginning of an element, // output a new line and indent the next line. if (($char == ',' || $char == '{' || $char == '[') && $outOfQuotes) { $result .= $newLine; if ($char == '{' || $char == '[') { $pos ++; } for ($j = 0; $j < $pos; $j++) { $result .= $indentStr; } } $prevChar = $char; } return $result; } However it outputs: { "timeline":{ "headline":"FifteenTwo", "type":"default", "startDate":"2012,1" } } When I would rather it be: { "timeline": { "headline":"FifteenTwo", "type":"default", "startDate":"2012,1" } } If anyone can help me do this that would be great. Thanks in advance A PS to the Admin's, the PHP button is outputing [m][/m] so I had to manually do the PHP tags.
-
I think Ill marked this closed, think it out better and come back later. Thanks for some pointers for now guys.
-
Im running my own custom software, so Im trying to figure out how to achieve that with it
-
Why would you make such a claim? This is the typical way to go about this. SOrry to everyone, I just didnt think that Google would be doing a load of vhost writes ... my apologies
-
Thanks but I dont necessarily (and correct me if I am wrong by all means) think this is how Tumblr or Blogger (Google) do it.
-
So thats what Id have to do in order to do what Blogspot and Tumblr do?
-
Hi guys, I am wanting to do the same as Blogger.com (aka Blogspot) and Tumblr. And allow people to set their own domain names for "pages" or blog sites. So if I was to tell them to set their own CNAME (on domain) to domains.mydomain.com What would be the PHP part to make this work? Or how would I make this work if its not PHP? Like Blogger and Tumblr it would not be a redirect (to view) (unless I am wrong about this). Any and all help is much appreciated. (PS - Am running Apache/PHP and MySQL on dedicated server).
-
okay, many thanks
-
So when setting the cookie id set it as ".mydomain.com" or "/"?
-
Ive put together a PHP/MySQLi login script for my site. However I was wandering: 1. Does Facebook use PHP Cookies or Sessions for their login? (Figured out my own answer ) 2. How does FB set the Cookie/Session so that when I log into facebook.com I am also logged into developers.facebook.com Thanks in advance.
-
Hi guys, I have and am using this code: $postQuery = array('grant_type'=>'authorization_code', 'client_id'=> $app_id, 'client_secret'=> $app_secret, 'code'=> $_REQUEST['code'], 'redirect_uri'=> $my_url); $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, 'http://localhost/token.php'); curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:9.0.1) Gecko/20100101 Firefox/9.0.1"); curl_setopt($ch, CURLOPT_HEADER, false); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_POSTFIELDS, $postQuery); curl_setopt($ch, CURLOPT_TIMEOUT, 10); $output = curl_exec($ch); curl_close($ch); $params = null; parse_str($output, $params); $api_url = "http://localhost/?access_token=" . $params['access_token']; Now token.php returns: {"access_token":"24379238d539a2874069c6602e235bd7b6c3c0d3","expires_in":3600,"token_type":"bearer","scope":"","refresh_token":"e9de4c94038e135b0592bc0886b1b4d5a14e6105"} However the PHP script (mostly the part below) $params = null; parse_str($output, $params); $api_url = "http://localhost/?access_token=" . $params['access_token']; is returning: Notice: Undefined index: access_token in \public\app.php on line 47 How can I resolve this? Many thanks in advance
-
PDO returning single string not associative array.
hackalive replied to hackalive's topic in PHP Coding Help
Managed to get it working now. http://www.phpfreaks.com/forums/index.php?topic=357211.0 (If anyone is game ) Anyone whos after a relatively debugged (thanks to you guys) oAuth library for PHP feel free to PM me -
PDO returning single string not associative array.
hackalive replied to hackalive's topic in PHP Coding Help
Ran the Manual SQL query. It found a result. I updated the code to run the SQL query to: [php $sql = "SELECT $tokenName, client_id, expires, scope, user_id FROM $tableName WHERE token = :token"; [/code] If I echo the return it now gives me: Array However if I echo $token["expires"] I get: Notice: Undefined index: expires in .... -
PDO returning single string not associative array.
hackalive replied to hackalive's topic in PHP Coding Help
So you guys know what I have tried and maybe can help narrow down the prolem. If I do this (add 'return' to the line in its exiting place): return $stmt->bindParam(':token', $token, PDO::PARAM_STR); It reruns the a value of: However if I was to return the execute() line I again get no value returned. -
PDO returning single string not associative array.
hackalive replied to hackalive's topic in PHP Coding Help
If I do return $sql; The output is: Which is all correct I believe. -
PDO returning single string not associative array.
hackalive replied to hackalive's topic in PHP Coding Help
If i modify the code to return $result; It returns no value still at all. As an added note, PHP is not returning any errors either. -
Hi guys, I am using this oAuth library https://github.com/elbunce/oauth2-php But more specifically these lines of code: protected function getToken($token, $isRefresh = true) { try { $tableName = $isRefresh ? self::TABLE_REFRESH : self::TABLE_TOKENS; $tokenName = $isRefresh ? 'refresh_token' : 'oauth_token'; $sql = "SELECT $tokenName, client_id, expires, scope, user_id FROM $tableName WHERE token = :token"; $stmt = $this->db->prepare($sql); $stmt->bindParam(':token', $token, PDO::PARAM_STR); $stmt->execute(); $result = $stmt->fetch(PDO::FETCH_ASSOC); return $result !== FALSE ? $result : NULL; } catch (PDOException $e) { $this->handleException($e); } } However, this is retuning no value. If I modify the code to be: protected function getToken($token, $isRefresh = true) { return $token; } It returns the $token value, so the $token is definitely being passed to the function. The code should return an associative array: i.e., $token["expires"], $token["client_id"], $token["userd_id"], $token["scope"], etc Also $token should not === NULL. PS. I run a few checks on $tableName = $isRefresh ? self::TABLE_REFRESH : self::TABLE_TOKENS; $tokenName = $isRefresh ? 'refresh_token' : 'oauth_token'; And they are returning the correct values. Which from my thinking narrows it down to: $sql = "SELECT $tokenName, client_id, expires, scope, user_id FROM $tableName WHERE token = :token"; $stmt = $this->db->prepare($sql); $stmt->bindParam(':token', $token, PDO::PARAM_STR); $stmt->execute(); $result = $stmt->fetch(PDO::FETCH_ASSOC); return $result !== FALSE ? $result : NULL; Any and all help is greatly appreciated. Thanks in advance.
-
This is the library I am using https://github.com/elbunce/oauth2-php And the scope are accessible from the URL ie.e localhost/index.php?scope=one,two&client_id=aadasdsafd
-
Using this oAuth library https://github.com/elbunce/oauth2-php Running authorize.php and clicking "yep" button System is returning Fatal error: Uncaught {"error":"invalid_client","error_description":"No client id supplied"} thrown in A:\public\lib\OAuth2.php on line 837 Reason it is returning that and not doing as it should is because line ~830+ if (!isset($inputData)) { $inputData = $_GET; } $input = filter_var_array($inputData, $filters); is returning no value. If you manually set values (on line 835+) $input["client_id"] = "0123456789ab"; $input["redirect_uri"] = "http://www.google.com.au"; $input["response_type"] = "code"; it works as it should. Hope this now makes senese
-
I have narrowed it down to around line 830 of OAuth2.php if (!isset($inputData)) { $inputData = $_GET; } the $_GET is returning no value, which is wrong. It should be returning all the field values from the form.
-
This is the error I get Fatal error: Uncaught {"error":"invalid_client","error_description":"No client id supplied"} thrown in A:\public\lib\OAuth2.php on line 837
-
Hi guys, I have managed to get all my oAuth to work (basically), however the autorize.php is getting this error when "Allowing". Any ideas why? Only happens once I press allow and it should have redirected to the REDIRECT_URI. Thanks in advance.
-
Hi guys, Im using this https://github.com/elbunce/oauth2-php But unable to find where to add supported scopes that works. Any help is greatly and much appreciated. PS on OAuth2.php i found const CONFIG_SUPPORTED_SCOPES = 'supported_scopes'; // Array of scopes you want to support but changing 'supported_scopes' did not work.