Announcement

Collapse
No announcement yet.

Showing PHP widget

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Edwin Brown
    replied
    I'll just throw in my two cents.

    What you're trying to do is never going to work well in vBulletin. You are trying to do a form submittal, but I call your attention to this line:

    $string .= "<form action='' method='post' enctype='multipart/form-data'>";

    since the action is empty, you're not going to submit anywhere. And it can't be a widget, it would have to be a php page. If you want this to work you need to
    • create this as a php page
    • put the page url as the "action" in the form above.
    • Set the cache time to zero. That only works in the more recent versions. About 4.08 if I recall correctly. Please don't quote me.


    The whole vBulletin system is designed to cache information to improve performance, so you are working against the it. If we were going to do that, we'd do javascript in a widget. It could also be a static page, but I think a widget would be more useful. That way there's no form submittal, no caching concerns, and you can do it all on one page. I thought there might be a google gadget that did what you want, but I looked and didn't find one. Sorry.

    Leave a comment:


  • Microlight
    replied
    Originally posted by bszopi View Post
    I can see your point, but it seems kind of ridiculous... Anyway, I can't figure it out, but I will give you another way to do it, albeit not the best way. Instead of creating a PHP widget, create a Static HTML widget and use an iframe to display your original PHP file.

    HTML Code:
    <p align="center"><iframe src="LINK TO YOUR FILE HERE" width="620" height="500" frameborder="0"></iframe></p>
    Vary the width and height as needed to fit your needs. I did this awhile back, mainly for an Ajax script I wrote that had a couple external file calls, so I didn't think it would work in a PHP widget. Here is my example: http://60degreev6.com/content.php/101-CR-Calc
    Brilliant matey, sorted. I'll remember that. Well I hope I will :-)

    Leave a comment:


  • Microlight
    replied
    Originally posted by Zachery View Post
    It is a modification in the sense that is not default code. We don't support third party proudcts/plugins/code as a whole. This includes: html, css, php, javascript, etc modifications to the code.
    A Widget that is PHP direct execution should be able to put PHP inside and "run it" Everything is contained in the one form. There's no connecting to a DB or anything. I've got a site running Joomla and it works fine on there.

    Leave a comment:


  • bszopi
    replied
    I can see your point, but it seems kind of ridiculous... Anyway, I can't figure it out, but I will give you another way to do it, albeit not the best way. Instead of creating a PHP widget, create a Static HTML widget and use an iframe to display your original PHP file.

    HTML Code:
    <p align="center"><iframe src="LINK TO YOUR FILE HERE" width="620" height="500" frameborder="0"></iframe></p>
    Vary the width and height as needed to fit your needs. I did this awhile back, mainly for an Ajax script I wrote that had a couple external file calls, so I didn't think it would work in a PHP widget. Here is my example: http://60degreev6.com/content.php/101-CR-Calc

    Leave a comment:


  • Zachery
    replied
    It is a modification in the sense that is not default code. We don't support third party proudcts/plugins/code as a whole. This includes: html, css, php, javascript, etc modifications to the code.

    Leave a comment:


  • bszopi
    replied
    I wouldn't really consider trying to use PHP inside a PHP widget as being a modification. You'd think there would be a way to have a form that returns something after user input using this method, but perhaps not. I'm not done looking yet, though.

    Leave a comment:


  • Zachery
    replied
    The php widget processes php, you're already in another application (vBulletin). For more help with modifications please see vbulletin.org

    Leave a comment:


  • Microlight
    replied
    Why can't the "php" widget work with "php" that's stupid.

    Leave a comment:


  • bszopi
    replied
    This may take a better programmer than I to get to work. Since everything is being rendered via the $output, I'm not sure it can actually do the addition of the hours inside of the widget. In order to get the form to display, you need to render it (via $output), but that is the last bit of the widget. I just don't see a way to get it to display everything, and then go back and do the calculation, then display everything again.

    Still looking though...

    Leave a comment:


  • Microlight
    replied
    Thanks mate, I really do appreciate it. I'll be glad when I can tell the users it works. :-)

    Leave a comment:


  • bszopi
    replied
    Yeah, I noticed that, just wasn't sure if it had anything to do with the logged.php file. With that said, I'll look at it some more...

    Leave a comment:


  • Microlight
    replied
    Hi bszopi.

    Thanks again for your input. I'm not getting the error anymore, but the calculator doesn't work. I put my figures in the boxes and click "add" and it clears it out instead of adding it up. The highlight_file('logged.php'); can be removed altogether. This was so that it outputted the whole of itself (as code) after you clicked add. It was put in there by the original writer of the script for me to copy and paste.

    See here clicking the add simply re-sets it.

    Leave a comment:


  • bszopi
    replied
    Ok, after some searching, I solved the security token issue.

    FIND
    PHP Code:
    $string .= "</form>";
     
    highlight_file('logged.php');
    $output $string
    BEFORE, Insert the following:
    PHP Code:
    $string .= "<input type='hidden' name='securitytoken' value=" $securitytoken vb::$vbulletin->userinfo['securitytoken'] . ">"
    It still doesn't seem to be doing anything for me, but that might be because I don't have the logged.php file. Anyway, check that out and let me know how it goes again.

    Leave a comment:


  • Microlight
    replied
    Thanks for your work bszopi.

    It shows up in the widget now but when I click the button to do the adding up I get the following error message...

    Your submission could not be processed because a security token was missing.

    If this occurred unexpectedly, please inform the administrator and describe the action you performed before you received this error.

    Leave a comment:


  • bszopi
    replied
    Ok, I did this in a PHP Eval page instead of a widget, but see if it works for you in the widget. You may need to alter the file path for the log file as well. I haven't actually tested it, but the output on screen looks correct. For all I know, I doesn't function worth a damn, though. Anyway, let me know and I'll mess with it more if needed. Lunch break is over, so back to work!

    PHP Code:
    /*  
    Name: Add Times Calculator 
    URI: http://dynainternet.com/logged.php 
    Description: Add multiple hours and minutes using whole or decimal numbers 
    Version: 2.4 
    Author: Jay Przekop (aka:Quick) 
    Author URI: http://dynainternet.com 
    License: GPL 
    */ 

    $hours $_POST['hour']; 
    $minutes $_POST['minute']; 

    if(
    $hours != '' || $minutes != '') { 

    $allhours array_sum(array_filter($hours)); 
    $explode_hours explode(".",$allhours); 
    $collect_hours $explode_hours['0']; 
    $collect_hours_decimal $explode_hours['1']; 
    $collect_hours_decimal substr(round($collect_hours_decimal,2),0,2); 
    if (
    $collect_hours_decimal != '') { 
    if(
    strlen($collect_hours_decimal) <= 1){ 
    $collect_hours_decimal $collect_hours_decimal *10

    $hours_dec_convert_minutes substr($collect_hours_decimal*60/100,0,2); 
    } else { 
    $hours_dec_convert_minutes 00


    $allminutes array_sum(array_filter($minutes));  

    $explode_minutes explode(".",$allminutes); 
    $collect_minutes_zero $explode_minutes['0']; 
    $collect_minutes_one $explode_minutes['1']; 

    $explode_seconds explode(".",$collect_minutes_one); 
    $collect_seconds_zero $explode_seconds['0']; 
    if(
    $collect_seconds_zero != ''){ 
    if(
    strlen($collect_seconds_zero) <= 1){ 
    $collect_seconds_zero $collect_seconds_zero *10

    $seconds_dec_convert_seconds substr($collect_seconds_zero 60/100,0,2); 
    } else { 
    $seconds_dec_convert_seconds $collect_seconds_zero


    $collect_minutes_one $seconds_dec_convert_seconds $collect_minutes_one

    if(
    $collect_minutes_one != ''){ 
    if(
    strlen($collect_minutes_one) <= 1){ 
    $collect_minutes_one $collect_minutes_one *10

    $minutes_dec_convert_minutes substr($collect_minutes_one*60/100,0,2); 
    } else { 
    $minutes_dec_convert_minutes $collect_minutes_one

    $add_allminutes $hours_dec_convert_minutes $collect_minutes_zero

    $hoursfromminutes floor($add_allminutes 60); 
    $deduct_amount 60 $hoursfromminutes
    $totalminutes $add_allminutes $deduct_amount
    $totalhours $collect_hours $hoursfromminutes



    $string "<h1>Logbook Calculator</h1><br />";
    $string .= "Put your figures into the boxes and click the Add button.<br />";
    $string .= "Now works if you put 0.75 into an hour box it adds it as 45 minutes.";

    $string .= "<form action='' method='post' enctype='multipart/form-data'>";

    $string .= "<table style='color: #000000; font-family: Verdana; font-weight: bold; font-size: 12px; background-color: #c7f6d2;' width='501' border='1' cellspacing='5' cellpadding='5'>";

    //set this for how many input fields you want 
    $how_many_fields 12

    $input_field_array range(0,$how_many_fields -1); 

    foreach (
    $input_field_array as $input_number) { 
    $string .= "<tr>";
    $string .= "<td width='150'>"
    $string .= "<input type='int' name='hour[]' value='$hours[$input_number]' size='20' maxlength='10' /> Hrs</td>"
    $string .= "<td width='150'>"
    $string .= "<input type='int' name='minute[]' value='$minutes[$input_number]' size='20' maxlength='10' /> Mins</td>";
    $string .= "</tr>"
    $string .= "<tr>"

       
    $string .= "<tr>"
    $string .= "<td><input style='height: 50px; width: 100px; color: #000000; font-family: Verdana; font-weight: bold; font-size: 12px; background-color: #34f325;' size='15' type='submit' name='submit' value='Add' />";
    $string .= "<input type='button' style='height: 50px; width: 100px; color: #000000; font-family: Verdana; font-weight: bold; font-size: 12px; background-color: #87f87e;' size='100' value='Reset' onClick='location.href=" filter_var($_SERVER["SCRIPT_NAME"], FILTER_SANITIZE_STRING) . "'></td>";
    $string .= "<td><input type='int' size='20' maxlength='10' value=" $totalhours "> Hrs";
    $string .= "<input type='int' size='20' maxlength='10' value=" $totalminutes "> Mins</td>";
    $string .= "</tr>"
    $string .= "</table>"
    $string .= "<tr></tr>";

    $string .= "</form>";
     
    highlight_file('logged.php');
    $output $string

    Leave a comment:

widgetinstance 262 (Related Topics) skipped due to lack of content & hide_module_if_empty option.
Working...
X