This is the community forum. For a developer response use the Client Area.
Follow us on Facebook, Twitter and YouTube!

Changing code
#1
Question 

HI Steven,
I would like to get some pointers as to how to modify the source so that it works with variables. It would be great if you would give me pointers as to how each file functions. Thanks.

EDIT: also, this is a good reason to have two sections in code changes. One for help and tutorials, another for posting actual code.

I'm giving you three guesses...
Reply
#2

Okay I have it working on my test site so that a single page shows a different set of comments depending on the query. I set my test site up so that these two URLs store/show different comments:

http://localhost/commentics/example.php?test=1
http://localhost/commentics/example.php?test=2

Aside from adding the Preserve Query add-on, you just need to replace the referrer section (starting at line 57) in comments/includes/app/processor.php with this:

PHP Code:
<?php 
/* Check Referrer */
if (isset($_SERVER['HTTP_REFERER'])) { //if referrer available
$referrer = $_SERVER['HTTP_REFERER']; //get referrer
$referrer = urldecode($referrer); //decode it
if (stripos($referrer, "?") !== false) { //remove any parameters
$parameter = substr($referrer, stripos($referrer, "?"));
$referrer = str_ireplace($parameter, "", $referrer);
}
$referrer = strtolower($referrer); //convert to lowercase
$this_page = get_page_url();
if (
stripos($this_page, "?") !== false) { //remove any parameters
$parameter = substr($this_page, stripos($this_page, "?"));
$this_page = str_ireplace($parameter, "", $this_page);
}
if (
$referrer != $this_page) { //if referrer does not match current URL
ban(BAN_REASON_INCORRECT_REFERRER); //ban user for incorrect referrer
}
} else {
error(ERROR_MESSAGE_NO_REFERRER); //reject user for no referrer
}

Have you completed the interview?
Reply
#3

Thanks, I'll test it out, test some more, and post back with issues and possible fixes(if they appear).

I'm giving you three guesses...
Reply
#4

Okay I look forward to your results.

Of course the only other thing is to make sure that you have the correct Page ID in example.php.

I think you know how to handle that part.

Have you completed the interview?
Reply
#5

Yes, it works. Though it's a little tedious to write some code so it displays the correct id for certain pages. Having the id be the page name(without hash) would be easier, or at least have the id be a changeable string. I'll try to make it work.
As far as I understand, you simply remove the part after the question mark. I need to know what the sanitize function does, because it's clearly a custom function. The file it's in would be enough.
Never mind, I found it. Should have searched first. Such an obvious place Blush.

I'm giving you three guesses...
Reply
#6

I suppose that I could add the ability to set an optional user-friendly Page ID in Manage -> Pages.

Then code it so that you can use either the given Page ID or your own entered Page ID.

This approach has the advantage of being backwards compatible.

Have you completed the interview?
Reply
#7

How come you're looking at the sanitize function?

Have you completed the interview?
Reply
#8
Thumbs Up 

I thought that the sanitize function might have something to do with checking the page id. Apparently, not really. I must say, your code is very well written. There aren't too many files, they are clearly named, files well commented, everything is very clear.

I'm giving you three guesses...
Reply
#9

Thanks I appreciate you saying that.

Have you completed the interview?
Reply
#10

I need help locating the place where the page id is set into the database, and the places where it's used that are important. I found the following files which seem relevant:
- App/processor.php
- Functions/processor.php
- Admin/Pages/manage_pages.php

I'm giving you three guesses...
Reply


Possibly Related Threads…
Thread / Author Replies Views Last Post
Last Post by noblues
09-Jun-2014, 10:11 PM
Last Post by Steven
10-Oct-2013, 09:51 PM
Last Post by 2hands
30-Dec-2012, 01:34 AM
Last Post by 2hands
24-Jun-2012, 08:56 PM

Forum Jump:


Users browsing this thread: 1 Guest(s)