Jump to content

stealthrt

New Members
  • Posts

    6
  • Joined

  • Last visited

stealthrt's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Hey all I am new at doing anything regarding PHP Shell_exec commands. I have some UCI code that allows me to add a rule to my firewall. This works just fine in SSH but when I try running the same thing in the PHP page it does not seem to do anything and without any error lettings me know whats going on.... My code: <?php try { $cmd = "uci add firewall rule ". "uci set firewall.@rule[-1].name='my iphone' ". "uci set firewall.@rule[-1].src='lan' ". "uci set firewall.@rule[-1].dest='wan' ". "uci set firewall.@rule[-1].src_mac='XX:XX:XX:XX:XX:XX' ". "uci set firewall.@rule[-1].proto='all' ". "uci set firewall.@rule[-1].target='REJECT' ". "uci set firewall.@rule[-1].enabled='1' ". "commit firewall ". "service firewall restart "; echo 'command: ', $cmd; $output = shell_exec($cmd); } catch (Exception $e) { echo 'Caught exception: ', $e->getMessage(), "\n"; } echo "<pre>output: $output</pre>"; ?> I've even tried adding 2>&1 at the end: <?php try { $cmd = "uci add firewall rule 2>&1". "uci set firewall.@rule[-1].name='my iphone' 2>&1". "uci set firewall.@rule[-1].src='lan' 2>&1". [more code here] And I've tried using only 1 uci for the whole command: <?php try { $cmd = "uci add firewall rule 2>&1". "set firewall.@rule[-1].name='my iphone' 2>&1". "set firewall.@rule[-1].src='lan' 2>&1". [more code here] And I've tried using the same as above but without the 2>&1 <?php try { $cmd = "uci add firewall rule ". "set firewall.@rule[-1].name='my iphone' ". "set firewall.@rule[-1].src='lan' ". [more code here] And lastly I've tried it with the 2>&1 just at the end of the command and with only 1 uci: <?php try { $cmd = "uci add firewall rule ". "set firewall.@rule[-1].name='my iphone' ". "set firewall.@rule[-1].src='lan' ". [more code here] "service firewall restart 2>&1"; [more code here] and with each having uci: <?php try { $cmd = "uci add firewall rule ". "uci set firewall.@rule[-1].name='my iphone' ". "uci set firewall.@rule[-1].src='lan' ". [more code here] "service firewall restart 2>&1"; [more code here] It first code block above outputs this on the page: But like I said, it doesn't give any errors. I tested a simple ls command with it and it works as expected: So, what am I missing?
  2. Ah, got what you were saying. Thanks! it works now
  3. Hey all I am just now getting around to the newest version of the PHP sdk for Facebook. It seems to use a new array of returned data that I can not seem to be able to parse out what I need and not all other gibberish it has contained inside the array. The array returned looks like this: Array ( [data] => Array ( [0] => stdClass Object ( [id] => 439676913452345546787863523525 [name] => John Doe [picture] => stdClass Object ( [data] => stdClass Object ( [is_e] => [url] => https://blah.com.... ) ) ) [1] => stdClass Object ( [id] => 56594790468026754634524674 [name] => Bob Barker [picture] => stdClass Object ( [data] => stdClass Object ( [is_e] => [url] => https://blah.com.... ) ) ) [2]...etc etc... [paging] => stdClass Object ( [cursors] => stdClass Object ( [before] => QWFMmhllXN5JH....Rk52QWc= [after] => WGHtdnNIwaDlRz....05RNB0E= ) ) ) ) In the older version of the Facebook SDK I just needed to do something along these lines (below code example is getting the id within the returned array and checking also to make sure it has a value or not): foreach($theReturnedArray['data'] as $rData) { $id = (isset($rData['id']) ? $rData['id'] : null); $name = (isset($rData['name']) ? $rData['name'] : null); echo $name . ' ' . $id . '<br />'; } in order to get the value that I needed. I have also tried: foreach($graphObject['data'] as $rData) { echo $rData->id + '<br/>'; echo '======================================<br/>'; } and that just gives me 0's for each one it finds.. Now the return has an added stdClass object within the array itself and I am unsure on how to go about getting id, name & picture url from it. Any help would be awesome!
  4. I am currently using the sample.php page provided with the code here. Now it does create the access token just fine. It also shows my account info as it should be. It finds all the file directory's in the "files array" part. It can upload a test image just fine to dropbox. It can get all the meta data for current images in my dropbox folder. However, I can not seem to download the images from dropbox! The error i get once it gets to this code: echo "\r\n\r\n<b>Downloading $file->path:</b>\r\n"; print_r($dropbox->DownloadFile($file, $test_file)); Is this below: ( ! ) Fatal error: Uncaught exception 'DropboxException' with message ' in C:\wamp\www\test\DropboxClient.php on line 634 ( ! ) DropboxException: Could not retrieve meta data from header data: Array ( [0] => HTTP/1.1 404 Not Found [1] => Server: nginx [2] => Date: Sat, 29 Mar 2014 18:07:54 GMT [3] => Content-Type: application/json [4] => Transfer-Encoding: chunked [5] => Connection: keep-alive [6] => ) in C:\wamp\www\test\DropboxClient.php on line 634 Call Stack # Time Memory Function Location 1 0.0016 156816 {main}( ) ..\sample.php:0 2 1.0901 343472 DropboxClient->DownloadFile( ) ..\sample.php:80 3 1.4278 344872 DropboxClient::getMetaFromHeaders( ) ..\DropboxClient.php:223 I'm not sure where i am needing to check out (either in the code or on the wamp side) in order to correct this issue above? Any help would be great!
  5. Hey all i am using the following code to post to a posting on my news feed: <?php require '../src/facebook.php'; $facebook = new Facebook(array( 'appId' => 'xxxxxxxxxxxxxxx', 'secret' => 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx', 'fileUpload' => true, 'cookie' => true )); $user = $facebook->getUser(); if ($user) { try { $access_token = $facebook->getAccessToken(); $user_profile = $facebook->api('/me'); $comment = $facebook->api('/xxxxxxxxxxxxxx/comments', 'POST', array( 'access_token' => $access_token, 'message' => 'testing!' ) ); } catch (FacebookApiException $e) { echo ($e); $user = null; } } <?php if ($user): ?> <a href="<?php echo $logoutUrl; ?>">Logout</a> <?php else: ?> <a href="<?php echo $loginUrl; ?>">Login with Facebook</a> <?php endif ?> if ($user) { $logoutUrl = $facebook->getLogoutUrl(); } else { $statusUrl = $facebook->getLoginStatusUrl(); $params = array( 'scope' => 'read_stream, friends_likes, email, read_mailbox, read_requests, user_online_presence, friends_online_presence, manage_notifications, publish_actions, publish_stream, user_likes, user_photos, user_status, user_videos, read_insights' ); $loginUrl = $facebook->getLoginUrl($params); } ?> <?php print_r($user_profile); ?> For some reason i get this error: OAuthException: (#221) Photo not visible And i have no idea since i am posting a text comment and not even an image?? If i comment out the code line /*$comment = $facebook->api('/xxxxxxxxxxxxxx/comments', 'POST', array( 'access_token' => $access_token, 'message' => 'testing!' ) );*/ it works just fine (as in, displays my info with user_profile). I've tried reading over the page that tells you how to use the comments https://developers.facebook.com/docs/graph-api/reference/object/comments/ and i do - it just doesn't seem to want to work? Using the graph API i was able to do the same thing i am trying to do via PHP so i know it works since it returns a json ID and when i refresh the page i see the "testing" comment...: And what makes it more odd is that, i can use the above code to comment on just a comment that doesnt have an image posted... But if i am commenting on a image that was posted then i get that error???!?!?!? I use this code to sussesfully post to a non-image post (as in, just someone posting text). Where xxxxxxxxxxxx is the post ID and yyyyyyyyyyyyyy is the users ID who posted the comment that i am posting my comment to. $comment = $facebook->api('/xxxxxxxxxxx_yyyyyyyyyyyyy/comments', 'post', array( 'message' => 'testing!', ) ); What am i missing???
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.