bbilal
01-10-2013, 05:40 PM
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
<?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();
?>
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
<?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();
?>