Ravens PHP Scripts: Forums
 

 

View next topic
View previous topic
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> Other - Discussion
Poll
want it?
Hell yeah!!!
85%
 85%  [ 6 ]
Hell no!!!
14%
 14%  [ 1 ]
Total Votes : 7


Author Message
wHiTeHaT
Life Cycles Becoming CPU Cycles



Joined: Jul 18, 2004
Posts: 579

PostPosted: Sun May 26, 2013 4:18 pm Reply with quote

I just created an admin module that is able to create front-end modules.

What it do:

When open it gives you a text-field/area to insert:
- the module name
-the content file name
-a wysiwyg text area to fill up the content file name.

Ofcourse the module name is self explained.
The content file name is the content what go show up inside the module itself.

Automaticly the following files/directory are created:

Directory => the module name
File => default EMPTY index.html
File => filename from inserted field (for example: mytestfile.html).

Screenshot 1
Image


Screenshot 2
Image


Screenshot 3
Image
 
View user's profile Send private message Send e-mail
neralex
Site Admin



Joined: Aug 22, 2007
Posts: 1772

PostPosted: Mon May 27, 2013 5:06 am Reply with quote

That is not really a module its only a simple html file inside a module-folder. But i think that its not the best practise to do this because you can not call the needed module functions. I think, its only my opinion, the best way is to create a module with php-files and follow the 'rules'. What are you trying solves the content module better because its full supported by own db-table and the needed module-functions. You can create own pages, categories with a lot of other things. For a custom-module is it better to create a real module with a own db-table and a admin-area. Its not really hard to code and you will find many examples in the core-modules, if you want only display a text.

_________________
Github: RavenNuke 
View user's profile Send private message
nuken
RavenNuke(tm) Development Team



Joined: Mar 11, 2007
Posts: 2024
Location: North Carolina

PostPosted: Mon May 27, 2013 6:22 am Reply with quote

I like the idea. It is a simple way to add a basic module/page. There are many uses for a basic module, like an about us page, donations thank you or cancel page, etc... Not all users understand how to create a module. This would give them the ability to create a simple html module without any knowledge of php or html.

_________________
Tricked Out News 
View user's profile Send private message Send e-mail Visit poster's website
neralex







PostPosted: Mon May 27, 2013 9:10 am Reply with quote

And what is with SEO, theme based css-styles, module restrictions for users and admins, specialchar filtering for other languages in different charsets etc...? It looks like a reinvention of the wheel, since everything is already in the RN. Guys we have so many cool functions in RN to create a basic module and then you would break with all... oO


Last edited by neralex on Mon May 27, 2013 10:12 am; edited 2 times in total 
wHiTeHaT







PostPosted: Mon May 27, 2013 10:05 am Reply with quote

@neralex , are you a database fetish?
And what you mean with: "because you can not call the needed module functions"
The created html file is called within a newly created php file

admin/modules/modulemaker.php

Code:


<?php
if ( !defined('ADMIN_FILE') )
{
   die ("Access Denied");
}
global $prefix, $db, $admin_file, $name;

if (is_mod_admin('admin')) {
   switch($op) {

   case 'MakeModule':
      MakeModule();
      break;
   case 'MakeModuleDir':
      csrf_check();
      MakeModuleDir($title, $HtmlFileName, $filecontent);
      break;
      
   }
} else {
   echo 'Access Denied';
}



function MakeModule() {
   global $admin,$prefix, $db, $admin_file;
   include_once('header.php');
   GraphicAdmin();
   OpenTable();
   echo "<form method=\"post\" action=\"".$admin_file.".php\">"
      ."<span class=\"option thick\">" . _ADDMAINCATEGORY . "</span><br /><br />"
      ."" . _NAME . ": <input type=\"text\" name=\"title\" size=\"30\" maxlength=\"100\" /><br />"
      ."" . _HTML_FILE_NAME . ": <input type=\"text\" name=\"HtmlFileName\" size=\"30\" maxlength=\"100\" /><br />"
      ."" . _DESCRIPTION . ":<br />";
      wysiwyg_textarea('filecontent', '', 'PHPNukeAdmin', '60', '15');
      echo "<input type=\"hidden\" name=\"op\" value=\"MakeModuleDir\" />"
      ."<input type=\"submit\" value=\"" . _ADD . "\" /><br />"
      ."</form>";
   CloseTable();
   include_once('footer.php');
   }
   
   function MakeModuleDir($title, $HtmlFileName, $filecontent) {
   global $admin_file, $db, $prefix;
   $DefaultPagename = "index";

   $title   = stripslashes(FixQuotes($title));
   $HtmlFileName   = stripslashes(FixQuotes($HtmlFileName));
   $filecontent   = stripslashes(FixQuotes($filecontent));
   mkdir ("./modules/" . $title, 0777);
   $newFilledHtmlFile = './modules/'.$title.'/'.$HtmlFileName.".html";
   
   $newFilledHtmlContent = $filecontent;
   
   $newEmptyHtmlFile = './modules/'.$title.'/'.$DefaultPagename.".html";
   
   $newEmptyHtmlFileContent = '';
   
   $newPhpFile = './modules/'.$title.'/'.$DefaultPagename.".php";
   
    $newPhpFileContent =  "<?php\n";
    $newPhpFileContent .=  "if ( !defined('MODULE_FILE') )\n";
    $newPhpFileContent .= "{\n";
    $newPhpFileContent .= "die('You can\'t access this file directly...');\n";
    $newPhpFileContent .="}\n";
    $newPhpFileContent .="require_once('mainfile.php');\n";
    $newPhpFileContent .="\$module_name = basename(dirname(__FILE__));\n";
    $newPhpFileContent .="get_lang(\$module_name);\n";
    $newPhpFileContent .="global \$db, \$prefix, \$module_name;\n";
    $newPhpFileContent .="include_once 'header.php';\n";
    $newPhpFileContent .="OpenTable();\n";
    $newPhpFileContent .="include_once 'modules/'.\$module_name.'/$HtmlFileName.html';\n";
    $newPhpFileContent .="CloseTable();\n";
    $newPhpFileContent .="include_once('footer.php');\n";
    $newPhpFileContent .=  "?>\n";
   
   file_put_contents($newFilledHtmlFile,$newFilledHtmlContent);   
   file_put_contents($newEmptyHtmlFile,$newEmptyHtmlFileContent);
   file_put_contents($newPhpFile,$newPhpFileContent);
Header("Location: ".$admin_file.".php?op=MakeModule");
   }
?>


admin/case/case.modulemaker.php

Code:


<?php

if (!defined('ADMIN_FILE')) {
   die('Access Denied');
}
switch ($op) {
   case 'MakeModule':
   case 'MakeModuleDir':
      include_once('admin/modules/modulemaker.php');
      break;
}
?>


admin/links/links.modulemaker.php

Code:


<?php

if (!defined('ADMIN_FILE')) {
   die('Access Denied');
}
global $admin_file;
if (is_mod_admin('admin')) {
   adminmenu($admin_file . '.php?op=MakeModule', 'ModuleMaker', 'modulesplus.png');
}
?>


For SEO , i was at the point to write a GT-$module_name.php .
For css based content from the theme....... why no one included it to the fck editor???????????????????????
What is the use or purpose of the editor?

I think you should see it from another perspective. Wink
 
neralex







PostPosted: Mon May 27, 2013 10:17 am Reply with quote

@wHiTeHaT: I live in the year 2013 with modern ways to create scripts and i have a cms with a database then i use it. Sorry but i love to work dynamically. Is it now a fetish to use a CMS as CMS?

I don't mean the tap-files, i mean the dh functions. FCK editor is outdated but theme styles include in the editor? Why so complicated?

In the most cases is not enough for a user to create a simple html file because the user is using a CMS. The user would create with the CMS a own look & feel and then the user should create all styles with the editor?

Anyway i'm out here!


Last edited by neralex on Mon May 27, 2013 10:29 am; edited 2 times in total 
wHiTeHaT







PostPosted: Mon May 27, 2013 10:27 am Reply with quote

@neralex , a database or html file have nothing to do with the year you living in.
Why is it bad coding , please explain that to me?
And if it is bad coding , and you seem so modern , tell me why you use Raven (sorry i don't want to be offensive against the team , but I'm a realist).

Did you ever took the time to explore what fck editor is capable of?
I'm sorry , but i cant take you serious.
On the other hand i take a quote from one of your lines above:

In the most cases
 
neralex







PostPosted: Mon May 27, 2013 10:33 am Reply with quote

wHiTeHaT wrote:
I'm sorry , but i cant take you serious.


I feel the same! Wink
 
wHiTeHaT







PostPosted: Mon May 27, 2013 10:42 am Reply with quote

nuken wrote:
I like the idea. It is a simple way to add a basic module/page. There are many uses for a basic module, like an about us page, donations thank you or cancel page, etc... Not all users understand how to create a module. This would give them the ability to create a simple html module without any knowledge of php or html.


Thats the spirit.

Wave
 
Guardian2003
Site Admin



Joined: Aug 28, 2003
Posts: 6799
Location: Ha Noi, Viet Nam

PostPosted: Tue May 28, 2013 5:29 pm Reply with quote

I like the idea 'in principle' but I don't see why you couldn't just store the page content in a DB table rather than physically creating a file unless you are actually creating the modules whole directory structure as well.
Even then, there are plenty of tutorials out there that explain how to create a simple html page in a module and that might be prefereable to having directories with read/write permissions.
 
View user's profile Send private message Send e-mail
jakec
Site Admin



Joined: Feb 06, 2006
Posts: 3048
Location: United Kingdom

PostPosted: Wed May 29, 2013 6:04 am Reply with quote

I am with Guardian2003 on this. Great idea, but it would be good to store the page content in the DB. This would enable admins who don't have access to the server to create additional module pages.
 
View user's profile Send private message
wHiTeHaT







PostPosted: Wed May 29, 2013 12:30 pm Reply with quote

This would enable admins who don't have access to the server to create additional module pages.

You don't need to "upload" the html file , if that is where you pointing to.

I like the idea 'in principle' but I don't see why you couldn't just store the page content in a DB table rather than physically creating a file unless you are actually creating the modules whole directory structure as well.

Yes the whole module structure is created.
 
Guardian2003







PostPosted: Wed May 29, 2013 2:02 pm Reply with quote

If the whole module structure is created then the /modules/ directory would need to writable to allow PHP to create the files. I know you are a capable developer but from a security point of view, I could never use or recommend anything that required the main modules directory to be writable.
Your module itself might be fine and work perfectly but there is always the chance another third party module might not be 'safe' and there may be potential for harm.

That said, you might want to plan out how you would achieve/ finish your module and hold off on a final release until RavenCMS is released as there are some BIG changes coming.
 
neralex







PostPosted: Wed May 29, 2013 3:53 pm Reply with quote

The write access is one of my reasons why i'm so skeptical. The other thing is, 777 is the badest value what you can choose and with the current php versions is it not more possible to create a dir or a file with chmod 777 because all folders and files would created with max chmod 755 - more is not needed. To set chmod 777 to folder or a file is big security risk - everyone can write on it. Also the using of stripslashes or the old function FixQuotes is outdated. Currently it exists better functions.
 
wHiTeHaT







PostPosted: Wed May 29, 2013 3:57 pm Reply with quote

Ok, that sounds interesting , is there more news about RN v3.0?

What can i/we expect?

I will consider about the security issue and go re-think if go use the db instead (but theres nothing wrong for using a .html file as content Wink )

Would be nice to have "check integrity system" for users, after they installed RN.
Just to be sure their folder structure and content is secure.
And what to do if it isn't.
 
neralex







PostPosted: Wed May 29, 2013 4:17 pm Reply with quote

Writing php code in a html file is not the best practise. You can do it also in php with echo lines or functions. You can use a rewrite rule to use the php file or better the module as html but to code php in a html file with switching between html and php looks like wordpress and joomla and that is very ugly. If you are work with php then you should stay on it instead to switch between both. With this type of writing, the code would very hard to read and for me is the best choice to write all in php. For all other things you can use rewrite rules.
 
montego
Site Admin



Joined: Aug 29, 2004
Posts: 9457
Location: Arizona

PostPosted: Thu May 30, 2013 7:09 am Reply with quote

wHiTeHaT wrote:
Would be nice to have "check integrity system" for users, after they installed RN.
Just to be sure their folder structure and content is secure.
And what to do if it isn't.


One could re-run the installSQL.php and click on the Environment Check button, but you have given me an idea for a new ACP "applet". Thanks!

_________________
Where Do YOU Stand?
HTML Newsletter::ShortLinks::Mailer::Downloads and more... 
View user's profile Send private message Visit poster's website
wHiTeHaT







PostPosted: Thu May 30, 2013 9:32 am Reply with quote

montego wrote:


One could re-run the installSQL.php and click on the Environment Check button, but you have given me an idea for a new ACP "applet". Thanks!


That was the intention Laughing
 
wHiTeHaT







PostPosted: Thu May 30, 2013 3:57 pm Reply with quote

neralex wrote:
Writing php code in a html file is not the best practise. You can do it also in php with echo lines or functions. You can use a rewrite rule to use the php file or better the module as html but to code php in a html file with switching between html and php looks like wordpress and joomla and that is very ugly. If you are work with php then you should stay on it instead to switch between both. With this type of writing, the code would very hard to read and for me is the best choice to write all in php. For all other things you can use rewrite rules.


I truly understand your perspective on how code must look.
But as you stated, you speak for yourself.
I admit php in html can be unreadable, but for that it exist syntax highlighting .But to say php in html is ugly , nah sorry.
I think the mistake you make is that you try to look to code in a coders view.
But you should try to also see it on the clients side.
My client or friend in this case, he don't know php, shall i give him your contact details?
I wrote the above especially for him , and thought , why not share it.
I really don't care what others do with it, but i would like it to be used in a secure way.For that i considered using a db.
But to get really to the point about security.
Shouldn't i be feel secure to use the available PHP functions inside a (any) cms, as long as i respect it's code or current api?

They say: If it ain't broke, don't fix it
I say: If it ain't broke, consider it will be some day.
 
neralex







PostPosted: Thu May 30, 2013 5:49 pm Reply with quote

A coder is also a client and self with syntax highlighting is it not better! An non-coder could be in the next time a coder and then he wants read the code and if he looks in the rest of the RN-files and then in yours he get a problem. You as coder give the right way for the user and if you don't write clear, then your user can't read it. And sure i speak for me, because i had self the problem for years ago with bad written code and this is the reason why i would never do that.
 
wHiTeHaT







PostPosted: Mon Jun 10, 2013 3:23 pm Reply with quote

An update to the Modulemaker module.

Sofar i tweaked it so that you can have modules and group modules.
Group modules can contain modules.
A group module is a main module , you can give it a name and content.
Within a Group module you can add modules (only modules created with the module maker)
For example: Group_Module1 >> Module1 >> Module2
If a visitor go to Group_Module1 he sees the content added to this group in the content section of the page.
On the blocks side there is called up a block what loads all modules names.
For it i used WB_Blocks_Manager ( this is really a critical must have module for RN)
When navigate with the block , the content of each module within is loaded from the database over javascript.

The module maker of course also give option to create standalone modules.

For each Group module or stand-alone module you make , theres created a directory in the Modules directory with the corresponding module name.
In each created Group module theres a index.php file with content for calling the corresponding group content and its module(s).

For the stand-alone modules theres a index.php generated to just cal the module content from the database.
You can EDIT-DELETE-RENAME each Group_Module or stand-allone Module.
Image
 
neralex







PostPosted: Tue Jun 11, 2013 5:58 am Reply with quote

I know not all is written in stone but i have readed for while ago that a main goal of RavenNuke is to not have interdependencies of modules. It seems for me you are creating with your 'groups' single pages in catagories like News or Content.
 
Guardian2003







PostPosted: Tue Jun 11, 2013 1:58 pm Reply with quote

wHiTeHaT wrote:
... i used WB_Blocks_Manager ( this is really a critical must have module for RN)

I'm not sure how that block manager works but I can tell you (spolier alert)....
RavenCMS v1.0 (code named Aurora) will have a blocks manager that allows different blocks to be shown depending on the currently active module. This includes ALL blocks, even center blocks but this will only work with the new themes that have been developed (mostly by spasticdonkey) because there is now also a theme manager that lets you select how your theme layout; two column, three column, left and right columns together etc.
 
Guardian2003







PostPosted: Tue Jun 11, 2013 2:14 pm Reply with quote

@ wHiTeHaT
I do not want to side track you from your project but I did have an idea that might help you get around some of the possible problems raised in this topic just as the need to have writable directories and creating files etc.
I have actually been working on something for myself (caching the results databse queries as files) so maybe this might help you......
RavenNuke already has a writable directory that is used for things like RSS feed data so you could store your 'created' files in there.
To help prevent unauthorised access, when you create a file you can give it new name [code] $new_filename = sha1($filename);[code]
It is highly unlikely anyone would "guess" such a name to be able to access the file directly and even if they did, it wouldnt actually have an extension so neither PHP or a browser would be able to parse it(assuming the file is just content and doesnt have an actual HEAD element).
 
wHiTeHaT







PostPosted: Tue Jun 11, 2013 4:42 pm Reply with quote

Thanks Guardian for the tips.
But i think i go solve it by let the module listing check the db instead of the module directory.
By use a reference for 'virtual module' or something like that.

Is there a Git available for aurora?
 
Display posts from previous:       
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> Other - Discussion

View next topic
View previous topic
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum


Powered by phpBB © 2001-2007 phpBB Group
All times are GMT - 6 Hours
 
Forums ©