TheUnknown Posted November 14, 2007 Share Posted November 14, 2007 Im getting this error Parse error: parse error, unexpected $ in /home/dfgh/public_html/backend/cleanup.php on line 135 This is line 135 - ?> <?php require_once("functions.php"); function docleanup() { global $torrent_dir, $signup_timeout, $max_dead_torrent_time, $autoclean_interval; set_time_limit(0); ignore_user_abort(1); do { $res = mysql_query("SELECT id FROM torrents WHERE external = 'no'"); $ar = array(); while ($row = mysql_fetch_array($res)) { $id = $row[0]; $ar[$id] = 1; } if (!count($ar)) break; $dp = @opendir($torrent_dir); if (!$dp) break; $ar2 = array(); while (($file = readdir($dp)) !== false) { if (!preg_match('/^(\d+)\.torrent$/', $file, $m)) continue; $id = $m[1]; $ar2[$id] = 1; if (isset($ar[$id]) && $ar[$id]) continue; $ff = $torrent_dir . "/$file"; } closedir($dp); if (!count($ar2)) break; $deadtime = deadtime(); mysql_query("UPDATE snatched SET seeder='no' WHERE seeder='yes' AND last_action < FROM_UNIXTIME($deadtime)"); $deadtime = time() - $signup_timeout; mysql_query("DELETE FROM users WHERE status = 'pending' AND added < FROM_UNIXTIME($deadtime) AND last_login < FROM_UNIXTIME($deadtime) AND last_access < FROM_UNIXTIME($deadtime) AND last_access != '0000-00-00 00:00:00'"); $deadtime = time() - $signup_timeout; $user = mysql_query("SELECT invited_by FROM users WHERE status = 'pending' AND added < FROM_UNIXTIME($deadtime) AND last_access = '0000-00-00 00:00:00'"); $arr = mysql_fetch_assoc($user); if (mysql_num_rows($user) > 0) { $invites = mysql_query("SELECT invites FROM users WHERE id = $arr[invited_by]"); $arr2 = mysql_fetch_assoc($invites); if ($arr2[invites] < 10) { $invites = $arr2[invites] +1; mysql_query("UPDATE users SET invites='$invites' WHERE id = $arr[invited_by]"); } mysql_query("DELETE FROM users WHERE status = 'pending' AND added < FROM_UNIXTIME($deadtime) AND last_access = '0000-00-00 00:00:00'"); } $secs = 28*86400; $dt = sqlesc(get_date_time(gmtime() - $secs)); mysql_query("DELETE FROM messages WHERE added < $dt"); function autoinvites($length, $minlimit, $maxlimit, $minratio, $invites) { $time = sqlesc(get_date_time(gmtime() - (($length)*86400))); $minlimit = $minlimit*1024*1024*1024; $maxlimit = $maxlimit*1024*1024*1024; $res = mysql_query("SELECT id, invites FROM users WHERE class > 0 AND enabled = 'yes' AND downloaded >= $minlimit AND downloaded < $maxlimit AND uploaded / downloaded >= $minratio AND warned = 'no' AND invites < 10 AND invitedate < $time") or sqlerr(__FILE__, __LINE__); if (mysql_num_rows($res) > 0) { while ($arr = mysql_fetch_assoc($res)) { if ($arr[invites] == 9) $invites = 1; elseif ($arr[invites] == 8 && $invites == 3) $invites = 2; mysql_query("UPDATE users SET invites = invites+$invites, invitedate = NOW() WHERE id=$arr[id]") or sqlerr(__FILE__, __LINE__); } } } autoinvites(10,1,4,.90,1); autoinvites(10,4,7,.95,2); autoinvites(10,7,10,1.00,3); autoinvites(10,10,100000,1.05,4); $torrents = array(); $res = mysql_query("SELECT torrent, seeder, COUNT(*) AS c FROM peers GROUP BY torrent, seeder"); while ($row = mysql_fetch_assoc($res)) { if ($row["seeder"] == "yes") $key = "seeders"; else $key = "leechers"; $torrents[$row["torrent"]][$key] = $row["c"]; } $res = mysql_query("SELECT torrent, COUNT(*) AS c FROM comments GROUP BY torrent"); while ($row = mysql_fetch_assoc($res)) { $torrents[$row["torrent"]]["comments"] = $row["c"]; } $fields = explode(":", "comments:leechers:seeders"); $res = mysql_query("SELECT id, seeders, leechers, comments FROM torrents WHERE external = 'no'"); while ($row = mysql_fetch_assoc($res)) { $id = $row["id"]; $torr = $torrents[$id]; foreach ($fields as $field) { if (!isset($torr[$field])) $torr[$field] = 0; } $update = array(); foreach ($fields as $field) { if ($torr[$field] != $row[$field]) $update[] = "$field = " . $torr[$field]; } if (count($update)) mysql_query("UPDATE torrents SET " . implode(",", $update) . " WHERE id = $id"); } } ?> any help would be great Quote Link to comment Share on other sites More sharing options...
rajivgonsalves Posted November 14, 2007 Share Posted November 14, 2007 I think you forgot one } at the end it should be } } ?> Quote Link to comment Share on other sites More sharing options...
TheUnknown Posted November 14, 2007 Author Share Posted November 14, 2007 Thats what i figured but its not the problem I kicks the same error Quote Link to comment Share on other sites More sharing options...
TheUnknown Posted November 14, 2007 Author Share Posted November 14, 2007 Anyone else have any ideas? Thanks Quote Link to comment Share on other sites More sharing options...
rajivgonsalves Posted November 14, 2007 Share Posted November 14, 2007 ok you forgot the } and you forgot to put while (condition) syntax of do-while do { } while (condition); Quote Link to comment Share on other sites More sharing options...
TheUnknown Posted November 14, 2007 Author Share Posted November 14, 2007 that didn't do the trick I'm still getting the same errror Quote Link to comment Share on other sites More sharing options...
kenrbnsn Posted November 14, 2007 Share Posted November 14, 2007 Fix up the structure of your source and you will, most likely, find the missing end "}". Put all the lines in the same block at the same indent. Ken Quote Link to comment Share on other sites More sharing options...
GingerRobot Posted November 14, 2007 Share Posted November 14, 2007 Well, there's a missing while condition and a missing closing brace to end your function definition. To fix the parse errors, try: <?php require_once("functions.php"); function docleanup() { global $torrent_dir, $signup_timeout, $max_dead_torrent_time, $autoclean_interval; set_time_limit(0); ignore_user_abort(1); do { $res = mysql_query("SELECT id FROM torrents WHERE external = 'no'"); $ar = array(); while ($row = mysql_fetch_array($res)) { $id = $row[0]; $ar[$id] = 1; } if (!count($ar)) break; $dp = @opendir($torrent_dir); if (!$dp) break; $ar2 = array(); while (($file = readdir($dp)) !== false) { if (!preg_match('/^(\d+)\.torrent$/', $file, $m)) continue; $id = $m[1]; $ar2[$id] = 1; if (isset($ar[$id]) && $ar[$id]) continue; $ff = $torrent_dir . "/$file"; } closedir($dp); if (!count($ar2)) break; $deadtime = deadtime(); mysql_query("UPDATE snatched SET seeder='no' WHERE seeder='yes' AND last_action < FROM_UNIXTIME($deadtime)"); $deadtime = time() - $signup_timeout; mysql_query("DELETE FROM users WHERE status = 'pending' AND added < FROM_UNIXTIME($deadtime) AND last_login < FROM_UNIXTIME($deadtime) AND last_access < FROM_UNIXTIME($deadtime) AND last_access != '0000-00-00 00:00:00'"); $deadtime = time() - $signup_timeout; $user = mysql_query("SELECT invited_by FROM users WHERE status = 'pending' AND added < FROM_UNIXTIME($deadtime) AND last_access = '0000-00-00 00:00:00'"); $arr = mysql_fetch_assoc($user); if (mysql_num_rows($user) > 0) { $invites = mysql_query("SELECT invites FROM users WHERE id = $arr[invited_by]"); $arr2 = mysql_fetch_assoc($invites); if ($arr2[invites] < 10) { $invites = $arr2[invites] +1; mysql_query("UPDATE users SET invites='$invites' WHERE id = $arr[invited_by]"); } mysql_query("DELETE FROM users WHERE status = 'pending' AND added < FROM_UNIXTIME($deadtime) AND last_access = '0000-00-00 00:00:00'"); } $secs = 28*86400; $dt = sqlesc(get_date_time(gmtime() - $secs)); mysql_query("DELETE FROM messages WHERE added < $dt"); function autoinvites($length, $minlimit, $maxlimit, $minratio, $invites) { $time = sqlesc(get_date_time(gmtime() - (($length)*86400))); $minlimit = $minlimit*1024*1024*1024; $maxlimit = $maxlimit*1024*1024*1024; $res = mysql_query("SELECT id, invites FROM users WHERE class > 0 AND enabled = 'yes' AND downloaded >= $minlimit AND downloaded < $maxlimit AND uploaded / downloaded >= $minratio AND warned = 'no' AND invites < 10 AND invitedate < $time") or sqlerr(__FILE__, __LINE__); if (mysql_num_rows($res) > 0) { while ($arr = mysql_fetch_assoc($res)) { if ($arr[invites] == 9) $invites = 1; elseif ($arr[invites] == 8 && $invites == 3) $invites = 2; mysql_query("UPDATE users SET invites = invites+$invites, invitedate = NOW() WHERE id=$arr[id]") or sqlerr(__FILE__, __LINE__); } } } autoinvites(10,1,4,.90,1); autoinvites(10,4,7,.95,2); autoinvites(10,7,10,1.00,3); autoinvites(10,10,100000,1.05,4); $torrents = array(); $res = mysql_query("SELECT torrent, seeder, COUNT(*) AS c FROM peers GROUP BY torrent, seeder"); while ($row = mysql_fetch_assoc($res)) { if ($row["seeder"] == "yes") $key = "seeders"; else $key = "leechers"; $torrents[$row["torrent"]][$key] = $row["c"]; } $res = mysql_query("SELECT torrent, COUNT(*) AS c FROM comments GROUP BY torrent"); while ($row = mysql_fetch_assoc($res)) { $torrents[$row["torrent"]]["comments"] = $row["c"]; } $fields = explode(":", "comments:leechers:seeders"); $res = mysql_query("SELECT id, seeders, leechers, comments FROM torrents WHERE external = 'no'"); while ($row = mysql_fetch_assoc($res)) { $id = $row["id"]; $torr = $torrents[$id]; foreach ($fields as $field) { if (!isset($torr[$field])) $torr[$field] = 0; } $update = array(); foreach ($fields as $field) { if ($torr[$field] != $row[$field]) $update[] = "$field = " . $torr[$field]; } if (count($update)) mysql_query("UPDATE torrents SET " . implode(",", $update) . " WHERE id = $id"); } }while($var == 'somevalue');//replace with your condition } ?> However, i wouldn't be at all surprised if this doesn't run the way you want it to - i would imagine there is some logic errors in there somewhere. Without proper indentation, you're going to cause yourself all sorts of problems. And don't forget to change the while condition from the one i added in. Edit: p.s. Curly i thing Its a dollar sign. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.