61
Dylian
Change the redirect_header() url.
  • 2009/12/23 8:43

  • Dylian

  • Friend of XOOPS

  • Posts: 237

  • Since: 2007/7/21


I have a little problem with rewriting my urls from www.dylian.eu to en.dylian.eu This is what IS working: xlanguage module installed; .htaccess rewrite of en.dylian.eu to www.dylian.eu/?lang=english | www.dylian.eu/?something=somethingelse[edit] & lang = english (without the spaces) (why does the textsanitizer remove the & symbol if something is put right next to it??)[/edit] smarty plugin to rewrite all url's in smarty templates to the new one where needed. And this is what isn't working: preload file to rewrite the url of redirect header(). These are the files i use (removed all the irelevant stuff...): /domainroot/.htaccess (Working)
RewriteEngine On 

rewriteCond 
%{REQUEST_URI} ^(.*)?
RewriteRule ^en.dylian.eu/(.*)$ www.dylian.eu/$1?=english [QSA,L]

rewriteCond %{REQUEST_URI} !^(.*)?
RewriteRule ^en.dylian.eu/(.*)$ www.dylian.eu/$1?lang=english [QSA,L]
/domainroot/www.dylian.eu/class/smarty/xoops_plugins/outputfilter.xoLangRewriteModule.php (Working / Based on the xoRewriteModule)
<?php
include_once XOOPS_ROOT_PATH '/Frameworks/smarty/xoSmartyFunctions.php';

function 
smarty_outputfilter_xoLangRewriteModule$source, &$smarty ) {
    if(
$_GET['lang'] == "english"){
        
$GLOBALS['xoopsLogger']->addExtra("plugin smarty for XOOPS => xoLangRewriteModule ""Loaded");
        
$newurl str_replace("www." "en." XOOPS_URL);
        
$source str_replace(XOOPS_URL $newurl $source);
    }

    return 
$source;
}
?>
/domainroot/www.dylian.eu/modules/xHacks/preloads/core.php (Not fully working)
<?php
defined
('XOOPS_ROOT_PATH') or die('Restricted access');

class 
xHacksCorePreload extends XoopsPreloadItem
{
    function 
eventCoreHeaderAddmeta($args// Working
    
{
        
$GLOBALS['xoopsTpl']->load_filter('output''xoLangRewriteModule');
    }
    
    function 
eventCoreIncludeFunctionsRedirectheader($args){ // Not working
        // $args[0] Contains the url variable (The URL to redirect to) 
        
if($_GET['lang'] == "english"){
            
$GLOBALS['xoopsLogger']->addExtra("plugin preload for XOOPS => xoLangRewriteModule ""Loaded");
            
$newurl str_replace("www." "en." XOOPS_URL);
            
$args[0] = str_replace(XOOPS_URL $newurl $args[0]);
            
//redirect_header($args[0], $args[1], $args[2], $args[3], $args[4]);
            //exit();
        
}
    } 
}
?>
As you can see i tried to fix this be just calling the function again but this caused my pages to never stop loading. Does someone know how to fix this? Greets Dylian.



62
Dylian
Re: Create Random Name to uploaded file
  • 2009/12/23 7:27

  • Dylian

  • Friend of XOOPS

  • Posts: 237

  • Since: 2007/7/21


See my example... (It adds the original filename and the extension)

[edit] This is the updated line in my original post:
$uploader->setTargetFileName($prefix.$uploader->mediaName);

[/edit]
Greets Dylian.



63
Dylian
Re: Create Random Name to uploaded file
  • 2009/12/23 7:13

  • Dylian

  • Friend of XOOPS

  • Posts: 237

  • Since: 2007/7/21


Whoops forgot something... I've updated the previous post with the correct code.

Greets Dylian.



64
Dylian
Re: Create Random Name to uploaded file
  • 2009/12/23 6:01

  • Dylian

  • Friend of XOOPS

  • Posts: 237

  • Since: 2007/7/21


Try:
$prefix substr(md5(time()),0,7); 
$uploader = new XoopsMediaUploader(XOOPS_ROOT_PATH "/" "modules/test/upload/"$allowed_mimetypes$maxfilesize); 
if (
$uploader->fetchMedia($_POST["xoops_upload_file"][0])) { 
    
$uploader->setTargetFileName($prefix.$uploader->mediaName); // ADDED | UPDATED
    
if (!$uploader->upload()) {


Didn't try it but i think it should work.

For more information click [HERE] and [HERE].

Greets Dylian.



65
Dylian
Re: XoopsCache class.
  • 2009/12/22 22:51

  • Dylian

  • Friend of XOOPS

  • Posts: 237

  • Since: 2007/7/21


Quote:
I need 'XoopsCache' class documentation which is located in \class\cache\xoopscache.php.


Go tohttp://dev.xoofoo.org/dev_xoops_242/ then classes > XoopsCache .

Don't know if this is what you mean't by documentation...

Greets Dylian.



66
Dylian
Re: Passing $_REQUEST variable to theme
  • 2009/12/22 22:44

  • Dylian

  • Friend of XOOPS

  • Posts: 237

  • Since: 2007/7/21


First can you send a copy of your .htaccess file?

And second, if you do your redirect like this the users id will be passed correctly.

RewriteEngine On
RewriteRule 
^([0-9]+)$ your/desired/path/file.php?userid=$[R]


The [R] flag tels apache to redirect. And if you want to keep it real nice you could replace [R] with [L]. If you do this the user won't be redirected but just stays on the current url, while the desired file is still loaded.

Greets Dylian.

BTW To get the users id from within the template you could then use <{$smarty.get.userid}>



67
Dylian
Re: All available preloads in XOOPS 2.4.2
  • 2009/12/22 20:21

  • Dylian

  • Friend of XOOPS

  • Posts: 237

  • Since: 2007/7/21


Could one of the moderators put a space after class in the second code block? [edit]Whoops, didn't see it was possible to edit your post after a new post has been added...[/edit]

And thanks for the reaction trabis, do you know if these are all the available preloads in XOOPS 2.4.2?

And could new preloads be notified in the changelog or in an other way?

Greets Dylian.



68
Dylian
All available preloads in XOOPS 2.4.2
  • 2009/12/22 17:04

  • Dylian

  • Friend of XOOPS

  • Posts: 237

  • Since: 2007/7/21


I'm creating a new module (xHacks) to implement XOOPS hacks from within the administration area. And to do this i use preloads, but i couldn't find a list of all available preloads so i created one.

These are all the preloads i could find in XOOPS 2.4.2

CORE:

class\database\databasefactory.php :
$xoopsPreload->triggerEvent('core.class.database.databasefactory.connection', array(&$class));
Before database connection

class\smarty\xoops_plugins\function.xoInboxCount.php
$xoopsPreload->triggerEvent('core.class.smarty.xoops_plugins.xoinboxcount', array($pm_handler));
Before counting the number of new pm's

class\theme_blocks.php
$xoopsPreload->triggerEvent('core.class.theme_blocks.retrieveBlocks', array(&$this, &$template, &$block_arr));
Before retrieving the blocks

class\xoopsform\formdhtmltextarea.php
$xoopsPreload->triggerEvent('core.class.xoopsform.formdhtmltextarea.codeicon', array(&$code));
After setting the button toolbar of the DTHML text area

edituser.php
$xoopsPreload->triggerEvent('core.edituser.start');
At the beginning of edituser.php

footer.php
$xoopsPreload->triggerEvent('core.footer.start');
At the beginning of footer.php
$xoopsPreload->triggerEvent('core.footer.end');
At the end of footer.php

header.php
$xoopsPreload->triggerEvent('core.header.start');
At the beginning of header.php
$xoopsPreload->triggerEvent('core.header.addmeta');
At the loading of the META data
$xoopsPreload->triggerEvent('core.header.end');
At the end of header.php

include\common.php
$xoopsPreload->triggerEvent('core.include.common.start');
At the beginning of common.php
$xoopsPreload->triggerEvent('core.include.common.language');
Before loading the language files
$xoopsPreload->triggerEvent('core.include.common.end');
At the end of common.php

include\functions.php
$xoopsPreload->triggerEvent('core.include.functions.redirectheader', array($url, $time, $message, $addredirect, $allowExternalLink));
At the beginning of the redirectheader() function.

index.php
$xoopsPreload->triggerEvent('core.index.start');
At the beginning of index.php.

lostpass.php
$xoopsPreload->triggerEvent('core.lostpass.start');
At the beginning of lostpass.php.

pmlite.php
$xoopsPreload->triggerEvent('core.pmlite.start');
At the beginning of pmlite.php

readpmsg.php
$xoopsPreload->triggerEvent('core.readpmsg.start');
At the beginning of readpmsg.php

register.php
$xoopsPreload->triggerEvent('core.register.start');
At the beginning of register.php

user.php
$xoopsPreload->triggerEvent('core.user.start');
At the beginning of user.php

userinfo.php
$xoopsPreload->triggerEvent('core.userinfo.start');
At the beginning of userinfo.php

viewpmsg.php
$xoopsPreload->triggerEvent('core.viewpmsg.start');
At the beginning of viewpmsg.php

SYSTEM MODULE:

modules\system\admin\users\main.php
$xoopsPreload->triggerEvent('system.admin.users.main.start');
At the beginning of main.php.

modules\system\blocks\system_blocks.php
$xoopsPreload->triggerEvent('system.blocks.system_blocks.usershow', array(&$pm_handler));
At the loading of the XOOPS "User Menu" block.

modules\system\class\gui.php
$xoopsPreload->triggerEvent('system.class.gui.header');
At the end of the header() function.

But i don't know if these are all available preloads in XOOPS 2.4.2 so if you know some more please post.

After i created this list i started working out the actual preload files.

So for all module developers that want to use preloads but don't know how to use them... This could come in handy:

modules/YourModule/preloads/core.php: (All core preloads)
<?php
###############################################################################
##   Copyright (C) 2009  Dylian Melgert                                      ##
##                                                                           ##
##      This program is free software: you can redistribute it and/or modify ##
##      it under the terms of the GNU General Public License as published by ##
##      the Free Software Foundation, either version 3 of the License, or    ##
##      (at your option) any later version.                                  ##
##                                                                           ##
##      This program is distributed in the hope that it will be useful,      ##
##      but WITHOUT ANY WARRANTY; without even the implied warranty of       ##
##      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the        ##
##      GNU General Public License for more details.                         ##
##                                                                           ##
##      You should have received a copy of the GNU General Public License    ##
##      along with this program.  If not, see <http://www.gnu.org/licenses/>.##
###############################################################################

defined('XOOPS_ROOT_PATH') or die('Restricted access');

class 
YourModuleCorePreload extends XoopsPreloadItem{

    function 
eventCoreClassDatabaseDatabasefactoryConnection($args){
        
// $args[0] Contains the classname of the Database connection class
        
        // Something to do at the event...
    
}
    
    function 
eventCoreClassSmartyXoops_pluginsXoinboxcount($args){
        
// $args[0] Contains the pm handler
        
        // Something to do at the event...
    
}
    
    function 
eventCoreClassTheme_blocksRetrieveBlocks($args){
        
// $args[0] Contains the current object
        // $args[1] Contains XoopsTpl() object
        // $args[2] Contains an array of XoopsBlock() objects
        
        // Something to do at the event...
    
}
    
    function 
eventCoreClassXoopsformFormdhtmltextareaCodeicon($args){
        
// $args[0] Contains the code variable (DHTML icon bar)
        
        // Something to do at the event...
    
}
    
    function 
eventCoreEdituserStart(){
        
// Something to do at the event...
    
}
    
    function 
eventCoreFooterStart(){
        
// Something to do at the event...
    
}
    
    function 
eventCoreFooterEnd(){
        
// Something to do at the event...
    
}
    
    function 
eventCoreHeaderStart(){
        
// Something to do at the event...
    
}
    
    function 
eventCoreHeaderAddmeta(){
        
// Something to do at the event...
    
}
    
    function 
eventCoreHeaderEnd(){
        
// Something to do at the event...
    
}
    
    function 
eventCoreIncludeCommonStart(){
        
// Something to do at the event...
    
}
    
    function 
eventCoreIncludeCommonLanguage(){
        
// Something to do at the event...
    
}
    
    function 
eventCoreIncludeCommonEnd(){
        
// Something to do at the event...
    
}
    
    function 
eventCoreIncludeFunctionsRedirectheader($args){
        
// $args[0] Contains the url variable (The URL to redirect to)
        // $args[1] Contains the time variable (How long to wait before redirecting)
        // $args[2] Contains the addredirect variable (If you want to add [[?/&]]xoops_redirect=[[current_url]] to the redirect url.)
        // $args[3] Contains the message variable (The message to show to the user)
        // $args[4] Contains the allowExternalLink variable (If you want to allow redirects to external url's)
        
        // Something to do at the event...
    
}
    
    function 
eventCoreIndexStart(){
        
// Something to do at the event...
    
}
    
    function 
eventCoreLostpassStart(){
        
// Something to do at the event...
    
}
    
    function 
eventCorePmliteStart(){
        
// Something to do at the event...
    
}
    
    function 
eventCoreReadpmsgStart(){
        
// Something to do at the event...
    
}
    
    function 
eventCoreRegisterStart(){
        
// Something to do at the event...
    
}
    
    function 
eventCoreUserStart(){
        
// Something to do at the event...
    
}
    
    function 
eventCoreUserinfoStart(){
        
// Something to do at the event...
    
}
    
    function 
eventCoreViewpmsgStart(){
        
// Something to do at the event...
    
}
    
}
?>


modules/YourModule/preloads/systemModule.php: (All sytem module preloads)
<?php
###############################################################################
##   Copyright (C) 2009  Dylian Melgert                                      ##
##                                                                           ##
##      This program is free software: you can redistribute it and/or modify ##
##      it under the terms of the GNU General Public License as published by ##
##      the Free Software Foundation, either version 3 of the License, or    ##
##      (at your option) any later version.                                  ##
##                                                                           ##
##      This program is distributed in the hope that it will be useful,      ##
##      but WITHOUT ANY WARRANTY; without even the implied warranty of       ##
##      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the        ##
##      GNU General Public License for more details.                         ##
##                                                                           ##
##      You should have received a copy of the GNU General Public License    ##
##      along with this program.  If not, see <http://www.gnu.org/licenses/>.##
###############################################################################

defined('XOOPS_ROOT_PATH') or die('Restricted access');

class 
YourModuleSystemModulePreload extends XoopsPreloadItem{

    function 
eventSystemAdminUsersMainStart(){
        
// Something to do at the event...
    
}
    
    function 
eventSystemBlocksSystem_blocksUsershow($args){
        
// $args[0] Contains the pm handler
        
        // Something to do at the event...
    
}
    
    function 
eventSystemClassGuiHeader(){
        
// Something to do at the event...
    
}
    
}
?>


I hope this helped and that someone will check whether the information is correct.

Greets Dylian.



69
Dylian
Re: Passing $_REQUEST variable to theme
  • 2009/12/22 15:17

  • Dylian

  • Friend of XOOPS

  • Posts: 237

  • Since: 2007/7/21


If i'm not wrong you could use <{$smarty.get.the_var_you_want}> in smarty templates as this equals $_GET['the_var_you_want'] in PHP.

Click [HERE] for more information.

Greets Dylian.



70
Dylian
Re: Syndication module
  • 2009/12/20 20:20

  • Dylian

  • Friend of XOOPS

  • Posts: 237

  • Since: 2007/7/21


d3Pipes does that if i'm not wrong.

http://xoops.peak.ne.jp/md/mydownloads/visit.php?cid=1&lid=100&extension=zip

Greets Dylia




TopTop
« 1 ... 4 5 6 (7) 8 9 10 11 »



Login

Who's Online

204 user(s) are online (133 user(s) are browsing Support Forums)


Members: 0


Guests: 204


more...

Donat-O-Meter

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

Latest GitHub Commits