Mys 1.3.1 one central location location for seperate addons

Forum
Last Post
Threads / Messages

schepers12

Member
Premium Member
Joined
Sep 18, 2012
Messages
26
Points
0
Location
netherlands
Mysidian Dollar
5,176
i thought: hey, i've installed multiple mods and addons, but what if i get lost in which ones i have installed? the solution for me is simple (and hopefully for you too), i've made a folder called "mods" in the main directory, and added a seperate folder for every mod in it with the needed files.

so now i have for example:
maindir
  • mods
    • blacksmith
      • index.php
    • map
      • index.php

a lot easier for addons or such to organize, isn't it?

now how do we go to the pages on a simple way without showing the full url?

by replacing the code in pages.php by this one:
PHP:
<?php

include("functions/functions.php");
include("functions/functions_users.php");
include("inc/bbcode.php");
include("inc/lang.php");

//***************//
//  START SCRIPT //
//***************//

// Grab the page from the get parameter

$page = $_GET["page"];

$pagecontent = getsitecontent($page);

if($pagecontent[content] == ""){



// Page does not exist...

$article_title = "404 Page Not Found";
$article_content = "The page you are looking for cannot be found on this site.  
It is possible that it never existed or that the site admin deleted it.";
//for example modification 1
} elseif ($pagecontent[content] == "blacksmith") {
  include('mods/blacksmith/index.php');
}
//for example modification 2
} elseif ($pagecontent[content] == "map") {
  include('mods/map/index.php');
} else {


$article_title = $pagecontent[title];
$article_content = $pagecontent[content];

$article_content = nl2br($article_content); // New line breaks


}

//***************//
//  OUTPUT PAGE  //
//***************//

echo showpage($article_title, $article_content, $date);

?>

and simply add an elseif loop for each new mod~

last thing: add a url in the link manager to the correct page or pages~ :wiii:

NOTE: i haven't tested this, but i hope it'll work and get you onto the path~ ;)
 
it is nice

maybe with this code snippet is it possible to automatic include mods with out the need to edit files

its taken from my own script and written as a function

maybe with some edits it could be possible to use that to check if some maps exist
and then showing the index file based on the map (or add a double check so it does not only look for php files but for the maps that contains a index file )


PHP:
//show admin pages + staff pages +  normal pages 
if ($_SESSION['admin'] == "1")
{
function showpage()
{
$file = "./pages/".$_GET['page'].".php";
$admin = "./pages/admin/".$_GET['admin'].".php";
$staff = "./pages/staff/".$_GET['staff'].".php";
if (file_exists($file))
{
include ("$file");
}
else if (file_exists($admin)) 
{
include ("$admin");
}
else if (file_exists($staff)) 
{
include ("$staff");
}
else
{
include ("./pages/home.php");
}
}
}
// show only staff + normal pages
else if ($_SESSION['staff'] == "1")
{
function showpage()
{
$file = "./pages/".$_GET['page'].".php";
$staff = "./pages/staff/".$_GET['staff'].".php";
if (file_exists($file))
{
include ("$file");
}
else if (file_exists($staff)) 
{
include ("$staff");
}
else
{
include ("./pages/home.php");
}
}
}
else if ($_SESSION['ban'] > "0")
{
// show a banned text and prevent other pages from opening
function showpage()
{
echo ("we are sorry , but your account is banned");
}
}
else
{
// show normal pages only
function showpage()
{
$file = "./pages/".$_GET['page'].".php";
if (file_exists($file))
{
include ("$file");
}
else
{
include ("./pages/home.php");
}
}
}

in the above example i just need to put a file in a certian folder and it works
i can call the page then with ?admin=xxx or ?staff=XXX or ?page=XXX

to be able to work with this mod does it need a rewrite ofcourse , but this is just the core function

Greetings From PowerChaos
 
Well in Mys v1.4.0 there will be a folder called Plugin in which each Addon/Mod owners can manage their own products. A complete plugin system standardized redesign will be carried out for Mys v1.5.0 though, but in the next major version I try to make lives easier for coders.
 

Similar threads

Users who are viewing this thread

  • Forum Contains New Posts
  • Forum Contains No New Posts

Forum statistics

Threads
4,277
Messages
33,122
Members
1,602
Latest member
BerrieMilk
BETA

Latest Threads

Latest Posts

Top