Jump to content

Curly i thing


TheUnknown

Recommended Posts

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.