Go Back   vb.org Archive > vBulletin 4 Discussion > vB4 General Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 11-27-2011, 10:54 PM
Scalemotorcars's Avatar
Scalemotorcars Scalemotorcars is offline
 
Join Date: Mar 2006
Location: NC
Posts: 619
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Need help with a php code in a widget

Ive been messing with this for some time now. Im trying to use the code in a PHP widget. Ultimately I want to use this to find the hex code from a image then insert the hex code into a field that I can then search my albums with.

For example if the script returns the hex code#000, then that number is automatically filled into the search box of my vb albums and at that point I simply click search and it returns the matching paint colors. So this would be Black paint....

My problem is I cant seem to get it to work because the code has forms in it. Im no coder so Im hoping someone here can help out.

I have the hex search working on my test page. Here...

http://scalemotorcars.com/forum/colo...method=precise

This is the source code. Here... http://jrm.cc/color-palette-generator/

Here's the full index.php from the page above. ANY help would be great especially if you know how to search the albums once a hex code is returned.

I should also mention I've already installed a mod that allows for album search. I don't remember the name off hand but its here on vb.org.


PHP Code:
<?php    
/*
    Color Palette Generator v1.2
        by Jeff Minard cpg (aht) jrm.cc
        http://scalemotorcars.com/forum/
        
    Please read and abide by the accompanying license: 
        gpl.txt        
        -or-
        http://creativecommons.org/licenses/GPL/2.0/
*/     

require("cpg.php");

if( 
$_GET['image'] ) // selected image from bookmark or get form
    
$file $_GET['image'];

if( 
$_FILES['userfile']['tmp_name'] ) // Upload detected captain!
    
handle_upload();

// Recommended Image Form Items
$recommended get_image_list($rec_image_dir);

// User Submitted Image
$user_submitted get_image_list($image_dir);

// Steps Form Options
$step_options get_steps_list();

// Methods!
$method_options get_method_list();

if( 
$file // hoooo buddy, process the image.
    
$color_palette get_color_palette($file);


?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>Color Palette Generator</title>
    <style type="text/css">@import "app.css";</style>
    <script type="text/javascript" src="funcs.js"></script>
</head>
<body><div id="page">

<div id="header">
    <h1>Color Palette Generator</h1>
    <p id="tag"><strong>Generate a color palette based on an image.</strong></p>
    <hr />
    
    <?php if($errors) { ?>
        <p id="error"> - <?php echo implode('<br> - '$errors); ?></p>
    <?php ?>
    
    <?php if($thanks) { ?>
        <p id="thanks"><?php echo $thanks?></p>
    <?php ?>
    
    <form enctype="multipart/form-data" action="" method="post">
        <label for="userfile">Upload an image:</label><input name="userfile" id="userfile" type="file" /><input type="submit" value="Send File" />
    </form>
    
    <form action="index.php" method="get">
        <label for="image">Select an image:</label>
        <select name="image" id="image">
            <option value="">Recommended:</option>
            <option value="">------------------------</option>
            
            <?php echo $recommended ?>
            
            <option value="">------------------------------</option>
            <option value="">User Submitted:</option>
            <option value="">------------------------------</option>
            
            <?php echo $user_submitted?>
            
        </select>

        <br />
        
        <label for="steps">Grid size:</label>
        <select name="steps" id="steps">
          <?php echo $step_options ?>
        </select>
        <label for="method">Method:</label>
        <select name="method" id="method">
            <?php echo $method_options ?>
        </select>
        
        <input type="submit" value="Select Image" />
        
    </form>
</div>

<hr />

<div id="lower">
    
    <?php if($color_palette) { ?>
    
        <div id="l1"><div id="l11">
        
            <h2>Color Palette</h2>
            
            <ul class="prow g<?php echo $steps ?>">
                <?php echo $color_palette?>
            </ul>
            
            <p>Current color: <br /><span id="disp">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>&nbsp;&nbsp;<span id="disptx">&nbsp;&nbsp;&nbsp;</span></p>
            <p>Selected color: <br /><span id="selc">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>&nbsp;&nbsp;<span id="selctx">&nbsp;&nbsp;&nbsp;</span></p>
        
        </div></div>
        
        <div id="l2"><div id="l22">
        
            <h2>Original Image</h2>
            
            <p><img src="<?php echo $file ?>" alt="image preview" /></p>
            <p><small>Image may be smaller or larger - it has been forced to a width of 300 pixels. <br /> 
            - <a href="<?php echo $file ?>" title="link to normal sized image">Normal Size Image</a></small></p>
            
        </div></div>
    
    <?php } else { ?>
    
        <div style="padding: 10px;">
            <p>Welcome! Start with one of the following actions:</p>
            <ol>
                <li>Browse for an image (of type <code><?php echo implode(' '$accept_file_types); ?></code>) and upload it</li>
                <li>Select an image from the drop down menu</li>
            </ol>
        </div>
    
    <?php ?>
    
</div>

<?php if($file) { 
    
$location "http://scalemotorcars.com/forum/color-palette-generator/?image=" urlencode($file) . "&amp;steps=" $steps "&amp;method=" $method;
    
?>
    <p id="current">
        You are currently viewing <code><?php echo $file?></code>. You can bookmark this page with the following URL:<br />
        <a href="<?php echo $location ?>"><?php echo $location ?></a>
    </p>
<?php ?>        

<hr />

<p id="footer">
    <em>Color Palette Generator by <a href="mailto:cpg-jeff@creatimation.net" title="send me mail!">Jeff Minard</a> &mdash; Licensed under the <a href="http://creativecommons.org/licenses/GPL/2.0/">CC-GNU GPL</a> <br />
    <strong>Source code available upon request.</strong></em>
</p>

<!--

<rdf:RDF xmlns="http://web.resource.org/cc/"
    xmlns:dc="http://purl.org/dc/elements/1.1/"
    xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
<Work rdf:about="">
   <license rdf:resource="http://creativecommons.org/licenses/GPL/2.0/" />
   <dc:type rdf:resource="http://purl.org/dc/dcmitype/Software" />
</Work>

<License rdf:about="http://creativecommons.org/licenses/GPL/2.0/">
   <permits rdf:resource="http://web.resource.org/cc/Reproduction" />
   <permits rdf:resource="http://web.resource.org/cc/Distribution" />
   <requires rdf:resource="http://web.resource.org/cc/Notice" />
   <permits rdf:resource="http://web.resource.org/cc/DerivativeWorks" />
   <requires rdf:resource="http://web.resource.org/cc/ShareAlike" />
   <requires rdf:resource="http://web.resource.org/cc/SourceCode" />
</License>

</rdf:RDF>

-->


</div></body>
</html>
Reply With Quote
  #2  
Old 12-09-2011, 05:34 PM
Scalemotorcars's Avatar
Scalemotorcars Scalemotorcars is offline
 
Join Date: Mar 2006
Location: NC
Posts: 619
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Sorry to bump, anyone have a clue on this one? Thanks
Reply With Quote
  #3  
Old 12-09-2011, 05:44 PM
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Location: California/Idaho
Posts: 41,180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Where have you put that code? Into a php widget? You can't have all the html there. You need to assign all the output to the variable $output. It says this at the top of the Configure screen:
Quote:
Enter Php Code, in the form "$output = <your code>"
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 01:42 AM.


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.03845 seconds
  • Memory Usage 2,215KB
  • Queries Executed 11 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (1)bbcode_php
  • (1)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (3)post_thanks_box
  • (3)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (3)post_thanks_postbit_info
  • (3)postbit
  • (3)postbit_onlinestatus
  • (3)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.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/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.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
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete