US-ASCII not supported

I'm recovering from a very serious break in the ZenPhoto system following a major OS upgrade(FreeBSD v10.1 to v10.2); MySQL upgrade from 5.6 to 5.7.10; and PHP to v.5.6.16. Something in the upgrades wiped out most of my *.php scripts; however, I've been able to recover from my inventory of manual backups, etc. I did mysteriously loose several but not all album contents (fortunately backed up). I finally decided to run a restore database from about a year old version and now I cannot even get past the login prompt . . .see the following:
Notice: unserialize(): Error at offset 0 of 38 bytes in /usr/local/www/zenphoto/zp-core/setup/index.php on line 431 Zenphoto Setup

<b>Warning</b>: htmlspecialchars(): charset `US-ASCII' not supported, assuming utf-8 in <b>/usr/local/www/zenphoto/zp-core/functions-common.php</b> on line <b>307</b>

`
306 function html_encode($this_string) {
307 return htmlspecialchars($this_string, ENT_FLAGS, LOCAL_CHARSET);

308 }
`
I've tweaked the code of lines 307-9 in ./zp-core/functions-common.php and the value of `$this_string` is NULL before the function call.

`


function html_encode($this_string) {

307 echo "str=<$this_string>\n...", ENT_FLAGS, "-", LOCAL_CHARSET; // ***rtw!

308 return htmlspecialchars($this_string, ENT_FLAGS, LOCAL_CHARSET);

309 }

`
. . .and this is displayed in the login user field:
str=<>...11-US-ASCII<b>Warning</b>: htmlspecialchars(): charset `US-ASCII' not supported, assuming utf-8 in <b>/usr/local/www/zenphoto/zp-core/functions-common.php</b> on line <b>308</b>

. . .so where to fix or repair this? Where can US-ASCII be identified to the system?

Where in the code (or setup table, etc.) is the character set specified?

Comments

  • acrylian Administrator, Developer
    Nothing to repair, "US-ASCII" is not the actual name of an encoding and not supported by the PHP function therefore:
    http://php.net/manual/en/function.htmlspecialchars.php

    ISO 8859-1 would probably be the one to use. But utf-8 should actually cover everything and is the default that should be used nowadays and is also the default Zenphoto sets generally.
  • Thanks for the reply. Unfortunately, I just cannot determine where the `US-ASCII` argument value is specified. I have always specified `utf-8` in the configuration files, tables, etc.

    I cannot logon and rerun the setup per displayed message, "You must be logged in to run setup."

    BTW, I've added a temporary line of code to display the function arguments in /www/zenphoto/zp-core/functions-common.php

    `echo "str=<$this_string>, ", ENT_FLAGS, ", ", LOCAL_CHARSET, " -- ";`

    The result is the following display in the User field of the User/Password form:
    str=<>, 11, US-ASCII -- <b>Warning</b>: htmlspecialchars(): charset `US-ASCII' not supported, assuming utf-8 in <b>/usr/local/www/zenphoto/zp-core/functions-common.php</b> on line <b>308</b>

    This is the point of failure. I understand that the htmlspecialchars function (http://php.net/manual/en/function.htmlspecialchars.php) is choking on the "US-ASCII" argument . . .somewhere in either the php code, or in a MySQL table, the value, "US-ASCII", is interjected into the mix. Can this be originating in a MySQL table element . . .following the attempted restore from backup?

    Seems that somewhere? . . .I should be able manually edit something to change a value from US-ASCII back to utf-8.

    Also as an afterthought, I find occasional commented code, `// force UTF-8 \xc3\x98`. Does something like this need to be enabled . . .somewhere?

    Thanks again for any suggestions.
  • acrylian Administrator, Developer
    Zenphoto has an option for the charset that defines the `LOCAL_CHARSET` constant. Maybe that is set wrong from earlier day. You would find it in the `options` table named `charset`.
  • *** stand by ***

    Found the following:

    `
    charset UTF-8

    filesystem_charset US-ASCII
    `
    . . .changed `filesystem_charset` to `UTF-8`
    but no joy :-(

    Found `charset US-ASCII` in table, `zenphoto-options`
    . . .changed to `UTF-8`

    Problem re: `htmlspecialchars()` apparently solved; however still cannot login.
  • . . .error msg. display at top of page is:
    Notice: unserialize(): Error at offset 0 of 38 bytes in /usr/local/www/zenphoto/zp-core/setup/index.php on line 430

    There was an error logging in.
    Check your username and password and try again.

    This code from the script:

    `428 $taskDisplay = array('create' => gettext("create"), 'update' => gettext("update"));

    429 if ($i = getOption('zenphoto_install')) {

    430 $install = unserialize($i);

    431 $prevRel = $install['ZENPHOTO'];

    432 } else {

    433 $prevRel = '';

    434 }`
  • acrylian Administrator, Developer
    Probably you need to delete the adminstrators table and re-start fresh by creating a new user account. Maybe because of your update trouble and the encoding the password hash doesn't match anymore. Just a quick guess off hand but if it is so that is your only chance.
  • I have decided to install fresh Zenphoto-1.4.11 . . .too much broken in old install. I've save and removed the production MySQL tables, configuration files, etc., from the ZenPhoto environment and started from "scratch."

    I downloaded `zenphoto-zenphoto-1.4.11.tar.gz` (don't understand why it arrived named as a hyphenated "zenphoto-zenphoto" object, but I've removed that unnecessary spelling.)

    Started the installation, all seemed to go as advertised until the install system prompted for a database user and password. I assumed this meant the MySQL db user, so I provided the userid and password for the same. Some processing transpired and now the system tosses me into a prompt panel (form) that instructs that
    You must be logged in to run setup.
    At this point, no userid/password will allow me to access the system. I don't understand this. There are no tables in the `/var/db/MySQL/ZenPhoto` data base. Apparently, the install did not progress to the point where I assume that it would prompt for a target location and create the db tables.

    What to do?
  • acrylian Administrator, Developer
    (don't understand why it arrived named as a hyphenated "zenphoto-zenphoto" object
    That's GitHub doing that automatically. It always prepends the repo name since we name our tags/releases like `zenphoto-1.4.11` traditionally. There was a time they didn't do that. But it really doesn't matter how the zip file or the resulting folder is names. You can rename it to anything or install in the root of your webspace/domain.

    Are you sure you really deleted all tables? Maybe delete the whole database and re-create it. If Zenphoto request to login there is already at least a administrators table present. Otherwise it should directly run setup as a fresh install naturally doesn't have anything to login.
    http://www.zenphoto.org/news/login-and-password-problems

    Note that deleting the tables will cause any data entered to albums, images manually to be lost naturally.
  • Thanks for the quick reply.

    No problem with GitHub's idiosyncrasy.

    Yes, all MySQL db tables are "out of the picture"
    root@bravo:/var/db/mysql/ZenPhoto # ls -lsa
    total 548
    2 drwx------ 2 mysql mysql 2048 Jan 15 11:35 .
    2 drwxr-xr-x 14 mysql mysql 1536 Jan 13 12:09 ..
    272 -rw-r--r-- 1 root mysql 257520 Jan 15 10:23 ZenPhoto-1.4.8-20160115.tar.gz
    272 -rw-rw---- 1 mysql mysql 257307 Jan 15 10:15 db.opt

    The tar backup of `ZenPhoto-1.4.8-20160115.tar.gz` should not be a problem; phpMyAdmin doesn't "see" anything other than an empty ZenPhoto and reports "No tables found in database."

    I'm not clear on the purpose of the `db.opt` file.

    FYI, the instructions from the documentation that I'm following are:
    3. Create a MySQL database. (Technically Zenphoto can do that but virtually no host allows this!)
    Navigate to your gallery. Example: if you uploaded in a subfolder named "zenphoto" navigate to www.yoursite.org/zenphoto/. Setup.php will run. (If it somehow does not, please navigate directly to www.yoursite.org/zenphoto/zp-core/setup.php.). Info about the required permissions if you run into issues.Create a MySQL database. (Technically Zenphoto can do that but virtually no host allows this!)

    4. Navigate to your gallery. Example: if you uploaded in a subfolder named "zenphoto" navigate to www.yoursite.org/zenphoto/. Setup.php will run. (If it somehow does not, please navigate directly to www.yoursite.org/zenphoto/zp-core/setup.php.). Info about the required permissions if you run into issues.

    I might ask how ARE the database schema (tables) created?
  • acrylian Administrator, Developer
    The db.opt file is nothing Zenphoto related. Setup will create the tables in the database noted either when setup asks with a form or if you already set them in the config file. After you hit "Go" to be exact.
Sign In or Register to comment.