I’m interested in modifying a pre-written PHP web script. I’m no expert at PHP code, but have some level of knowledge of it. I’m trying to figure out how to modify the social media link boxes on it’s login page. Which is this line of code:
<?php echo pvs_get_social_networks();?>
I know this because when I comment out this line, the social media link boxes disappear.
I believe the pvs is the initials of the script name.
So, I’m trying to learn more about this script, before I contact the developer directly.
Based on the file’s code (named members/login_content.php) provided below, could you provide any suggestions/guess on how I might determine where I could modify the social media link boxes? Any enlightenment will be appreciated.
Yes, that is calling a function.
Find where the function of that name is defined. It will likeley either be in the script or in an include included in the script.
At the top of the file, you see this code. This prevents the file from executing in the first place when a web browser attempts to load it directly because “site_root” is not defined. That means that the function will likely be defined elsewhere and this file is included/required from another file. From a command line, you can ‘cd’ to the directory where the website files live and run a command like this on Windows:
findstr /sic:“pvs_get_social_networks” *.php
Or a similar command at a Linux/Mac command line (terminal or SSH session):
That will locate all files that either define or call the function named pvs_get_social_networks() and show each line that matches. The function itself should stand out pretty quickly.
Thanks for that explanation & instruction. Very helpful/appreciated.
When you say “This prevents the file from executing in the first place when a web browser attempts to load it directly because “site_root” is not defined”. That’s a good thing ?
I have worked with older PHP, that’s why this is a learning curve for me.
I’d like to ask for additional guidance, please.
The text, for example, on the displayed log-in page shows:
“You have not signed up for your free account. The registration process is quick and easy. Once you have an account, you will be able to make a purchase from our website.”
Yet, the login-content.php shows:
<?php
$sql = "select * from " . PVS_DB_PREFIX . "pages where link='login'";
$rs->open( $sql );
if ( ! $rs->eof ) {
echo ( pvs_translate_text( $rs->row["content"] ) );
}
?>
Can you shed some light on where I would go to modify the displayed page text?
Thanks for your accurate ‘guess’. I went to the db and table ‘pages’ and at the bottom I see the text in question “You have not signed up for your free account …”
(see attached image).
So, based on what I see it shows under ‘url’ column: /pages/login.html
I’ve manually looked around the main script folder and don’t see a ‘pages’ folder.
Is their a more efficient way to search a script’s folders/files?
Or does this text only get modified in the db table?
Any additional ideas/guidance will be much appreciated.
There may be some rewrite rules going on in your .htaccess file that mean the files or pages are stored elsewhere. Equally, that column might not be in use. The query to retrieve the text only passes in the link column value and retrieves the text from content, then sends that to the function.
Easy way to find out - change it in the db table, and see if your screen output changes.
Note that the query has the value of PVS_DB_PREFIX stuck on the beginning of it, so you need to find out what’s in that in case it points to a different table, something that just ends in pages.
I have received a reply from the developer that said:
“The most of seo-friendly URLs are virtual. The html files don’t exist really. They are created by Apache mod_rewrite (there is /htaccess file with mod_rewite instructions)”
The htaccess file looks like this, here’s a sample:
And here’s an example of what the php looks like this:
<?php
$site = "login";
include ( "../admin/function/db.php" );?>
<?php
if ( isset( $_SESSION["people_id"] ) ) {
header( "location:" . site_root . "/" );
}
?>
<?php
include ( "../inc/header.php" );?>
<h1><?php echo pvs_word_lang( "member area" )?></h1>
<?php
if ( isset( $_GET["d"] ) ) {
if ( $_GET["d"] == 1 ) {
echo ( "Error. The login is incorrect." );
}
if ( $_GET["d"] == 2 ) {
echo ( "Error. You failed to login several times. The new password was generated and sent to your email." );
}
if ( $_GET["d"] == 3 ) {
echo ( "Error. The IP was blocked" );
}
}
?>
<?php
include ( "login_content.php" );?>
<?php
include ( "../inc/footer.php" );?>
(the text files are in the admin panel)
This is pretty new to me. How tough would it be to make design changes of this script?
I’m used to modifying code in a file page and css changes.
There’s plenty of documentation around on how .htaccess rewrites work, and I’ve never tried it myself. My guess is:
When someone navigates to a page called /category/something.html, that gets sent to index.php with a parameter called category which is set to whatever the “something” was.
When someone navigates to a page called /category/moretext/something.html, that gets sent to index.php with a parameter called category set to whatever “something” was, and a second parameter called vd with a value of whatever the moretext was.