SimplePortal
Customization => Custom Coding => Topic started by: cieplutki on January 03, 2016, 09:56:07 AM
-
I have this code
<?php
// A PHP comment.
// A function:
function hub()
{
$hub[] = "imperium1.pl:1234" ;
for( $a = 0 ; $a < count( $hub ) ; $a++ )
{
$ent = explode( ":", $hub[$a] ) ;
$adres = $ent[0] ;
$port = $ent[1] ;
$fp = @fsockopen($adres, $port, $errno, $errstr, 5);
if ($fp) {
echo '<img src="http://dcmaniak.com.pl/images/hubon.gif" alt="On-Line" title="HUB ON-Line " border="0" /><br />';
} else {
echo '<img src="http://dcmaniak.com.pl/images/huboff.gif" alt="Off-Line" title="HUB OFF-Line " border="0" /><br />';
}
}
// Some HTML
echo 'Hub: <b>Imperium</b>';
}
return hub();
?>
how to add another
-
Hi, please post your own topics without bumping 7 years old ones.
Can you explain what you need? Your question doesn't tell me anything useful :/
Regards
-
Hello
This code is to show the effect of dc ++ hub
link http://www.dcmaniak.com.pl/index.php?action=forum
code runs on a single hub how to add more using this code block
sorry for my english :(
-
You need the rest of the code, I cannot invent it ._. Like:
<?php
// A PHP comment.
// A function:
function hub()
{
$hub[] = "imperium1.pl:1234" ;
for( $a = 0 ; $a < count( $hub ) ; $a++ )
{
$ent = explode( ":", $hub[$a] ) ;
$adres = $ent[0] ;
$port = $ent[1] ;
$fp = @fsockopen($adres, $port, $errno, $errstr, 5);
if ($fp) {
echo '<img src="http://dcmaniak.com.pl/images/hubon.gif" alt="On-Line" title="HUB ON-Line " border="0" /><br />';
} else {
echo '<img src="http://dcmaniak.com.pl/images/huboff.gif" alt="Off-Line" title="HUB OFF-Line " border="0" /><br />';
}
}
// Some HTML
echo 'Hub: <b>Imperium</b>';
}
return hub();
// Hub2
function hub2()
{
$hub2[] = "whatever:whateverport" ;
for( $a = 0 ; $a < count( $hub2 ) ; $a++ )
{
$ent = explode( ":", $hub2[$a] ) ;
$adres = $ent[0] ;
$port = $ent[1] ;
$fp = @fsockopen($adres, $port, $errno, $errstr, 5);
if ($fp) {
echo '<img src="http://dcmaniak.com.pl/images/hubon.gif" alt="On-Line" title="HUB ON-Line " border="0" /><br />';
} else {
echo '<img src="http://dcmaniak.com.pl/images/huboff.gif" alt="Off-Line" title="HUB OFF-Line " border="0" /><br />';
}
}
// Some HTML
echo 'Hub: <b>Whatever</b>';
}
return hub2();
?>
But like I said you need to replace the code parts with the logic you have for the first hub, I cannot invent that data.
-
have code to second hub, but its not working
I do not know on php please help
<?php
function hub()
{
$hub[] = "imperium1.pl:1234" ;
for( $a = 0 ; $a < count( $hub ) ; $a++ )
{
$ent = explode( ":", $hub[$a] ) ;
$adres = $ent[0] ;
$port = $ent[1] ;
$fp = @fsockopen($adres, $port, $errno, $errstr, 5);
if ($fp) {
echo '<img src="http://dcmaniak.com.pl/images/hubon.gif" alt="On-Line" title="HUB ON-Line " border="0" /><br />';
} else {
echo '<img src="http://dcmaniak.com.pl/images/huboff.gif" alt="Off-Line" title="HUB OFF-Line " border="0" /><br />';
}
}
// Some HTML
echo 'Hub: <b>Imperium</b>';
}
return hub();
// Hub2
function hub2()
{
$hub2[] = "ironmaiden.odysejahub.com:1090" ;
for( $a = 0 ; $a < count( $hub2 ) ; $a++ )
{
$ent = explode( ":", $hub2[$a] ) ;
$adres = $ent[0] ;
$port = $ent[1] ;
$fp = @fsockopen($adres, $port, $errno, $errstr, 5);
if ($fp) {
echo '<img src="http://dcmaniak.com.pl/images/hubon.gif" alt="On-Line" title="HUB ON-Line " border="0" /><br />';
} else {
echo '<img src="http://dcmaniak.com.pl/images/huboff.gif" alt="Off-Line" title="HUB OFF-Line " border="0" /><br />';
}
}
// Some HTML
echo 'Hub: <b>IROM MAIDEN</b>';
}
return hub2();
?>
-
I would add to the array, but that alone is not enough, so let's change the code a bit and use:
<?php
// A PHP comment.
// A function:
function hub()
{
$hub[] = array(
"imperium1.pl:1234",
'Hub: <b>Imperium</b>'
);
$hub[] = array(
"ironmaiden.odysejahub.com:1090",
'Hub: <b>IROM MAIDEN</b>'
);
for( $a = 0 ; $a < count( $hub ) ; $a++ )
{
$ent = explode( ":", $hub[$a][0] ) ;
$adres = $ent[0] ;
$port = $ent[1] ;
$fp = @fsockopen($adres, $port, $errno, $errstr, 5);
if ($fp) {
echo '<img src="http://dcmaniak.com.pl/images/hubon.gif" alt="On-Line" title="HUB ON-Line " border="0" /><br />';
} else {
echo '<img src="http://dcmaniak.com.pl/images/huboff.gif" alt="Off-Line" title="HUB OFF-Line " border="0" /><br />';
}
// Some HTML
echo $hub[$a][1];
}
}
return hub();
?>
Next time you want to add a new hub, you copy&paste the bit at the beginning and change what you need, for example:
function hub()
{
$hub[] = array(
"imperium1.pl:1234",
'Hub: <b>Imperium</b>'
);
$hub[] = array(
"ironmaiden.odysejahub.com:1090",
'Hub: <b>IROM MAIDEN</b>'
);
$hub[] = array(
"this.other.hub.com:1234",
'Hub: <b>Random</b>'
);
Hope it does make sense. ;)
-
Thanks :)
-
almost good
but on Aattach screen
how to add a new row or something similar?
thanks for help
-
Are you sure you want to have each of them on a new line?
Wouldn't be nicer to have them aligned on the same line?
echo $hub[$a][1];
to:
echo $hub[$a][1] . '<br />';
to have new lines, but I would do something like this:
echo '<div class="hubs">' . $hub[$a][1] . '</div>';
and then add this to a css file:
.hubs {
width: 33%;
display: inline-block;
min-width: 10em;
padding-bottom: 1.5em;
}
-
great working
thank you
-
I will go ahead and mark it as solved then, feel free to do it yourself next time by hitting the relative button, thanks!
Regards