Include all "name();" files etc.

Hello, I have a problem.

This is my core.php file.

[php]<?php

require_once(“src/ts3admin.class.php”);
require_once(“config/config-admin.php”);
require_once(“config/config-login.php”);

function include_all_php($folder){
foreach (glob(“funkcje/Administrator/*.php”) as $filename)
{
include $filename;
fopen(“filename”, “r”);
}
}
include_all_php(“my_classes”);

$ts = new ts3admin($Polaczenie[‘logowanie’][‘Address’], $Polaczenie[‘logowanie’][‘Port-Query’]);
if($ts->getElement(‘success’, $ts->connect())) {
$ts->selectServer($Polaczenie[‘logowanie’][‘Port-Login’]);
$ts->login($Polaczenie[‘logowanie’][‘Login’], $Polaczenie[‘logowanie’][‘Password’]);
$ts->setName(’’.$Polaczenie[‘logowanie’][‘Nick_BoT_Admin’]);
$whoami = $ts->getElement(‘data’, $ts->whoAmI());
$ts->clientMove($whoami[‘client_id’], $Polaczenie[‘logowanie’][‘Channel_ID’]);
}
while(true) {

adminsonline();
adminList();
autoeRanks();
ban();
channelsAdmins();
PokeAdmin();
Promotion();
ochronaGroup();
test();
sleep(1);
}
?>
[/php]
And I have this

[php]function include_all_php($folder){
foreach (glob(“funkcje/Administrator/*.php”) as $filename)
{
include $filename;
fopen(“filename”, “r”);
}
}
include_all_php(“my_classes”);
[/php]
but how can I do the same to name(); so I dont have to write every single function.

Like:

[php]$ts = new ts3admin($Polaczenie[‘logowanie’][‘Address’], $Polaczenie[‘logowanie’][‘Port-Query’]);
if($ts->getElement(‘success’, $ts->connect())) {
$ts->selectServer($Polaczenie[‘logowanie’][‘Port-Login’]);
$ts->login($Polaczenie[‘logowanie’][‘Login’], $Polaczenie[‘logowanie’][‘Password’]);
$ts->setName(’’.$Polaczenie[‘logowanie’][‘Nick_BoT_Admin’]);
$whoami = $ts->getElement(‘data’, $ts->whoAmI());
$ts->clientMove($whoami[‘client_id’], $Polaczenie[‘logowanie’][‘Channel_ID’]);
}
while(true) {

$filename();

sleep(1);
}
?>

[/php]
This is my start of every function:

function adminsonline(){
etc

In this code:
foreach (glob(“funkcje/Administrator/*.php”) as $filename)
{
include $filename;
fopen(“filename”, “r”);
}
You use a folder address to locate filenames. But, then, you use an include command without using the address.
Then, for some reason, you open the file, but, that is just a dummy command because it doesn’t do anything.
Normally, you need to also include the address to load the file. Like include “funkcje/Administrator/”.$filename;
(Unless the file is in the same folder that the program is. Which, in that case, you would not need it in the glob!)
Also, when you open a file, you use the data and then close it, you don’t just open it. (unless you did not show
all of your code there…)

Hope that helps!

Sponsor our Newsletter | Privacy Policy | Terms of Service