DragonPrime - LoGD Resource Community
Welcome Guest
  • Good morning, Guest.
    Please log in, or register.
  • July 19, 2019, 02:59:25 AM
Home Forums News Downloads Login Register Advanced Search
* * *
DragonPrime Menu
Login
 
 
Resource Pages
Search

Pages: [1] 2 3 4   Go Down
  Print  
Author Topic: Custom Colors : File Submission/Discussion  (Read 15403 times)
0 Members and 1 Guest are viewing this topic.
Aeolus
Mod God
*****
Offline Offline

Posts: 1934


You're welcome.


View Profile WWW
« on: September 27, 2013, 12:12:41 AM »

Name: Custom Colors
Author: Aeolus
Version: 1.2
Category: General
Compatible: Tested and used on 1.1.2 (should work on any 1.x.x)

Description:
You can now add and modify custom colors to your website via a simple editor, instead of having to edit multiple core files for each new color. Account ID-only colors allowed.

-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

Core Edits:
CORE EDITS ARE DANGEROUS IF YOU DON'T KNOW WHAT YOU'RE DOING!

lib/forms.php:
Find:
Quote
x++;
Add Before:
Quote
");
modulehook("previewform");
rawoutput("

-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

lib/output.php
Find:
Quote
do {
Add Before:
Quote
$colors = modulehook("appoencode", $colors);

-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

This module also comes with three modified sanitize functions (so that custom colors can be sanitized as well). So, instead of using:
Quote
require('lib/sanitize.php');
sanitize_function($in);
Use:
Quote
require('modules/custom_colors.php');
new_sanitize_function($in);

Or replace the core's sanitize functions with the modified ones. Whatever floats your boat.

-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

Suggestions, ideas and bugs are welcome.
« Last Edit: July 22, 2014, 01:41:41 PM by The Doctor » Logged

Megan|SaraBeth
Mod God
*****
Offline Offline

Posts: 1065



View Profile WWW
« Reply #1 on: September 27, 2013, 09:49:32 AM »

I think replacing the sanitize functions is much easier because arent there many files/modules that use require('lib/sanitize.php');? That would be a pain to change each one.  Changing one file is much easier.


EDIT: If I replace, for example, function sanitize with function new_sanitize it wont break the modules or files that use require('lib/sanitize.php');, will it?  Also, cant you just add in the new functions and have function sanitize and function new_sanitize?
« Last Edit: September 27, 2013, 10:36:26 AM by Megan|SaraBeth » Logged

Rockie
Militia
**
Offline Offline

Posts: 33

I'm Twisted


View Profile
« Reply #2 on: September 27, 2013, 12:40:01 PM »

I did the lib/form.php   lib/output.php  edits and changed the sanitize functions with the new ones. But when I set the editor it does nothing. I am using the six digit hex colors codes also.

These are the changes to sanitize I did using the new ones from the module. I think my problem may be in here since the others were pretty straight forward edits.

Edit: After I posted this I noticed the extra bracket in there so I looked through my file and it isn't there, only when I copy and past it.  Huh

Code:
function sanitize($in){
$out = preg_replace("/[`][1234567890!@#\$%^&)~QqRVvGgTtjJeElLxXyYkKpPmM?*AabicnHw".getcustomchars()."]/", "", $in);
return $out;
}
}

function newline_sanitize($in){
$out = preg_replace("/`n/", "", $in);
return $out;
}

function new_color_sanitize($in){
$out = preg_replace("/[`][1234567890!@#\$%^&)~QqRVvGgTtjJeElLxXyYkKpPmM?*Aabi".getcustomchars()."]/", "", $in);
return $out;
}

function new_comment_sanitize($in) {
$out = preg_replace("/[`](?=[^1234567890!@#\$%^&)~QqRVvGgTteEjJlLxXyYkKpPmM?*Aa".getcustomchars()."])/", chr(1).chr(1), $in);
$out = str_replace(chr(1),"`",$out);
return $out;
« Last Edit: September 27, 2013, 12:52:59 PM by Rockie » Logged
Aeolus
Mod God
*****
Offline Offline

Posts: 1934


You're welcome.


View Profile WWW
« Reply #3 on: September 27, 2013, 09:26:51 PM »

Megan:

As I said, whatever floats your boat. You'd need to keep the function name the same, and simply replace the contents of said function. Also, why would you want both sanitize() and new_sanitize()? Sanitize is useless if you're using custom colours, since it won't sanitize your new colours.

Rockie:

You've got an additional bracket after sanitize(), you're missing a bracket after new_comment_sanitize(), and you haven't kept the function names the same (i.e. modules that use comment_sanitize() can't find the comment_sanitize() function - they'll need new_comment_sanitize()). As I said to Megan, simply replace the contents of the function.

Also, in the lib/sanitize.php file, you'll need to add require 'modules/custom_colours.php';, so that it knows what the getcustomchars() function does.
Logged

Megan|SaraBeth
Mod God
*****
Offline Offline

Posts: 1065



View Profile WWW
« Reply #4 on: September 27, 2013, 09:43:01 PM »

Where does require('modules/custom_colors.php'); go in the sanitize file?
Logged

Aeolus
Mod God
*****
Offline Offline

Posts: 1934


You're welcome.


View Profile WWW
« Reply #5 on: September 27, 2013, 09:53:45 PM »

Where does require('modules/custom_colors.php'); go in the sanitize file?

Where have you tried? It's obvious - before the first occurrence of getcustomchars(). So, probably at the top of the file.
Logged

Megan|SaraBeth
Mod God
*****
Offline Offline

Posts: 1065



View Profile WWW
« Reply #6 on: September 27, 2013, 10:46:16 PM »

Derp. I knew that. Its just been one of those nights for me...
Logged

Aeolus
Mod God
*****
Offline Offline

Posts: 1934


You're welcome.


View Profile WWW
« Reply #7 on: September 28, 2013, 04:36:18 AM »

Version 1.1:

  • User-only colors now allowed! (separate by commas)
  • If a user is not allowed to use a certain color, then it will be sanitized from any input they use it in, and not show in the commentary preview.
  • List of added custom colors now shown underneath editor with its actual color displayed.
  • Adding an existing color code (e.g. `7 or `~) with a new HEX color will override the existing one, due to the nature of the appoencode and (modified) previewform hook (saves an admin from having to edit the CSS file).
  • Editing of existing custom colors now available! (This was not an option in v1.0).
  • Layout of editor modified so delete is at the bottom.
  • Instructions concerning the sanitize functions included in-file.
Logged

Rockie
Militia
**
Offline Offline

Posts: 33

I'm Twisted


View Profile
« Reply #8 on: September 28, 2013, 06:48:41 PM »

I uploaded the updated module and now it's throwing white screen errors at me. It was working perfect before.

Fatal error: Allowed memory size of 67108864 bytes exhausted (tried to allocate 130968 bytes) in /home/thereal2/public_html/lib/settings.php on line 61


Fatal error: Allowed memory size of 67108864 bytes exhausted (tried to allocate 130968 bytes) in /home/thereal2/public_html/lib/modules.php on line 16


Fatal error: Allowed memory size of 67108864 bytes exhausted (tried to allocate 32 bytes) in /home/thereal2/public_html/lib/dbwrapper_mysql.php on line 185



I get those errors when I refresh.  



Edit:It fixed it's self some how but I'm scared to activate the module again.
« Last Edit: September 28, 2013, 07:25:17 PM by Rockie » Logged
Aeolus
Mod God
*****
Offline Offline

Posts: 1934


You're welcome.


View Profile WWW
« Reply #9 on: September 28, 2013, 10:30:44 PM »

What is the code at lib/settings.php on line 61, lib/modules.php on line 16, and lib/dbwrapper_mysql.php on line 185? (Not at a computer right now, plus they're probably not the same as mine.)
Logged

Rockie
Militia
**
Offline Offline

Posts: 33

I'm Twisted


View Profile
« Reply #10 on: September 28, 2013, 10:54:23 PM »

Suppose I should have included that info the first time

lib/settings.php  line 61
Code:
loadsettings();

lib/modules.php line 16
Code:
//same args.

lib/dbwrapper_mysql.php line 185
Code:
if (file_exists("prefixes.php")) require_once("prefixes.php");
Logged
Aeolus
Mod God
*****
Offline Offline

Posts: 1934


You're welcome.


View Profile WWW
« Reply #11 on: September 29, 2013, 02:02:09 AM »

Hmm. Did it happen as soon as you uploaded it? Works on both my live server and test server..
Logged

Rockie
Militia
**
Offline Offline

Posts: 33

I'm Twisted


View Profile
« Reply #12 on: September 29, 2013, 03:40:57 AM »

Yes. As soon as I uploaded the updated one and went into the module manager to activate it I got a white screen and an error. When I refreshed it changed between those errors until finally I got  new day page and it has worked fine since but I haven't touched the module again.

« Last Edit: September 29, 2013, 03:44:00 AM by Rockie » Logged
Aeolus
Mod God
*****
Offline Offline

Posts: 1934


You're welcome.


View Profile WWW
« Reply #13 on: September 29, 2013, 06:57:57 AM »

Try completely uninstalling the module (making note of any custom colors you have, since they'll disappear), re-upload, and re-install. If it works now, then it should be fine. Were you working with any other modules at the time?

I re-uploaded 1.0 to my test server, deactivated, uploaded 1.1, activated (copying your method of activation after upload), and.. nothing. Huh I'm curious as to if anyone else got these errors.. Since line 16 of lib/modules.php is simply a comment, not code that's executed.
Logged

Rockie
Militia
**
Offline Offline

Posts: 33

I'm Twisted


View Profile
« Reply #14 on: September 29, 2013, 11:45:20 AM »

Done and it is working perfect now. I wasn't working with any other modules when it happened. Thanks again Doc.
Logged
Pages: [1] 2 3 4   Go Up
  Print  
 
Jump to:  


*
DragonPrime Notices
Welcome to DragonPrime - The LoGD Resource Community!

Support Us
No funds raised yet this year
Your help is greatly appreciated!
Recent Topics
DragonPrime LoGD
Who's Online
98 Guests, 0 Users
Home Forums News Downloads Login Register Advanced Search