Page 4 of 5

Re: Castle Control Script

Posted: Mon Nov 28, 2011 6:01 pm
by trellos
I have the same issue regarding downloading the file. Could you please upload again the file ?



Thank you

Re: Castle Control Script

Posted: Mon Dec 05, 2011 10:26 am
by DareStrike

Code: Select all

 <?php //---------------// Made by Daedalus email : daedalus at hotmail dot fr//--------------- $db_serv = 'x';         //the address of the database goes here $db_user = 'x';             //your sql username goes here$db_pass = 'x';                 //your sql password goes here $db_name = 'l2jgs';             //your database name goes here $filename = './helios.js';      //generated javascript file you need to put attribute 777 in your folder 

this problem :S

Code: Select all

 $filename = './helios.js';      //generated javascript file you need to put attribute 777 in your folder$filename = '7777./helios.js';      //generated javascript file you need to put attribute 777 in your folder 

Re: Castle Control Script

Posted: Mon Jan 30, 2012 11:03 pm
by darknessneo
hello,
i added this features for my website, but i needed to edit a little the generator:

here is my patch

Code: Select all

   $req =  @mysql_query("SELECT `name`, `seed_price` FROM `etcitem`, `castle_manor_production` WHERE `seed_id` = `item_id` AND `castle_id` = '$castle[id]' UNION (SELECT `name`, `c`.`price` FROM `etcitem` e, `castle_manor_procure` c WHERE `crop_id` = `item_id` AND `castle_id` = '$castle[id]') ORDER BY `name`");     $i = 1;    while ($row = mysql_fetch_array($req, MYSQL_NUM)) {        $gen .= '<tr>';        $gen .= '<td style="background-color: #'.( ($i % 2) ? 'EEE' : 'DDD' ).'">'.$row[0].'</td>';        $gen .= '<td style="background-color: #'.( ($i % 2) ? 'EEE' : 'DDD' ).'">'.$row[1].'</td>';        $gen .= '</tr>';        $i++;    }
what i edited?

'$castle[id]' in the sql request.

without this edit, i eat a Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given.....

Oh, and, ofc, i needed to reput the table etcitem in the database with a old backup, cuz now, l2jserver use xml.

Re: Castle Control Script

Posted: Wed Apr 18, 2012 12:21 pm
by Eray
thanks.

Re: Castle Control Script

Posted: Sun Sep 09, 2012 11:59 pm
by VeNoML2
so i have 1 problem

i have my server on my PC and if i make this script on my pc with Xampp work fine
and if i add script on website host say this "Coudn't connect to host"


anyone can help me pls

Re: Castle Control Script

Posted: Mon Sep 10, 2012 10:04 am
by VeNoML2
someone?

Re: Castle Control Script

Posted: Sun Oct 28, 2012 5:34 pm
by gmakhs
you have to give remote acces on your database

Re: Castle Control Script

Posted: Tue Feb 12, 2013 2:19 pm
by busta
Does any php guru know why the script doesnt rewrite the helios.js again, after the sieges timestamp change in mysql table castle on column siegeDate ?
For example I have this problem:
the generator writen once the siege date and time first time, but after the time expire, it didnt rewrite with the new timestamp for the next siege. I think it doesnt check MySQL anymore.
2 castles which has not been sieged Gludio and Schuttgart get new timestamp same as all the rest in MySQL, but in the website I still see them with the same old date Feb 9, all others are Feb 23. All others were Feb 23 before too, only Gludio and Schuttgart were on Feb 9 for siege. Why is this happening?

Re: Castle Control Script

Posted: Wed Feb 13, 2013 10:11 pm
by xban1x
Post the code that was "supposed to rewrite helios.js"

Re: Castle Control Script

Posted: Thu Feb 14, 2013 2:02 pm
by busta
This is the script I use:

Code: Select all

<?php //---------------// Made by Daedalus email : daedalus at hotmail dot fr//--------------- $db_serv = '****';          //the address of the database goes here $db_user = 'root';              //your sql username goes here$db_pass = '****';              //your sql password goes here $db_name = 'l2jgs';             //your database name goes here $filename = './gen/helios.js';          //generated javascript file you need to put attribute 777 in your folder //----------------------------------------------------------------------------------------------- mysql_connect ( $db_serv, $db_user, $db_pass ) or die ('Coudn\'t connect to host');mysql_select_db( $db_name ) or die ('Couldn\'t select database'); $sql = mysql_query('SELECT id,name,taxPercent,siegeDate FROM `castle`') or die('Query failed!'); $gen = "\n"; while ($castle = mysql_fetch_array($sql)){    $gen .= "\n".strtolower($castle['name']) . 'info = \'<div class="castleWrapper">';    $gen .= '<div class="castlePic" id="' . ucfirst(strtolower($castle['name'])) . 'Pic"></div>';    $gen .= '<div class="castleInfo">';    $gen .= '<div class="castleName"><strong>' . ucfirst(strtolower($castle['name'])) . ' Castle</strong></div>';        $clan = mysql_fetch_array(mysql_query('SELECT clan_name,hasCastle FROM `clan_data` WHERE hasCastle = ' . $castle['id']));    $clan_name = (isset($clan['clan_name'])) ? htmlspecialchars($clan['clan_name'], ENT_QUOTES) : '<font color="22FF22">Unclaimed</font>';        $gen .= '<div><strong>Controlled by:</strong> ' . $clan_name . '</div>';        if (isset($clan['clan_name'])) $gen .= '<div><strong>Tax Rate:</strong> ' . $castle['taxPercent'] . '%</div>';        $gen .= '<div><strong>Next Siege:</strong> ' . date('M d Y ',$castle['siegeDate']/1000) . '</div>';    $gen .= '</div></div>\';'."\n\n";} $handle = fopen($filename, 'w+');fwrite($handle, $gen);fclose($handle); ?>
I believe the last 3 rows do the rewrite, but it seems that somehow they dont rewrite it.

Code: Select all

$handle = fopen($filename, 'w+');fwrite($handle, $gen);fclose($handle);
./gen/ is the location of generator.php and helios.js in my site.

P.S. I try to make a cronjob on 1 hours for this castle manager, but I cant really make it work. Dont know how to setup it correctly.

Re: Castle Control Script

Posted: Fri Feb 15, 2013 8:17 pm
by xban1x
cron job on linux ?

Tell me which linux

Re: Castle Control Script

Posted: Fri Feb 15, 2013 8:47 pm
by busta
I cant see from the cPanel which version is Linux.
How to define the cronjob command so to be able to refresh the content of helios.js?

P.S. Nevermind, I figured it out and it works.

Now I will explain where I was wrong.
First I have put a path for $filename which was wrong. My folder containing generator.php and helios.js is /gen just like I mention. So inside $filename must be writen this:

Code: Select all

$filename = 'helios.js';
Second and very important just like deadalus said, you must put attribute to helios.js, but the attribute must be 755. You dont need to make it 777. This can be done by clicking in your cPannel on file helios.js and clicking the key icon "Change Permissions", or by right mouse click and again "Change Permissions". After this operation it will be opened a new window with many boxes:
Image
Click on them so in row Permissions to be 755.
Now on the question how to automate the castle script, so to have regular update.
Go into your cPannel and find the Cronjob button. Its usually near MIME Types or Index Manager. Click on it. Sellect on what interval of time you wish the script generator.php to update helios.js. This can be made on Add New Cron Job table. Its enought to choose from Common Settings: sub-menu "Once an hour(0****)"
This choice will run the script and update it on every hour.
After that go to Command: field and write this for a php file(which generator.php is):

Code: Select all

php /home/[user name]/public_html/gen/generator.php
This is it!
Further more, the webhost will send to your main email of your site mail for each cronjob which has been done. If you dont want it to spam your mail simply add this after the command you previously put: >/dev/null 2>&1
It should look like this:

Code: Select all

php /home/[user name]/public_html/gen/generator.php >/dev/null 2>&1
And there will be no more mails. Dont worry, cronjob will continue to run, this disable only the email notification.
If you wish to stop this cronjob you must delete it from the Cronjob manager.
I hope this little guide will help to someone!

Re: Castle Control Script

Posted: Mon Feb 25, 2013 4:54 pm
by KaTSiKa
seems like a quite usefull thing. i will sure take a look

Re: Castle Control Script

Posted: Mon May 27, 2013 3:11 pm
by OrcBubba
Hi guys. I am getting this error:

Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in generator.php on line 57

Any suggestions? Thanks

Re: Castle Control Script

Posted: Mon May 27, 2013 3:31 pm
by jurchiks
Means the query failed to execute and returned FALSE on mysql_query(), possibly a typo somewhere.
Also, mysql_* is deprecated, time to switch to mysqli/PDO.