0
Welcome Guest! Login
0 items Join Now

how to better include php files ?

    • djemmers's Avatar
    • djemmers
    • Jr. Rocketeer
    • Posts: 22
    • Thanks: 0

    how to better include php files ?

    Posted 15 years 10 months ago
    • I know this forum is not exactly the place to put it but I don't know where else.

      I have a joomla site with standard free template and I am going to use one of the rockettheme templates to make it look good! (probably versitality 4, looks nice and still simple/sober looking)

      In the site I have lots of self coded functionaliteis all stored in php files wich get included in joomla through the "jumi" plugin (which alows jou to include php files in the content or in modules)
      (all use an extra database where events can be stored in)

      But now that I am going to make the site look good, I might as well code it right.
      How do I bigin such a task?

      Here is my site (don't be scared of the way it looks, it will change, I made the functionalities first)
      www.tornooi.net
      (I included the google translation of the site as it is a dutch site.)

      examples of the coded links to the db are:
      quick reference (on the right)
      x events added this year ... (on the left)
      last toegevoegd (in the center)

      in short it lets people add/change/lookup sport events in the netherlands and belgium
    • tornooi.net dutch tournament and camp sport database.
      *one fine day I'll be a joomla expert...
    • Franck's Avatar
    • Franck
    • Elite Rocketeer
    • Posts: 1049
    • Thanks: 0

    Re: how to better include php files ?

    Posted 15 years 10 months ago
    • I think Jumi is the right way to go. I use it in my website to include php files using geotarget database. I really don't know another way to inclupe php code in joomla. :cry:
    • djemmers's Avatar
    • djemmers
    • Jr. Rocketeer
    • Posts: 22
    • Thanks: 0

    Re: how to better include php files ?

    Posted 15 years 10 months ago
    • ah geotarget database, something new, will look into that right away.
      tnx for your reply
    • tornooi.net dutch tournament and camp sport database.
      *one fine day I'll be a joomla expert...
    • djemmers's Avatar
    • djemmers
    • Jr. Rocketeer
    • Posts: 22
    • Thanks: 0

    Re: how to better include php files ?

    Posted 15 years 9 months ago
    • So I will stay with jumi then.
      Now, what is the good way to code a mysl db connection in php
      I have an external db with the extra data needed in my site.
      I used to use db_mysql.inc and
      DBconnect.inc
      $tordb                = new DB_Sql;
                $tordb->Database   = 'dbname';
                $tordb->Host        = 'host';
                $tordb->User        = 'username';
                $tordb->Password   = 'pasw';
           $tordb->connect();
      typical instructions in php to use the sql db would be:
      $sql="sql command";
      $db->query($sql);
      $aantal=$db->num_rows();
      $db->next_Record();
      $db->free();

      but now I wonder if that is safe enough
      I came accros this:
      <?php
      function mysql_prep($string){ 
          $mysql_connection_resource = mysql_connect('host', 'login', 'pawd');
           $magic_quotes_active = get_magic_quotes_gpc();
           $new_enough_php = function_exists("mysql_real_escape_string");
          // i.e PHP >= v4.3.0
          if ($new_enough_php) {
              //undo any magic quote effects so mysql_real_escape_string can do the work
              if ($magic_quotes_active) {
                  $string = stripslashes($string);
              }
              $new_string = mysql_real_escape_string($string);//, $mysql_connection_resource);
              if (empty($new_string) && !empty($string)) {
                  die("mysql_real_escape_string failed."); //insert your error handling here
              }
              $string = $new_string;
          } else { // before PHP v4.3.0
              // if magic quotes aren't already on this add slashes manually
              if (!$magic_quotes_active) {
                  $string = addslashes($string);
              } //if magic quotes are active, then the slashes already exist
          }
          return $string;
      }
      ?>
      wich looks pretty safe to me.
      but how do I use it ?
      could someone explain the way to go ? of give an alternative?
    • tornooi.net dutch tournament and camp sport database.
      *one fine day I'll be a joomla expert...
    • Ragdata's Avatar
    • Ragdata
    • Elite Rocketeer
    • Posts: 614
    • Thanks: 0
    • Software Engineer

    Re: how to better include php files ?

    Posted 15 years 9 months ago
    • Hi Djemmers,

      Because of the nature of your custom code, I'd recommend that you consider creating a custom Joomla component to do the job and draw upon the libraries and security provisions contained in the core. To do otherwise MAY introduce security holes in your application (and site) if you're not careful. The Joomla Devs have done a lot of work to ensure that SQL Injection and other attacks are protected against - I encourage you to take advantage of all of that work rather than try to replicate it on your own.
    • Ragdata's Rubber Duck
      www.ragdata.net/
    • djemmers's Avatar
    • djemmers
    • Jr. Rocketeer
    • Posts: 22
    • Thanks: 0

    Re: how to better include php files ?

    Posted 15 years 9 months ago
    • custom component?
      I ve looked around but can't get my head around how to begin ..

      simply put I want (it is more complicated then this but if i get this to work I'll be able to get the rest to work to)
      en external db (not in the joomla db) with events
      *where registered/logged in users (from joomla) can add/update/delete/view their events
      *where guests can add events (off course I'll ad some spam and bot checks here)
      *get all kinds of data from the table (normal get querries)
      (like show all events in category x that bigin after dat y)

      I would think a basic component like that exists? (or at least for the first *)
      would be great, that way I can go from there
      but can't find it ;-(
    • tornooi.net dutch tournament and camp sport database.
      *one fine day I'll be a joomla expert...
    • Ragdata's Avatar
    • Ragdata
    • Elite Rocketeer
    • Posts: 614
    • Thanks: 0
    • Software Engineer

    Re: how to better include php files ?

    Posted 15 years 9 months ago
    • Fair enough ...

      The simple answer is to search a bit harder for JEvents or something similar in the extensions directory (there's dozens of them).

      extensions.joomla.org/

      If you end up wanting to use your custom code (a "wrapper" is the easy way to include custom code), I strongly encourage you to work a bit harder at wrapping your head around a custom component.
    • Ragdata's Rubber Duck
      www.ragdata.net/
    • djemmers's Avatar
    • djemmers
    • Jr. Rocketeer
    • Posts: 22
    • Thanks: 0

    Re: how to better include php files ?

    Posted 15 years 9 months ago
    • came across eventlist. looks basic and good enough to start from.
      Was a bit to quick in my previous post (thank you Ragdata for staying polite)

      So I guess I'll try to edit that component to my liking...
      will take a while I guess but hopefully will be worth it...
      and at least I will get a better understandig of components/extentions/plugins wich will come in handy now I have decided to go forth with joomla...

      tnx for the reply's
    • tornooi.net dutch tournament and camp sport database.
      *one fine day I'll be a joomla expert...
    • Ragdata's Avatar
    • Ragdata
    • Elite Rocketeer
    • Posts: 614
    • Thanks: 0
    • Software Engineer

    Re: how to better include php files ?

    Posted 15 years 9 months ago
    • Definately worth doing mate - I can't recommend Joomla enough.

      As a long-time coder, I've always seen the Joomla codebase as a thing of beauty - the equal of poetry by Yeats.
      (thank you Ragdata for staying polite)
      You're welcome ... and thank you ... I AM trying VERY hard :cheesy:
    • Ragdata's Rubber Duck
      www.ragdata.net/
    • djemmers's Avatar
    • djemmers
    • Jr. Rocketeer
    • Posts: 22
    • Thanks: 0

    Re: how to better include php files ?

    Posted 15 years 9 months ago
    • well, you clearly convinced me
      made a developmentsite where I will be trying to modify eventlist to my needs.
      And as you are so polite, I'll try you on this... :oops:

      I started buttom up
      I want to add a table in mysql (no problem) and do with it the same with as the code below does with the table catagories:
      <?php
       
                               $html = JHTML::_('select.genericlist', $this->categories, 'catsid','size="1" class="inputbox required validate-catsid"', 'value', 'text', $this->row->catsid );
       
                               echo $html;
       
                          ?>
      I found api.joomla.org/Joomla-Framework/HTML/JHT...ect.html#genericlist
      -> WOW this looks great! I see what you mean by "a thing of beauty"

      everything looks straightforward, only, I am having trouble getting my head around the $this (wich seems to be the most important thing)
      how do you manipulate it?
      in other words
      where and how do you set $this->categories
      (wich is an array of value and text taken from the db of the component eventlist.)

      or do you know a forum that is better for these kind of questions (as an experianced coder I think you have had you share of looking around forums)

      If you don't want to continue this, just say so, I'll understand
    • tornooi.net dutch tournament and camp sport database.
      *one fine day I'll be a joomla expert...

Time to create page: 0.054 seconds