Results 1 to 3 of 3
  1. #1
    Join Date
    Dec 2001
    Location
    Kansas
    Posts
    19

    Cron/PHP Problem

    I'm trying to install the turn base game Promisance on my site. I finally got the Cronjob working thanks to Joseph_M, but now when I get my updates by email I get this:

    /home/kryptenx/public_html/Promisance/turns.php: line 1: ?: No such file or directory
    /home/kryptenx/public_html/Promisance/turns.php: line 2: syntax error near unexpected token `"const.php"'
    /home/kryptenx/public_html/Promisance/turns.php: line 2: `include("const.php");'
    I'm certain that const.php is all there and working(since it runs all the mysql part of the game), and the game is at http://game.kryptenx.com


    Turns.php:
    <?
    include("const.php");
    include("funcs.php");
    include("et.php"); // PGT - Comment to disable, that's it!
    if ($REQUEST_URI)
    {
    HTMLbegin("Error");
    # print "Access forbidden!<br>\n";
    HTMLend();
    exit;
    }
    if (!$link = @mysql_pconnect($dbhost,$dbuser,$dbpass))
    {
    print "Error! Database unavailable!\n";
    exit;
    }
    mysql_select_db($dbname);
    if ($playerdb != "") { $numplayers = mysql_num_rows(mysql_query("Select num from $playerdb;")); }
    $hour = date("H");
    $min = date("i");
    $time = time();
    if ($lockdb)
    {
    # print "Database is currently locked! No turns given...\n";
    // so everyone doesn't get deleted when turns start running
    mysql_query("UPDATE $playerdb SET idle=$time;");
    }
    else
    {
    # print "$datetime: Processing turns...";
    if ($min == $turnoffset)
    {
    if ($hour == 12)
    {
    randomize();

    $lotterynum = mt_rand(1,3 * sqleval("SELECT num FROM $playerdb ORDER BY num DESC LIMIT 1;"));

    $jackpot = sqleval("SELECT cash FROM $lotterydb WHERE num=0 AND ticket=$tick_curjp;");
    $lastjackpot = sqleval("SELECT cash FROM $lotterydb WHERE num=0 AND ticket=$tick_lastjp;");

    mysql_query("UPDATE $lotterydb SET cash=$lotterynum WHERE num=0 AND ticket=$tick_lastnum;");

    if ($lastjackpot > $jackpot)
    $lastjackpot = $config[jackpot];
    mysql_query("UPDATE $lotterydb SET cash=$jackpot WHERE num=0 AND ticket=$tick_lastjp;");
    mysql_query("UPDATE $lotterydb SET cash=($jackpot-$lastjackpot) WHERE num=0 AND ticket=$tick_jpgrow;");

    $win = sqleval("SELECT num FROM $lotterydb WHERE num>0 AND ticket=$lotterynum;");
    if ($win)
    {
    $winner = loadUser($win);
    addNews(101,$winner,$winner,$jackpot);
    $winner[cash] += $jackpot;
    saveUserDataNet($winner,"networth cash");
    mysql_query("UPDATE $lotterydb SET cash=$config[jackpot] WHERE num=0 AND ticket=$tick_curjp;");
    }
    else $win = 0;
    mysql_query("UPDATE $lotterydb SET cash=$win WHERE num=0 AND ticket=$tick_lastwin;");
    mysql_query("DELETE FROM $lotterydb WHERE num>0;");
    }
    mysql_query("OPTIMIZE TABLE $lotterydb, $marketdb;"); // the only tables that get deleted from

    mysql_query("UPDATE $playerdb SET aidcred=(aidcred+1) WHERE aidcred<5;");
    mysql_query("UPDATE $playerdb SET attacks=(attacks-1) WHERE attacks>0;");
    mysql_query("UPDATE $playerdb SET vacation=(vacation+1) WHERE vacation>0;");
    }
    mysql_query("UPDATE $playerdb SET turns=(turns+$turnsper) WHERE vacation=0 AND disabled<=2;");
    mysql_query("UPDATE $playerdb SET turns=(turns+1),turnsstored=(turnsstored-1) WHERE vacation=0 AND disabled<=2 AND turnsstored>0;");
    mysql_query("UPDATE $playerdb SET turnsstored=(turnsstored+(turns-$config[maxturns])),turns=$config[maxturns] WHERE turns>$config[maxturns];");
    mysql_query("UPDATE $playerdb SET turnsstored=$config[maxstoredturns] WHERE turnsstored>$config[maxstoredturns];");

    mysql_query("UPDATE $playerdb SET msgcred=(msgcred+1) WHERE msgcred<5;");

    mysql_query("UPDATE $playerdb SET bmperarmtrp=(bmperarmtrp-(100*(1+shops/land))) WHERE bmperarmtrp > (100*(1+shops/land));");
    mysql_query("UPDATE $playerdb SET bmperlndtrp=(bmperlndtrp-(100*(1+shops/land))) WHERE bmperlndtrp > (100*(1+shops/land));");
    mysql_query("UPDATE $playerdb SET bmperflytrp=(bmperflytrp-(100*(1+shops/land))) WHERE bmperflytrp > (100*(1+shops/land));");
    mysql_query("UPDATE $playerdb SET bmperseatrp=(bmperseatrp-(100*(1+shops/land))) WHERE bmperseatrp > (100*(1+shops/land));");
    mysql_query("UPDATE $playerdb SET bmperarmtrp=0 WHERE bmperarmtrp < (100*(1+shops/land));");
    mysql_query("UPDATE $playerdb SET bmperlndtrp=0 WHERE bmperlndtrp < (100*(1+shops/land));");
    mysql_query("UPDATE $playerdb SET bmperflytrp=0 WHERE bmperflytrp < (100*(1+shops/land));");
    mysql_query("UPDATE $playerdb SET bmperseatrp=0 WHERE bmperseatrp < (100*(1+shops/land));");

    mysql_query("UPDATE $playerdb SET forces=(forces - 1) WHERE forces < 11 and forces > 0 ;"); // works the unsharing of troops

    mysql_query("UPDATE $playerdb SET pmkt_armtrp=(pmkt_armtrp+(8*(land + barracks))) WHERE pmkt_armtrp < (250 * (land+(2 * barracks)));");
    mysql_query("UPDATE $playerdb SET pmkt_lndtrp=(pmkt_lndtrp+(5*(land + barracks))) WHERE pmkt_lndtrp < (200 * (land+(2 * barracks)));");
    mysql_query("UPDATE $playerdb SET pmkt_flytrp=(pmkt_flytrp+(3*(land + barracks))) WHERE pmkt_flytrp < (180 * (land+(2 * barracks)));");
    mysql_query("UPDATE $playerdb SET pmkt_seatrp=(pmkt_seatrp+(2*(land + barracks))) WHERE pmkt_seatrp < (150 * (land+(2 * barracks)));");
    mysql_query("UPDATE $playerdb SET pmkt_food=(pmkt_food+(50*(land + farms))) WHERE pmkt_food < (2000 * (land + farms));");
    mysql_query("UPDATE $playerdb SET online=0 WHERE idle<($time-(3600 / $perminutes));"); // set 'em offline after they're idle for 2 turns updates

    mysql_query("UPDATE $playerdb SET idle=$time WHERE password='farm';"); // so the land farms won't idle to death

    /* new players must validate their accounts within 48 hours */
    /* you can not idle for more than 7 days unless you are on vacation or disabled */
    /* dead empires get deleted after 2 days */
    /* empires marked for deletion are deleted immediately */
    $delusers = mysql_query("SELECT * FROM $playerdb WHERE
    (validated=0 AND disabled=1 AND idle<($time-86400*2)) OR
    (disabled<=1 AND vacation=0 AND land>0 AND idle<($time-86400*7)) OR
    (land=0 AND disabled=1 AND ip!='0.0.0.0' AND (idle<($time-86400*2)) or idle=0) OR
    (disabled=4)
    ;");
    while ($users = mysql_fetch_array($delusers))
    {
    # print "Deleting user $users[empire] (#$users[num])...\n";
    if ($users[clan]) // remove user from clan
    {
    $clan = loadClan($users[clan]);
    if ($clan[founder] == $users[num])
    { // transfer ownership if necessary
    if ($newf = mysql_fetch_array(mysql_query("SELECT * FROM $playerdb WHERE clan=$clan[num] AND num!=$users[num] ORDER BY networth DESC;")))
    {
    mysql_query("UPDATE $clandb SET founder=$newf[num] WHERE num=$clan[num];");
    addNews(116,$newf,$newf,0);
    }
    }
    mysql_query("UPDATE $clandb SET members=members-1 WHERE num=$clan[num];");
    }
    mysql_query("UPDATE $messagedb SET deleted=1 WHERE src=$users[num] OR dest=$users[num];");
    // delete any messages to/from that user
    mysql_query("DELETE FROM $marketdb WHERE seller=$users[num];"); // any of the user's items on the market
    mysql_query("DELETE FROM $lotterydb WHERE num=$users[num];"); // any lottery tickets
    $users[name].= ".DEAD.".$time;
    $users[username] .= ".DEAD.".$time;
    $users[password] = md5($users[password]);
    $users[email] .= ".DEAD.".$time;
    $users[disabled] = $users[validated] = 1;
    $users[land] = $users[shops] = $users[homes] = $users[industry] = $users[barracks] = $users[labs] = $users[farms] = $users[towers] = $users[freeland] = 0;
    $users[ip] = "0.0.0.0";
    $users[clan] = 0;
    $users[idle] = $time;

    mysql_query("delete from $playerdb where num=$users[num]"); // and kill the user
    saveUserDataNet($users,"networth name username password email disabled validated land shops homes industry barracks labs farms towers freeland ip clan idle");
    }

    $clanmemchk = mysql_query("select * from $clandb;");
    while ($clana = mysql_fetch_array($clanmemchk))
    {
    $clanmembers = mysql_num_rows(mysql_query("SELECT num from $playerdb where clan=$clana[num];"));
    mysql_query("update $clandb set members=$clanmembers where num=$clana[num];");
    }
    $clangrace = time() - 86400;
    $delclans = mysql_query("SELECT * FROM $clandb WHERE (members<$config[clanmin]) AND (createtime<$clangrace);");
    while ($clan = mysql_fetch_array($delclans)) // remove all associations with
    { // empty clans and make clan
    # print "Deleting clan $clan[name] ($clan[tag])...\n"; // invisible to game
    # if ($clan[members] != 0) { addNews(120,$clan[founder],$clan[founder],0); } // must keep for news
    mysql_query("UPDATE $clandb SET ally1=0 WHERE ally1=$clan[num];");
    mysql_query("UPDATE $clandb SET ally2=0 WHERE ally2=$clan[num];");
    mysql_query("UPDATE $clandb SET ally3=0 WHERE ally3=$clan[num];");
    mysql_query("UPDATE $clandb SET war1=0 WHERE war1=$clan[num];");
    mysql_query("UPDATE $clandb SET war2=0 WHERE war2=$clan[num];");
    mysql_query("UPDATE $clandb SET war3=0 WHERE war3=$clan[num];");
    mysql_query("UPDATE $clandb SET members=-1 WHERE num=$clan[num];");
    mysql_query("UPDATE $clandb SET founder=0 where num=$clan[num];"); // Set new founder as 0
    mysql_query("UPDATE $playerdb set clan=0 where clan=$clan[num];"); // Make sure empires are removed from the clan too
    }

    # print "...done! ";
    }
    #print "Updating ranks...";
    $users = mysql_query("SELECT num FROM $playerdb ORDER BY networth DESC;");
    $urank = 0;
    while ($user = mysql_fetch_array($users))
    {
    $urank++;
    mysql_query("UPDATE $playerdb SET rank=$urank WHERE num=$user[num];");
    }
    mysql_query("OPTIMIZE TABLE $playerdb;");
    mysql_query("OPTIMIZE TABLE $messagedb;");
    mysql_query("OPTIMIZE TABLE $newsdb;");
    mysql_query("OPTIMIZE TABLE $clandb;");
    #print "done!\n\n";
    ?>
    http://www.Kryptenx.com/Promisance/turns.php

  2. #2
    on first line put this:
    #!/usr/local/bin/php

  3. #3
    Join Date
    Dec 2001
    Location
    Kansas
    Posts
    19
    Wow, thanks alot, it's working =)

Posting Permissions

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