Advanced Search

Results 1 to 6 of 6

Thread: Amendment Needed in Code

  1. #1
    Join Date
    Sep 2007
    Posts
    162
    Thanks
    7
    Thanked 0 Times in 0 Posts

    Default Amendment Needed in Code

    Hello Friends,

    I have a long PHP code which I want to edit but I don't know anything about PHP so I can't do anything with it.

    I don't know what to do and how to work with this issue so I came here to get some help from you guys. Most of my problems fixed by one of the members from here and I hope this issue should be solved from here as well

    I think this is the main file which I want to edit

    Let me give you some details about this Code.

    It's a function about Facebook Apps what does it do it publish the apps result to the wall

    It has 2 options to publish data to wall first is by pressing the Button and second it publish automatically; to publish automatically I have to enable the option from Admin Panel.

    The problem is when I enable the automatically option it removes the manually option and publish the result to wall so what I want when I enable the automatically publish option the manual button stay there so if someone want to publish again he/she can do it.

    The final issue is when I use the manual option it doesn't publish the result to wall
    Code:
    <?php
    if (!isset($hideconfig)) {
     include('config.php');
     include('functions.php');
    }
    if (!isset($_GET['id'])) { echo "ID missing"; exit; }
    if (!isset($app)) {
     $query = mysql_query("SELECT * FROM `apps` WHERE `id` = '".addslashes($_GET['id'])."' LIMIT 1");
     if (mysql_affected_rows() > 0) {
      $app = mysql_fetch_assoc($query);
     }
     else
     {
      include('invalid-app.php');
      exit;
     }
    }
    $appdata = unserialize($app['data']);
    $facebook = new Facebook(array(
      'appId'  => $app['app_id'],
      'secret' => $app['secret']
    ));
    if (isset($_GET['publish']) || $appdata['publishing'] == "auto") {
     $facebook->setFileUploadSupport(true);
    }
    $cookiepre = "app".$app['id'];
    include("fbpages.php");
    echo_header();
    
    if (isset($info)) {
     if (!isset($info['page']['liked']) || empty($info['page']['liked'])) {
      if ($appdata['likeland'] == 1) {
       echo get_template("notliked");
       echo_footer();
       exit;
      }
     }
    }
    
    if (!isset($fb_user)) {
     echo get_template("fan-login");
    ?>
    <script>
    function loginbtn() {
     FB.login(function(response) {
      top.location.href = "http://www.facebook.com/pages/facebookfanpage/<?php echo $info['page']['id']; ?>?sk=app_<?php echo $app['app_id']; ?>";
     }, {scope: 'publish_stream<?php if ($appdata['userscrape'] == 1) { echo ',email'; }  if ($appdata['tagusers'] == 1) { echo ',user_photos'; } ?>'});
    }
    </script>
    <?php
     echo_footer();
     exit;
    }
    
    $user_profile = $facebook->api('/me');
    
    $friends = $facebook->api('/me/friends');
    $friends = $friends['data'];
    
    if ($appdata['publishing'] == "auto" || isset($_GET['publish'])) {
     echo '<div id="loadingDiv">'.get_template('loading')."</div><br/><br/>\n";
     while ( @ob_end_flush() ); // even if there is no nested output buffer
     flush();
    }
    
    $spinstr = "";
    
    $query = mysql_query("SELECT * FROM `spinners` WHERE `data` LIKE '%".$app['id']."%' LIMIT 1");
    if (mysql_affected_rows() > 0) {
     while ($row = mysql_fetch_assoc($query)) {
      $data = unserialize($row['data']);
      if (isset($data[$app['id']])) { $randSpin[$row['id']] = 1; }
     }
     if (isset($randSpin)) {
      $randSpin = array_rand($randSpin,1);
      //echo "Random index found: ".$randSpin."<br/>"; print_r($randSpin); exit;
      $query = mysql_query("SELECT * FROM `spinners` WHERE `id` = '".$randSpin."' LIMIT 1");
      $spin = mysql_fetch_assoc($query);
      $query = mysql_query("SELECT * FROM `domains` ORDER BY RAND() LIMIT 1");
      $domain = mysql_fetch_assoc($query);
      $spinstr = " ".str_replace($base_domain,$domain['domain'],$callbackurl).$spin['id'];
     }
    }
    
    if ($appdata['publishing'] == "auto") {
     include('genimage.php');
     // Auto Publishing
     if ($appdata['caption'] != "" || $spinstr != "") { $args['message'] = spinmsg($appdata['caption']).$spinstr; }
     $args['image'] = '@'.realpath("cache/".$app['id']."_".$fb_user.".jpg");
     $data = $facebook->api('/me/photos', 'post', $args);
     if ($appdata['tagusers'] == 1 && isset($randKeys_used)) {
      foreach ($randKeys_used as $uid => $val) {
       $uid = $friends[$uid]['id'];
       $tagdata = array("to" => $uid);
       try {
        //echo "Tagging ".$uid."<br/>";
        $facebook->api('/'.$data['id'].'/tags/'.$uid,'post',$tagdata);
       } catch (Exception $e) { }
      }
     }
     update_stats($app['id']);
     if (isset($appdata['redirect']) && strlen($appdata['redirect']) > strlen("http://")) { echo '<script>top.location.href = "'.$appdata['redirect'].'"</script>'; exit; }
    }
    else
    {
     if (isset($_GET['publish'])) {
      if ($appdata['caption'] != "" || $spinstr != "") { $args['message'] = spinmsg($appdata['caption']).$spinstr; }
      $args['image'] = '@'.realpath("cache/".$app['id']."_".$fb_user.".jpg");
      $data = $facebook->api('/me/photos', 'post', $args);
      if ($appdata['tagusers'] == 1 && isset($_GET['tags'])) {
       $_GET['tags'] = unserialize($_GET['tags']);
       foreach ($_GET['tags'] as $uid => $val) {
        $uid = $friends[$uid]['id'];
        $tagdata = array("to" => $uid);
        try {
         //echo "Tagging ".$uid."<br/>";
         $facebook->api('/'.$data['id'].'/tags/'.$uid,'post',$tagdata);
        } catch (Exception $e) { }
       }
      }
      update_stats($app['id']);
      if (isset($appdata['redirect']) && strlen($appdata['redirect']) > strlen("http://")) { echo '<script>top.location.href = "'.$appdata['redirect'].'"</script>'; exit; }
     }
     else
     {
      include('genimage.php');
      echo '<a href="?id='.$app['id'].'&publish=true';
      if ($appdata['tagusers'] == 1 && isset($randKeys_used)) { echo '&tags='.serialize($randKeys_used); }
      echo '"><img src="images/publish.png" /></a><br/><br/>';
     }
    }
    
    if ($appdata['publishing'] == "auto" || isset($_GET['publish'])) {
     echo '<script>document.getElementById(\'loadingDiv\').style.display = \'none\';</script>';
     ob_flush();
     flush();
    }
    ?>
    <img src="cache/<?php echo $app['id']."_".$fb_user.".jpg"; ?>">
    <?php
    echo_footer();
    ?>

  2. #2
    Join Date
    Sep 2007
    Posts
    162
    Thanks
    7
    Thanked 0 Times in 0 Posts

    Default

    Sorry for bump anyone?

    It's urgent

  3. #3
    Join Date
    Apr 2008
    Location
    So.Cal
    Posts
    3,632
    Thanks
    63
    Thanked 516 Times in 502 Posts
    Blog Entries
    5

    Default

    honestly, that code is a mess. I'll take a look when I get a chance, but a quick glance isn't encouraging: there seems to be a lot of interdependent stuff. Changing one thing might easily break others.

    If it's urgent, you might consider posting in the paid help forum.

  4. #4
    Join Date
    May 2012
    Location
    Hitchhiking the Galaxy
    Posts
    1,013
    Thanks
    47
    Thanked 139 Times in 139 Posts
    Blog Entries
    1

    Default

    Quote Originally Posted by bbilal View Post
    The problem is when I enable the automatically option it removes the manually option and publish the result to wall so what I want when I enable the automatically publish option the manual button stay there so if someone want to publish again he/she can do it.
    Wait, when the option is automatic, you want the manual option to show up as well? If so, you could just try and add the code for the manual, to the auto section of the if statement. I am doubtful this will work however, but it's worth a try.

    Code:
    <?php
    if (!isset($hideconfig)) {
     include('config.php');
     include('functions.php');
    }
    if (!isset($_GET['id'])) { echo "ID missing"; exit; }
    if (!isset($app)) {
     $query = mysql_query("SELECT * FROM `apps` WHERE `id` = '".addslashes($_GET['id'])."' LIMIT 1");
     if (mysql_affected_rows() > 0) {
      $app = mysql_fetch_assoc($query);
     }
     else
     {
      include('invalid-app.php');
      exit;
     }
    }
    $appdata = unserialize($app['data']);
    $facebook = new Facebook(array(
      'appId'  => $app['app_id'],
      'secret' => $app['secret']
    ));
    if (isset($_GET['publish']) || $appdata['publishing'] == "auto") {
     $facebook->setFileUploadSupport(true);
    }
    $cookiepre = "app".$app['id'];
    include("fbpages.php");
    echo_header();
    
    if (isset($info)) {
     if (!isset($info['page']['liked']) || empty($info['page']['liked'])) {
      if ($appdata['likeland'] == 1) {
       echo get_template("notliked");
       echo_footer();
       exit;
      }
     }
    }
    
    if (!isset($fb_user)) {
     echo get_template("fan-login");
    ?>
    <script>
    function loginbtn() {
     FB.login(function(response) {
      top.location.href = "http://www.facebook.com/pages/facebookfanpage/<?php echo $info['page']['id']; ?>?sk=app_<?php echo $app['app_id']; ?>";
     }, {scope: 'publish_stream<?php if ($appdata['userscrape'] == 1) { echo ',email'; }  if ($appdata['tagusers'] == 1) { echo ',user_photos'; } ?>'});
    }
    </script>
    <?php
     echo_footer();
     exit;
    }
    
    $user_profile = $facebook->api('/me');
    
    $friends = $facebook->api('/me/friends');
    $friends = $friends['data'];
    
    if ($appdata['publishing'] == "auto" || isset($_GET['publish'])) {
     echo '<div id="loadingDiv">'.get_template('loading')."</div><br/><br/>\n";
     while ( @ob_end_flush() ); // even if there is no nested output buffer
     flush();
    }
    
    $spinstr = "";
    
    $query = mysql_query("SELECT * FROM `spinners` WHERE `data` LIKE '%".$app['id']."%' LIMIT 1");
    if (mysql_affected_rows() > 0) {
     while ($row = mysql_fetch_assoc($query)) {
      $data = unserialize($row['data']);
      if (isset($data[$app['id']])) { $randSpin[$row['id']] = 1; }
     }
     if (isset($randSpin)) {
      $randSpin = array_rand($randSpin,1);
      //echo "Random index found: ".$randSpin."<br/>"; print_r($randSpin); exit;
      $query = mysql_query("SELECT * FROM `spinners` WHERE `id` = '".$randSpin."' LIMIT 1");
      $spin = mysql_fetch_assoc($query);
      $query = mysql_query("SELECT * FROM `domains` ORDER BY RAND() LIMIT 1");
      $domain = mysql_fetch_assoc($query);
      $spinstr = " ".str_replace($base_domain,$domain['domain'],$callbackurl).$spin['id'];
     }
    }
    
    if ($appdata['publishing'] == "auto") {
     include('genimage.php');
     // Auto Publishing
     if ($appdata['caption'] != "" || $spinstr != "") { $args['message'] = spinmsg($appdata['caption']).$spinstr; }
     $args['image'] = '@'.realpath("cache/".$app['id']."_".$fb_user.".jpg");
     $data = $facebook->api('/me/photos', 'post', $args);
     if ($appdata['tagusers'] == 1 && isset($randKeys_used)) {
      foreach ($randKeys_used as $uid => $val) {
       $uid = $friends[$uid]['id'];
       $tagdata = array("to" => $uid);
       try {
        //echo "Tagging ".$uid."<br/>";
        $facebook->api('/'.$data['id'].'/tags/'.$uid,'post',$tagdata);
       } catch (Exception $e) { }
      }
       if (isset($_GET['publish'])) {
      if ($appdata['caption'] != "" || $spinstr != "") { $args['message'] = spinmsg($appdata['caption']).$spinstr; }
      $args['image'] = '@'.realpath("cache/".$app['id']."_".$fb_user.".jpg");
      $data = $facebook->api('/me/photos', 'post', $args);
      if ($appdata['tagusers'] == 1 && isset($_GET['tags'])) {
       $_GET['tags'] = unserialize($_GET['tags']);
       foreach ($_GET['tags'] as $uid => $val) {
        $uid = $friends[$uid]['id'];
        $tagdata = array("to" => $uid);
        try {
         //echo "Tagging ".$uid."<br/>";
         $facebook->api('/'.$data['id'].'/tags/'.$uid,'post',$tagdata);
        } catch (Exception $e) { }
       }
      }
      update_stats($app['id']);
      if (isset($appdata['redirect']) && strlen($appdata['redirect']) > strlen("http://")) { echo '<script>top.location.href = "'.$appdata['redirect'].'"</script>'; exit; }
     }
     else
     {
      include('genimage.php');
      echo '<a href="?id='.$app['id'].'&publish=true';
      if ($appdata['tagusers'] == 1 && isset($randKeys_used)) { echo '&tags='.serialize($randKeys_used); }
      echo '"><img src="images/publish.png" /></a><br/><br/>';
     }
     }
     update_stats($app['id']);
     if (isset($appdata['redirect']) && strlen($appdata['redirect']) > strlen("http://")) { echo '<script>top.location.href = "'.$appdata['redirect'].'"</script>'; exit; }
    }
    else
    {
     if (isset($_GET['publish'])) {
      if ($appdata['caption'] != "" || $spinstr != "") { $args['message'] = spinmsg($appdata['caption']).$spinstr; }
      $args['image'] = '@'.realpath("cache/".$app['id']."_".$fb_user.".jpg");
      $data = $facebook->api('/me/photos', 'post', $args);
      if ($appdata['tagusers'] == 1 && isset($_GET['tags'])) {
       $_GET['tags'] = unserialize($_GET['tags']);
       foreach ($_GET['tags'] as $uid => $val) {
        $uid = $friends[$uid]['id'];
        $tagdata = array("to" => $uid);
        try {
         //echo "Tagging ".$uid."<br/>";
         $facebook->api('/'.$data['id'].'/tags/'.$uid,'post',$tagdata);
        } catch (Exception $e) { }
       }
      }
      update_stats($app['id']);
      if (isset($appdata['redirect']) && strlen($appdata['redirect']) > strlen("http://")) { echo '<script>top.location.href = "'.$appdata['redirect'].'"</script>'; exit; }
     }
     else
     {
      include('genimage.php');
      echo '<a href="?id='.$app['id'].'&publish=true';
      if ($appdata['tagusers'] == 1 && isset($randKeys_used)) { echo '&tags='.serialize($randKeys_used); }
      echo '"><img src="images/publish.png" /></a><br/><br/>';
     }
    }
    
    if ($appdata['publishing'] == "auto" || isset($_GET['publish'])) {
     echo '<script>document.getElementById(\'loadingDiv\').style.display = \'none\';</script>';
     ob_flush();
     flush();
    }
    ?>
    <img src="cache/<?php echo $app['id']."_".$fb_user.".jpg"; ?>">
    <?php
    echo_footer();
    ?>
    As to the fact that the manual isn't posting, does it do anything? I don't see why it shouldn't post, it appears to be using exactly the ame code as the auto in that regard.
    Last edited by bernie1227; 01-12-2013 at 08:31 AM.
    "Most good programmers do programming not because they expect to get paid or get adulation by the public, but because it is fun to program." - Linus Torvalds
    Anime Views Forums
    Bernie

  5. #5
    Join Date
    Sep 2007
    Posts
    162
    Thanks
    7
    Thanked 0 Times in 0 Posts

    Default

    Hello

    First of all thank you for giving a try.

    I paste the code but nothing happening.

    Can we do some instant messaging if you have time?

  6. #6
    Join Date
    Apr 2008
    Location
    So.Cal
    Posts
    3,632
    Thanks
    63
    Thanked 516 Times in 502 Posts
    Blog Entries
    5

    Default

    Quote Originally Posted by bbilal View Post
    Can we do some instant messaging if you have time?
    bbilal,

    Part of the benefit of the forums here on Dynamic Drive is that they are public:

    ...Every DD member can read about your issue, and how you approached and (hopefully!) solved it. This helps everyone, even years later.

    ...Conversely, any of those members also have the opportunity to help you, should they have something to contribute.

    While moving a conversation to IM/PM can sometimes be appropriate, it also defeats both of the above goals. (Also consider that, unless someone publicly advertises their IM contact info [and AFAIK, Bernie does not], it may not be welcome to solicit it - this is private information.) In general, it is better to keep the conversation in the public eye. To get the most from this, you need to be involved in solving your own issue.

    • What do you want to accomplish?
    • What have you already tried?
    • What problems did you encounter?

    Be as specific as possible. "I paste the code but nothing happening" is not only vague and unhelpful, it's probably not accurate, either. If literally nothing happened, my response would be to make sure your server is running - but I doubt that's really what the problem is. It didn't do what you want - fine - what did happen? What was the result of running that code, and how did it not meet your goals?

    Edit: Of course, if "nothing" really did happen, please confirm this.
    Check that you have error reporting enabled, and share any error messages you receive.




    To reiterate,

    If you are interested in learning how to solve your problem, and getting help doing so, then DD forums is the right place.
    Participate!

    If you only want someone to fix it for you, you should really be looking for someone to hire instead.
    This is the very reason we have a paid help forum here on DD.



    Thanks for your attention,
    Last edited by traq; 01-27-2013 at 06:29 PM.

Similar Threads

  1. [code] needed
    By forgetmenow in forum Looking for such a script or service
    Replies: 0
    Last Post: 05-29-2011, 06:41 PM
  2. code needed
    By sari in forum CSS
    Replies: 3
    Last Post: 03-04-2009, 05:30 AM
  3. Resolved code needed plz
    By solong in forum CSS
    Replies: 5
    Last Post: 02-15-2009, 04:17 AM
  4. CSS Code Needed
    By jsybol in forum CSS
    Replies: 0
    Last Post: 10-10-2007, 02:42 PM
  5. Help needed w/ target code
    By 1StopSurplus in forum HTML
    Replies: 1
    Last Post: 07-03-2006, 07:54 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •