Jump to content
  • 0

FluxCP Snippets - [new] :: Giveaway Add-on 2012-09-15


Jupeto

Question


  • Group:  Members
  • Topic Count:  34
  • Topics Per Day:  0.01
  • Content Count:  225
  • Reputation:   39
  • Joined:  01/20/12
  • Last Seen:  

Just wanna share what I've done/edited so far with flux cp

SNIPPETS

  • WOE STATUS -
    1. Execute the sql below in your fluxcp database if `agit_status` field is not yet existed in your `ragsrvinfo` table, else skip this step
    ALTER TABLE `ragsrvinfo`
    ADD `agit_status` TINYINT(1) UNSIGNED NOT NULL DEFAULT '0' AFTER `drop`;
    


    2. Download agit_status.txt. Place the file in rAthena/npc/custom/ and install it or copy below and create a new file named agit_status.txt and install

    //===== eAthena Script =======================================
    //= Agit Status Checker
    //===== By: ==================================================
    //= Entwined
    //===== Current Version: =====================================
    //= 1.1
    //===== Compatible With: =====================================
    //= eAthena SVN (SQL only)
    //===== Description: =========================================
    //= Updates WoE status, so CeresCP can display
    //= if WoE is on or off in real time.
    //===== Additional Comments: =================================
    //= Run this SQL query:
    //= ALTER TABLE `ragsrvinfo` ADD `agit_status` TINYINT(1) UNSIGNED NOT NULL DEFAULT '0' AFTER `drop`;
    //============================================================
    - script AGIT_STATUS -1,{
    OnInit:
    // check if `agit_status` column exists
    if (query_sql("SHOW COLUMNS FROM ragsrvinfo LIKE 'agit_status'", .@dummy$,.@dummy$,.@dummy$,.@dummy$,.@dummy$,.@dummy$) == 0) {
     // Or... if we have the ALTER privilege, try to add the column
     query_sql "SELECT DATABASE()", .@rag_db$;
     query_sql "SHOW GRANTS", .@grants$;
     for (set .@i,0; .@i<getarraysize(.@grants$); set .@i,.@i+1)
      if (compare(.@grants$[.@i], "`"+.@rag_db$+"`")) {
    if (compare(.@grants$[.@i], "ALTER,") || compare(.@grants$[.@i], "ALTER ON"))
     query_sql "ALTER TABLE `ragsrvinfo` ADD `agit_status` TINYINT(1) UNSIGNED NOT NULL DEFAULT '0' AFTER `drop`;";
    break;
      }
    
     // verify
     if (query_sql("SHOW COLUMNS FROM ragsrvinfo LIKE 'agit_status'", .@dummy$,.@dummy$,.@dummy$,.@dummy$,.@dummy$,.@dummy$) == 0) {
      debugmes strnpcinfo(3)+" : unable to modify SQL table (needs ALTER privilege)";
      atcommand "@unloadnpc " + strnpcinfo(3);
      end;
     }
    }
    OnAgitStart:
    OnAgitStart2:
    OnAgitEnd:
    OnAgitEnd2:
    query_sql "UPDATE ragsrvinfo SET agit_status = " + (agitcheck() || agitcheck2());
    end;
    }
    


    3. Open fluxcp/modules/server/status.php
    Copy below code and paste before ?>

    // Name : WoE Status
    // Email : [email protected]
    // Author : Jupeto
    // NOTE : Uncomment all commented lines below if you want to cache the checking of status
    // and add a line in your fluxcp/config/application.php
    /*
    find : ServerStatusTimeout
    add after :
    
    'WoEStatusCache'	 => 2,						// Store a cached woe status and refresh every X minutes.  Default: 2 minutes (value is measured in minutes).
    'WoEStatusTimeout'	=> 2,						// For each server, spend X amount of seconds to determine whether it's up or not.
    */
    // if (file_exists($cache_woe_status) && (time() - filemtime($cache_woe_status)) < (Flux::config('WoEStatusCache') * 60)) {
    // $woeStatus = unserialize(file_get_contents($cache_woe_status));
    // }
    // else {
    $woeStatus = array();
    foreach (Flux::$loginAthenaGroupRegistry as $groupsName => $loginAthenaGroup) {
     if (!array_key_exists($groupsName, $woeStatus)) {
      $woeStatus[$groupsName] = array();
     }
     foreach ($loginAthenaGroup->athenaServers as $athenaServer) {
      $serverName = $athenaServer->serverName;
      $sql = "SELECT agit_status AS woe_status FROM {$athenaServer->charMapDatabase}.ragsrvinfo WHERE `name` = '" . $serverName . "'";
      $sth = $loginAthenaGroup->connection->getStatement($sql);
      $sth->execute();
      $woe_status = $sth->fetch();
    
      $woeStatus[$groupsName][$serverName] = array(
    'woe_status' => $woe_status->woe_status
      );
     }
    }
    
    // $fp = fopen($cache_woe_status, 'w');
    // if (is_resource($fp)) {
     // fwrite($fp, serialize($woeStatus));
     // fclose($fp);
    // }
    // }
    


    Save and exit.
    4. Open fluxcp/themes/your_theme/server/status.php
    Copy below code and paste it after the end of file

    <?php foreach ($woeStatus as $privServerName => $gameServers): ?>
    <h3>War Of Emperium Status for <?php echo htmlspecialchars($privServerName) ?></h3>
    <table id="server_status">
    <tr>
     <td class="status"><?php echo htmlspecialchars(Flux::message('ServerStatusServerLabel')) ?></td>
     <td class="status">Status</td>
    </tr>
    <?php foreach ($gameServers as $serverName => $gameServer): ?>
    <tr>
     <th class="server"><?php echo htmlspecialchars($serverName) ?></th>
     <td class="status"><?php echo $this->serverUpDown($gameServer['woe_status']) ?></td>
    </tr>
    <?php endforeach ?>
    </table>
    <?php endforeach ?>
    


    Save and exit.

  • CASTLE PAGE PAGINATION
    Got it working na without search function! final code below po,
    in modules/castle/index.php copy below and replace your current castle index code
    
    <?php
    if (!defined('FLUX_ROOT')) exit;
    
    $title = 'Castles';
    
    // $sql  = "SELECT castles.castle_id, castles.guild_id, guild.name AS guild_name, guild.emblem_len FROM {$server->charMapDatabase}.guild_castle AS castles ";
    // $sql .= "LEFT JOIN guild ON guild.guild_id = castles.guild_id ORDER BY castles.castle_id ASC";
    
    // $sth  = $server->connection->getStatement($sql);
    // $sth->execute();
    
    $sql  = "SELECT COUNT(castle_id) AS total FROM {$server->charMapDatabase}.guild_castle";
    
    $sth  = $server->connection->getStatement($sql);
    
    $sth->execute();
    $paginator = $this->getPaginator($sth->fetch()->total,array('perPage'=>(int)Flux::config('CastleLimit')));
    
    $sql  = "SELECT castles.castle_id, castles.guild_id, guild.name AS guild_name, guild.emblem_len FROM {$server->charMapDatabase}.guild_castle AS castles ";
    $sql .= "LEFT JOIN guild ON guild.guild_id = castles.guild_id ORDER BY castles.castle_id ASC";
    
    $sql  = $paginator->getSQL($sql);
    $sth  = $server->connection->getStatement($sql);
    
    $sth->execute();
    
    $castles = $sth->fetchAll();
    $castleNames = Flux::config('CastleNames')->toArray();
    
    ?>
    


    save and exit.
    in themes/your_theme_name/castle/index.php copy below and replace your current castle index code

    <?php if (!defined('FLUX_ROOT')) exit; ?>
    <h2>Castles</h2>
    <p>This page shows what castles are activated and which guilds own them.</p>
    <?php if ($castles): ?>
    <?php echo $paginator->infoText() ?>
    <table class="vertical-table">
    <tr>
    <th>Castle ID</th>
    <th>Castle</th>
    <th colspan="2">Guild</th>
    </tr>
    <?php foreach ($castles as $castle): ?>
    <tr>
    <td align="right"><?php echo htmlspecialchars($castle->castle_id) ?></td>
    <td>
    <?php if (array_key_exists($castle->castle_id, $castleNames) && $castleNames[$castle->castle_id]): ?>
    <?php echo htmlspecialchars($castleNames[$castle->castle_id]) ?>
    <?php else: ?>
    <span class="not-applicable">Unknown<?php echo " (".$castle->castle_id.")" ?></span>
    <?php endif ?>
    </td>
    <?php if ($castle->guild_name): ?>
    <?php if ($castle->emblem_len): ?>
    <td width="24"><img src="<?php echo $this->emblem($castle->guild_id) ?>" /></td>
    <td>
    <?php if ($auth->actionAllowed('guild', 'view') && $auth->allowedToViewGuild): ?>
    <?php echo $this->linkToGuild($castle->guild_id, $castle->guild_name) ?>
    <?php else: ?>
    <?php echo htmlspecialchars($castle->guild_name) ?>
    <?php endif ?>
    </td>
    <?php else: ?>
    <td colspan="2"><?php echo htmlspecialchars($castle->guild_name) ?></td>
    <?php endif ?>
    <?php else: ?>
    <td colspan="2"><span class="not-applicable"><?php echo htmlspecialchars(Flux::message('NoneLabel')) ?></span></td>
    <?php endif ?>
    </tr>
    <?php endforeach ?>
    </table>
    <?php echo $paginator->getHTML() ?>
    <?php else: ?>
    <p>No castles found. <a href="javascript:history.go(-1)">Go back</a>.</p>
    <?php endif ?>
    


    save and exit.
    in lib/Flux/Paginator.php
    find

    public function infoText()
    {
     $currPage = $this->currentPage;
     $results  = Flux::config('ResultsPerPage');
     $infoText = sprintf(
      Flux::message('FoundSearchResults'),
      $this->total, $this->numberOfPages, ($currPage*$results-($results - 1)), $currPage * $results < $this->total ? ($currPage*$results) : ($this->total)
     );
     return sprintf('<p class="info-text">%s</p>', $infoText);
    }
    


    change to

    
    
    public function infoText()
    {
    $currPage = $this->currentPage;
    // $results  = Flux::config('ResultsPerPage');
    $results  = $this->perPage;
    $infoText = sprintf(
    Flux::message('FoundSearchResults'),
    $this->total,
    $this->numberOfPages,
    ($currPage*$results-($results - 1)),
    $currPage * $results < $this->total ? ($currPage*$results) : ($this->total)
    );
    return sprintf('<p class="info-text">%s</p>', $infoText);
    }
    


    save and exit.
    in config/application.php
    find

    'CharRankingLimit'	=> 10,						//
    


    add above

    'CastleLimit'	   => 5,						 // Number of castle limit result per page
    


    save and exit.
    now try your castle list

ADD-ON / EXTENSIONS

My Services

Click here for my services

Edited by Jupeto
Link to comment
Share on other sites

10 answers to this question

Recommended Posts


  • Group:  Members
  • Topic Count:  30
  • Topics Per Day:  0.01
  • Content Count:  313
  • Reputation:   23
  • Joined:  12/27/11
  • Last Seen:  

Nice one :D

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  29
  • Topics Per Day:  0.01
  • Content Count:  566
  • Reputation:   34
  • Joined:  11/17/11
  • Last Seen:  

Thanks master Jupeto! /no1

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  10
  • Topics Per Day:  0.00
  • Content Count:  108
  • Reputation:   0
  • Joined:  08/01/12
  • Last Seen:  

is this for rathena renewal only?

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  34
  • Topics Per Day:  0.01
  • Content Count:  225
  • Reputation:   39
  • Joined:  01/20/12
  • Last Seen:  

is this for rathena renewal only?

My snippets and add-on can be used on all existing FluxCP versions.

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  10
  • Topics Per Day:  0.00
  • Content Count:  108
  • Reputation:   0
  • Joined:  08/01/12
  • Last Seen:  

woe status didnt work for me T____T.....plz help guide me usign video..

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  34
  • Topics Per Day:  0.01
  • Content Count:  225
  • Reputation:   39
  • Joined:  01/20/12
  • Last Seen:  

WARNING: MUTE YOUR SOUND

Here's a

showing how to install my woe status.

PS: Sorry for the background music, it's already late here and I'm still awake. I tried to listen to those music to try to make me feel sleepy but no effect /pif

@ALL

I have a new add-on working on just check it out

So what do you think?

Edited by Jupeto
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  29
  • Topics Per Day:  0.01
  • Content Count:  566
  • Reputation:   34
  • Joined:  11/17/11
  • Last Seen:  

WARNING: MUTE YOUR SOUND

Here's a

showing how to install my woe status.

PS: Sorry for the background music, it's already late here and I'm still awake. I tried to listen to those music to try to make me feel sleepy but no effect /pif

@ALL

I have a new add-on working on just check it out

So what do you think?

It's a great add-on idol! /heh useful on any server type. I just wanted to suggest if you can send a whole guild or party so it will automatically send the prizes for all members of guild or party.

Is it free add-on or paid?

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  34
  • Topics Per Day:  0.01
  • Content Count:  225
  • Reputation:   39
  • Joined:  01/20/12
  • Last Seen:  

WARNING: MUTE YOUR SOUND

Here's a

showing how to install my woe status.

PS: Sorry for the background music, it's already late here and I'm still awake. I tried to listen to those music to try to make me feel sleepy but no effect /pif

@ALL

I have a new add-on working on just check it out

So what do you think?

It's a great add-on idol! /heh useful on any server type. I just wanted to suggest if you can send a whole guild or party so it will automatically send the prizes for all members of guild or party.

Is it free add-on or paid?

That's already in my to do list :P paid I guess hehe

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  29
  • Topics Per Day:  0.01
  • Content Count:  566
  • Reputation:   34
  • Joined:  11/17/11
  • Last Seen:  

WARNING: MUTE YOUR SOUND

Here's a

showing how to install my woe status.

PS: Sorry for the background music, it's already late here and I'm still awake. I tried to listen to those music to try to make me feel sleepy but no effect /pif

@ALL

I have a new add-on working on just check it out

So what do you think?

It's a great add-on idol! /heh useful on any server type. I just wanted to suggest if you can send a whole guild or party so it will automatically send the prizes for all members of guild or party.

Is it free add-on or paid?

That's already in my to do list :P paid I guess hehe

planning to purchase this! hope it is not over price! /sob

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  34
  • Topics Per Day:  0.01
  • Content Count:  225
  • Reputation:   39
  • Joined:  01/20/12
  • Last Seen:  

FluxCP Add-on :: Giveaway 1.0.0 is now officially released ~ http://rathena.org/b...addon-giveaway/

Edited by Jupeto
Link to comment
Share on other sites

×
×
  • Create New...