vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB4 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=252)
-   -   Help please displaying an image after reading a file (https://vborg.vbsupport.ru/showthread.php?t=314982)

Sicilian 10-20-2014 08:15 AM

Help please displaying an image after reading a file
 
I've been trying to add some code in a Forum block to display a status image that shows on one of our download sites
Code:

www.openvix.co.uk
I've tried adding the code below to a sidebar block and advertising block, but all that vbulletin outputs is: -

Code:

';  ?>
Code I'm using is below: -

Code:

<?php

$domain = 'http://openvix.co.uk/';
$StatusFile = "./feeds/status";

$states = array('stable', 'un-stable', 'updating');

if(($currentState = @file_get_contents($domain.$StatusFile)) !== false)
{
    $currentState = intval(trim($currentState));
}
else
{
    $currentState = 2;
}

print '<img src="'.$domain.$states[$currentState].'.png" class="statusimage" alt="OpenViX status: '.$states[$currentState].'" />';

?>

Any ideas anyone please?

Thanks in advance.

kh99 10-20-2014 09:59 AM

You want to create a "Custom HTML/PHP" block and make sure you select the "PHP" radio button in the Content Type section. Then you need to "return" the output instead of printing it.

Try using this code:

PHP Code:

$domain 'http://openvix.co.uk/';
$StatusFile "./feeds/status";

$states = array('stable''un-stable''updating');

if((
$currentState = @file_get_contents($domain.$StatusFile)) !== false)
{
    
$currentState intval(trim($currentState));
}
else
{
    
$currentState 2;
}

return 
'<img src="'.$domain.$states[$currentState].'.png" class="statusimage" alt="OpenViX status: '.$states[$currentState].'" />'

Of course the "Cache Time" setting will control how often it updates. If you want every page request to check you could set it to 0, but if you have a busy forum it could take a lot of server time, so it would be better to set it to at least 1, if it's acceptable to have it update only once per minute.

Sicilian 10-20-2014 10:05 AM

1 Attachment(s)
Thank you, just tested, no joy :(

See attached.

Sicilian 10-20-2014 10:07 AM

Sorry, my mistake, had HTML checked.

Massive thank you for your help :)


All times are GMT. The time now is 02:56 PM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01049 seconds
  • Memory Usage 1,721KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (3)bbcode_code_printable
  • (1)bbcode_php_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (4)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete