php-general Digest 16 Dec 2005 11:00:06 -0000 Issue 3853
Topics (messages 227506 through 227525):
Re: Is it possible to use header() to POST form data?
227506 by: pw
227508 by: Gustavo Narea
227518 by: Curt Zirzow
Re: encrypt and dcrypt
227507 by: Anas Mughal
Re: Questions from a ColdFusion Developer
227509 by: Christopher Jordan
227521 by: Robert Cummings
Klorofil Platform 0.1.1 released with Linux Support
227510 by: Reza Iqbal
Re: Post-Vars doubled / corrupted
227511 by: Aaron Koning
Re: Help with the copy command...
227512 by: Hristo Yankov
227525 by: Robin Vickery
Random Images with no duplicates?
227513 by: Mike Rondeau
227514 by: Mike Rondeau
227515 by: Aaron Koning
227519 by: Curt Zirzow
Binary Config file: Protect script(s): Powered-by logo: How to?
227516 by: Michael Hulse
227517 by: Michael Hulse
Re: 4 Digit ID with Leading Zeros
227520 by: Curt Zirzow
One big file or many includes?
227522 by: Martin Leduc
227523 by: Aaron Koning
227524 by: Adrian Bruce
Administrivia:
To subscribe to the digest, e-mail:
[EMAIL PROTECTED]
To unsubscribe from the digest, e-mail:
[EMAIL PROTECTED]
To post to the list, e-mail:
[email protected]
----------------------------------------------------------------------
--- Begin Message ---
Philip Hallstrom wrote:
Does anyone know if it's possible to use the
header() function to POST form data to a URL?
If so what syntax needs to be used?
No, but a quick search for "HTTP POST PHP example" will get you the code
you need.
Thanks,
I googled and, as you said, there was code there.
'sendToHost'
Hopefully it's current enough to work for me.
Thanks again,
Peter
--- End Message ---
--- Begin Message ---
Hello.
pw wrote:
Does anyone know if it's possible to use the
header() function to POST form data to a URL?
If so what syntax needs to be used?
I guess you cannot use the header() function in that way. Take a look at
the header() documentation <http://php.net/header>.
What do you need to do?
Are you working with wrappers? If so, take a look at the 2nd example in
the streams documentation <http://php.net/stream>.
Cheers.
--
Gustavo Narea.
PHP Documentation - Spanish Translation Team.
Valencia, Venezuela.
--- End Message ---
--- Begin Message ---
On Thu, Dec 15, 2005 at 03:02:01PM -0800, pw wrote:
> Philip Hallstrom wrote:
> >>Does anyone know if it's possible to use the
> >>header() function to POST form data to a URL?
> >>
> >>If so what syntax needs to be used?
> >
> >
> >No, but a quick search for "HTTP POST PHP example" will get you the code
> >you need.
> >
>
> Thanks,
>
> I googled and, as you said, there was code there.
>
> 'sendToHost'
I've always disliked this well known function, mostly because it is
prone to to many unexepcted errors, and that for the fact that it
is very old.
You would be best off using on of the following solutions:
http:://php.net/curl
http://php.net/fsockopen
(note the ability to handle errors in Example 1)
http://us3.php.net/manual/en/ref.stream.php
(if you want to write your own)
Curt.
--
cat .signature: No such file or directory
--- End Message ---
--- Begin Message ---
I use TriCrypt to encrypt simple strings. It supports two directional.
http://www.fiacre.net/phpcode.php
(Code available at http://www.fiacre.net/download/TriCrypt.txt)
Sample:
Original String=World
Encrypted String=Nx9yJu
I haven't gotten around at figuring out how do I make the code produce only
lower case letters in encrypted strings. Could someone on this list offer
any suggestions on how to modify the code to support numbers and only lower
case numbers.
Thank you very much.
--
Anas Mughal
--- End Message ---
--- Begin Message ---
Robert Cummings <[EMAIL PROTECTED]> wrote:>On Wed, 2005-12-14 at 21:34,
Christopher Jordan wrote:
> Rob,
>
> Thanks for responding. :) I have more questions. I hope
>that's okay. :)
>*lol* No problem :)
Thanks! :)
>
> You said:
> "Share nothing" refers to the PHP philosophy of not tying
>any data sharing system to the engine itself.
> In this way developers are free to create applications in
>such a way that if they need more power, they can just add
>more computers.
> -----
> I guess I'm a little confused, by this and by what Jochem
>originally posted. I'm not sharing data between different
>computers within the application (if that makes sense). In
>other words, of course all my data (in this case inventory
>data) is in a MySQL table, and so multiple users could be
>accessing the data simultaneously. The session variable
>only serves to store (for display purposes, really) the results
>of the users last search. I also maintain a
>$_SESSION["LoggedIn"] variable to keep track of whether
>the user has access in this session.
>Sorry, I was merely responding to your question about what
>"share nothing" meant.
No worries. I'd still like to hear (from anybody, really) what specific
business examples they have where this "share nothing" concept came into play.
Also, I promise to go out and Google it to try and find out for my self, as
soon as my work load dies down. I've got three projects going simultaneously
and four more "little ones" (I hope) on the way. I'm sure most of you can
relate. :) But, as long as people on this list are willing to discuss things
with me and answer my questions, I'd greatly appreciate it! :)
>With respect to how this relates to you, your sessions and
>what Jochem wrote... If I read your above comment correctly
>it doesn't really sound like it applies to your problem only
>that you used ColdFusion to describe what you would have
>done in that environment. Sessions by nature are per user
>only and not application scoped.
Of course. Jochem, feel free to jump in here if you've got time. :) Your
comment may not have *really* applied to my specific situation, but I'm
intrigued now. :)
> You said:
> This becomes a much more difficult issue when a program
>holds private data in memory that requires a specific way to
>access it. For instance if you stored some kind of
>application variable in memory (a la ColdFusion, Java,
>ASP) then this value would not be normally transparent to
>other computers without some kind of synchronization
>system to transfer it around.
> ----
> Perhaps I'm being dense (it wouldn't be the first time), or
>maybe a bit unimaginative, but I can't think of an instance
>where while a user is logged into an app and using it, that
>another computer (besides the web server, database server
>and the client machine), would need to have access to that
>data.
> Are you referring to "state" here? Or.... well other than
>passing data around between browser windows, I'm not
>really sure what you mean. I'd love it if you could find the time
>to expand on that.
>Imagine a configuration system loaded from a slow medium
>and cached in the running process for all subsequent page
>requests. The speed advantage is immense, but it violates
>the "share nothing" rule.
Okay, I can see what you mean there. Only that *one* machine has the data
cached, so if you were to want to spread the load out over several machines,
they'd all have to cache the same configuration and any time it changed they'd
all have to re-cache it, since none of the machines knows about the others...
that kind of thing?
>To emulate this in PHP one would punt the cached data to a >database so that
>it could be retrieved in a single lightweight
>query. In this respect PHP often differs from Java or ASP
>that often load configuration data and keep it resident for
>some time. That said, PHP merely forces the user into the
>share nothing philosophy, whereas Java lets the developer
>choose since anyone can write their code to share nothing if >they want.
>In this regard-- protect the users from shooting themselves
>in the foot-- PHP often takes an arguably overzealous
>position.
Okay, I think I'm starting to understand now. Right now, I'm working on a very
large CF project for a national company and I'm trying to think of where I
might apply the idea of the "share nothing" rule. Nothing leaps to mind, but it
may when I least expect it.
I'd still be interested in hearing from anyone who's applied this idea on any
scale. Sometimes I've got to be beaten over the head with something before I
can get my mind around it, so examples would help. Heck I'm *just now* starting
to get to the "Ah-ha!" stage of OO programming (and I'm loving it, by the by),
but it took what seems like forever to get there. You know?
> You Said:
> Using the share nothing philosophy such data doesn't
>generally exist, and if it does, then it is stored in a database.
>Databases are a better system for such data since they
>were designed for heterogeneous external access and quite >handily solve the
>race condition and deadlock issues.
> ---
> Typically I think of the session variable scope as a way to
>preserve state. Are you suggesting that state be preserved
>by dumping information down to and then reading it again
>from a database? For example my session variable which
>indicates the user has successfully logged in...
>Nope you are right, I think perhaps Jochem unintentionally
>confused the issue by bringing up the "share nothing"
>philosophy. I merely spoke to that when I described it.
I think you've hit the nail on the head there, but I'm sorta glad the subject's
come up since I'm learning about a concept that I've not used before. Is it
mostly used for purposes of scalability? It seems like it might be that way.
> In speaking of *large* scale applications I suppose I might
>be able to see where you'd want something different than
>the session superglobal since the more users you have
>accessing the app and using that scope, the more memory
>it's taking up on the server. I thought cookies might be used
>in such cases. I don't usually use cookies, because
>ColdFusion has an configuration option of storing session
>data in the system registry (windows version obviously)...
>which alleviates the problem of running out of memory via
>the session scope.
>
> Have I completely missed your point? :)
>Nope, we're just off track :)
>Cheers,
>Rob.
Thanks so much Rob for sharing your knowledge with me. :) It's very nice to see
that folks on the list seem to be patient and responsive.
Have a great day!
-Chris
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
--- End Message ---
--- Begin Message ---
On Thu, 2005-12-15 at 22:24, Christopher Jordan wrote:
>
> I think you've hit the nail on the head there, but I'm sorta glad the
> subject's come up since I'm learning about a concept that I've not
> used before. Is it mostly used for purposes of scalability? It seems
> like it might be that way.
There's a decent article here that goes on about the "shared nothing"
philosphy. It's a bit of a PHP vs. Java blog, but it does make many
references to "shared nothing".
http://www.sitepoint.com/blogs/2004/07/01/the-j2ee-guy-still-doesnt-get-php/
> Thanks so much Rob for sharing your knowledge with me. :) It's
> very nice to see that folks on the list seem to be patient and
> responsive.
No problem... you got us on a good day ;)
Cheers,
Rob.
--
.------------------------------------------------------------.
| InterJinn Application Framework - http://www.interjinn.com |
:------------------------------------------------------------:
| An application and templating framework for PHP. Boasting |
| a powerful, scalable system for accessing system services |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for |
| creating re-usable components quickly and easily. |
`------------------------------------------------------------'
--- End Message ---
--- Begin Message ---
Dear all,
Klorofil Platform 0.1.1 has been released. In this version, Klorofil
added a GUI framework named "gambArt" for Linux. In prior version,
Klorofil provided gambArt for Windows only.
So, Klorofil Platform 0.1.1 allows developers to build cross-platform
windowed applications to run right on desktops easily. This version is
just a preview Linux support release. In early January 2006, Klorofil
0.2 will be released with enhanced features, and available with fully
source code and documentation.
For more information and snapshots gallery, you can visit Klorofil's website at
http://www.klorofil.org
Sincerely,
R. Iqbal
--- End Message ---
--- Begin Message ---
Hi Sabine,
Its been my experience that you need square brackets after the input
checkbox name for PHP to see an array. This page discusses that:
http://www.evolt.org/article/Storing_form_array_data_to_MySQL_using_PHP/18/60222/
Change your code to the following and give it a try.
<ul id="colors">
<li><input name="colors[]" id="id1" type="checkbox" value="1"
/><label for="id1">red</label></li>
<li><input name="colors[]" id="id2" type="checkbox" value="2"
/><label for="id2">blue</label></li>
</ul>
Aaron
On 12/15/05, Sabine <[EMAIL PROTECTED]> wrote:
>
> Hi Aaron,
> thanks for your answer. The HTML elements, which "represent" arrays are
> causing problems.
> I just added
> <ul id="colors">
> <li><input name="colors" id="id1" type="checkbox" value="1"
> /><label for="id1">red</label></li>
> <li><input name="colors" id="id2" type="checkbox" value="2"
> /><label for="id2">blue</label></li>
> </ul>
>
> to your minimalistic script.
> Checked both and got
> Array ( [colors] => Array ( [0] => 1 [1] => 2 [2] => 2 ) [testvar] =>
> pleasedontcorrupt [submit] => submit )
> for post.
>
> I don't really think it's a problem of my code.
> Perhaps a problem of the servers configuration. But I'm not really
> familiar with installation and configuration duties. So I don't know
> where to search.
>
> But meanwhile I read something about input filters in Apache 2.
> And thought if there is a filter on this server which corruptes my post
> vars?
>
> Config is (I don't know which parameters are really importend):
> ["IHOST_VERSION"]=> "Linux-1.0"
> ["SERVER_SOFTWARE"]=> "Apache/2.0.55
> ["SERVER_PROTOCOL"]=> "HTTP/1.1"
>
> PHP 4.3.11
> Server API Apache 2.0 Filter
>
> I searched for information if PHP 4.3.11 is supposed to work fine with
> Apache 2.0.55, but didn't find a clear answer.
>
> Perhaps you know (or someone else knows) if my thoughts are going in the
> right direction?
>
> Bye
> Sabine
>
>
>
>
>
>
>
>
>
>
>
>
> Aaron Koning schrieb:
>
> > I wasn't aware you could use = instead of echo (<?
> > =$_SERVER['PHP_SELF'] ?>). Try making an even simpler HTML/PHP example
> > and see if the problem exists there. Then you can incrementally build
> > your HTML/PHP back up to the point where it is breaking. Example:
> >
> > <?php
> > print_r($_POST);
> > ?>
> > <html>
> > <head>
> > </head>
> > <body>
> > <form action="" method="post">
> > <input type="hidden" name="testvar" value="pleasedontcorrupt" />
> > <input type="submit" name="submit" value="Submit" />
> > </form>
> > </body>
> >
> >
> > Aaron
> >
> > On 12/15/05, *Sabine* <[EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]>> wrote:
> >
> > Hello to all,
> >
> > I distributed my app to a new server and suddenly had values saved
> > twice
> > in the db and so on.
> > I tracked it down and found out, that the problem is the content
> > of $_POST.
> > Vars are doubled, Strings corrupted. Absolutely absurd.
> > I have no idea where to search for the reasons.
> > PHP-Version is 4.3.11
> > Does anybody else have an idea?
> >
> > Thank you in advance
> > Sabine
> >
> >
> > A simple testcase:
> >
> > <?php
> > echo "Post:";
> > var_dump($_POST);
> > ?>
> > <html>
> > <body >
> > <form id="formular" action="<?=$_SERVER['PHP_SELF'] ?>"
> > method="post">
> >
> > <ul id="colors">
> > <li><input class="buttons" name="colors[]" id="id1"
> > type="checkbox" value="1" title="chose color" /><label
> > for="id1">red</label></li>
> > <li><input class="buttons" name="colors[]" id="id2"
> > type="checkbox" value="2" title="chose color" /><label
> > for="id2">blue</label></li>
> >
> > <li><input class="buttons" name="colors[]" id="id3"
> > type="checkbox" value="3" title="chose color" /><label
> > for="id3">green</label></li>
> > <li><input class="buttons" name="colors[]" id="id4"
> > type="checkbox" value="4" title="chose color" /><label
> > for="id4">yellow</label></li>
> > </ul>
> >
> > <fieldset class="nolegend">
> > <input type="submit" value="change colors"
> > name="aendern" />
> > <input type="submit" value="save colors"
> > name="speichern" />
> > </fieldset>
> > </form>
> > </body>
> > </html>
> >
> > Output for $_POST, if you just click on "change colors":
> > Post: array(1) { ["aendern"]=> string(34) "change
> colorsaendern=change
> > colors" }
> >
> >
> > Output, if you check only "red" and click "change colors":
> > Post: array(2) { ["colors"]=> array(1) { [0]=> string(1) "1" }
> > ["aendern"]=> string(13) "change colors" }
> >
> > output for 2 colors checked:
> > Post: array(2) { ["colors"]=> array(3) { [0]=> string(1) "1" [1]=>
> > string(1) "2" [2]=> string(1) "2" } ["aendern"]=> string(13) "change
> > colors" }
> >
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> >
> >
>
>
--- End Message ---
--- Begin Message ---
The two examples you give are not the same? I see
different files. Please, doublecheck.
--- Tim Meader <[EMAIL PROTECTED]> wrote:
> Okay, this seems like a ridiculously easy question
> which shouldn't even
> need asking, but I'm having trouble getting the
> builtin copy command to
> work properly. It seems to work fine as long as I
> feed it a full
> constant string path for each argument (ie - in the
> form
> "/the/path/to/the/file"). However, if I try to feed
> it two variables as
> the arguments, it craps out somewhere along the
> line. Here are the two
> different sets of calls I'm making:
>
> These two work perfectly:
>
>
copy("/usr/local/apache/htdocs/ipreg2/crons/regservice_rep/snapshot.baseline",
>
"/usr/local/apache/htdocs/ipreg2/crons/regservice_rep/snapshot.baseline.bak")
> ;
>
copy("/usr/local/apache/htdocs/ipreg2/crons/regservice_rep/lastrun.timestamp",
>
"/usr/local/apache/htdocs/ipreg2/crons/regservice_rep/lastrun.timestamp.bak");
>
> These two fail:
>
> $l_stLastRun =
>
"/usr/local/apache/htdocs/ipreg2/crons/regservice_rep/lastrun.timestamp";
> $l_stSnapshotBase =
>
"/usr/local/apache/htdocs/ipreg2/crons/regservice_rep/snapshot.baseline";
>
> copy($l_stSnapshotBase, $l_stSnapshotBase.".bak");
> copy($l_stLastRun, $l_stLastRun.".bak");
>
> Can anyone offer any insight on what the problem
> might be with this? The
> "unlink" function seems to accept the variable
> inputs with absolutely no
> problem, so I can't understand the discrepancy
> between the two.
>
> Thanks in advance.
>
> Tim
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
===========================================
Hristo Yankov, Developer at Portellus, Inc.
ICQ - 191445567
Yahoo! - yankov_hristo
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
--- End Message ---
--- Begin Message ---
On 12/15/05, Tim Meader <[EMAIL PROTECTED]> wrote:
> Okay, this seems like a ridiculously easy question which shouldn't even
> need asking, but I'm having trouble getting the builtin copy command to
> work properly. It seems to work fine as long as I feed it a full
> constant string path for each argument (ie - in the form
> "/the/path/to/the/file"). However, if I try to feed it two variables as
> the arguments, it craps out somewhere along the line. Here are the two
> different sets of calls I'm making:
>
> These two work perfectly:
>
> copy("/usr/local/apache/htdocs/ipreg2/crons/regservice_rep/snapshot.baseline",
> "/usr/local/apache/htdocs/ipreg2/crons/regservice_rep/snapshot.baseline.bak")
> ;
> copy("/usr/local/apache/htdocs/ipreg2/crons/regservice_rep/lastrun.timestamp",
> "/usr/local/apache/htdocs/ipreg2/crons/regservice_rep/lastrun.timestamp.bak");
>
> These two fail:
>
> $l_stLastRun =
> "/usr/local/apache/htdocs/ipreg2/crons/regservice_rep/lastrun.timestamp";
> $l_stSnapshotBase =
> "/usr/local/apache/htdocs/ipreg2/crons/regservice_rep/snapshot.baseline";
>
> copy($l_stSnapshotBase, $l_stSnapshotBase.".bak");
> copy($l_stLastRun, $l_stLastRun.".bak");
>
> Can anyone offer any insight on what the problem might be with this? The
> "unlink" function seems to accept the variable inputs with absolutely no
> problem, so I can't understand the discrepancy between the two.
There's no problem with variable names as parameters to copy() - you
can test that in a few seconds.
$ touch foo
$ php -a
Interactive mode enabled
<?php
$a = 'foo';
copy($a, $a . '.bak');
?>
$ ls
foo foo.bak
So the problem is elsewhere.
99 times in 100 you've either messed up the filenames or you've not
got appropriate file permissions to do the copy.
-robin
--- End Message ---
--- Begin Message ---
Hi,
I'm still very green with PHP, but am working to fix that.
I've searched high and low for an answer to this question and so far
no solution has presented itself. I have a script to populate my web page
with random images:
<?php
#random images example
#this is your file
$file = "images.txt";
#open the file
$openFile = file($file);
#generate a random number
srand((double)microtime()*1000000);
#get one of the entries in the file
$random_image = $openFile[array_rand($openFile)];
#display the entry
echo "<img src='$random_image' height='170' width='100'></img>";
?>
This works beautifully, but my problem is that sometimes, the same image
displays twice or more on the same page-load. My page requires 10 different
places where my images need to load, but I can't have any duplicate images
show up.
Any suggestions on what I need to modify here?
Thanks in advance!
Mike
--- End Message ---
--- Begin Message ---
Hi,
I'm still very green with PHP, but am working to fix that.
I've searched high and low for an answer to this question and so far
no solution has presented itself. I have a script to populate my web page
with random images:
<?php
#random images example
#this is your file
$file = "images.txt";
#open the file
$openFile = file($file);
#generate a random number
srand((double)microtime()*1000000);
#get one of the entries in the file
$random_image = $openFile[array_rand($openFile)];
#display the entry
echo "<img src='$random_image' height='170' width='100'></img>";
?>
This works beautifully, but my problem is that sometimes, the same image
displays twice or more on the same page-load. My page requires 10 different
places where my images need to load, but I can't have any duplicate images
show up.
Any suggestions on what I need to modify here?
Thanks in advance!
Mike
--- End Message ---
--- Begin Message ---
This should work, although if there are only 9 lines in the file, it will
run infintely (or until the page times out)... so put a check in for that.
$imagesNeeded = 10;
$imageArr = array();
// Create array with $imagesNeeded number of elements.
for($i=0;$i<$imagesNeeded;$i++) {
// choose image
$tmpImg = $openFile[array_rand($openFile)];
// Keep getting images until the image you have is not in the existing
array of images
while(in_array($tmpImg,$imagesArr)) {
// choose image
$tmpImg = $openFile[array_rand($openFile)];
}
// Put unique image into array
array_push($imageArr,$tmpImg);
}
// You now have an array called imageArr with 10 elements/images in it.
Aaron
On 12/15/05, Mike Rondeau <[EMAIL PROTECTED]> wrote:
>
> Hi,
>
> I'm still very green with PHP, but am working to fix that.
>
> I've searched high and low for an answer to this question and so far
> no solution has presented itself. I have a script to populate my web page
> with random images:
>
> <?php
> #random images example
> #this is your file
> $file = "images.txt";
> #open the file
> $openFile = file($file);
> #generate a random number
> srand((double)microtime()*1000000);
> #get one of the entries in the file
> $random_image = $openFile[array_rand($openFile)];
> #display the entry
> echo "<img src='$random_image' height='170' width='100'></img>";
> ?>
>
>
> This works beautifully, but my problem is that sometimes, the same image
> displays twice or more on the same page-load. My page requires 10
> different
> places where my images need to load, but I can't have any duplicate images
> show up.
>
> Any suggestions on what I need to modify here?
>
> Thanks in advance!
> Mike
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
--- End Message ---
--- Begin Message ---
On Thu, Dec 15, 2005 at 08:45:33PM -0800, Mike Rondeau wrote:
> Hi,
>
> I'm still very green with PHP, but am working to fix that.
>
> I've searched high and low for an answer to this question and so far
> no solution has presented itself. I have a script to populate my web page
> with random images:
>
> <?php
> #random images example
> #this is your file
> $file = "images.txt";
> #open the file
> $openFile = file($file);
> #generate a random number
> srand((double)microtime()*1000000);
> #get one of the entries in the file
> $random_image = $openFile[array_rand($openFile)];
> #display the entry
> echo "<img src='$random_image' height='170' width='100'></img>";
> ?>
>
>
> This works beautifully, but my problem is that sometimes, the same image
> displays twice or more on the same page-load. My page requires 10 different
> places where my images need to load, but I can't have any duplicate images
> show up.
Depending on the complexity of the logic you want in selecting
random images you can do something like:
$files = file($file);
$want = 10; // how many I want
$max = count($files); // the range, we might need -1
// a simple range check, to avoid an infinate loop
$can_have = $want > $max? $max: $want;
// start off the loop with these values
$have = 0; // aka have none
$images = array(); // aka no random images
do {
// generate a random number
$random = mt_rand(0, $max);
// if we dont have it..
if(! isset($images[$random]) ) {
$have++;
$images[$random] = $files[$random];
}
// have we made it there yet?
} while($have < $can_have)
var_dump($images);
foreach($images as $random_image) {
echo "<img src='$random_image' height='170' width='100'></img>";
}
Now, keep in mind that if you have 15 images and you want 10, this
could potentially be very intensive on the cpu.
On the other hand if you have 10,000 images and are looking for 10
it wont be as intensive on the cpu, but will use a lot of memory
that really shouldn't be used by loading the file into an array. At
this point an index file should be used or a DB solution should be
considered.
Curt.
--
cat .signature: No such file or directory
--- End Message ---
--- Begin Message ---
Hey all,
A couple years ago, before I could write my own PHP, I used a
semi-commercial gallery script... Long story short, this gallery script
used a config.dat file with these contents:
<?php exit(); ?>
11001100
01101100
00000100
10001100
00001100
...
... (Picture 1,667 lines of this)
...
11101100
00000100
00101100
11101100
00000100
This config file controlled how a "Powered by Company Name" was
displayed on the bottom of the template page.
So, if you buy the gallery script, which I did (I think I spent like
20$), the "Powered by Company Name" disappears.
Since then, I have always wondered how I could do the same. I am
definitely not a PHP guru, but I can hold my own... There have been a
few scripts I have written for clients where I would have loved to
implement this same technique...
Recently, I re-downloaded the script and tried to break-it-down to see
how it works... I was able to narrow things down to a few methods, a
template page, and a tiny bit more of PHP script... But, it is really
hard to understand how this is done because the config.dat file is
unreadable!
Any thoughts on how I could go about doing this?
How are they making their config files (I am assuming that they
probably wrote a proprietary script to convert PHP code to binary 1's
and 0's)?
Any thoughts and/or suggestions?
If anyone is curious, I can post a bit of the code. Here is a link to
the gallery script:
http://www.stadtaus.com/en/php_scripts/gallery_script/
Does anyone else do something similar? I would love to see some code,
and/or read more about similar techniques....
Thanks all,
Cheers,
Micky
--
¸.·´¯`·.¸¸><(((º>`·.¸¸.·´¯`·.¸¸><((((º>
·´¯`·.¸¸.·´¯`·.¸¸.·´¯`·.¸¸.·´¯`·.¸¸><((((º>
`·.¸¸><((((º>¸.·´¯`·.¸¸><((((º>
--- End Message ---
--- Begin Message ---
On Dec 15, 2005, at 10:09 PM, Michael Hulse wrote:
So, if you buy the gallery script, which I did (I think I spent like
20$), the "Powered by Company Name" disappears.
I forgot to add:
When you buy the script, the company will send you a new replacement
config.dat file that "magically" removes the "Powered by Company Name"
from the bottom of the template pages.
--- End Message ---
--- Begin Message ---
I got lost in the mix of threads, so here is my input on the
situation.
On Thu, Dec 15, 2005 at 09:53:46AM -0500, Rahul S. Johari wrote:
> I want to assign a 4 Digit ID with leading zeros to each record added using
> a form I have created.
>
> The PHP scripts does two things:
> (a) It adds the data to a mySQL table
> (b) it generates a CSV file with the data
>
> The 4 Digit ID (beginning from 0001) will be used in two places:
> (a) It will be the ID for the record in the mySQL table, instead of the
> usual ID that we create in mySQL. It will be a Primary Key, Not Null,
> Auto_Increment
> (b) It will also be the filename for the CSV file.
>
> So basically it has to match the record adding in the mySQL table and the
> filename for the CSV.
There seems to be a design flaw with this. As mentioned, well you
dont expect to have over 9999 entries, you simply cant rely on the
auto_increment to deal with this as it easily can get over the
number with only one record. If 4 chars is an issue then i would
avoid using the auto_increment as the Primary key.
As Far as making sure that the file is written as the current
specifications call for the leading zero's is a virtual concept.
Consider:
The query to get the record with and ID of 0001:
select * from table where id = 0001
This since 0001 is the same as 1 there really isn't any meaning
behind the textual 0001.
A result from an auto_increment that is just '1' can easily be
formated to output as 0001:
$file = sprintf('%04s', 1);
At this point the only limiting factor is the output of the
filename.
As far as not expecting the auto_increment value never reaching
10000, when I was 10 years old I thought anyone that was 30 was an
old person.
HTH,
Curt.
--
cat .signature: No such file or directory
--- End Message ---
--- Begin Message ---
Hi everyones,
I coding PHP since 2002 and this is the first time I have to take this
decision.
My group and I have to build a VERY, VERY BIG website for a callcenter
users. Understand I have to create (or use ;)) several code for access,
transactions and management.
The customer had buy MSSQL server, so we have to use it and it's working
very fine. NO MYSQL!!!! (is not my personal choice ;))
Currently it's already hard to program and now we have many file. We have
only 20% done and the code are a real mess!!!
Creating Class, functions, splitting code in several php files using
include, see the files sitemap??
So for the optimisation topic, what is THE BEST for the PHP compiler. One
big file or many included files?
Regards
Martin
PS: If some one know somes related links about the subject, please dont
hesitate. ;)
--- End Message ---
--- Begin Message ---
I don't know about whats best for the compiler (rather interpreter), but if
it is a really big site with a lot of access, transaction and management
functionality I recommend you start breaking the code into classes and
separating each class into a file and documenting... A LOT! It will be
clearer to understand and maintain. IMHO.
There are lots of sites out there that describe how to separate web code
into layers such as: display, logic/rules, database interactivity, etc.
Aaron
On 12/15/05, Martin Leduc <[EMAIL PROTECTED]> wrote:
>
> Hi everyones,
>
> I coding PHP since 2002 and this is the first time I have to take this
> decision.
>
> My group and I have to build a VERY, VERY BIG website for a callcenter
> users. Understand I have to create (or use ;)) several code for access,
> transactions and management.
>
> The customer had buy MSSQL server, so we have to use it and it's working
> very fine. NO MYSQL!!!! (is not my personal choice ;))
>
> Currently it's already hard to program and now we have many file. We have
> only 20% done and the code are a real mess!!!
>
> Creating Class, functions, splitting code in several php files using
> include, see the files sitemap??
>
> So for the optimisation topic, what is THE BEST for the PHP compiler. One
> big file or many included files?
>
> Regards
>
> Martin
>
> PS: If some one know somes related links about the subject, please dont
> hesitate. ;)
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
--- End Message ---
--- Begin Message ---
Definitely sounds as if you should be employing the object-orientated
methodology, If the project is as big as you say it is then really you
should be looking to use some UML planning tool so that you can keep all
you code organised.
It is ok on smaller projects to bash out some rough plans and get into
the coding but with more complex requirements its a recipe for
disaster, wait until you client asks for a few seemingly simple changes
and then you realize just how important a good design and plan is.
good luck
Adrian
Aaron Koning wrote:
I don't know about whats best for the compiler (rather interpreter), but if
it is a really big site with a lot of access, transaction and management
functionality I recommend you start breaking the code into classes and
separating each class into a file and documenting... A LOT! It will be
clearer to understand and maintain. IMHO.
There are lots of sites out there that describe how to separate web code
into layers such as: display, logic/rules, database interactivity, etc.
Aaron
On 12/15/05, Martin Leduc <[EMAIL PROTECTED]> wrote:
Hi everyones,
I coding PHP since 2002 and this is the first time I have to take this
decision.
My group and I have to build a VERY, VERY BIG website for a callcenter
users. Understand I have to create (or use ;)) several code for access,
transactions and management.
The customer had buy MSSQL server, so we have to use it and it's working
very fine. NO MYSQL!!!! (is not my personal choice ;))
Currently it's already hard to program and now we have many file. We have
only 20% done and the code are a real mess!!!
Creating Class, functions, splitting code in several php files using
include, see the files sitemap??
So for the optimisation topic, what is THE BEST for the PHP compiler. One
big file or many included files?
Regards
Martin
PS: If some one know somes related links about the subject, please dont
hesitate. ;)
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--- End Message ---