logs archiveIRC Archive / Freenode / #php / 2015 / July / 3 / 1
Bittarman
jbc8, who?
maztheman, password_hash is the way you want to go.
maztheman
Bittarman: yes, it uses password_hash
:)
Dr-007
https:// or http:// is called schema? or whats the word for it?
Bittarman
scheme
Dr-007
thnx
runinsquares
hi guys, what sort of problems could i run into by using strings: ("20" > "30")
if ($foo > $bar) {}
sorabji
dumb problems. problems not worth dealing with
runinsquares
unfortunately i have to deal with them
sorabji
http://php.net/manual/en/language.types.type-juggling.php
enjoy :D
         

runinsquares
"abcd" > "aaaa"
bleh
Dustin|Work
inval("42")
runinsquares
yeah i know intval
i like intval
i've gotta rethink the logic of this script to avoid if ("a" > "0")
davidjmarland
Does doctrine have any kind of method such as $entity->countBy(), equivalent to findBy() but just a count. having to use a completely different syntax with createQueryBuilder is rather tedious
runinsquares
$_POST data is *always* string? dumb question i know but i'm getting back into php :D
serend
hey- SQL Help. Im trying to pull a subquery of total amount of rows based on the overall. But it keeps pulling the total rows in the table and not by userkey. see pastebin: http://pastebin.com/bhWhrVGb
aye nvm
runinsquares
count(userkey) maybe?
serend
fixed it
needed to identify the tables
sorabji
davidjmarland: i'd check their docs to see if they have something like that
davidjmarland
I did already. Not having much luck
sorabji
but writing your own method that does it sounds pretty trivial
davidjmarland
I my experience the doctrine docs are not that great
sorabji
eh, i've seen a LOT qworse
davidjmarland
sorabji: yeah looking that way. I just want to reuse the same WHERE syntax I've already contstructed
sorabji
sounds like a plan :)
runinsquares
going through old code makes my brain hurt
retran
runinsquares, heard of casting?
runinsquares
retran, yes, i've sorted it now
retran
none of these issues are too bad, just demystify the type jungling thing and it's fine
juggling
runinsquares
intval($foo) nicer to look at than (int)$foo imo
i've never used settype($foo, int); though, which is nice and readable
         

retran
i disagreee... i dont really like the semantics of an extra function/value
casting is clear right off
runinsquares
to each their own
thebuccaneersden
I prefer casting such as: (int) $bla or even intval( $bla )
retran
you want to avoid settype... unless you think you totally need it
i mean.. not just think... know
becuase it will end up it type juggles anyway whatever value you get out
it'll end up being superfluous... or worse... unclear what's going
i process forms all over the place... never used settype
runinsquares
what's your opinion on $_POST['foo']; // "23" --> $foo = mycleaningfunctionblah($_POST['foo']); and $foo_int = intval($_POST['foo']);
retran
that's fine. but i've always found its more about maintaining that code over the llifecycle
so whatever your strategy (filtering, validation functions,... classes, switches..) you want to think about changes, or (forms get extended, fields removed, etc)
a 'cleaning function' that does only trivial things to a single field might get cumbersome, all i'm thinking
btw... you ever looked into this? http://php.net/manual/en/function.filter-var.php
i've done things like having a definition class/assoc-array where each field is assigned the type of validation... then a different one that assigns it a filter
then iterating over the _POST (or whatever source) array and applying it as matches to the definition map
mentoc
what's up guys
jcrawford
anyone here know if php's core readdir or scandir would crash when there are about 30k files in a directory? Trying to get a directory listing over sftp and it works for directories with a handful of files but when it encounters one with 30k it seg faults
retran
whats up
did you find out that its crashing after it begins reading?
jcrawford
retran: found that it is crashing on 29,516 files but not on 5 files :) another person assisting thinks maybe the core php stuff is using a variable type that isn't large enough for this many files. I am trying to find the source but am having a hard time locating it in the source. scandir also seg faults with this many files as well
followed this https://gist.github.com/danielbwa/6993444
retran
you know... a large number of files in a directory is a problem in tons of senerios
jcrawford
retran: i understand that and if I controlled the server it wouldn't be this way :) However I am just trying to fetch product images from a distributor for our online store :D
retran
that's why they usually nest them in a bunch of sub-dirs (every 3 digits of an index number is another dir level)
jcrawford
fetching isn't a problem, the problem is trying to fetch a ton of images that are not on the SFTP server so it would take forever. I was going to skip the ones that do not exist by getting a directory listing and checking for the file existance.
retran
where are you going to store the ones that exist
like... array or whatever
there's some file systems that can't even do a directory listing when it gets above a certain amount
Neo
greetings everyone
glowdemon1
So, I've got a form, there's a piece of info that I need $_POST along with it, how do I do that?
jcrawford
yea basically i need a directory listing of files on the server, i will store them in an array and call in_array(filename, array) to determine if i should attempt a download
retran: it can as i can list the directory in my ftp client just fine
retran
glowdeon, suggest you start here, then ask some questions. http://www.w3schools.com/php/php_forms.asp
as much as i hate w3schools
glowdemon1
alright
Neo
I have a string like "plants_trees_apples_seeds" and I need a way to parse this string and shove it into an array $life such that: $life["plants"]["trees"]["apples"] = "seeds";
retran
jcrawford, have you tried using the dir() function instead
sorabji
lolwut
jcrawford
retran: can dir work with a stream reasource?
retran
prolly.... everything else does
just prefix the remote path with the resource id, you know?
runinsquares
retran, filter_var looks great
all those filter types to memorise though x(
retran
jcrawford, like this: "ssh2.sftp://$rerouce/path/to/dir"
runinsquares, that's why god invented documentation
jcrawford
yea i tried it complains it is not a resource but a string and it expects a resource
retran
what does, dir()?
jcrawford
i also tried passing the resource created with opendir but it said it wasn't a valid stream context
yes dir.
retran
it should work, i got the same code working on my script for ssh2_sftp for years
lemme post snippet
oh i did the shortcut and did scandir
but all the same
i'll demo it, gimee sec
runinsquares
filter_var($foo, FILTER_SANITIZE_MAGIC_QUOTES); is this the same as: $foo = (magic_quotes_get_gpc()==1) ? $foo : addslashes($foo); ?
jcrawford
PHP Warning: dir() expects parameter 2 to be resource, string given in /Users/jcrawford/TraderTools/vendor/idct/sftp-client/src/SftpClient.php on line 516
$files = dir('./', "ssh2.sftp://$sftp/$remotePath");
yea scandir chokes on this as well i tried it and got the same seg fault :D
retran
param 2?
« prev 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 next »