DragonPrime - LoGD Resource Community

Coding Support => Coding Support Desk => Topic started by: TGTarheel on October 09, 2017, 03:00:16 PM



Title: How Do I Remove Color-Coding Notations From Page Headers?
Post by: TGTarheel on October 09, 2017, 03:00:16 PM
Even if it is a two-step process, no biggie.

But in my Dwellings, when anyone uses bolds or color in their Dwelling name...then the page header for their dwelling us the name f their Dwelling, as should be...but the stupid color codes are there so that I get "` b Joe's Dwellling ` b" etc, when all I WANT there is "Joe's Dwelling"

So...how do I strip those color codes out so that the page header will not include them, since they do not parse in page headers?


Title: Re: How Do I Remove Color-Coding Notations From Page Headers?
Post by: Aeolus on October 09, 2017, 09:44:49 PM
Where the dwellings code uses the page_header function when you enter a dwelling, use the sanitize function first on the dwelling name, then pass that into page_header.


Title: Re: How Do I Remove Color-Coding Notations From Page Headers?
Post by: TGTarheel on October 10, 2017, 05:02:41 AM
Where the dwellings code uses the page_header function when you enter a dwelling, use the sanitize function first on the dwelling name, then pass that into page_header.

Thanks.  I wonder how come dwellings was not done that way to begin with. Oh well.  Should solve my problem.


Title: Re: How Do I Remove Color-Coding Notations From Page Headers?
Post by: Aeolus on October 10, 2017, 02:24:30 PM
Because not everything is made perfect. Dwellings were created a long time ago, and colouring dwelling names probably wasn't implemented in its first version so they would have had no need to do this.


Title: Re: How Do I Remove Color-Coding Notations From Page Headers?
Post by: TGTarheel on October 10, 2017, 02:25:04 PM
Where the dwellings code uses the page_header function when you enter a dwelling, use the sanitize function first on the dwelling name, then pass that into page_header.

Humm...not sure I get it.  It LOOKS like the sanitize is already being used, nevertheless, I still get unwanted stuff in my page headers.

Here is the code snip for case_enter on dwellins:
Code:
<?php
if (
$session['user']['location'] != get_module_setting("logoutlocation"))
set_module_pref("location_saver"$session['user']['location']);
$sql "SELECT name,description,ownerid FROM ".db_prefix("dwellings")." WHERE dwid=$dwid";
$result db_query($sql);
$row db_fetch_assoc($result); 
if($row['name'] == ""){
$name translate_inline("Unnamed");
}else{
$name $row['name'];
}
page_header("%s",sanitize($name));

Is that not supposed to sanitize the name and get the bold and color codes out of the page header?

Or am I missing something here?


Title: Re: How Do I Remove Color-Coding Notations From Page Headers?
Post by: Stephen.Kise on October 12, 2017, 09:26:32 AM
Where the dwellings code uses the page_header function when you enter a dwelling, use the sanitize function first on the dwelling name, then pass that into page_header.

Humm...not sure I get it.  It LOOKS like the sanitize is already being used, nevertheless, I still get unwanted stuff in my page headers.

Here is the code snip for case_enter on dwellins:
Code:
<?php
if (
$session['user']['location'] != get_module_setting("logoutlocation"))
set_module_pref("location_saver"$session['user']['location']);
$sql "SELECT name,description,ownerid FROM ".db_prefix("dwellings")." WHERE dwid=$dwid";
$result db_query($sql);
$row db_fetch_assoc($result); 
if($row['name'] == ""){
$name translate_inline("Unnamed");
}else{
$name $row['name'];
}
page_header("%s",sanitize($name));

Is that not supposed to sanitize the name and get the bold and color codes out of the page header?

Or am I missing something here?


You should look for another declaration of page_header() then. Unless your lib/sanitize.php functions are edited - yes, that should remove the backtick character and anything in the set of [1234567890!@#\$%^&)~QqRVvGgTtjJeElLxXyYkKpPmM?*AabicnHw] (as of 1.2).


Title: Re: How Do I Remove Color-Coding Notations From Page Headers?
Post by: TGTarheel on October 12, 2017, 05:25:56 PM
I do not believe that was in any way edited or why I would.

I will look for another declaration of page_header then.

Just looked, I do not see another declaration.  I am stumped.

Do you have to somewhere require_once /lib/sanitize.php or something?

That is the only thing I can think of...


Title: Re: How Do I Remove Color-Coding Notations From Page Headers?
Post by: Stephen.Kise on October 13, 2017, 08:08:35 AM
I do not believe that was in any way edited or why I would.

I will look for another declaration of page_header then.

Just looked, I do not see another declaration.  I am stumped.

Do you have to somewhere require_once /lib/sanitize.php or something?

That is the only thing I can think of...

You shouldn't have to. There should have been a fatal error because of the undeclared function if you didn't require the file. You should probably try that out before posting about it o.O.


Title: Re: How Do I Remove Color-Coding Notations From Page Headers?
Post by: TGTarheel on October 13, 2017, 01:45:11 PM
I do not believe that was in any way edited or why I would.

I will look for another declaration of page_header then.

Just looked, I do not see another declaration.  I am stumped.

Do you have to somewhere require_once /lib/sanitize.php or something?

That is the only thing I can think of...

You shouldn't have to. There should have been a fatal error because of the undeclared function if you didn't require the file. You should probably try that out before posting about it o.O.

That was what I thought.
And I do not get a fatal error.

I know I got a number of fatal errors with the Item system for not requiring /lib/itemhandler.php - but those all got fixed long ago.

So...so come this is not working for me?  I still get the stupid codes...

I am pretty sure I never messed with the sanitize function, I would have had no reason to.

Any help here?


Title: Re: How Do I Remove Color-Coding Notations From Page Headers?
Post by: Talisman on October 13, 2017, 05:08:22 PM
I am pretty sure I never messed with the sanitize function, I would have had no reason to.

Just curious...do you document all your code and especially your changes to the core code in the files?  If not, strongly recommended...


Title: Re: How Do I Remove Color-Coding Notations From Page Headers?
Post by: TGTarheel on October 13, 2017, 10:43:50 PM
I am pretty sure I never messed with the sanitize function, I would have had no reason to.

Just curious...do you document all your code and especially your changes to the core code in the files?  If not, strongly recommended...

Well, my site goes back quite some time.  I do not think, at the beginning, I was doing that.

I do now.

But I am pretty sure I never had any reason to muck around with the sanitize function.

I should look, what file is this?  I do have archived the original core files I could always try uploading a fresh copy and see.

Of course I would save my own so I could do a side by side compare.


Title: Re: How Do I Remove Color-Coding Notations From Page Headers?
Post by: phu on November 20, 2017, 08:12:42 PM
I am pretty sure I never messed with the sanitize function, I would have had no reason to.

Just curious...do you document all your code and especially your changes to the core code in the files?  If not, strongly recommended...

TGTarheel: Since LotGD is a download and not a repository you clone, if you intend to change it much, you could use git to track your changes (by creating a new repository in your LotGD directory with git init) so you can always see what you've changed (and why, as long as you use good commit messages).

Really, you could use any version control mechanism, but git is my favorite. git-flow (https://danielkummer.github.io/git-flow-cheatsheet/) is a really nice utility that provides some great convenience methods for managing branches. You can also set up a repository on GitHub or BitBucket (the latter allows private repos on a free account, which is nice) so you can always keep a web-browsable, up to date backup of your personal LotGD installation.


Title: Re: How Do I Remove Color-Coding Notations From Page Headers?
Post by: TGTarheel on November 24, 2017, 03:23:26 PM
I am pretty sure I never messed with the sanitize function, I would have had no reason to.

Just curious...do you document all your code and especially your changes to the core code in the files?  If not, strongly recommended...

TGTarheel: Since LotGD is a download and not a repository you clone, if you intend to change it much, you could use git to track your changes (by creating a new repository in your LotGD directory with git init) so you can always see what you've changed (and why, as long as you use good commit messages).

Really, you could use any version control mechanism, but git is my favorite. git-flow (https://danielkummer.github.io/git-flow-cheatsheet/) is a really nice utility that provides some great convenience methods for managing branches. You can also set up a repository on GitHub or BitBucket (the latter allows private repos on a free account, which is nice) so you can always keep a web-browsable, up to date backup of your personal LotGD installation.

Thanks.  Would have been nice to know about this before all my mucking around, LOL...sounds to me like this has to be maintained "as you go"


Title: Re: How Do I Remove Color-Coding Notations From Page Headers?
Post by: Aeolus on November 24, 2017, 04:50:09 PM
Thanks.  Would have been nice to know about this before all my mucking around, LOL...sounds to me like this has to be maintained "as you go"

At least it has been maintained, we could have all just dropped it and let it die. By all means, do better. No? I'm wondering if you even understand what phu said.


Title: Re: How Do I Remove Color-Coding Notations From Page Headers?
Post by: TGTarheel on November 24, 2017, 10:41:33 PM
Thanks.  Would have been nice to know about this before all my mucking around, LOL...sounds to me like this has to be maintained "as you go"

At least it has been maintained, we could have all just dropped it and let it die. By all means, do better. No? I'm wondering if you even understand what phu said.

Actually, wondering if you know what I was saying!!

It seems to me like I would need to maintain, somewhere within this...the changes I have made.  And since I am not starting clean, there are a lot of changes I made that I might not remember and thus could not put into it.

Why must you always assume horrible things about me?

I was saying NOTHING about this site maintaining the app...saying that I WOULD NEED TO MAINTAIN IT FROM CLEAN...in order to have all my changes properly noted.

OMG, I swear, you must think I am some kind of ogre...


Title: Re: How Do I Remove Color-Coding Notations From Page Headers?
Post by: Aeolus on November 24, 2017, 11:44:58 PM
Actually, wondering if you know what I was saying!!

It seems to me like I would need to maintain, somewhere within this...the changes I have made.  And since I am not starting clean, there are a lot of changes I made that I might not remember and thus could not put into it.

Why must you always assume horrible things about me?

I was saying NOTHING about this site maintaining the app...saying that I WOULD NEED TO MAINTAIN IT FROM CLEAN...in order to have all my changes properly noted.

It doesn't have to be maintained as you go. Do what you want to your code. It's up to you to log what changes you make, not us, so that's your fault and not ours.

OMG, I swear, you must think I am some kind of ogre...

Oh, just the worst! Big, green and layered like an onion! I so love my swamp.


Title: Re: How Do I Remove Color-Coding Notations From Page Headers?
Post by: phu on November 26, 2017, 07:10:15 PM
Thanks.  Would have been nice to know about this before all my mucking around, LOL...sounds to me like this has to be maintained "as you go"

Yeah, version control is very much about recording changes over time. While your code and code comments should always be up to date, regardless of what came before, version control comments should document the changes made since the previous commit. That way you can look back at your commit history and see changes that might be entirely gone in your current code.

If you really want to start, you could:

  • Download a clean copy of the LotGD version you started with
  • Start a git repository in the clean copy's directory
  • Add all of the code and create the first commit from the clean code
  • Copy the contents of your current code into the clean directory, overwriting all files (don't overwrite the clean directory itself, just the contents, otherwise the git information will be deleted)

At this point, the outstanding changes in git should represent the changes you have made. If you want, you can try to add files in groups and make commits that approximate your changes. Otherwise you can just add all of your changes, make that a single "first update" commit, and make commits for individual changes going forward.

It's a bit of effort, and it depends on you getting the exact version of the game you started with, but if you want to start using version control it's one option.


Title: Re: How Do I Remove Color-Coding Notations From Page Headers?
Post by: TGTarheel on November 27, 2017, 10:41:41 PM
Actually, wondering if you know what I was saying!!

It seems to me like I would need to maintain, somewhere within this...the changes I have made.  And since I am not starting clean, there are a lot of changes I made that I might not remember and thus could not put into it.

Why must you always assume horrible things about me?

I was saying NOTHING about this site maintaining the app...saying that I WOULD NEED TO MAINTAIN IT FROM CLEAN...in order to have all my changes properly noted.

It doesn't have to be maintained as you go. Do what you want to your code. It's up to you to log what changes you make, not us, so that's your fault and not ours.

OMG, I swear, you must think I am some kind of ogre...

Oh, just the worst! Big, green and layered like an onion! I so love my swamp.

My GOD...That wwas what I JUST SAID...that I would need to log my changes AS I GO...and since I have already made a number of changes before having this...i would have to figure out what changes I already made and log them!!

WHY do you deliberately frustrate me?  I never said ANYTHING about this being your fault!!  Holy Lord, I just made an OBSERVATION...that I had already made changes that would not be already logged!  Did I assign any blame to you or to DP for that?? NO!!!  So why will you continue to be this way towards me?  Do you have some special hate for me or something?


Title: Re: How Do I Remove Color-Coding Notations From Page Headers?
Post by: TGTarheel on November 27, 2017, 10:46:27 PM
Thanks.  Would have been nice to know about this before all my mucking around, LOL...sounds to me like this has to be maintained "as you go"

Yeah, version control is very much about recording changes over time. While your code and code comments should always be up to date, regardless of what came before, version control comments should document the changes made since the previous commit. That way you can look back at your commit history and see changes that might be entirely gone in your current code.

If you really want to start, you could:

  • Download a clean copy of the LotGD version you started with
  • Start a git repository in the clean copy's directory
  • Add all of the code and create the first commit from the clean code
  • Copy the contents of your current code into the clean directory, overwriting all files (don't overwrite the clean directory itself, just the contents, otherwise the git information will be deleted)

At this point, the outstanding changes in git should represent the changes you have made. If you want, you can try to add files in groups and make commits that approximate your changes. Otherwise you can just add all of your changes, make that a single "first update" commit, and make commits for individual changes going forward.

It's a bit of effort, and it depends on you getting the exact version of the game you started with, but if you want to start using version control it's one option.

Thanks.
I can try this.
One thing I DID do...while making changes...was to normally save a backup copy of the original code file in the actualy directory...so most of my changes should be able to be identified...as to WHAT FILES I changed...but not necessarily what changes were made...that I would have to go in and look at code...or does this do that for you?

For example...one file I radically changed was pageparts.php

I have a helluva stats bar on the right side on my screen.

But, in my file directory, I have papeparts.php and pageparts.php.orig
The second file being the clean copy that got uploaded in the first place.

I am not certain I did this from jump street with my game, but pretty sure I started doing this early on when I started messing with core code...so that if I screwed up somehow, I could always get back to the original.


Title: Re: How Do I Remove Color-Coding Notations From Page Headers?
Post by: phu on November 27, 2017, 11:50:08 PM
If you follow the procedure I suggested, you'll get the same as taking the difference between the old files you kept and your updated versions; they'll just be part of the git history (which you can browse or revert at any time). I think your best bet is to stick with the procedure I suggested; keep a couple copies in a couple places of your current files, just in case something catastrophic happens, which it can when you're new at this sort of thing. ;)

© 2017 DragonPrime - LoGD Resource Community
Email Talisman: talisman -at- gmail.com
&oeXs)2U7=V BmܲV.U e=;p\}eG )Jj} C5EH7ˤH=j } mo|*Ŋw{drV_@IV>/- TFQJ׀̀Ve}l1,V O iNYx͘$e$;
Forums: Powered by SMF 1.1.21 | SMF © 2006-2007, Simple Machines