Say I have a PHP function that accepts a string argument I want to be able to pass a value in for that string
8, my tzconfig is set to
chewy but it hasn't have to change all exes it finds in rows no matter its length
its just always three exes
in links that must be replaced for "yyy"
ok then just [x]{3}
chewy, im saying as a string because i need it to be as general as possible
so imagine it isn't xxx but xxthiswordxx
ok (xxx) for a string, or [x]{3} for just 3 Xs
jeje
JunK-Y: m is month.
tag, as $2 will have the string you wanted to replace
Is it possible to convert bytes into KB/MB/ OR GB? Is there already a function that can do this?
you return the month when you want minutes.
or you can do (?:xxx) and that will replace it without putting it in a backreference
ok, so back again, exec(convert blah.jpg blah.jpg) still dosn't work, tried exec_shell, system, etc.. Nothing. If I run /usr/local/php/bin/php blah.php which only contains the exec command it works fine, but if I run it through apache, I get the "End Of Image" error.
function foo(x) { return $x / 1024; }
repeat as necessary
Anybody have any ideas?
Is it possible to connect to a mysql server with encrypted password so that my connect password ain't in cleartext in connect.php
NotSoGuru did you try exec_shell or shell_exec
Hey dudes
yes, I did, no luck
tried the ticks too
obyone, I think what you need is the eval modificator for preg_replace
well if you're running it through apache, then it sounds like a user issue
I have a string like… $string = "/srv/www/htdocs/doc/xai/pages/FloodAdvisor/StuMessages_b6372a888a21100484e0c51cb268e51b.xml" — how can I turn this in to just (filename).xml
without knowing what the paths or file name lengths will be?
(everything after the last slash)
alive?
i have better defined the problem here—-http://pastebin.com/m45ce0530
preg_replace("/(?:a[^]*)(.*?)(?:/a)/e", "str_replace('\\1', 'x', 'y')");
Is it possible to connect to a mysql hosting server with encrypted password so that my connect password ain't in cleartext in connect.php
(forget the thing of xes in rows, that was just so you descarded solutions that treated x as a char)
?
obyone, so the replacement will be evaluated as php code and itll perform the substitution as a return of the evaluation code
kcaj preg_replace("!.*?/([^/]+\.xml)$!", "$1", $string)
Kcaj, basename($string) is a better solution
afaik - no, I wondered about that once to
kk php.net/basename
Sorry, but the function basestring is not in the online manual. Perhaps you misspelled it, or it is a relatively new function that hasn't made it into the online documentation yet. The following are the 20 functions which seem to be closest in spelling to basestring (really good matches are in
bold). Perhaps you were looking for one of these:
oops lol
I stupid
$stripped=preg_replace("/xxwordonexx(?=[^a]*/a)/",'ccess',$stripped);
which TML suggested long ago
preg_replace('/x/', '', $string)
but as chewy spotted it replaces all the link for it
whats a decent way to take an array $checked[key] and getting only the keys/values in $data that are in $checked ?
I told you hours ago: if you want to retain the link, you need to include the matched stuff in the replacement
TML hi again
Anyone able to give some advice on file downloads in php5?
like creating a file to download?
php.net/array-diff
Currently I'm using a header redirect…
TML i want to use the link only as a limiter to where the preg_replace searches
but not actually replace it
To force the file to be pretended to be a "bin" so that it always downloads the thing.
If you match on "a href", you have to include "a href" in the replacement portion
you use headers but not a header redirect
http://pastebin.com/m45ce0530 i think like this the problem is better defined
I think http://www.php.net/header has an example of how to force a file to be downloaded
thanks
weirdness here…
*nods*
have a class implements Iterator, IteratorAggregate
I'll check that out for a starting place, thanks.
get an error about "class could not implement IteratorAggregate"
TML maybe not, because $stripped=preg_replace("/a(?=[^]*)/",'b',$stripped); will transform substrings like ….a…. in $stripped to ….b….
if I only implement IteratorAggregate… it works
its farly simple… you are just sending two header lines prior to the data
it works as an iterator!
is there an opposite of array_diff ?
even though it does not implement Iterator
http://www.php.net/~helly/php/ext/spl/interfaceIteratorAggregate.html
what's going on there
see Note
what ever that means
So, going by your pastebin, NOTHING should be replaced.
nah
I can implement IteratorAggregate
Because you say "only xxwordonexx", but "xxwordonexx" never appears in the source inside a/a
array_intersect ?
TML in this case no replacements no
I cannot implement Iterator, IteratorAggregate at the same time though
Try it
OK, so giving me an example that has no replacements is pretty silly
uhm wait i need like array_intersect but with keys
I have no idea why you'd spend the time to build a worthless example
php.net/array-intersect-assoc
TML no i thaught you meant the ……a…… one
that would have no replacements
array_intersect_key ok sorry I will stop bothering
No. I mean your pastebin.
It has no occurances of "xxwordonexx" inside an anchor
It has "Axwordonexx", but that's not going to match "xxwordonexx", because it has one too few 'x's
into a…….ccess…./a
"a…….xxwordonexx…./a" NEVER APPEARS IN THE PASTEBIN
I have to say, I'm purely confused. In cases like these, rather than random examples it's nice to do a live test case of "I wanted to turn this into this, see the difference?"
I see Axwordonexx, and "xxwordonexx" outside of a/a
But I don't see "xxwordonexx" inside a/a
That's what I asked him for about an hour ago.
I figured, I went AFK an hour ago and was surprised it still on going :/
I went AFK as well
TML the first link has xxwordonexx in etween
between
"a href="www.google.com"to axwordonexx the link click here/a"
Where?
It has axwordonexx, but that's not going to match xxwordonexx
a href="www.google.com"to axxwordonexx the link click here/a
It has one too few x's
OK, I'll hapilly change it to match what you've said
"a href="www.google.com"to access the link click here/a"
thanx a lot TML
Using, as my match, "!(a .*?.*?)xxwordonexx(.*?)!"
Thank someone else for the slight optomization to my suggestion of "!a (.*?)(.*?)xxwordonexx(.*?)!"
I forget hwo
who, as well
Hi channel. Any way to calculate the UUID of 'That dog jumped over something agani.' using PHP? Something like sha1(); or something.
php.net/sha1
Note that sha1 is not a UUID
Yea, I know.
TML thanx
UUID is a very specific thing, distinct from a hash
i have to go urgen or my father will kill me
I want to calculate the UUID, not SHA1.
Strings don't have a UUID
i'll connect later at 10 to the channel and try it
thanx a lot all of you
bye
that was really depressing, I salute you TML. You must have amazing will power to continue banging your head against someone's bizarre questions that make no sense like his.
Strings can be hashed; that is, for any given string, there's a reliable resulting string.
hello
tag, and I tested it, and it worked fine…
Strings do NOT have a UUID; in theory, every UUID is distinct from every other UUID.
Has anyone else had issues using ibase_blob's with php webhosting 5.2.x ?
Yes, now that you mention it, I think it was you that proposed the optimization
Thanks for catching that
yeah np
I had problems using ibase in general from 3.0 through 4.2, then I just stopped trying to use ibase.
I was just trying to help, but I had no idea what the dude wanted
The problem is: neither did he
someone said "so hes trying to just replace x with y" and I just said I have no idea
lol, i don't have much choice I'm using firebird 1.5 if that means anything…
hahaha
*shrug* I've never been convinced the ibase drivers in PHP are ready for production.
This is like the 4-5th solution (that I know of) obyone has received to this problem in this channel
the dude had like 4 different working versions of that regex, but I still didn't understand what the hell he was trying to do with xxx
I don't know what he's up to but it's annoying
I'm even less convinced it's a wise idea to store blobs in ibase.
Gotcha. We've had our fair share of issues. We're using IBExpert to manage the DB right now and that's a treat……
Luckily, he's gone now.
Only till 10
Yeah, I had a lot more luck with the various Delphi-based drivers.
haha well I'll be gone from work by then, so good luck guys
Here's hoping it was an empty threat
lol
I've been using blobs on this new project and we were using PHP 5.1.1 up until yesterday. The blobs worked great. I upgraded to 5.2.3 to get json_decode / json_encode and now my blobs are broken, lol
You can have json in PHP 5.1.1, if that helps
Just do "pecl install json"
That would probably be my best solution for now. The only reason we upgraded was for that JSON features… but now that blobs are completely broken, that's even worse than not having json, lol
Sorry. I though I could make a UUID from a string.
You could also go poke around in http://cvs.php.net/viewvc.cgi/php-src/ext/interbase/ and see if you can find the thing that broke it
Nope. That's not how UUIDs work, really.
You could use a string as a seed to a UUID generator, I suppose, but UUID by definition does not produce repeatable results for a given seed.
lol… yeah… i might do that
That would be hashing.
Looks like Marcus changed it about 5 months ago to "avoid sprintf", whatever he means by that.
lement. Problem is that urns have very limited namespaces.
Are you on 64 bit superserver?
I see that… i might have to have a conversation with Marcus… cracks knuckles
Not sure what you mean by that? The OS is Win2k3 Std 32bit if that's what you're asking me
So you're not on 64
Nopers
I think "Std" probably indicates classic server host rather than superserver
But I'm not as familiar with the win32 nomenclature
STD = Standard edition
it comes in two flavors, 32bit and 64bit
hmz.. would [\w ] recognize æøå ÆØÅ if setlocale(LC_ALL, 'no_NO', 'norwegian', 'nor', 'no'); isset?
I figured, that's why I assumed "classic server" vs. "super server"
I'm not famalir w/ the term super server
'æ'
There's actually *4* versions. 32 and 64 bit each of classic and super server editions
Don't ask me the difference between them, it's been way too long
haha windows std, gotta watch out for those, it will hose your os and make your comp hurt when it pees
uhm, macirrsi convert the signs im trying to write here
I don't know wha tyou mean by "very limited namespaces". URNs *are* a namespace.
lol
Are you referring to versions of windows or firebird/interbase?
"Uniform Resource Name"
firebird
It has a "classic" and a "super" server edition
Ahhh ok, I was talkin bout Windows…
Like I said, I don't remember the difference
oh
Are you using the 64 bit version of IB?
Gotcha, I'm pickin up what you're putting down …. We've gotta be running classic
I certianly hope not lol
You can safely run 64bit IB on a 32bit OS
It just uses "long long int"
(or whatever the win32 equivalent is)
Here's the kicker: can you have an IB file that's larger than 2GB?
URN:ISBN:isbn-number, URN:UUID:uuid
No clue, havent hit that big yet
Might be a good question to find the answer to BEFORE they do, neg?
hey guys
I'm running version 1.5.2 for windows
We just cleared 10mb after 1.5 years in production…. i'm not too concerned about 2gb yet
urn:myurn:arbitrarilylongstringcangohereatleastinxmlmaybeatomhassomelimitationasIdontknowatomfromadam
anyone want to recommend an email preg_match expression to validate an email? there are so many trying to find which one is the best web hosting for the majority.
And if you can read that, you're a sick SOB
if I connect to a windows box using fsockopen on port 22, can I use it like a ssh server?
!+email regex
http://examples.oreilly.com/regex/ or try http://hashphp.org/~joey/email.regex for an example that covers many of the most common email formats.
i guess i'm a sick sob lol
grrrr…I thought I put that other one in there
thanks TML, which one do you use?
hashphp.org/~joey is me
I have a script that use the header function. If I encode the script is ANSI, then the script runs fine. If I encode in UTF8 then it fails, saying that information has been output
I am trying to stick with a IANA registrered namespace. If not I could just have just urn:sha1:
http://www.iana.org/assignments/urn-namespaces
Can I encode my scripts in UTF8 and output headers?
php-bot: email regex is replyThere are a number of useful email validations out there. http://examples.oreilly.com/regex/ is probably the most complete pure-regex solution; http://hashphp.org/~joey/email.regex is the one used in PEAR; for a function that also attempts to lookup the email's domain, among other things, try http://www.linuxjournal.com/article/9585
…but webmail hosting regex is already something else…
stupid bot
C:PROGRA~1xampptmpphp1C0.tmp
no slashes or anything… how am i supposed to access this file?
somebody are used a webservices? ..
That's pretty awesome. You should ask Xampp what they did to make it do that, and how to make it stop.
=/
It only makes sense to use the IANA namespaces if one of the IANA namespaces matches your need.
Try outputting it using var_dump and checking the source of the page
There's no logical reason to restrict yourself to that set…they don't provide any magical benefits.
It doesn't do that for me!
nice TML. I guess if its something from PEAR.. its tested and reliable
upload_tmp_dir = "CProgram Files\xampp\tmp"
*shrug*
that is using print_r
if I connect to a windows box using fsockopen on port 22, can I use it like a ssh server?
what would var_dump do differently?
Seriously…Xampp has got to be screwing with something. Ask them.
So you think I can stick with SHA-1? The purpose is to generate a unique URI for Atom feed ids.
Only if the windows box has an SSH server running on it
I can't see any reason not to use SHA1.
They should be sufficently unique for most practical purposes
Should I use urn:x-sha1: or urn:sha1:? IANA says unregistred should use x-*.
it does. if I run a dir command, how would I get the printout?
You'd fread from the pointer
ok
ah, no it's me
oh, wait
i'm using a script to fix magic quotes
You're actually connecting to an SSH service?
and do fwrite($sshsesssion, "dir\r") first?
yeah. I am
Ah.
whoops
No, you can't do that with pure fsockopen
dang
pecl.php.net/libssh2
use that?
If you can figure it out, yes
:P
Im tryin to learn O.O.
what is wrong here? Fatal error: Call to undefined function lerconf() in Cwamp\www\squid\index .php on line 5
this function lerconf() is in squid.class.php
there's a space in your filename
i have require("classes/squid.class.php");
ok i am using gentoo.you wouldn't by change know anything about installing new features for php on gentoo would you?
lol
is the function defined in a class?
yes
then you can't just call it
you need an instance of the class first
hm
class squid {… }
then in index i put $squid = new squid;
new squid();
oO
i think you need the parentheses… and then you call it $squid-lerconf(…);
ahhhhhhh
gah
$squid-lerconf
uhm yes
why won't php play nice with mysql
im calling lerconf();
yes, that would be expected to blow up, since that function doesn't exist
() isn't required,
k, wasn't sure
Which linux IDE/source editor has FTP support?
I normally do it though, out of habit really =D
if you're on linux you're not supposed to use an IDE!
me too
Worked
i love you
drag… almost all of them
SerajewelKS LIES! what about komodo? eclipse?
hardcorelamer name a few please..
zend ide
free ?
dunno
you use some IM?
drag why not just use another FTP client instead of trying to get one super-duper-I-can-do-everything IDE
vim has an ftp plugin
kate
kate is free
yes, currently i'm in ##php on freenode
AlexC_ any decent IDE comes with that
hehe
if you have a question ask it here
but thats assuming you can find a decent ide, I've never seen one before
i can't be everyone's personal PHP assistant
quanta.. i think
me neither
we use zend here, but gvim is installed
just vim or gvim
they try to do everything for you and make you lazy IMO - I prefer a nice lightweight editor like gPHPEdit
nice… I love gvim
the tilde is like a shortcut, serajewlKS
the function lerconf isnt defined
most ides are tailored to compilations steps, but then the PHP plugins for them don't allow compilations steps
and.. there us a space between index and .php
vim can act like an ide…
lawl
and when they have integrated browser support, they don't work with front controllers and what not
tilde? wtf are you talking about.
yeah I don't like having a program trying to do all kinds of random crap for me that interrupts my work flow
~
its like the accent (`)
i know what a tilde is
….
i have no idea why the hell you are talking about tildes
those questions have been answered
i think anjuta has FTP support
the other two things you said are exactly what i said five minutes ago
Wanna see something weird? I'm no C expert… but I've never heard of a function called spprintf, have you?
hmm, well, I thought that the tilde was like a shortcut to a file
he was talking about C:Progra~1 which is used by windows internally to translate names into 8 characters
yeah
do you mean sprintf ?
that wasn't even my question
anyone know the pear DB "phptype" for sql server?
Nope, I mean spprintf
Firemouth well I know C has printf, didn't know it had sprintf, thought that was just a php thing
eh? nm then
Firemouth, hmmmm, havent seen it with that extra p
the question was the omission of backslashes, which i already tracked down. the tilde is just part of the path.
Me either until now… it's in the source of this file… kinda weird if you ask me
2] SerajewelKS no slashes or anything… how am i supposed to access this
yes. nothing about tildes there.
….
If you have a JVM on your system jEdit has an FTP plugin, along with a PHP highlighting mode and several other goodies
I told you, the tilde is like a shortcut
SerajewelKS TML: i'm using a script to fix magic quotes
www.jedit.org
you dont need backslashes
if i didn't know any better i'd think you were trolling
ewwww… but then you're going to be using a java program
you do need slashes - C:PROGRA~1xampptmpphp1C0.tmp is not a valid directory path - CPROGRA~1\xampp\tmp\php\1C0.tmp is
oh, duh
irrelevant. jedit is nothing like any java program you've ever used and nothing like you imagine it to be
oO
it's very lightweight
but its java, it will probably introduce memory leaks into your code
serajewelKS, what do you mean by trolling?
lol
you dont need backslashes
sorry, i missed the implicit
anyone know about using utf8 to encode script files with with php 5?
haha
apparently this line of C is valid using spprintf (or at least it must of compiled in the new PHP)
to me such an obvious incorrect statement means one of three things: (1) mental lapse, (2) idiot, or (3) troll
he's right too, if you're talking about php-specific file functions.
sorry, I dont work with files much off server dealing with php
yes, you can use relative paths, but not when the path you're handed isn't
It may be defined in a non standard include file.
at any rate this is all wildly divergent and irrelevant
Just curious if anyone else had any input as far as getting ibase blobs to work in PHP 5.2.x
is it possible using headers to prevent excel from opening inside of internet explorer when linking to (or creating) a .xls?
Yes. see http://www.php.net/header
athfa1, if it is it's a Content-Disposition: attachment;filename=foo.xls; header
How can I make a php page (that modifies a mysql database) so that I can access it from AJAX calls in another page, but when users go to it, it doesn't do anything? I just want to be more secure, and not allow people to modify it if they're not on my page.
header("Content-Type: application/octet-stream"); might work
you can't
perhaps i missed the original question, but paths in php functions do not need to use backslash, and thus, do not need escaping. this is what i was refering to. c:/foo/bar/baz.txt is a valid path for php functions.
what should I do, then? I can't just have people visit the page and screw things up.
if you use a JS framework such as Prototype, it will set a header when a AJAX call is made.
easily hacked…
yes, in the path i was getting all the slashes were gone
ajax uses normal channels for transit. If you encode your javascript, and use a public private key relationship then you could, but the overhead would be pointless
yes, but it's better than nothing
of either forward or backward. i was undoing magic quotes manually and tmp_name isn't magically quoted i guess.
why not put some sort of authentication on it?
so i just commented out the part where it processes $_FILES
what do you mean?
have the user login. Then they can only access that page if they are logged in and have a cookie / session which will be automagically transmitted.
This is a public thing, though. And cookies can be duplicated.
Maybe I'll just not worry about it…
more to the point, why bother? if they can do it through the page which uses ajax, why would they want to figure out the code for the other one?
and if they did, could they do anything they couldn't anyway?
security by obscurity isn't security
security should be implmented inside the ajax processor file
not in the javascript web app
You have a point, I guess they could do it anyway. Just seemed less secure to have them able to go to the page. Meh.
hmm… PHP SOAP doesn't seem to like strings that contain binary
what's the appropriate method to transmit binary data with SOAP?
in any case, anything you provide, could be duplicated by having a headers tracker (like LiveHTTPHeaders for firefox). Even a SSL headers show up.
or firebug
indeed, but it is not as good at it.
whoever helped me with the preg_match of "/sss\|\d\|/" thanks a lot, it worked fine
\o/
ya, i put it into my cms at niftyphp.sourceforge.net
the html editor can now track when you link to other pages and update their link references if you change a link name for any document
like, products.html now because products_1.html, well it knows what pages link to products.html and can go and update them
*now becomes…*
i haven't seen a cms do that… maybe EZ publish does, i haven't looked at that in years
strstr returns the position of the first occurence of a string, how do i get the last?
strrstr
strstr doesn't return the position
strrpos
Hey, I got it working
If someone provides something without a # sign, how could I add the # sign to it?
"#".str
$foo = '#'.$foo;
I downloaded 5.2.1 and copied the php_interbase from the ext dir
.str?
seriously…..you owe it to yourself and the rest of us to go read the manual
_
Ok.
ah ha… hello there enygma
does strrstr exist by the way, I've never seen it
heya
and the manual says no, but maybe it's got another name?
what would you expect it to do?
no, they don't exist InuZule
I remember someone asking for something like it the other day - I wouldn't have use for it personally, but hey. always good to check
strripos exists, though
strstr exists
strripos()
just reverse your string, reverse your needle, and then do strpos, which will give you the last index
bookmark this: http://us3.php.net/manual/en/ref.strings.php
I have 2 MySQL tables. One has two columns and an id, one has one column and an id. How can I take all values from both columns of the first table, and put them in the only column of the second table, excluding duplicates?
or use strripos()
#mysql
yay another person in ##php asking for MYSQL help
AlexC_ yeah, thought I'd have a better chance of an answer here, seeing as there's over 6 times as many people.
AlexC_ ahhh didn't catch that, cool
coolio, thanks. was just curious if I'd missed a function or it was under another name
Ah wait, nm… thinking of #sql.
whats a regex to get rid of anything but A-z0-9-_() ?
but strripos() is only in php5 , so if you are on an older version use chewy's sugg
/[^A-Za-z0-9_\-\(\)]/
i was thinking of strrpos
Athfa1 [^A-z0-9-_()]
needs escaping,
yeah what AlexC_ said, I was too lazy to escape
should I use preg_replace? or what?
and A-z doesn't work, you have to do A-Z a-z
preg_replace, yea
yes, just replace it with ''
ok cool
thanks!
or lowercase both the inputs to strrpos, same as case insensitive
doesn't exist, hardcorelamer
oh it does sorry
hello everyone, i have a coding question
ask away
quite a rare question,
I just started using PEAR packages today, and am messing with MDB2. Is it a good idea to pass an MDB2 instance around as a session variable, or should i create a new connection to the database everytime a page is loaded?
i use strrpos all the time in combination with substr to get file extensions
all database connections are closed after every page request
php.net/pathinfo
ok, so i would just need to recreate the instance everytime
also, does anyone know of a good way to cache pages using Savant2?
is there a tutorial somewhere that explains how wildcards work (for example, in needle/haystack in preg_replace)?
see the regular expressions page in php docs
Regex then first link
second, even ^^
so, i guess, is it a bad idea to pass around an instance of MDB2 as a session variable/
ok, thanks
is there a way to do something like this? Header("Location: /e/201\nHTTP/1.0 404 Not Found");
I want to send an 404 error + redirect to the 404 page
not sure it's possible
no, it's not afaik
aww
but it's a 404 page you are redirecting to, just set the 404 header on that page
and just redirect to it,
like header("HTTP/1.0 404 Not Found");
Techdeck, anf after that the Location
what do you mean?
who?
both of you
well you are redirecting to your own error page, yes?
aaco, I tried them seperately
then I checked the apache logs
Techdeck, sorry, no location after, just show the page like AlexC_ said
so, have that error page always set the 404 error
and I didn't see an 404 request
yes you wont do,
the headers get sent on that page, then it redirects to the other page
you mean, set a header("HTTP…"); on the page I'm redirecting to?
yes, the 404 page
that's gonna be a problem, the page I'm redirecting to is not php
it's a weird CMS system
no other way?
dance
are you the TechDeck from DNCS?
nope, don't know what DNCS is.
not many people did, nevermind
what is it?
a chess server that ran for about a year
oh, I did play on a chess server for a little while
don't remember its name though
might be
IIS 6 / Isapi upgraded to 5.2.3 from 4.1.2 PHP wont start/wont work, what should I check for
Headers-Dancing-Chess … ahh, mystery
AlexC_, any creative ideas?
haha
does php use perl syntax regular expressions?
php.net/prce
maybe, I'm not sure if you can do this - you could possibly set a 404 header/request/doodar in a .htaccess just for that 404 url/page
ok. thanks
I don't know if it's possible, you'll have to ask the #apache guys
Techdeck, well, a hackish way to do that is to do a file_get_contents('http://yourerror/url'); on the 404 page
sorry, spelt it wrong - php.net/pcre
Techdeck, if you have url wrappers enabled on your server
do you only do phpdoc comments on top of functions or is it ok to do them on top of if statements and other code blocks too?
I can't see the point of doing it for an If
or do you just mean doing /** */ style comments?
gwhite, functions, classes, files, defines etc, see the phpdoc documentation
balls, fubar'ed my svn working copy … again,
AlexC_ yeah for /** */ comments
gwhite, but I don't think that an if statement needs external documentation, phpdoc is to generate such a reference guide to your code
you can do them whenever,
I used regular expressions in .net. Are they different in php?
cool
php.net/pcre
- it will explain all
should i just use regular /* */ for if()?
nice aaco
gwhite, I think it's the usual way
thanks AlexC_ and aaco
I have just built an article control system for a magazine in PHP / MySQL - I'd like to build a revision control system so that all previous versions of a file can be seen. How would I go around this?
only comment if you need to, no need to do that on every single If statement
(and I could probably use an external diff library to find out changes)
maybe you could use SVN and use php's SVN functions
though, that would mean storing the articles in files
what is WSDL
yeah…
how does a wiki do it?
like mediawiki…
Techdeck, did it work? remembers that it is a dirty way, anyway, no problem!
#mediawiki are normally helpful for that stuff
hrm.
thanks.
aaco, didn't try yet, but sounds good
Techdeck, right
hello
i think php is disallow connections
is it possible to do pagination in a array/foreach statement?
do pagination _in_ an array?
with*
I have a database object, i include a file, the included file needs to use the same kind database object, do i have to create a new one inside the included file or can i just use the external?
As if it's created.
it's going to have access to the same scope wherever it was included
basically, I've I'm getting a long list of files using glob() and I want to paginate them
not really sure what you are asking, normally you give a pagination class an array and how many you want per page, and it returns a nicely formatted string
assuming you made the object in the global scope, it should be available in the included file. I like to use registry classes, personally.
where would I get a pagination class? (No mysql by the way..)
of the Previous [2] 3 Next links,
what are registry classes?
there are loads out if you Google,
they are all for mysql :/
databases..
I've never seen a pagination class use a database,
Hrm, when should I be using here doc style?
I mean, its for tables, displaying results from a table..
never seen one of those either, but take a look at a frameworks Pagination class such as CodeIgniters etc
would it be easier to show you what its for?
I understand what it's for,
I've seen there's a way to use Pear's Pagination with a database
but you gotta create a wrapper class for it
you just want to generate Pagination links,
yes - http://icache.ihack.co.uk/?my
it's documented
?
it's an OO pattern you can use to build an object with static methods to store and retrieve variables. So you can put your objects into it, and get access to it anywhere through a static method on the class (not having to worry about accessing the global scope)
you will need to 'open' a url like this - http://icache.ihack.co.uk/?u=http%3A%2F%2Fwww.google.com%2F then view the ?my page
or you could just go and look at a frameworks Pagination class
that will provide you with a very simple way of creating pagination links
you give it an array and how many you want per-page, it generates the links
then again, I am not sure if it works in PHP4. I know it does in PHP5. I can code up a little example you can use, if you'd like.
I'm unsure what to search/look for exactly, could you point me in the right direction?
find a PHP framework, such as Codeigniters - download it, look for a Pagination class
of course, checking the license to make sure you can use it
CakePHP has a decent pagination class too
Can php (mod_php) so that when users use mail(), emails that bounce will return to a specifc address instead of nobody@hostname ?
Hello all
can it be setup =P
Hey … a "too stupid" question… but I seem to have forgotten it… if I add "\n" to a PHP string, it actually outputs as "\n" … how do you let it output a NewLine again?
maybe something in pph.ini
know where the pagination class is stored in cakephp?
that would be very nice of you.
show us the code of how you are doing it
just look through the source, it's not that hard to find it
this doesn't add a new line…
where should I start looking?
'\n' wont work, you need to do "\n"
in the extraced files you got from the archive
thanks, didn't know that.
s/extraced/extracted
there are a lot!
what can be the problem for my php application is denied multi connections of same phpsessid ?
the directories are named logicaly
the optional fifth parameter to mail() will let you do that ($additional_parameters)… if you're using sendmail on the backend look into the -f option
i think is phpsessid
it's a class library (hint)
because diferent browsers can open the browser
i need to force this so it doesnt depend on how a script is made
I have a very odd behavior. If a request comes into my server with only a "Cookie" specified, start_session, just reuses the cookie based session. If the same exact request comes in with a "Referer" header, start_session tries to issue a new cookie… any ideas as to why this is/how I can
prevent it?
Im sick of poorly configured wordpress installs, etc, having bounced mails go to nobody@hostname
do you admin the box the scripts are running on?
yep
Well, owner, not admin =P
the same browser cannot open multi-connections…. the connection stay on backend, only when first page open, the second page going to open
then create a small shell wrapper around sendmail that passes the -f option, then point php.ini to use that as the sendmail binary instead of the real one
cakePHP has a pagination class?? lol
thanks for the idea
np
"Results from select 2", etc…
got it, It states I need to define a "base_url" where the controller class/function contains my pagination. What does this mean?
bgot it, It states I need to define a "base_url" where the controller class/function contains my pagination. What does this mean?/b
it means the base url it will start creating the links from - basically, the page you are on
(is that the CodeIgniter one yeah?)
could you repeat that, I cleared the window lol
it means the base url it will start creating the links from - basically, the page you are on
Ok, yes its the codeigniter one
where do I input my "array" or links…
read the docs for Pagination on their websites
I am
s/websites/website
http://www.codeigniter.com/user_guide/libraries/pagination.html - totally lost
Its just stuff on the display options etc..
the example is pretty straight forward - go into #codeigniter for help on that
basically you need to do new Pagination( $config );
After more hacking it turns out that this is a "feature" of a default cakePHP installation. It has Security set to high, which in turn sets session.referer_check on…. *sigh*
header("Content-Disposition: $mode; $fname"); - what be supost be $mode and $fname ? (i am trying to understund download system + resume mode)
$fname i supost is filename
$mode i dont know what can be
hi
MalMen, http://www.ietf.org/rfc/rfc2183.txt
krustofski thanks
hello
why do people not like smarty?
it's a forbidden word
anyone here from England ?
KairuMaiku, haha,, ok,, why?
pick a finger or toe and be prepared to lose it
thanks, i'll have a look.
you want the english PHP channel. (har har!)
mostly there's no need for silly things like smarty because php itself is a templating system.
no, I just want to know anyone here is from England or not
KairuMaiku, hmm, well it does offer some nice simple features..
I am, lets go on a date!
have you ever been to poole ?
#phpc
ady, i'm in Ireland if that's any good.
wow, that's an absurd statement. There are good reasons to use a templating engine besides PHP. You can also it with PHP, but it's absurd to say it's never a good idea.
they do make no sense, why code a templating system in a templating language?
that offers the same features, but you have to learn a different syntax
yeah, but if you have a designer, then it's much easier for them to learn smarty.
hello…i am trying to exclude text from printing to my website…using str_replace ….cannot get it…will someone look at my .php file and tell me what i am doing wrong?
and PHP, imo, is much more than a templating language.
sure, paste it to pastebin.com or http://pastebin.ca/
Smarty is great, i love it
why? just use a design pattern that means your HTML files are just that, HTML files - never ever inside the php files
what pastebin
thanks
http://pastebin.ca/667233
you can see hwere i tried to put it
does strstr() work despite of linebreaks being in the string?
"templating" doesn't mean you have no php in your files. it means you're seperating out logic from them.
there is a difference between HTML in PHP and PHP in HTML
Hi, I cant make the php_fbsql.dll extension to load, does it have any dependencies?
I couldn't be sure what it doesn't work without seeing the actual line you're trying to replace as it outputs it to the page
the former means they are not seperated,
if that works for you. I am not arguing against it. There's a purpose for templating. Like when you want to internationalize, load a language config, etc.
they're not seperated in either case.
PHP in HTML is more seperated in the sense of what we are talking about,
http://theatomichiltz.com/index.php?option=com_mmsblog&user=3&Itemid=40
the goal is to reduce and favorably eliminate excessive logic in the tamplate. you're still going to have code there.
as in, the HTML view file (which may contain PHP) is not in the logic php file
its the easyedge text that appears on all the shots
yes, but like I said - there is a difference between HTML in PHP and PHP in HTML
yes, but if you don't want, for example, to allow your templates to read files, what do you do?
if you say so.
it works faster than a bunch of includes and crap :-\
or to make database connections, etc.
I have no idea what you mean by that
if it's done right, you shouldn't notice a speed difference.
i added line 132
why would you want a template file creating a database connection? O_o
sometimes. But if you consider caching, you can get a lot of benefit from templating.
my sites update too frequently to use caching
exactly, so PHP offers a lot more functionality than a templating system needs.
uexactly, so PHP offers a lot more functionality than a templating system needs./u
… what are you on about?
the str_replace looks fine, are you sure it's being called at the right place
i have to cache the data behind the site, not the site itself, because an element on the page is always changing
i think…
i tried all over the place
just because you don't see the point, doesn't mean there isn't one.
I am _against_ templating systems such as Smarty, but I am _for_ seperating logic from presentation
if some includes are making it too slow, you have bigger problems.
you could try something simple like just replacing the word easyedgeSM with wordhasbeenreplaced or something simple
I was trying to replace the string "xxwordonexx" for "ccess" but only on the links of an HTML code http://pastebin.com/m3790a74b and Im using $stripped=preg_replace("!a (.*?)(.*?)xxwordonexx(.*?)!","ccess",$stripped); without success
just to make sure it's in the right place
can anyone help me?
is cakephp any good?
I am for using a templating system where appropriate.
cool…well…if it looks like a good line than ill keep trying in other places
ive no clue
you're missing something to stop the (.*?) at the end from matching to the end of the line.
also, you have to use references to the captures in your replacement. the whole match is replaced, not just the parts you do or don't capture.
Say I have a PHP function that accepts a string argument. I want to be able to pass a value in for that string that says: "Ignore me! Do not use!". I would have thought that NULL was the obvious choice. But it seems as if, in PHP, NULL and "" are equivalent. Is this correct? If so, what value
should I use?
For the absolute LAST FREAKING TIME. The problem is NOT IN THE REGEX. The problem is in your REPLACEMENT STRING.
I've told you exactly what you need to do at least 5 times.
pass in false, and test for if $str === false
null and "" are not equivalent. use ===
You have to use the captured parts in the repleacement, such as "$1ccess$2"
ferguscan, "" == null is true, null === "" is false
null == ""
Ah, thanks guys. I'm a PHP newbie, and didn't know about the === operator.
from where i'm sitting, the problem is partially his regex.
he doesn't match the closing tag.
Is there a way to determine what Client SSL certificate was used to reach the current php page?
I think earlier TML gave a better regex so I'm not sure why it's back to that one
As long as he stuffs everything that was captured back where he got it, does it really matter?
on the same line.
Hello people
What's the easiest way to stored one digit to check every time a page loads?
Fair enough
TML sorry
i had to go and i didn't understood well
try looking at phpinfo() and see if you see the name of your cert in the apache vars/server vars/etc. you may also be able to set an environment variable from the client certificate.
What's the easiest way to store one digit to check every time a page loads? 1) text file 2) db 3) other?
also everything i tried didn't work before
in theory, using (.*?)foo(.*?) is bad too, since it may match a closing tag, and then 'foo' and then stuff, and then another closing tag.
I don't have an answer, offhand, because I haven't done a lot of client ssl certificate work. At least, not in a long time, and I never tried to validate it in PHP (or use its data)
It won't match a closing tag if you have '/a' in the match
It'll stop at the first one
sure it could
matching his word with a typo is far easier
it sees
foo /a
.*? will swallow up to 'foo'
no, it would fail because he's looking for "a .*", and you have no space after your a
TML and how can i break then the link's string and rename them as $1 and $2 at the same time??
it was a generic example intended to use TML's simplified regex. bite me.
can i save this as a replace.php and include once in the head of another php file to replace certain text that wants to print to my page? http://pastebin.ca/667247
That's a red herring.
Read php.net/pcre.pattern.syntax
sorry, I put a smiley in there. I'll bite caffinated.
There's a section on "back references"
this is usually why i tell people that DOM is a good idea for this stuff
can anyone recommend a site that has good examples of ways of handling form validation and all that fun stuff that stateless programming gives you
Except that DOM assumes the markup is well-formed.
yes, there is that problem.
of course, if you don't control the html, you shouldn't be scraping it in the first place
and if you do control the html, then you control the data ssource, and you shouldn't be doing it anyway
Well, controlling it does not, unfortunately, insure that it's well-formed.
How would you using PHP, access another website, which requires a cookie to login?
depends. I usually use cURL.
mrpoundsign, Where do I find cURL?
TML pdf_begin_pattern ??
but it does mean that if it's not, you can fix it
Multiply, curl extension is handy for that
if your PHP script is in the same domain as the login cookie, you can use that cookie.
I'd have to create the cookie.
otherwise, you need to log in, perhaps with a cookie jar.
I'll try with cURL
http://curl.haxx.se/libcurl/php/examples/ebay_login.html
but you may want to base your cookie file off the logged in user, or the session ID, or something. There can be a lot of problems with this, such as cleaning up stayle cookie files, etc.
php.net/pcre.pattern.syntax
Or that you can rely on it being "consistently broken", which is where I usually end up.
does anyone have a function that sends a telnet command and waits for it to finish?
I have had pretty good success with http://htmlpurifier.org/ — but the scope of my usage is pretty limited. (HTMLized comments, forums, etc)
http://blogs.pcworld.com/tipsandtweaks/archives/feature.jpg - LOL
http://pear.php.net/pepr/pepr-proposal-show.php?id=284 ?
oops, that's not a package.
I could have sworn there was one.
oh
the thing with it being broken though in a case like this is that the regex method isn't going to work in some cases either.
/join #slackware
tag content replacement.
hmm, there are a few classes floating around. you can also 'popen' a telnet session, etc. Are you looking for interactivity? Do you need it to remain open between requests?
XPath for the win
indeed
TML im lost with all those functions
isn't there one that does the captures automatically?
do you understand what a capture is, and how to use it?
I got an "extension not found" error trying to connect to sql server via pear DB. How does one install the extensions?
it's ok if you don't, i can help explain it. but it makes it easier if i can get a feel for what your level of knowledge is on the subject.
caffinated i am doing $stripped=preg_replace("!a (.*?)(.*?)xxwordonexx(.*?)!",$1."ccess".$2,$stripped); but i need to capture somehow all before and after xxwordonexx
into $1 and $2
ok, yes, those are captures. however, captures start at 1, so you actually have 3 there
is $1, the one before xxwordonexx is $2 and the one at the end is $3
anything in () is a capture
there are two problems with your regex. the first is that you have no closing tag to match against.
FrontBase dll for PHP5 where can I find it?
by default, '.' means "any chaarcter except newline"
* means "0 or more times" and ? on a quantifier (the *) means to make the match 'ungreedy'
so what you're doing is making the final match ungreedy to the end of the line
'ungreedy' basicly means "stop matching at the first occurance of whatever comes after this"
the second problem is one i iterated over earlier
In order to enable this module on a Windows environment, libeay32.dll and ssleay32.dll must be present in your PATH." - Which path, and where?
aha
Multiply, THE PATH
if you have two anchors on the same line, and one contains your target string, and the next doesn't, it's going to match all of the first anchor, and all of the next
%PATH%
(well TML was shouting at me before that the regex was fine)
Multiply, check your PATH environment variable
err sorry, backwards. if the first doesn't and the next does
I cant believe the regexp sledgehammer obyone wants for a simple typo like that $yourdoc=str_replace("axess","access",$yourdoc); will fix for him
anyone know the redhat package name to install php support for sql server?
Neither of the things caffinated is talking about have anything to do with the problem you were complaining about at the time.
Even after understanding caffinated's point, you'll still need to learn how to use the captures in your replace.
In the php.ini?
so, if this second point is not a concern to you, you could use !a (.*?)(.*?)yourword(.*?)/a!
No. %PATH%.
http://se.php.net/manual/en/faq.installation.php#faq.installation.addtopath
Your operating system has an environment variable named "PATH"
but i would be aware of point #2 as a potential flaw
It contains a list of directories
The DLLs need to be in one of those directories.
Lol
Now I got it.
caffinated is simply addressing the point that I wrote a regex to specifically target the text you provided me as your source document. Instead of writing to a particular document, he's elucidating the general concepts involved in matching markup with a regex.
I thought it was the stupid config files :p
I cant get frontbase extension to work on Win, it says that it cant be fount, other exts works fine, ist it dependencies or what?
TML so what im doing cant be done
did i miss the point? i did sort of come in halfway
*shrug* I asked him to show me his source HTML, and I targetted it specifically.
What you're doing is definitely "more correct", I simply lost patience with obyone hours ago.
ah, gotcha. i have not seen that part. i just noticed specific flaws with the regex which may or may not stop it from working
He doesn't seem to understand what I consider to be fairly simple English phrases or snippets of code.
i see. so you're working on the basis that each anchor will occupy a single line
sorry if my english is a bit italian
then - TML is right. you just have to use the captures correctly.
can someone please explain $_FILES['userfile']['name'] to me? what is the 'name' part?
that is the name the user specified at the time of upload
if i upload foo.gif, that variable will contain 'foo.gif'
I thought the 'userfile' was that
caffinated and any idea on what functions to include inside the main big function to capture??
can someone help me with RSS? http://paste.css-standards.org/23459
because there are several components to the aarray for a user file upload, ['userfile'] represents the portion of the array which deals specificly with that upload element
Well, the reason I didn't "argue" the point was because you're absolutely right: it's better to teach the correct principle. I just lost the patience for it with him.
a form can upload more than one file at a time
ah…..okay, thanks
so both are kinda part of the name
everything validates except one of the pubDate
no problem, i could see there was some frustration. i just tried to make it somewhat clearer to him.
what security risks to I need to address? I only need them to be able to upload images
TML you are right after the whole afternoon im more focused on the solution than on trying new functions
No one suggested, at ANY point, that you try any new functions.
the capture ones
i mean
There are no functions involved
http://blogs.pcworld.com/tipsandtweaks/archives/feature.jpg (it's a feature, not a bug)
We simply expect that you understand the one you ARE trying to use *before* trying to use them.
LOL. That's great.
anyone here that is good with MySQL stuff?
yeah, my boss just sent me that. i love it.
using setcookie(), can I update information on an existing cookie? And, if I set a cookie with the same name, will it be overwritten?
any idea why the php_flag register_global On in .htaccess wont work?
TML thanks
is there a way to unselect a database?
#mysql
i'm asking about a php command though…
mysql_select_db() a different one
i see no point to using mysql with no database selected though.
Where is the php5.dll file? I'm trying to use dependecies checker and it asks for the php5.dll not the isapi dll
TML but ive never done captures before and i find it yet as a very complicatid thing to deduce myself
is it a lot of code that i need to add?
maybe is an apache issue, probably I shouldn't ask here, I just thought someone might met it before.
it's not, really. each capture - denoted with () - is numbered. they start at 1
I'm modifying sugarcrm and I guess it doesn't like my $db_selected variable. I have tried unset on it, but the database remains selected. I need something that will unselect my database
if anything is confusing about that, it's that it starts at 1 and not 0
so tha captures have been done already, i just need to show them up??
well, yes. once a database is selected, it's selected. altering the variable will not change that.
however, this should not make any difference at all
so how do I unselect said database? or is there a different method that you would recommend?
you don't.
is there a file upload function in php that only allows images?
you use the link resource and select a new one. there is no purpose to unselecting a database
swirr you can check mime type of uploaded file
after a file is uploaded to my php server, firefox has that file "in use" until I close firefox. any ideas?
my functions point to an osCommerce database. I need the osCommerce database not to be selected when my function finishes
contact firefox support
sounds like a firefox issue, not a php issue…
swimrr*
your problem is different then. if your software is designed properly, those would use different link resources.
can you point me to some info on how to do it?
or the correct database would be selected at the time it was needed. there is still no point to unselecting a database. there may be a point to selecting a new one though/
ok, ty
Hello all, what would be the BEST way to go about keeping some sort of history for records based on an Event? Say I have 2 tables, one with personal information and a few fields that may change depending on the event at the time, which the events are stored in their own table
This is more a MySQL question but
Many people can fall under the same event thhough, its more for statistical research later down the line, based on the event
And, the event will not ever be re-used
image/jpeg
okay
and you get mime type of uploaded file in $_FILES['file']['type']
which you should never use
Anyone good at extensions on windows, I'm having an emergency ?
Well, you should never blindly rely on
imo, you should just never use it, at all.
there are better ways to test if something is an image or not.
Fair enough
I will often check $_FILES['file']['type'] vs. fileinfo and if they types do not match, I will bail immediately.
I assume it's a malicious attempt.
swimrr, and than you compare. example:
if ($_FILES['datoteka']['type'] != "image/jpeg" AND $_FILES['datoteka']['type'] != "image/pjpeg") {
unlink($_FILES['datoteka']['tmp_name']);
boha…thank you
sure. i usually go a step further and run it against getimagesize() in the case of an image.
i guess you weren't listening during that conversation
I think it's probably a semantic issue…I consider "reading $_FILES['file']['type'] in order to compare it against something else" to be "using" it
don't rely on that. it's very, very insecure.
caffinated, sorry i wasnt reading your posts
$_FILES['file']['type'] is incredibly trivial for evil-doers to tamper with. Use something like pecl.php.net/fileinfo or php.net/getimagesize instead.
that would explain why you were leading him in to incorporating a very large security hole in to his script. mimetypes are sent to the webserver from the client. they are very easy to fake with a crafted request.
Those actually inspect the file itself.
thanks - can you show me an example script?
caffinated, can you give more details on how to fake mimetype ?
lol
send your own content type.
Do you know Omar Kilani at all?
caffinated, yes but how can that be done ?
The browser sends the content type
it really is that simple. http requests are just text over a socket.
All you have to do is "telnet hostname 80", forge an HTTP request, and specify any mime type you want.
ok tnx you guys for explaning
PHP5.dll - I see this in the dependency walker but I cant find the file anywhere I use isapi
Or, if you're less skilled, install something along the lines of the firefox addon called "TamperData", which gives you a GUI tool for munging any part of the request you'd like
i didnt know that is a security risk
:-)
There's absolutely nothing wrong with ignorance.
oh, I know…I was just stating a fact
Ignorance can be fixed.
;p
can you guys show me an example script?
if i'm going to have a user manually order things… whats the best way to go about that?
it's a great reason to idle here, you pick up things you didn't know you didn't know
actually, if I'm using image magick, will that address all the security issues?
agreed
How do I extract a .tar.bz2 file in a server with a PHP script? I tried doing exec("tar -xvjf file.tar.bz2"); but it is not working it seems.
bunzip2
was there some problem with the manual?
those functions that TML gave you are not complicated.
lol - its not in english - its in tech
oh, okay…I'll look at those then
snoop-, tried it just now. But it too is not working.
does using something like image magick address security issues, since its for images
did you understand the fundimental problem with how you were going to do it?
why do you run it against getimagesize() ?
I keep getting an error 'Unknown column '2' in 'field list''
When you're doing SQL queries that you know returns only one string, is there an easier way to fetch it than going something like, $row = mysql_fetch_array(mysql_query("…")); $thing = row[0]; ?
I think so - you send a fake mimetype and upload a malicious file because you get around the img requirement?
rule #1 of web development - assume the user is going to lie to you, any way he can.
fundamental
this means, if it comes from the user, you should expect that it's wrong by default.
assume the user is out to hack you
yeah, but people like me don't know all the ways they can lie to you ;p
you will find out
hehe
everytime you get haxored
hopefully you don't find out too late
Please - Has anyone got FrontBase extension working for PHP5 on windows?
that's fine. we told you how it could be done there. now, you were also told that the methods provided check the contents of the file, as opposed to a single piece of easily forgeable data
What is "FrontBase"?
both of which are well documentedc.
php.net/frontbase leads nowhere
As does pecl.php.net/frontbase
i'd ask that you at least *try* to help yourself once in a while.
thanks
I'll try
TML fbsql
Which more than likely means it's a third-party piece of software — and ##PHP doesn't really have the capacity to support those.
Ah. That *does* go somewhere.
So do you have the frontbase client installed?
TML Yes my problem is that I had a PHP 4.1.2 running and I now updated to PHP 5.x and theres no dll that works
and yes, i'll take a 'B' on my report card today
I've tried the dependency walker on the one that krohmann has
And?
it stops first on php5.dll