291171
brash
What Infrastructure Do You Use To Serve Your Xoops Site?
  • 2003/10/8 6:44

  • brash

  • Friend of XOOPS

  • Posts: 2206

  • Since: 2003/4/10


Hi All,

I have just implemented some code as per this thread to show the page loading time at the bottom of each page, and am finding (as I suspected) that my loading times are a bit slow at around 1.3 seconds to load my main page. This is about 1 second slower than what I'd consider a decent average time.

I think this is attributable to two main reasons;
(a) My hardware is getting a bit old
(b) My site runs too many queries on site entry

I ran the MySQL/Blocks dubugging mode, and I found that upon entry to my site the server runs 77 queries, 23 blocks in about 1.3 seconds. Short of removing content, or upgrading my hardware I have no idea if there are any other methods to reduce this time.

Anyway, I was just curious as to what infrastructure other Xoopers used to serve their XOOPS sites, and if possible a few other details such as I've provided below. Mine is as follows;


Hardware & Internet Connection Environment

PIII 550Mhz
1024MB PC-133 SDRAM
10GB ATA-66 5400RPM HDD

512k/512k SDSL Connection


Software & XOOPS Environment

Windows 2000 Adv Server
IIS 5
Xoops 2.0.4
MySQL 4.0.13
PHP 4.3.2

Total queries run upon site entry = 77
Total blocks on site entry = 23
Approximate average time taken = 1.3 seconds



291172
PatrickW
Re: SQL error with installation Mantis Bugtracker
  • 2003/10/8 6:43

  • PatrickW

  • Just popping in

  • Posts: 40

  • Since: 2003/8/29


Hi,

Version 2.0.3

Patrick



291173
skalpa
Re: user name characters count
  • 2003/10/8 6:36

  • skalpa

  • Quite a regular

  • Posts: 300

  • Since: 2003/4/16


It's in System admin / Prefs / User info settings

(It's the 2nd time I answer that to someone in 5mins, we should make that page a bit more accessible )

Skalpa.>



291174
skalpa
Re: Pop up window
  • 2003/10/8 6:25

  • skalpa

  • Quite a regular

  • Posts: 300

  • Since: 2003/4/16


OK...

As hsalazar took the time to write a nice & long tutorial, I can take 5mins to translate that
(I also corrected it, as I think the original article has been written for XOOPS v1.x despite what its title says)

Skalpa.>

PS: Don't forget that if you let everything like that, the popup will be displayed again if an user comes back the next day. If, as I think considering your "chat" example, it's not what you want, I'd suggest you to save your orignal theme.html file so you can switch with / without popup as will.

---
Within the themes/yourtheme/theme.html, insert the following code just after the <head> tag:

<SCRIPT LANGUAGE="JavaScript">

function 
OpenPopup() {
// Check that the cookie isn't already there
if (GetCookie("pop")==null) {

// Create the popup window
window.open("<{$xoops_url}>/pop.html","pop","width=350, height=150, toolbars=no, scrollbars=no");

// Create a cookie that will last 24 hours
var pathname=location.pathname;
var 
myDomain=pathname.substring(0,pathname.lastIndexOf('/')) +'/';
var 
date_exp = new Date();
date_exp.setTime(date_exp.getTime()+(24*3600*1000)); // 24 heures
SetCookie("pop","ok",date_exp,myDomain);
}
}

function 
SetCookie (namevalue) {
var 
argv=SetCookie.arguments;
var 
argc=SetCookie.arguments.length;
var 
expires=(argc 2) ? argv[2] : null;
var 
path=(argc 3) ? argv[3] : null;
var 
domain=(argc 4) ? argv[4] : null;
var 
secure=(argc 5) ? argv[5] : false;
document.cookie=name+"="+escape(value)+
((
expires==null) ? "" : ("; expires="+expires.toGMTString()))+
((
path==null) ? "" : ("; path="+path))+
((
domain==null) ? "" : ("; domain="+domain))+
((
secure==true) ? "; secure" "");
}

function 
getCookieVal(offset) {
var 
endstr=document.cookie.indexOf (";"offset);
if (
endstr==-1)
endstr=document.cookie.length;
return 
unescape(document.cookie.substring(offsetendstr));
}
function 
GetCookie (name) {
var 
arg=name+"=";
var 
alen=arg.length;
var 
clen=document.cookie.length;
var 
i=0;
while (
i<clen) {
var 
j=i+alen;
if (
document.cookie.substring(ij)==arg)
return 
getCookieVal (j);
i=document.cookie.indexOf(" ",i)+1;
if (
i==0) break;}
return 
null;
}
</
SCRIPT>

Then, call the function when the page loads by inserting this within the <body> tag:

<SCRIPT LANGUAGE="JavaScript">
OpenPopup();
</
SCRIPT>


And last, create the page that will be displayed in your popup window, and save it at the root of your XOOPS site, using the filename you used earlier (in the above example, "pop.html"):

<HTML>
<
TITLE>Pop</TITLE>
<
BODY>
 
Content
</BODY>
</
HTML>




291175
gruessle
user name characters count
  • 2003/10/8 6:21

  • gruessle

  • Friend of XOOPS

  • Posts: 348

  • Since: 2003/9/20


How can I change user name max. characters from 10 to 15 or 20?



291176
Mitch
Re: How to allow forum avatar uploads?
  • 2003/10/8 6:20

  • Mitch

  • Just popping in

  • Posts: 7

  • Since: 2003/10/7


ok kool that worked?

I have nearly finished setting up my page "http://www.above-performance.oz-hosting.net/xoops/"

I have a few problems:
1) no matter what i do i cant get it to accept the name in the title bar, i type it in and click accept and it goes away.
2) for some reason usernames with gaps arnt accepted, is there anyway to fix this?



291177
limecity
Re: Restaurant Guide Module Wanted
  • 2003/10/8 6:16

  • limecity

  • Friend of XOOPS

  • Posts: 1602

  • Since: 2003/7/6 0


Sorry for the late reply
As you can see in my site
the restaurant thing i did.
I include a form inside there..
the form will execute a CGI program and send an reservation email to the restaurant.

Thats how i manage mine.

So..I am planning to add more stuff like
REservation TIME :
MR /Mrs....
Date :....

Thats should be it..



291178
skalpa
Re: Instructions on how to hack a block [Warning: looong post]
  • 2003/10/8 6:06

  • skalpa

  • Quite a regular

  • Posts: 300

  • Since: 2003/4/16


It's quite nice you took the time to explain

Would be cool if you could copy that to the wiki so people can find it easily later.

Cheers

Skalpa.>



291179
skalpa
Re: How to allow forum avatar uploads?
  • 2003/10/8 6:00

  • skalpa

  • Quite a regular

  • Posts: 300

  • Since: 2003/4/16


The option is in System admin / Preferences / User info settings.
Users will then be allowed to upload an avatar by choosing "View account" in main menu.



Skalpa.>



291180
hsalazar
Instructions on how to hack a block [Warning: looong post]
  • 2003/10/8 5:53

  • hsalazar

  • Just popping in

  • Posts: 78

  • Since: 2003/2/6 1


All:

For those avid xoopsers in search for a natural high, here's a slightly modified version of a post I made in Dr. Clone's site, this time in English for those who either don't speak Cervantes' language or don't visit Dr. Clone's site. The post was an answer to this query (please excuse my very free translation):
Quote:

Hi, everyone:
I know the answer to this has to be easy but I don't have a clue about PHP.
Those of you who use the phenomenal WF-Section will have seen that the blocks showing articles display the title and the date. I'd like to also show the author, just as in the index.php page of WF-Section.
Does anybody know how to do this...?


So, this is the (edited) answer... Let's say that it's not E-A-S-Y as in A-B-C, but neither is this too complicated (me and my big mouth). So let's take advantage of this opportunity to create this micro-tutorial we could call... ta-daaaa! "Instructions on how to hack a block". Ok? Well, then, grab yourself half a ton of patience and try to follow this logic.

(1) Let's begin assuming you've installed WF-Section verion 1.0.1. If you open xoops_version.php, you'll read in lines 68-74:

$modversion['blocks'][6]['file'] = "wfs_new.php";
$modversion['blocks'][6]['name'] = _MI_WFS_BNAME5;
$modversion['blocks'][6]['description'] = "Shows recent articles";
$modversion['blocks'][6]['show_func'] = "b_wfs_new_show";
$modversion['blocks'][6]['edit_func'] = "b_wfs_new_edit";
$modversion['blocks'][6]['options'] = "published|10|25";
$modversion['blocks'][6]['template'] = 'wfs_block_new.html';


(2) What does it tell us? It says that the content displayed through the template called wfs_block_new.html:

<ul>
  <{foreach 
item=wfs from=$block.new}>
    <
li><a href="<{$xoops_url}>/modules/wfsection/article.php?articleid=<{$wfs.id}>"><{$wfs.title}></a> (<{$wfs.new}>)</li>
  <{/foreach}>
</
ul>


is defined functionally in the file wfs_new.php, and that the function involved in this definition, the one in charge of retrieving the most recent articles, is the function called b_wfs_new_show.

(3) Armed with this fearsome knowledge, let's take a look at the said function (lines 29-56 of blocks/wfs_new.php):

function b_wfs_new_show($options) {
    global 
$xoopsDB;
    
$myts =& MyTextSanitizer::getInstance();
    
$block = array();
    
$sql "SELECT articleid, title, published, expired, counter, groupid FROM ".$xoopsDB->prefix("wfs_article")." WHERE published < ".time()." AND published > 0 AND (expired = 0 OR expired > ".time().") AND noshowart = 0 AND offline = 0 ORDER BY ".$options[0]." DESC";
    
$result $xoopsDB->query($sql,$options[1],0);
    while ( 
$myrow $xoopsDB->fetchArray($result) ) {
        
    if(
checkAccess($myrow["groupid"])) {    
        
$wfs = array();
        
$title $myts->makeTboxData4Show($myrow["title"]);
        if ( !
XOOPS_USE_MULTIBYTES ) {
            if (
strlen($myrow['title']) >= $options[2]) {
                
$title $myts->makeTboxData4Show(substr($myrow['title'],0,($options[2] -1)))."...";
            }
        }
        
$wfs['title'] = $title;
        
$wfs['id'] = $myrow['articleid'];
        if ( 
$options[0] == "published" ) {
            
$wfs['new'] = formatTimestamp($myrow['published'],"s");
        } elseif ( 
$options[0] == "counter" ) {
            
$wfs['new'] = $myrow['counter'];
        }
        
$block['new'][] = $wfs;
    }
    }
    return 
$block;
}


(4) As you can probably read in this code, we're retrieving an article's Id, its title, its publication date, its expiration date, its counter and the id of the group with read privileges over the item. No author here. So? Well, do we have any clue about the article's author in the table xoops_wfs_article? If we cheat a little and take a look at its structure, we'll soon find the table includes the user Id of the article's author (uid). This should serve our evil purpose well, hehe. <-- This is supposed to be a diabolical laugh...

(5) Ok. To retrieve the user's name, first we need the database query to retrieve also the field uid. In other words, we need the query to say:

$sql "SELECT articleid, uid, title, published, expired, counter, groupid FROM ".$xoopsDB->prefix("wfs_article")." WHERE published < ".time()." AND published > 0 AND (expired = 0 OR expired > ".time().") AND noshowart = 0 AND offline = 0 ORDER BY ".$options[0]." DESC";


(6) What next? Now we need to assign to a variable not the user Id, but the user's name. In order to do this, we'll execute a little "surgery" from another of Catzwolf's modules, WF-FAQ, and with the swiftness of experienced thiefs, we'll steal a very useful function called getLinkedUnameFromId. This is that function:

function getLinkedUnameFromId($userid)
     {
        
$userid intval($userid);
              if (
$userid 0) {
                
$member_handler =& xoops_gethandler('member');
                  
$user =& $member_handler->getUser($userid);
                      if (
is_object($user)) {
                          
$ts =& MyTextSanitizer::getInstance();
                          
$linkeduser "<a href='".XOOPS_URL."/userinfo.php?uid=".$userid."'>".$ts->htmlSpecialChars($user->getVar('uname')) ."</a>";
                          return 
$linkeduser;
                      }
            }
              return 
$GLOBALS['xoopsConfig']['anonymous'];
      }


(7) I suggest you paste this snippet into the file include/functions.php. Now, for the module to be able to access this function, you need to include in blocks/wfs_new.php, just after the first include_once, the following line:

include_once XOOPS_ROOT_PATH '/modules/wfsection/include/functions.php';


Now the module will know what to do when you use the function, which, as you can deduce from its syntax, is called with the user Id as parameter. What does the function return when called? The user's name, but not in plain old text, but with a hyperlink to the user's profile. Neat!

(8) So let's return to the file blocks/wfs_new.php. Just after the line $wfs['title'] = $title; let's add another line:

$wfs['author'] = getLinkedUnameFromId($myrow['uid']);


Now you'll see a sequence containing the following lines...

$wfs['title'] = $title;
        
$wfs['author'] = getLinkedUnameFromId($myrow['uid']);
        
$wfs['id'] = $myrow['articleid'];


(9) Logic says we're done. The function kicks all variables within the array $wfs, so in the template, where up to this point we were using <{$wfs.id}>, <{$wfs.title}> and <{$wfs.new}>, we can add now <{$wfs.author}>. And your template could say something like:

<ul>
  <{foreach 
item=wfs from=$block.new}>
    <
li><a href="<{$xoops_url}>/modules/wfsection/article.php?articleid=<{$wfs.id}>"><{$wfs.title}></a>, by <{$wfs.author}> (<{$wfs.new}>)</li>
  <{/foreach}>
</
ul>


(10) Initially I posted this sequence out of pure logic, with the utmost lack of good taste that's one of my personal trademarks. Of course there were bugs. Gentle readers made me aware of this, so I humbly ate crow, followed my own advice and hacked the block. Ahem. Had to do a little repair, ahem, a tiny repair, but eventually it worked, so now I can say this hack... works!

Dear xoopsers: if you have the curiosity and the means to follow these instructions, you'll not only be able to hack the block we've been talking about: you'll also learn a more or less general procedure to enjoy playing with XOOPS. And of course, there should be swifter ways, more elegant ways to accomplish the same result. If you know about one, please post it here so we can all benefit and the lesson will grow.

Cheers and best regards.







Login

Who's Online

143 user(s) are online (94 user(s) are browsing Support Forums)


Members: 0


Guests: 143


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: May 31
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits