Jump to content

Inherited mess


mistergarth
 Share

Recommended Posts

Hi all-

I'm a small town generalist web designer/developer, I mostly hand-code sites using Brackets, PHP, MySQLi, etc. I just started work for a new client who has several small sites. Even though the sites have inter-related content, each of them are pretty much in their own world in terms of structure and development tools. One's built on Wordpress, one has a simple custom mysql database, one's fairly sophisticated hand-coded html5 with some Bootstrap, and one is a ProcessWire site. I had never heard of ProcessWire until I got ftp access to this site and started looking at the files. I really don't know where to begin with the existing site in an unfamiliar CMS. Does anybody have any words of wisdom while I poke the thing with a stick? Is there some sort of an admin panel somewhere? Is it database driven? Once I start exploring Processwire am I likely to fall in love and start converting  other sites to it?

For reference, here's the ProcessWire site:

https://guidetodrawing.com/

Here's it's similar-looking, inter-related sister site built with different tools:

https://www.guidetooilpainting.com/index.html

Thanks in advance

     Garth

Link to comment
Share on other sites

28 minutes ago, Sergio said:

Thanks. The problem is, I wasn't given that login. The site was set up by a pre-previous webmaster, so the  more recent one almost certainly doesn't have this login. I've got logins for a hosting account, for ftp, and for a database, but not a PW admin. I've looked at the config file, thinking there might be a clue, I've tried using the ftp, db, and hosting logins, thinking the old webmaster might have recycled the login, all to no avail so far.

Link to comment
Share on other sites

2 hours ago, Sergio said:

As you may not know the user name, create a file called "change_pass.php" on /site/templates. Put this on it:

<?php namespace ProcessWire;

require "./index.php";
$admin = $users->get(41);
$admin->setAndSave('name', 'youNewUserName');
$admin->setAndSave('pass', 'yo123456');

Now, using a terminal, go the project directory and run the php file: 

cd myproject/
cd site/templates
php change_pass.php

Et voilà

  • Like 4
Link to comment
Share on other sites

Impressive, Sergio. You answered my next question before I asked it! Yes, I do not know the admin user name. I was trying  the password reset, but I looked at the code (I write vanilla PHP; my OOP PHP is really shaky) and I said "isn't that assuming I know what the admin user name is?" I'll give it a try.

Link to comment
Share on other sites

39 minutes ago, Sergio said:

As you may not know the user name, create a file called "change_pass.php" on /site/templates. Put this on it:


<?php namespace ProcessWire;

require "./index.php";
$admin = $users->get(41);
$admin->setAndSave('name', 'youNewUserName');
$admin->setAndSave('pass', 'yo123456');

Now, using a terminal, go the project directory and run the php file: 


cd myproject/
cd site/templates
php change_pass.php

Et voilà

If for any reason, you can't get terminal access, you can add the php code to any template that already exists in the /site/templates directory and then view any page based on the template to trigger it.
You won't require the first require line in that case, and don't forget to remove the password reset code again afterwards.

  • Like 4
Link to comment
Share on other sites

Well, fiddlesticks. It took some fumbling and googling to get terminal access.  Then it took a while figure out the path to use to replace "myproject". Once I had the full server path there, the error changed from "no such file or directory" to "could not open input file", but it still didn't work.

When I tried Chris' method, I just got a configuration error on the page I tried to view to trigger the reset, and the reset didn't happen.

I'm not sure what to try next, perhaps cloning the site to a domain I'm not using on a host environment I'm more familiar with.

Link to comment
Share on other sites

Try...

1. Create file "reset.php" containing the following (beware of non-printable characters creeping in - to be sure you could type it out rather than copy/pasting):

<?php
require './index.php'; // Bootstrap ProcessWire
$admin = $users->get(41); // Get the default superuser by ID
$admin->of(false); // Set output formatting off
$admin->name = 'yourNewUserName'; // Set the name
$admin->pass = 'yo123456'; // Set the password
$admin->save(); // Save the user

2. Upload reset.php to the site root (where the ProcessWire index.php file is).

3. Load the file in your browser: https://guidetodrawing.com/reset.php

4. Login with the user details at: https://guidetodrawing.com/admin/

5. Delete reset.php

  • Like 5
Link to comment
Share on other sites

22 hours ago, Sergio said:

Upgrade the site to PW 3+

I would skip this step for a while. Since he has just started to poke it with a stick, it is probably not recommended to start by updating things even though it is not WP so upgrades are generally safer in the case of ProcessWire than in the case of other CMSes, but still...

23 hours ago, mistergarth said:

Once I start exploring Processwire am I likely to fall in love and start converting  other sites to it?

If you do not give up poking it for a while, it is highly probable that you start converting your sites... Be careful though, ProcessWire is addictive ? 

Welcome aboard, BTW!

 

Edited by szabesz
typo
  • Like 2
Link to comment
Share on other sites

21 hours ago, Robin S said:

Try...

1. Create file "reset.php" containing the following (beware of non-printable characters creeping in - to be sure you could type it out rather than copy/pasting):


<?php
require './index.php'; // Bootstrap ProcessWire
$admin = $users->get(41); // Get the default superuser by ID
$admin->of(false); // Set output formatting off
$admin->name = 'yourNewUserName'; // Set the name
$admin->pass = 'yo123456'; // Set the password
$admin->save(); // Save the user

2. Upload reset.php to the site root (where the ProcessWire index.php file is).

3. Load the file in your browser: https://guidetodrawing.com/reset.php

4. Login with the user details at: https://guidetodrawing.com/admin/

5. Delete reset.php

This just throws up an internal server error without resetting. Double fiddlesticks.

 

Link to comment
Share on other sites

1 hour ago, mistergarth said:

This just throws up an internal server error

Enable debug mode to get more informative error messages. Open file /site/config.php via FTP or hosting file manager and edit the line below to set debug mode true, or add the line if none exists.

$config->debug = true;

 

58 minutes ago, mistergarth said:

Is it possible there is no user 41 in this install?

It's possible if the original superuser was deleted, but that's not a common scenario. You could try adding a new superuser account by adding and loading the following "add_user.php" file in the site root.

<?php
require './index.php';
$u = new User();
$u->name = 'new_user';
$u->pass = '123456';
$u->addRole('superuser');
$u->save();

 

Edit: by the way, you can also find the names and ids of the existing users by looking in the pages table of the database. In phpMyAdmin or similar, sort the table by the templates_id column, and look at the names and ids of rows where templates_id is 3 (3 is the id of the user template).

  • Like 4
Link to comment
Share on other sites

Eureka! I'm in. Robin's script new user script worked beautifully.  Now I have access to the admin panel for the live site and I've got a blank install of PW running on another domain to use as a sandbox so I can figure out if I want to invest a whole bunch of brain cells in PW for future projects.

What I'd been doing wrong... I think. I'd been adding a closing delimeter ( ?> )  to the scripts. I thought they were required. I noticed that nobody was using them, so I thought I'd try this one without the close, and voila! This is more of a PHP question than a PW one, but aren't closing delimeters always required? What's different about this case?

And thanks for all the help, everybody. It's a big point in PW's favor that it has this active helpful community.

 

  • Like 2
Link to comment
Share on other sites

43 minutes ago, mistergarth said:

This is more of a PHP question than a PW one, but aren't closing delimeters always required? What's different about this case?

It's a Wordpress thread, but it's a great explanation so I thought it was worth linking to: https://wordpress.org/support/topic/why-is-it-an-error-to-have-a-closing-tag-in-functions-php/#post-10430549

  • Like 2
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...