Advertisement:

Author Topic: error 500 when requiring a page  (Read 3940 times)

Offline glennmckenna

  • Jr. Member
  • **
  • Posts: 278
error 500 when requiring a page
« on: October 08, 2017, 08:47:01 AM »
hi i'm trying to include Gallery2.php into my page so i can echo the add image function (there for not having to use iframe), but when ever i do it i either get a error 500 or the page stops loding at that line...

here is the code

Code: [Select]
// Check for any suspicious activity
if (!defined('SMF'))
    die('Hacking attempt...');

function ManageMdl(){
    // Load the .template.php file
    loadTemplate('ManageMdl');

    // Load the language files
    if (loadlanguage('Mdl') == false)
        loadLanguage('Mdl','french-utf8');

    // Gallery Actions
    $subActions = array(
        'main' => 'main',
        'homead' => 'homead',
        'genaff' => 'genaff',
    );

    // Follow the sa or just go to main function
    if (isset($_GET['sa']))
        $sa = $_GET['sa'];
    else
        $sa = '';

    if (!empty($subActions[$sa]))
        $subActions[$sa]();
    else
        mainview();
}

function mainview() {

    global $context, $scripturl;

    $context['page_title'] = $context['forum_name'] . ' - genevent'; // Page title

    $context['sub_template']  = 'mainview';
}

Code: [Select]
function template_mainview() {
    global $boardurl, $context, $settings, $options, $txt, $scripturl, $modSettings, $sourcedir;



    $g_gen = allowedTo('genevent');


    if ($g_gen) {
        echo '
        <script src="../../../scripts/jquery-1.12.0.min.js"></script>
        <script src="', $boardurl, '/Themes/Redsy/scripts/mform.js"></script>

            <div class="col-md-12 col-xs-12 form-box">
               
                <form role="form" action="" method="post" class="registration-form">
                   
                    <fieldset>
                        <div class="form-top">
                            <div class="form-top-left">
                                <h3>' ,$txt['Step'], ' 1 / 4</h3>
                                <p>' ,$txt['Add-img'], '</p>
                            </div>
                        </div>
                        <div>';
        require_once($scripturl . '/Gallery2.php');
        echo AddPicture();
        echo '
                        </div>
                        <div class="form-bottom">
                            <button type="button" class="btn btn-next">Next</button>
                        </div>
                    </fieldset>
                   
                    <fieldset>
                        <div class="form-top">
                            <div class="form-top-left">
                                <h3>Step 2 / 4</h3>
                                <p>Set up your account:</p>
                            </div>
                        </div>
                        <div>
                            456
                        </div>
                        <div class="form-bottom">
                            <button type="button" class="btn btn-previous">Previous</button>
                            <button type="button" class="btn btn-next">Next</button>
                        </div>
                    </fieldset>
                   
                   <fieldset>
                        <div class="form-top">
                            <div class="form-top-left">
                                <h3>Step 3 / 4</h3>
                                <p>Set up your account:</p>
                            </div>
                        </div>
                        <div>
                            789
                        </div>
                        <div class="form-bottom">
                            <button type="button" class="btn btn-previous">Previous</button>
                            <button type="button" class="btn btn-next">Next</button>
                        </div>
                    </fieldset>
                   
                    <fieldset>
                        <div class="form-top">
                            <div class="form-top-left">
                                <h3>Step 4 / 4</h3>
                                <p>Social media profiles:</p>
                            </div>
                        </div>
                        <div>
                            159
                        </div>
                        <div class="form-bottom">
                            <button type="button" class="btn btn-previous">Previous</button>
                           <div class="btn">Sign me up</div>
                        </div>
                    </fieldset>
               
                </form>
               
            </div>



        ';
    }elseif (file_exists(dirname(dirname(__FILE__)) . '/Settings.php'))
    {
        // Found it!
        require(dirname(dirname(__FILE__)) . '/Settings.php');
        header('Location: ' . $boardurl);
    }
// Can't find it... just forget it.
    else
        exit;
}

i've tried putting the require in the php file that is in the sources (the first code) but with no luck...

any help would be great cause i know that it cant be any thing to big but i can't figgur out what it is

Offline vbgamer45

  • SMF Friend
  • SMF Super Hero
  • *
  • Posts: 19,350
    • smfhacks on Facebook
    • VBGAMER45 on GitHub
    • @createaforum on Twitter
    • SMF For Free
Re: error 500 when requiring a page
« Reply #1 on: October 09, 2017, 01:20:47 PM »
I am not sure if it is going to work exactly how you want it.

But it looks ike you just want to include the add picture form? If so that code is from themes/default/Gallery2.template.php
Community Suite for SMF - Take your forum to the next level built for SMF, Gallery,Store,Classifieds,Downloads,more!

SMFHacks.com -  Paid Modifications for SMF

Mods:
EzPortal - Portal System for SMF
SMF Gallery Pro
SMF Store SMF Classifieds Ad Seller Pro

Offline glennmckenna

  • Jr. Member
  • **
  • Posts: 278
Re: error 500 when requiring a page
« Reply #2 on: October 09, 2017, 04:56:07 PM »
I am not sure if it is going to work exactly how you want it.

But it looks ike you just want to include the add picture form? If so that code is from themes/default/Gallery2.template.php
many thanks but won't ialso this part of code for it to work or do i have to copy and paste into my code ?

Code: [Select]
function AddPicture()
{
global $context, $mbname, $txt, $modSettings, $sourcedir, $smcFunc;

isAllowedTo('smfgallery_add');

     if (isset($_REQUEST['cat']))
   $cat = (int) $_REQUEST['cat'];
    else
        $cat = 0;

    $context['gallery_cat_id'] = $cat;

    if (!isset($context['gallery_pic_title']))
        $context['gallery_pic_title'] = '';

    if (!isset($context['gallery_pic_description']))
        $context['gallery_pic_description'] = '';
    if (!isset($context['gallery_pic_keywords']))
        $context['gallery_pic_keywords'] = '';


$context['sub_template']  = 'add_picture';

$context['page_title'] = $mbname . ' - ' . $txt['gallery_text_title'] . ' - ' . $txt['gallery_form_addpicture'];

// Check if spellchecking is both enabled and actually working.
$context['show_spellchecking'] = !empty($modSettings['enableSpellChecking']) && function_exists('pspell_new');

    $context['linktree'][] = array(
'name' => '<em>' . $txt['gallery_form_addpicture'] . '</em>'
);

// Needed for the WYSIWYG editor.
require_once($sourcedir . '/Subs-Editor.php');

// Now create the editor.
$editorOptions = array(
'id' => 'descript',
'value' => $context['gallery_pic_description'],
'width' => '90%',
'form' => 'picform',
'labels' => array(
'post_button' => ''
),
);


create_control_richedit($editorOptions);
$context['post_box_name'] = $editorOptions['id'];

$dbresult = $smcFunc['db_query']('', "
  SELECT
  id_cat, title
  FROM {db_prefix}gallery_cat ORDER BY roworder ASC");
$context['gallery_cat_list'] = array();
while($row = $smcFunc['db_fetch_assoc']($dbresult))
{
$context['gallery_cat_list'][] = $row;
}
$smcFunc['db_free_result']($dbresult);

}

this is bering in mind that the images will only be uploaded to one category lets say the category id is 9

Offline glennmckenna

  • Jr. Member
  • **
  • Posts: 278
Re: error 500 when requiring a page
« Reply #3 on: October 23, 2017, 02:36:08 PM »
here is how i've tried including the pages

Code: [Select]
$gal = require_once($modSettings['gallery_url']);
$galtemp = loadtemplate('Gallery2');

neither work nore does include_once

i could only see it being a wrong path but i can't see what would be the right path unless i use an absolute link

any ideas ?

Offline vbgamer45

  • SMF Friend
  • SMF Super Hero
  • *
  • Posts: 19,350
    • smfhacks on Facebook
    • VBGAMER45 on GitHub
    • @createaforum on Twitter
    • SMF For Free
Re: error 500 when requiring a page
« Reply #4 on: October 23, 2017, 03:13:46 PM »
There is a lot of issues here. Your never really wanted to require a url.
You would do an include with $sourcedir then the php file.
Community Suite for SMF - Take your forum to the next level built for SMF, Gallery,Store,Classifieds,Downloads,more!

SMFHacks.com -  Paid Modifications for SMF

Mods:
EzPortal - Portal System for SMF
SMF Gallery Pro
SMF Store SMF Classifieds Ad Seller Pro

Offline glennmckenna

  • Jr. Member
  • **
  • Posts: 278
Re: error 500 when requiring a page
« Reply #5 on: October 24, 2017, 03:42:28 PM »
right iassume that i've fixed that part but when i call the function add picture it outputs nothing

here's the page
http://beta.mdl-palissy.fr/forum/index.php?action=mdl

here's what i've tried:
Code: [Select]
AddPicture()
Code: [Select]
echo AddPicture();
Code: [Select]
<?=AddPicture()?>
here is the code to the page managemdl.template.php
i've added a comment to say where i was trying to add it

Code: [Select]
<?php
/**
 * Created by PhpStorm.
 * User: glenn
 * Date: 08/10/2017
 * Time: 11:14
 */
$gal = include_once ("$sourcedir"/gallery2.php);

function 
template_mainview() {
    global 
$boardurl$context$settings$options$txt$scripturl$modSettings$sourcedir$gal$galtemp;



    
$g_gen allowedTo('genevent');


    if (
$g_gen) {
        echo 
'
        <script src="../../../scripts/jquery-1.12.0.min.js"></script>
        <script src="'
$boardurl'/Themes/Redsy/scripts/mform.js"></script>

            <div class="col-md-12 col-xs-12 form-box">
                
                <form role="form" action="" method="post" class="registration-form">
                    
                    <fieldset>
                        <div class="form-top">
                            <div class="form-top-left">
                                <h3>' 
,$txt['Step'], ' 1 / 4</h3>
                                <p>' 
,$txt['Add-img'], '</p>
                            </div>
                        </div>
                        <div>'
;
        
$galtemp;
       
$gal;

/*
 * tried putting the first two here then the third after the echo below
 */
        
echo '
 
                        </div>
                        <div class="form-bottom">
                            <button type="button" class="btn btn-next">Next</button>
                        </div>
                    </fieldset>
                    
                    <fieldset>
                        <div class="form-top">
                            <div class="form-top-left">
                                <h3>Step 2 / 4</h3>
                                <p>Set up your account:</p>
                            </div>
                        </div>
                        <div>
                            456
                        </div>
                        <div class="form-bottom">
                            <button type="button" class="btn btn-previous">Previous</button>
                            <button type="button" class="btn btn-next">Next</button>
                        </div>
                    </fieldset>
                    
                   <fieldset>
                        <div class="form-top">
                            <div class="form-top-left">
                                <h3>Step 3 / 4</h3>
                                <p>Set up your account:</p>
                            </div>
                        </div>
                        <div>
                            789
                        </div>
                        <div class="form-bottom">
                            <button type="button" class="btn btn-previous">Previous</button>
                            <button type="button" class="btn btn-next">Next</button>
                        </div>
                    </fieldset>
                    
                    <fieldset>
                        <div class="form-top">
                            <div class="form-top-left">
                                <h3>Step 4 / 4</h3>
                                <p>Social media profiles:</p>
                            </div>
                        </div>
                        <div>
                            159
                        </div>
                        <div class="form-bottom">
                            <button type="button" class="btn btn-previous">Previous</button>
                           <div class="btn">Sign me up</div>
                        </div>
                    </fieldset>
                
                </form>
                
            </div>



        '
;
    }elseif (
file_exists(dirname(dirname(__FILE__)) . '/Settings.php'))
    {
        
// Found it!
        
require(dirname(dirname(__FILE__)) . '/Settings.php');
        
header('Location: ' $boardurl);
    }
// Can't find it... just forget it.
    
else
        exit;
}

function 
template_homead() {
    global 
$boardurl$context$settings$options$txt$scripturl$modSettings$sourcedir;



    
$g_gen allowedTo('homeadadmin');


    if (
$g_gen) {




    }elseif (
file_exists(dirname(dirname(__FILE__)) . '/Settings.php'))
    {
        
// Found it!
        
require(dirname(dirname(__FILE__)) . '/Settings.php');
        
header('Location: ' $boardurl);
    }
// Can't find it... just forget it.
    
else
        exit;
}

function 
template_genaff() {
    global 
$boardurl$context$settings$options$txt$scripturl$modSettings$sourcedir;



    
$g_gen allowedTo('genaff');


    if (
$g_gen) {
        echo 
'<h1>lets create affiches to be printed</h1>';
    }elseif (
file_exists(dirname(dirname(__FILE__)) . '/Settings.php'))
    {
        
// Found it!
        
require(dirname(dirname(__FILE__)) . '/Settings.php');
        
header('Location: ' $boardurl);
    }
// Can't find it... just forget it.
    
else
        exit;
}