#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2013
    Posts
    1
    Rep Power
    0

    Trying to add PHP to Joomla website crashed forum


    I've never done any php coding before, but I'm using a forum extension from chronoforums and I'm trying to add some php to the forums so that if the user is logged in it will display Welcome: $user and if not it will display a link Login/Register. Here is the code I tried, but it crashed the forum page.

    Code:
    <?php 
      $user = JFactory::getUser();
      $status = $user->guest;
      if($status == 1) {
          $url = "/forum/login";
          echo "<a href=\"$url\">Login/Register</a>";
      } else { 
          echo "<p>Welcome: {$user->username}</p>";
      }   
    ?>

    Error:

    Code:
    ( ! ) Fatal error: Class '\GCore\Extensions\Chronoforums\Helpers\Elements' not found in D:\wamp\www\administrator\components\com_chronoforums\libs\view.php on line 36
    Call Stack
    #   Time    Memory  Function    Location
    1   0.0012  687992  {main}( )   ..\index.php:0
    2   0.1202  9310792 JSite->dispatch( )  ..\index.php:52
    3   0.1241  9381648 JComponentHelper::renderComponent( )    ..\application.php:220
    4   0.1306  9427712 JComponentHelper::executeComponent( )   ..\helper.php:335
    5   0.1310  9494592 require_once( 'D:\wamp\www\components\com_chronoforums\chronoforums.php' )  ..\helper.php:355
    6   0.1410  10314824    GCore\Libs\AppJ::call( )    ..\chronoforums.php:20
    7   0.1410  10317520    GCore\Libs\AppJ->dispatch( )    ..\app_j.php:290
    8   0.2651  13478640    GCore\Libs\View->initialize( )  ..\app_j.php:207
    Here is the whole page I added the code to:

    Code:
    <?php
    /**
    * ChronoCMS version 1.0
    * Copyright (c) 2012 ChronoCMS.com, All rights reserved.
    * Author: (ChronoCMS.com Team)
    * license: Please read LICENSE.txt
    * Visit http://www.ChronoCMS.com for regular updates and information.
    **/
    namespace GCore\Extensions\Chronoforums\Helpers;
    defined('_JEXEC') or die('Restricted access');
    defined("GCORE_SITE") or die;
    class Elements {
        function footer($data = array()){
            $topic = isset($data['topic']) ? $data['topic'] : null;
            $subscribed = isset($data['subscribed']) ? $data['subscribed'] : null;
    
            ?>
            <div class="cfu-navbar">
                <div class="cfu-inner">
                <span class="cfu-corners-top"><span></span></span>
                <ul class="cfu-linklist">
                    <li class="cfu-icon-home"><a accesskey="h" href="<?php echo r_("index.php?option=com_chronoforums"); ?>"><?php echo l_('CHRONOFORUMS_BOARD_INDEX'); ?></a></li>
    
                    <?php if(\GCore\Libs\Authorize::authorized('\GCore\Extensions\Chronoforums\Chronoforums', 'make_posts')): ?>
                        <?php if(isset($subscribed)): ?>
                            <?php if(!empty($subscribed['Subscribed'])): ?>
                            <li class="cfu-icon-unsubscribe"><a title="<?php echo l_('CHRONOFORUMS_UNSUBSCRIBE_TOPIC'); ?>" href="<?php echo r_("index.php?option=com_chronoforums&cont=topics&act=unsubscribe&t=".$topic['Topic']['id']); ?>"><?php echo l_('CHRONOFORUMS_UNSUBSCRIBE_TOPIC'); ?></a></li>
                            <?php else: ?>
                            <li class="cfu-icon-subscribe"><a title="<?php echo l_('CHRONOFORUMS_SUBSCRIBE_TOPIC_DESC'); ?>" href="<?php echo r_("index.php?option=com_chronoforums&cont=topics&act=subscribe&t=".$topic['Topic']['id']); ?>"><?php echo l_('CHRONOFORUMS_SUBSCRIBE_TOPIC'); ?></a></li>
                            <?php endif; ?>
                        <?php endif; ?>
                        <?php if(0): ?>
                        <li class="cfu-icon-bookmark"><a title="Bookmark topic" href="">Bookmark topic</a></li>
                        <?php endif; ?>
                    <?php endif; ?>
                </ul>
                <span class="cfu-corners-bottom"><span></span></span></div>
            </div>
            <?php
        }
    
        function header($data = array()){
            $forum = isset($data['forum']) ? $data['forum'] : null;
            ?>
            <div class="cfu-navbar">
                <div class="cfu-inner">
                <span class="cfu-corners-top"><span></span></span>
                <ul class="cfu-linklist cfu-leftside">
                    <li class="cfu-icon-home">
                        <a accesskey="h" href="<?php echo r_("index.php?option=com_chronoforums"); ?>"><?php echo l_('CHRONOFORUMS_BOARD_INDEX'); ?></a>
                        <?php if(!empty($forum)): ?>
                        <strong></strong>
                        <a href="<?php echo r_("index.php?option=com_chronoforums&cont=forums&f=".$forum['id']); ?>"><?php echo $forum['title']; ?></a>
                        <?php endif; ?>
                    </li>
    
                </ul>
    
                <div class="cfu-rightside">
                    <form action="<?php echo r_('index.php?option=com_chronoforums&cont=search'); ?>" method="post" name="searchform">
                    <fieldset>
                        <input type="text" value="" size="20" id="cfu-search_keywords" name="skeywords" class="cfu-inputbox cfu-search cfu-tiny"/>
                        <input type="submit" name="forums_search" value="<?php echo l_('CHRONOFORUMS_SEARCH'); ?>" class="cfu-button2"/>
                        <input type="hidden" name="f" value=""/>
                    </fieldset>
                    </form>
                </div>
    
                <span class="cfu-corners-bottom"><span></span></span></div>
            </div>
    <?php 
    $user = JFactory::getUser();
    $status = $user->guest;
    if($status == 1){
    $url = "/forum/login";
    echo "<a href=\"$url\">Login/Register</a>";
    }
    else
    { 
    echo "<p>Welcome: {$user->username}</p>";
    }   
    ?>   
            <?php
        }
    }
  2. #2
  3. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2013
    Posts
    1
    Rep Power
    0
    Have you backed up your existing codes means to say have you backed up all the php files to which you made changes as to safe guard yourself from any damage?

IMN logo majestic logo threadwatch logo seochat tools logo