SimplePortal

Customization => Custom Coding => Topic started by: cieplutki on January 03, 2016, 09:56:07 AM

Title: Html with php code in a block (split)
Post by: cieplutki on January 03, 2016, 09:56:07 AM
I have this code
Code: [Select]
<?php
// A PHP comment.

// A function:
function hub()
{
$hub[] = "imperium1.pl:1234" ;
for( $a $a count$hub ) ; $a++ )
{
$ent explode":"$hub[$a] ) ;
$adres $ent[0] ;
$port $ent[1] ;
$fp = @fsockopen($adres$port$errno$errstr5);
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
Title: Re: Html with php code in a block (split)
Post by: ♦ Ninja ZX-10RR ♦ on January 03, 2016, 10:08:26 AM
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
Title: Re: Html with php code in a block (split)
Post by: cieplutki on January 03, 2016, 01:44:23 PM
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   :(
Title: Re: Html with php code in a block (split)
Post by: ♦ Ninja ZX-10RR ♦ on January 03, 2016, 01:51:55 PM
You need the rest of the code, I cannot invent it ._. Like:
Code: [Select]
<?php
// A PHP comment.

// A function:
function hub()
{
$hub[] = "imperium1.pl:1234" ;
for( $a $a count$hub ) ; $a++ )
{
$ent explode":"$hub[$a] ) ;
$adres $ent[0] ;
$port $ent[1] ;
$fp = @fsockopen($adres$port$errno$errstr5);
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 $a count$hub2 ) ; $a++ )
{
$ent explode":"$hub2[$a] ) ;
$adres $ent[0] ;
$port $ent[1] ;
$fp = @fsockopen($adres$port$errno$errstr5);
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.
Title: Re: Html with php code in a block (split)
Post by: cieplutki on January 03, 2016, 03:11:07 PM
have code to second hub, but its not working
I do not know on php please help
Code: [Select]
<?php
function hub()
{
$hub[] = "imperium1.pl:1234" ;
for( $a $a count$hub ) ; $a++ )
{
$ent explode":"$hub[$a] ) ;
$adres $ent[0] ;
$port $ent[1] ;
$fp = @fsockopen($adres$port$errno$errstr5);
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 $a count$hub2 ) ; $a++ )
{
$ent explode":"$hub2[$a] ) ;
$adres $ent[0] ;
$port $ent[1] ;
$fp = @fsockopen($adres$port$errno$errstr5);
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();
?>
Title: Re: Html with php code in a block (split)
Post by: emanuele on January 03, 2016, 05:48:59 PM
I would add to the array, but that alone is not enough, so let's change the code a bit and use:
Code: [Select]
<?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 $a count$hub ) ; $a++ )
{
$ent explode":"$hub[$a][0] ) ;
$adres $ent[0] ;
$port $ent[1] ;
$fp = @fsockopen($adres$port$errno$errstr5);
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:
Code: [Select]
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. ;)
Title: Re: Html with php code in a block (split)
Post by: ♦ Ninja ZX-10RR ♦ on January 03, 2016, 06:16:12 PM
Thanks :)
Title: Re: Html with php code in a block (split)
Post by: cieplutki on January 04, 2016, 01:30:04 PM
almost good
but on Aattach screen
how to add a new row or something similar?
thanks for help
Title: Re: Html with php code in a block (split)
Post by: emanuele on January 04, 2016, 04:07:08 PM
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?
Code: [Select]
echo $hub[$a][1];to:
Code: [Select]
echo $hub[$a][1] . '<br />';to have new lines, but I would do something like this:
Code: [Select]
echo '<div class="hubs">' . $hub[$a][1] . '</div>';and then add this to a css file:
Code: [Select]
.hubs {
width: 33%;
    display: inline-block;
    min-width: 10em;
    padding-bottom: 1.5em;
}
Title: Re: Html with php code in a block (split)
Post by: cieplutki on January 05, 2016, 04:21:15 AM
great working
thank you
Title: Re: Html with php code in a block (split)
Post by: ♦ Ninja ZX-10RR ♦ on January 05, 2016, 09:17:00 AM
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
SimplePortal 2.3.8 © 2008-2024, SimplePortal