PostNuke

Flexible Content Management System

News

Time for Multiple Database

Personally I have only worked with mysql, and have never had something multi-database, but I think that will be not too complicated, maybe something like:





1-Include a variable in config.php where you can specify the database type (e.g. $database_type="mysql")





2-Make that variable global where needed (almost everywhere ;-)





3-And include databse functions (maybe in mainfile or a new database.php file) where you simple make a switch of the options.





Lets say that we make a function named do_query as follows:





function do_query($db,$query){





global $database_type;





swith ($database_type){





case "pg":


pg_exec($db, $query);


break;





case "mysql":


mysql_sd_query($db, $query);


break;


}





and so on, of course this will consume CPU time (I do not know how much), but this can meet many people needs.





What do you think? is this the time to implement multiple database support, or shuld this wait for version 2.0?





bye


mcanedo

Some suggestions...



  • With CSS disable and images loading OFF, Post-Nuke is a bit less readable. I mean, it's not easy to see where the previous story end and where the new one start.

    Maybe a few extra blank lines or a <hr> separator would help ?


  • With images loading OFF, the layout is different (and sometimes look like a big mess). This is because there are missing WIDTH, HEIGHT and ALT attributes for the IMG element. Beside the aspect, rendering a page is slower too because the page has to be re-rendered each time a new image is loaded.

    IMHO, the WIDTH, HEIGHT and ALT attributes should ALWAYS be present.

    There are some case where the WIDTH and HEIGHT size cannot be determined at coding time. But here is a suggestion I made several time on PHP-Nuke.org to bypass this problem (I discussed this with hombergs on phpnuke.org's Bug Fix forum when it was alive).

    In mainfile.php, add this function:



    function GetImgTag($dir, $image, $alttext=" ", $border=0) {

      global $language;



      $path = "$dir/$language/$image";

      if (!file_exists($path)) {

        $path = "$dir/$image";

      }

      $size = GetImageSize ($path);



      $ImgTag = "<img src="$path"";

      if ($size[0]) {

        $ImgTag .= " width="$size[0]"";

      }

      if ($size[1]) {

        $ImgTag .= " height="$size[1]"";

      }

      $imgTag .= " alt="$alttext"";

      $ImgTag .= " border="$border"";

      $ImgTag .= ">";



      return($ImgTag);

    }



    Now, if you want to build a IMG tag but you don't know what the size of the image will be, you can just call the function like this:

    echo "...something..." . GetImgTag("PicDir", "Image.png", "Alternative text") . "...something...";


  • To make sure the user name stored in the cookie is EXACTLY the same as stored in the users table (and thus, have a workaround for the savetheme problem); change in the user.php file, login() function, the lines:



      $result = mysql_query("select pass, uid, storynum, umode, uorder, thold, noscore, ublockon, theme, commentmax from users where uname='$uname'");



    by:



      $result = mysql_query("select pass, uid, uname, storynum, umode, uorder, thold, noscore, ublockon, theme, commentmax from users where uname='$uname'");



    and:



      docookie($setinfo[uid], $uname, $pass, $setinfo[storynum], $setinfo[umode], $setinfo[uorder], $setinfo[thold], $setinfo[noscore], $setinfo[ublockon], $setinfo[theme], $setinfo[commentmax]);



    by:



      docookie($setinfo[uid], $setinfo[uname], $pass, $setinfo[storynum], $setinfo[umode], $setinfo[uorder], $setinfo[thold], $setinfo[noscore], $setinfo[ublockon], $setinfo[theme], $setinfo[commentmax]);



  • In admin/modules/settings.php, the themes list is built using the following code:



      $handle=opendir('themes');

      while ($file = readdir($handle)) {

        if ( (!ereg("[.]",$file)) ) {

          $themelist .= "$file ";

        }

      }

      closedir($handle);



    assuming that anything in the themes/ directory that don't have a "." (dot) in its name IS a theme directory; which is bad, bad, bad !!!

    (Directories CAN have dots in their names, and files names CAN have no dots at all !)



    Someone told me that the is_file() and is_dir() PHP functions were not supported on Windows platforms.

    (Why aren't people definitively dropping Windoz ? ;-) )



    So, here is another solution:



      $handle=opendir('themes');

      while ($file = readdir($handle)) {

        if (!ereg("^[.]{1,2}$",$file)) {

          if ($test = @opendir("themes/$file")) {

            closedir($test);

            $themelist .= "$file ";

          }

        }

      }

      closedir($handle);



  • Since PHP-Nuke 5.0, a sumitted story is formatted with the nl2br() function. I don't think it's a good idea, especially when the story already contains HTML tags.

    I guess you've done that to find a solution for people who don't know about HTML and wish to have their stories published as they have submitted them ? Well, why not offer the choice then: submit as TEXT or HTML (with TEXT being default).

    For text stories, use the PRE element to keep them as is.

    As for comments, IMHO:

     - exttrans should keep HREF links as is, convert any conformant URL (starting with the protocol !!!) to link too, ignore (STRIP) any other HTML tags, THEN apply the nl2br() function.

     - plaintext should be just that, no HTML interpretation (so apply the htmlspecialchars() function here, not in exttrans); use the PRE element.

     - html: well, allowed HTML.


  • The 'lang' cookie (Haa, that awful annoying cookie...) ;-)

    Please drop that lang cookie; there's already too much cookies floating around, and this one is not always very usefull (Try to login WITHOUT the lang cookie...).

    I personnally find it very annoying to have to tell my browser: "No, I don't want this cookie" for each page I load, whereas the default language of a site suit my needs.

    IMHO, the language selection should be a feature offered to registered users only. The prefered language of a user should be a field in the user cookie (yet another good reason to register!), and this will be set only ONCE at loggin time, or when the user decide to change his preferences. No needs for another cookie.

    Now, here is how PHP-Nuke should check for the user's prefered language: for each HTTP request,

     - check from the user cookie if a lang is set and use it

     - IF NOT, check if the browser has sent a lang preference in the HTTP header, and use that

     - IF NOT, use the default language for the site.



    Ok, I guess it's easier to say it than to do it; so I'll try to provide an alternative for a better language auto-selection. Here is the idea (not tested, I'm writing this as I think about it).

    In mainfile.php, replace:



      if (isset($newlang)) {

        if (file_exists("language/lang-$newlang.php")) {

        setcookie("lang",$newlang,time()+31536000);

        include("language/lang-$newlang.php");

        } else {

        setcookie("lang",$language,time()+31536000);

        include("language/lang-$language.php");

        }

      } elseif (isset($lang)) {

        include("language/lang-$lang.php");

      } else {

        setcookie("lang",$language,time()+31536000);

        include("language/lang-$language.php");

      }



    by:



      if (!SetUserLang()) {

        if (!SetNavLang()) {

          include("language/lang-$language.php");

        }

      }



    (and bye bye the 'lang' cookie... hurray !!!) ;-)



    Now, add these functions to mainfile.php (or functions.php ?):



      function SetUserLang() {

        $usercookie = $HTTP_COOKIE_VARS["user"];

        if ($usercookie != "") {

          $usercookie = base64_decode($usercookie);

          $usercookie = explode(":", $usercookie);

          $userlang = $usercookie[10];

          if ($userlang != "") {

            if (file_exists("language/lang-$userlang.php")) {

              include("language/lang-$userlang.php");

              return TRUE;

            }

          }

        }

        return FALSE;

      }

     

      function SetNavLang() {

        $navlang = getenv("HTTP_ACCEPT_LANGUAGE");

        if ($navlang != "") {

          $navlang = explode(",", $navlang);

          for ($i=0; $i < sizeof($navlang); $i++) {

            $tmplang = ltrim($navlang[$i]);

            if ((eregi("^en", $tmplang)) AND (file_exists("language/lang-english.php"))) {

              include("language/lang-english.php");

              return TRUE;

            }

            elseif ((eregi("^fr", $tmplang)) AND (file_exists("language/lang-french.php"))) {

              include("language/lang-french.php");

              return TRUE;

            }

            elseif ((eregi("^de", $tmplang)) AND (file_exists("language/lang-german.php"))) {

              include("language/lang-german.php");

              return TRUE;

            }

            elseif ((eregi("^es", $tmplang)) AND (file_exists("language/lang-spanish.php"))) {

              include("language/lang-spanish.php");

              return TRUE;

            }

            elseif ((eregi("^nl", $tmplang)) AND (file_exists("language/lang-dutch.php"))) {

              include("language/lang-dutch.php");

              return TRUE;

            }

            elseif ((eregi("^it", $tmplang)) AND (file_exists("language/lang-italian.php"))) {

              include("language/lang-italian.php");

              return TRUE;

            }

            elseif ((eregi("^pt-br", $tmplang)) AND (file_exists("language/lang-brasilian.php"))) {

              include("language/lang-brasilian.php");

              return TRUE;

            }

            elseif ((eregi("^pt", $tmplang)) AND (file_exists("language/lang-portuguese.php"))) {

              include("language/lang-portuguese.php");

              return TRUE;

            }

            elseif ((eregi("^no", $tmplang)) AND (file_exists("language/lang-norwegian.php"))) {

              include("language/lang-norwegian.php");

              return TRUE;

            }

            elseif ((eregi("^da", $tmplang)) AND (file_exists("language/lang-danish.php"))) {

              include("language/lang-danish.php");

              return TRUE;

            }

            elseif ((eregi("^sv", $tmplang)) AND (file_exists("language/lang-swedish.php"))) {

              include("language/lang-swedish.php");

              return TRUE;

            }

            /* And so on for other languages available... */

          }

        }

        return FALSE;

      }



    Last, you can now drop the old interface language selection, and offer something else to registered users (Eg.: in the user's preference page). This time not creating a 'lang' cookie, but setting a new 'prefered language' field in the 'user' cookie (from this example code, it could be the 10th field in the 'user' cookie).



Off-topic note: Has anyone tried MakeLang on Post-Nuke yet ? How does it work ?





AmigaPhil at ping.be







Dev Update

So what's in there right now?



First off, a great addition by Matthew Scott with a new feature called "Theme Override". Basically with this function you will be able to change the theme that is called by just changing a category. It's very neat, and you should be able to find at least a few uses for this (expecially after we start to work on the theme structure a bit).



Next, it the ML integration by Crocket has been now placed into the core of Post-Nuke, and it is also up in CVS. This will come in handy for many of you. If you want a look at the possibilities, check out http://www.webmasters.be



We also have the Patrick Kellum's Advance Blocks integrated in, and are working through some of the issues there. There is still some work to do, namely to the SQL update, but it's starting to come together there. dctanner did the work in getting that together for Post-Nuke.



There is still plenty to do in the next week or so. We need to clean up some of the bugs submitted at SourceForge, and also evaluate some of the feature request. If you have any outstanding bugs that need to be corrected, please submit them on our SourceForge site.



We also hope to have at least a couple of the Forum addons released this coming week as well, so there should be plenty to download in the next few days.



I am not going to promise a release date on the .60, but we do plan on testing it in production for a few days before the release to catch the last minute bugs. When you see some new features here, then you will know that we are getting close.



I know that I am leaving something out, so my apologies in advance to anyone's pet project I left off:(



Thanks for reading, and please leave any questions here. We'll do our best to answer them.

Advanced Blocks - Temp. Workaround

Note : * replaces open tag to avoid html processing in this post.






In mainfile.php look for this line (around line 110)







$content = *font class="pn-normal">$content*/font>";






Now replace it with....







if (file_exists($content))



{



$content = $content;



} else {



$content = "*font class="pn-normal">$content*/font>";



}







That should od the job... I know there must be a better way to do it, but I am just getting my head around PHP so I'm going with what I know.





Hope this helps someone





StevenP

SSH client integrated in Nuke

You can download it in the downloads-section of Frizon.org





Note! The applett is included, but is AppGates MindTerm and is free for non-commercial and private use.. otherwise pay for it!





//Shadoe



A New Way to Help - The Nuke United Devices Team


One in four of us will at some time suffer from cancer. The high mortality rate, the suffering experienced by patients from the side effects of existing treatments, and the high costs of treatment all contribute to making cancer a priority for drug research.









The phpNuke community is very large. By joining the Nuke United Device Team we can show the world just how large and popular phpNuke has become. Currently the largest team is almost 8,100 members. Let's team together and show the world just how popular and great the phpNuke portal has become by making us the number 1 Nuke United Device Team!





To read more about helping support research projects by volunteering your unused CPU power check out http://www.nukeunited.com today!
First Page Previous Page Page 268 / 277 (2671 - 2680 of 2763 Total) Next Page Last Page