Jump to content
Latest News: (loading..)

Recommended Posts

I had not seen that error before, but a little Googling and reading showed that it's popping up for others with other software.  Normally, PHP errors can be found with Google and see how others solve it.  My thought was that it was a string that needed to be cast, but i wasn't certain.  Most of the OSC code cast variables years ago, but addons don't have it.  Anyway, we both learned today and that's always a good thing. 


I'm not really a dog.

Share this post


Link to post
Share on other sites

Try this.  Did a little searching on StackOverflow and learned a little more.  Had to add the Hash class so I could experiment.  This yeilds an output now.

  function tep_random_name()
  {
    $letters = 'abcdefghijklmnopqrstuvwxyz';
    $dirname = '.';
    $length = floor(Hash::getRandomInt(16, 20));
    for ($i = 1; $i <= $length; $i++) {
      $q = floor(Hash::getRandomInt(1, 26));
      $dirname .= $letters[(int)$q];
    }
    return $dirname;
  }

 


I'm not really a dog.

Share this post


Link to post
Share on other sites

It only works when there's no z in the output.  I ran into this on another piece of Harald's code I was playing with.  I found a workaround, but it's not a good one and I'm not sure why it even works.  Putting a -1 after $q stops errors.

  function tep_random_name()
  {
    $letters = 'abcdefghijklmnopqrstuvwxyz';
    $dirname = '.';
    $length = floor(Hash::getRandomInt(16, 20));
    for ($i = 1; $i <= $length; $i++) {
      $q = floor(Hash::getRandomInt(1, 26));
      $dirname .= $letters[(int)$q-1];
    }
    return $dirname;
  }

 


I'm not really a dog.

Share this post


Link to post
Share on other sites

I was just talking about the hash functions used, but I don't really have an argument for it.  http://www.php.net/Hash

I just put the function into a test page and the errors went away after the (int) addition, but I was just testing the output of the function.  I did get the string offset errors at first.


I'm not really a dog.

Share this post


Link to post
Share on other sites

There are various functions around (e.g., tempnam, or possibly tmpfile) for creating unique temporary file names. It might be cleaner to use one of them. Also, when generating names, you have two problems:

  1. I don't see anything to prevent duplicates (unlikely, but still possible).
  2. Depending on who can see these names, some might be offensive. An easy way out of this to to drop the vowels and use only the 20 consonants.

If you are running the "official" osC 2.3.4 or 2.3.4.1 download, your installation is obsolete! Get (stable) Frozen or (unstable) Edge. See also the naming convention and the latest community-supported responsive "Edge" release

Share this post


Link to post
Share on other sites
1 hour ago, Daniel204 said:

what about the PHP 7?

tried it, liked it


For a new install or if your store isn't mobile-friendly, get the community-supported responsive osCommerce (2.3.4.1 CE) here: https://github.com/gburton/Responsive-osCommerce/archive/2341-Frozen.zip

Working on generalising bespoke solutions for Quickbooks integration, Easify integration and pay4later (DEKO) integration at 2.3.x

Share this post


Link to post
Share on other sites

Hi,

I had the same problem with my site after upgrading the server to php 7.  After upgraded from php7 all is good.

Have a nice day!

Edited by burt
remove spam url

Share this post


Link to post
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

×