Jump to content
Latest News: (loading..)

Recommended Posts

1 hour ago, wHiTeHaT said:

@Peper can be any $var in this case.

But can try them all, my hunch however:
see the (int)
 


        if($this->GetY()+(int)$h>$this->PageBreakTrigger)

 

:biggrin: Thanks, working 100% no errors


Thanks to all source contributors, 2.3.4 Edge just works fine

https://github.com/gburton/Responsive-osCommerce/archive/master.zip

Share this post


Link to post
Share on other sites

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

I recently had a same kind of error, i was not able to solve it, yet i knew it was about type casting.
The error still persist:

// Returns a random name, 16 to 20 characters long
// There are more than 10^28 combinations
// The directory is "hidden", i.e. starts with '.'
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[$q];
  }
  return $dirname;
}


 

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

Why not use the PHP builtin has functions?

 


I'm not really a dog.

Share this post


Link to post
Share on other sites
5 minutes ago, John W said:

Why not use the PHP builtin has functions?

 

enlight me............
the function here makes a tmp dir for the downloads when activate d/l by redirect.
Nice thing is, it seems to overwrite the previous generated directory by the malfunctioning function.
It still works, it is just the notice.

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 the latest community-supported responsive "Edge" release

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

×