Another useless script on my trashbin.
hrm..
It works well enough I guess
http://hashphp.org/pastebin.php?pid=22986
Interesting. Would've been cool if you turned that into a single
big image.
Not a big step anymore. Just CBA. :]
Your error is obvious. Line 38 says "if ($room1='' ||
$room2='')"
does that say a threaded monkey
I guess I'll reimplement that for my IRC clients UI, though.
threeheaded! :[
that's why you do it if ('' == $room1 || '' ==
$room2)
You mean to say "if ($room1=='' || $room2=='')"
mybad SlashLife
In your code you are reassigning $room1 and $room2 to an
empty string (''). So it is doing basically:
$this-loc['']-isAvailableDir($room1Dir)
I've only been codingsince 1977... and I still do dumb things
like that...shame
1977 O_O
.oO( I hate that year. _
ohh, sorry...how about 1978
Oh and by the way... I don't see the usefulness in "return
'true'" and "return 'false'"
im telling you man, start writing your conditionals
backwards
Not really better. :/
you'll save so much time :p
yeah, you're right
Because I'm not sure whether I hate 1977 or 1978, so I hate
them both.
just a placeholder fo rnow
us stoners know our shit man :p
I guess it sucks that I've only been programming for 4 years
and I spot your so-called "dumb thing" :P
..2 seconds after I opened your pastebin page
younger eyes :p
i used to write complete systems (accounting packages,
inventory, etc) in mneumonic assembler back then... and I still get
creamed by ==
yeah, I have 4 that don't work well
I have bad eyesight, btw
heh me 2 :p
And all along, I was right. It was a problem with how you were
accessing the array
And all along, I was right. It was a problem with how you were
accessing the array
hahaha, you're really rubbing my nose in it. fair enough
Just messin' around
Anyone could've made that mistake. I make mistakes like that
over long nights.
php hurts my brains
The thing is, once you've made a mistake such as that, your
brain focuses to the next part of your code.
That's why it's so much harder to spot it.
U guz kan haz an eazeer language
lolcode ftw
kthxbye
yes. i wrote a long piece the other day using dynamic
variable names... that was a bitch too
wutz no luv 4 lolcode ?
That's why you use an associative array instead of dynamic
variables
i hate those, as useful as they are...it's like (if anyone
remembers) computed goto's
fine...
that would be too easy
No, easy is writing a program using a text editor :P
well...sometimes...nevermind
well, while I'm here...let me ask something about php host 5's
handling of objects. It appears that given a member, let's say,
SIZE, that unlike some other languages, I can't have a set(size) or
get(size) that are invoked automatically when the code sets or
gets, that I actually have to invoke the set/get method name. is
that true?
php.net/oop5 -- Read the section on overloading
will do...you're two for two. I think I'll go now...if you get
to 3 tonight I'll have to hang myself Thanks.
np
If an html form never sent
data to $_POST['variable'] - but I then set $variable =
$_POST['variable'] is $variable considered 'set'? I'm trying to do
error checking for whether the user forgot to enter data but if
(!isset($variable)) { echo "empty variable"; } isn't
working.
is something else setting $variable?
how can i grab information from my address bar. ex:
page.php?get=x and then in php if(get==x){}, but that doesn't seem
to be proper syntax, what is?
no, nothing other than setting $variable to
$_POST['variable']
i don't understand, i set xdebug.remote_autostart="1" in
/etc/php/cli-php5/ext-active/xdebug.ini but phpunit foo doesn't
trigger the debugger which is indeed listenning for connections. Of
course this setting isn't working in the apache2 php.ini, but when
the XDEBUG_SESSION_START is sent in http request : debugging is
possible. Using xdebug 2.0.0_rc3, php 5.2.1-pl3-gentoo, any idea
please ?
according to http://xdebug.org/docs-settings.php,
this is the only thing that i have to do to get the debugger on CLI
(autostart)
what happens if you var_export( $_POST )?
$_GET['get']
kk
anybody have a copy of cutenews handy? Site is down
anyone know if there is a minimum number of characters that
need to be sent before a "headers already sent" warning is
sent?
wow. i used the word "sent" three times.
hahah
yes, any
then why am i not seeing that behavior?
you must send /no/ characters before you use header
you may have output buffering enabled
the only way i can get it to warn me is by sending many 100s of
characters.
try sending a single newline
didn't work.
what didn't work?
the newline didn't cause the warning.
pastebin the code you're using
minimal. test. case.
first, phpinfo() says "output_buffering 4096 4096"
does that mean it's buffering up to 4096b?
it looks like it would buffer 4096 characters to me
i see.
then changing it, i must.
http://pastebin.com/931079
my tests would made sense then.
while(ob_get_level()){ ob_end_clean(); } # or similar
where should that go?
at the top
before you send any output
ok cool. so i can include that in a global include file?
i'm sure you can do it with an ini_set in a more friendly
way
yeah i just did that. i'm about to test it.
dang. still no luck. perhaps i've got the value wrong.
ini_set('output_buffering', 0);
i also tried 'Off' instead of zero.
anyone know how to properly turn off output_buffering using
ini_set()?
danggun it
Can't be done with ini_set()
?
ahhhh... i see.
http://us.php.net/manual/en/ini.php#ini.list
"PHP_INI_PERDIR"
"PHP_INI_PERDIR 2 Entry can be set in php.ini, .htaccess or
httpd.conf"
crap
my host (dreamhost) doesn't run php as an apache
module and so i can't use .htaccess.
are you sure you don't get .htaccesses anyway?
since .htaccess is read by apache, not mod_php
i already tried using it for setting the include_path but it
wouldn't work unless i did it through ini_set().
but also i verified it with support. they said ini_set() doesn't
work because they run php as a CGI.
ah, that'll be why it failed when i was playing with a
friends account then
they did however say that i can install php host myself but... that's too
much trouble for me.
how do you mean "install php yourself"?
well, basically i can compile host a
local install of PHP for myself so that i can have access to my
php.ini file.
i'll send you their wiki
hosting page on it. just a minute.
here is their response:
Changing PHP values in this manner is only available when php web hosting is setup
as
an Apache module. Since this poses a major security risk, we have
PHP
installed as a cgi
binary. To modify a php.ini value simply refer to the
following Wiki article:
http://wiki.dreamhost.com/PHP.ini
a href="http://wiki.dreamhost.com/PHP.ini"http://wiki.dreamhost.com/PHP.ini/a
not sure but i guess this will force me to write a better debugging
function anyway. :|
what do you mean?
you should be doing your "debugging" by running unit tests
tell me more about these "unit tests".
you snag a framework, you write code that says "when i call
foo(x) i expect the result to be y"
when you run the tests, it calls foo(x) and if the answer isn't
y, the test fails
you can use more complicated rules than exact equality
the idea being that you decide what the function (or class) will do
first, write the tests for the class
you run the tests, and everything will fail (at first)... you
put the class together until all the tests pass
hmm... which framework?
(most people don't write the tests first, but write them at
the same time instead)
You also hope you don't screw up the definitions of the
tests.
a testing framework, which one is not important
suggestions?
obviously the tests are code too
simple test is the one i've been using
thanks.
and if the function isn't well defined, then you shouldn't be
coding it anyway
tags and outputting that.
just a simple "what's $x right now?" kind of thing since php
doesn't do stepping.
there are debuggers that will allow you to step through php
code
you may not be able to load the debugging module though
oh. yeah.
I've gotten by without a debugger just fine... I wouldn't rely
on those.
But I suppose they can be helpful. Just don't forget how to
var_dump() when you need it.
if you require a debugger, your code is too complex
except for experimenting with this unit test stuff, my plan
is to write a debugging function that neatly prints the same output
as print_r() or var_dump() to a log. i'll just watch it with "tail
-f" as my page executes.
sound ok?
that'd work, depending on how you handle your logging...
logging.apache.org for log4php
my first attempt at the function looked like this:
function write_log($message, $line = '?')
{
// open the log file
$logfile = fopen($GLOBALS['logfile'], 'a');
$new_message = '['.date($GLOBALS['date_format'],
time())."]\t{$message}\t".$_SERVER['REQUEST_URI']."\t$line";
fwrite($logfile, $new_message."\n");
fclose($logfile);
}
PASTE BIN DAMN YOU
oh sorry. i thought that was just for really long stuff.
that's a terrible way to do logging
no, the rule is no pasting in the channel, at all, ever
ok. no problem.
(well, of code anyway)
not that it's a problem for me, but why?
3 lines = pastebin
also, your logging will fail if 2 requests are made at the same
time
and not even typing many lines of code manually, of
course
your log will be butchered
because of file locks?
or the lack thereof, yes
because of the lack thereof
lol
oh haha.
also, there is no meaning in the logs, just strings
glad i'm learning this now (at the start of my project)!
you can't later stick the stuff from that function into, say
a database log, or have it emailed in any meaningful
way
yeah i'd thought about how to make it useful if imported into
another program but i wasn't sure how to approach it.
log4php already does that, and more
i'm looking at log4php right now. does this "fix" my
problems?
i see.
it will "fix" your logging, yes
well... here goes!
hey another question... what's the recommended way of setting up
configuration settings? as you could see in my logging function i
am currently assigning values to $GLOBALS.
is there a better way to do that?
named constants, if that will work
a global associative array will work fairly well too
3 named constants
$config[mailer][smtp_host] = 'mail.foo.com'; etc
have a file filled with them for every project
except they can't be arrays, or objects
what are the merits of named constants?
what's on the can
they're constants
and they're named
they are readonly and they are only scalars
but if you need an array, then don't use them, obviously
so let's see... these $GLOBALS that i'm using now won't
change (except during initial setup) but at the same time i do like
the idea of group values together (e.g. associative
array).
then define it in a common file and include it in all the
files that use those values
yeah that's what i'm doing. i guess i'll stick with it.
thanks.
anyone know of a good performance profiler for php?
hi
!tell SeLfkiLL about g10
van be runn php4 with mysql in windows?
anybody has done thgis setup?
indeed you can
how
I get this error , and I checked everything:
xamp will do it all for you
performance profilers aren't generally scripts (I was looking
for some opions on pear or pecl packages)
haven't been on windows in ages, but there are some packages
that install apache/php/mysql, etc all in one
mysql_connect() [function.mysql-connect]: Client does not
support authentication protocol requested by server; consider
upgrading MySQL client in....
pear is 3rd party
no pear in here plz
yes, i know wanp, but it install php5 and mysql5
I need to have php4 and mysql5
doesn't it install both php4 and php5?
meh I guess I'll ask somewhere else then
weel, I did a manual setup...
so you picked those options, and are now complaining about
them?
well, the issue is that everithing is going ok
till i tried mysql from php
and I dont' hacve any idea of why it does not work
so you need to load the driver for the right version of mysql
you're using
perhaps you want mysqli
or you want to not have mysqli, depending on which version of
the server it is
well
its 5..027
but the isue is that seemsd that php 4.4.6 has an integrated
driver for mysql
it'd still be a module
and conector*/php only works for php 5
so using vconector/ph p with php4 gives an error
what is connector*?
sorry
connector/php i was meant
http://dev.mysql.com/doc/refman/5.0/en/old-client.html
--- interesting
does log4php require PEAR? i didn't mention it on the website
but the INSTALL file mentions it and so now i'm not sure.
it* didn't mention it...
if it required pear, it would be listed
I need to round the current time to the nearest 15 mins
how can I do that
use mod and *
whats the function to strip blank ascii?
mod's not what i want at all
"blank"?
spaces
f00li5h, spaces
just spaces?
what about tabs?
f00li5h, yes
that too
i'm sorry, but what exactly do you want?
how about nul/hor-tab etc?
or most of the unprintables?
5.70 and I dont want all that space infront of the
number
perhaps you should instead only extract what you want to
keep
will there be anything else in the string, besides that number?
trim, ltrim or rtrim
perhaps you can add zero to it, and then format it with
sprintf
f00li5h, nope, just number setup like that. currency
actually
http://www.topicify.com/poll.php
- anybody know why the stats here differ from the ones in http://www.topicify.com/cnnrepublican...all
I did was PHP include("cnnrepublican/index.php"); ?
Is there a shorter way of defining 128 0's in a list then
typing it out?
f00li5h, how could I extract only the integers and the
decimal?
oh lol, hey there
hrm?
well, you could use preg_match_all and capture the bits you
want
you could replace any non-digit/dot character
or you could just ltrim/rtrim/trim it
f00li5h, im trying ltrim now, thanks
you wouldn't know how to do the perl thing you told me about
in php would you?
which thing now?
(0) x 128
array_repeat
or array_fill, i'm not sure
okay thanks
f00li5h, worked like a charm. thanks mate
http://digg.com/2008_us_elections/Ron_Paul_On_FOX_NEWS_Video
erm
sorry
are you porting a perl script to php then?
log4php is driving me nuts. using this page (http://www.vxr.it/log4php/qsg.html)
as my starting point, where is it getting it's setup information
from????
it's config file
is that LoggerDOMConfigurator.php in log4php/xml/ ?
yeah
don't bother
why...
hello?
he might be busy doing something else...?
Tarantulafudge, do you need 128 0's in a string?
I figured that part out, thanks
is this the proper way to do it? $vquery = "SELECT * FROM
`COMMENTS` where `tvshow` = $tvshow AND `cid` = $cst['id'] AND
`type` = '$type'";
array_fill(0,128,0)
Tarantulafudge, if you need it as a string you can also use
str_pad
cool, thanks
no, it's a list
f00li5h, nah I didn't know
Hi, I use PHP shell and would like to send an email to myself
everytime someone logs in to the web interface. Whats the best way
to go about doing this?
why should I 'not bother'
i'd arue the perl version is faster, more secure and easier
to maintain (and that's without seeing it)
what don't you know?
f00li5h, I didn't know what he wants...
well personally I think perl is slow on websites but I could
be wrong
I still don't. but nvm now that you're back you can talk to
him
don't get me wrong, thats not why i'm porting it
oh, then why are you porting it?
if you're running straight CGI, it'll be far slower than if you run
with mod_perl, or fcgi
I just need it as part of an app I'm writing for my
website
I can't find the specific code in any other languge
what code?
its to decode bacula's broken/nonstandard base64
implementation
who's?
using code from "recover.pl", its nearly identical to
php
what are you trying to md5?
anyone have tried using the pdflib shared object? After placing
the .so in the extension_dir and adding the required line in
php.ini ..Im not able to restart my apache...
my apache crashes...
I'm trying to decode File.MD5 but its encoded in bacula's
wierd base64 format
is it a problem to do with apache or php...?
you may need to recomplie the module
http://www.aha.com/bacula/recover.pl
its a subroutine called "from_base64"
yeah ..will try that
why not just shell out to the perl script and have it do the
workf ory ou?
because recover.pl does something entirely different, and i'm
pretty sure running exec(perl blah.pl) would be slower than just
using php to begin with
so you're using base64?
'cause i'm pretty sure php has a function for that
php has a function to decode standard base64, but bacula's is
not
this script looks like a crap version controll package
yea but its the only place where I've actually seen how to
decode the md5 sums
bacula's md5 008TT6/8QF+FRG/yiwx0BB and my md5
917cb8a3d1d9eb24af6c5bcf3bf7e401
those are not the same files but I just wanted to show you how they
look different
well, you should be able to easily translage between
them
how so
if it is actually md5, the only difference can be that it's a
substitution cypher
if you have the time i'd appreciate your input on the log4php
issue. how do i specify (or find out where) the configuration
file?
the page you linked me to has links to the docs on those
constants
yeah and i read them. but they don't make sense. it doesn't
tell me where to set them and i can't find 'log4php.properties' OR
find instructions on creating a configuration file.
it says in the example code
/* Set LOG4PHP_* constants here */
oh duh. ok that's one piece of the puzzle. :|
array(9) {["talk"]=array(3) {...} ["edit"]=array(3) {...}
["history"]=array(3) {...}}
when I add new element, how can I change the possition within the
array of where it will be inserted?
like if I want new element to end up #2 right after
"edit"
gcardinal, $array['edit'][2] = 'new element';
is it what you're asking?
you'll have to reconstruct the array
garotosopa not really
f00li5h so there is no way to insert in a sertent place?
the traversal order is determined by the order the elements are
added, so you will have to remove all the elements after the spot
you're intersted in, add your element, then re-add the old ones
no, there is not
okey thx!, at least I am on the right way
how can i get the ip of the person trying to access my site?
$_SERVER['REMOTE_ADDR'] is reliable?
Athfar, it's reliable until the person is using proxy
isn't*
you said it right the first time
So you want proxy's IP, not the real one?
no lol
you answered my question
is it even possible to get the users ip from not the
proxy?
or if they are using a proxy
does this channel have a bot
like tell smth something
and it tells
php-bot
when I do a var-dump of my foreach can I have it give me all the
data back?
you can vardump a loop?
well, thats not really what I ment, I'm sleep and been
working on this stupid thing for a while. I am a lil confused with
the loop I have not, im posting a pastebin, one moment.
bwell, thats not really what I ment, I'm sleep and been working
on this stupid thing for a while. I am a lil confused with the loop
I have not, im posting a pastebin, one moment./b
http://pastebin.ca/573542
sorry if it looks bad, pastbin doesnt work well with long lines
of copy
ok - where are we supposed to look...
any particular lines?
144 - 170 is my XML parse
The first 100 lines of so are just data examples so you can see
the XML
Does PHP support duck typing? For example, if I write class A,
and a function in that class references method Q, does Q need to be
implemented in A, or is it OK if Q is implemented in B, where B is
a sub-class of A?
Assuming I never use an instance of A, that is. And only use
instances of B.
is B an abstract method in A ferguscan? if so - I think it would
work... though I am unsure if that would be considered late static
binding - and PHP has a problem with that
So is there a way to expand my loop
is there an efficient way to find overlaps between 4
numbers?
like, 300 -- 400 with 350 and 410
what means when there is a _asd
lig, Q is the method, and has no definition, abstract or
otherwise, in A. But it's called from some of A's functions. It's
then implemented in B.
lig, I come from the world of Python, where such things are
possible, and even normal.
ferguscan, then I doubt it could be used in A since it
doesn't exist yet when A is loaded
how to tell bot to remember smth?
marltu, without the proper karma - you can't
lig, OK. I will have to put in abstract shells for the
methods in question. Thanks.
what's the cmd?
marltu, if you have the proper karma - you would know
i want to make bot like this
and i need good examples
1 84-16-233-231 /USR/SBIN/CRON[9838]: (root) CMD ( [ -d
/var/lib/php5 ] && find /var/lib/php5/ -type f -cmin
+$(/usr/lib/php5/maxlifetime) -print0 | xargs -r -0 rm)
automatically installed after installing PHP via debian
package
id rather not have old files deleted ..
What is the best way to Parse XML data in php?
for RSS feeds in XML there is "magpie"
well
this is not RSS
its XML data for weather
php.net/xml
The manual is your friend
I have looked at the manual
say hello to my little friend!
and I have quite a bit of working code
X++
http://pastebin.ca/573542
I just need to extended my loop to get more nodes
mar++
marltu++
karma for marltu?
usually setting positive karma on yourself results in twice the
negative karma
RLO|RyanLanham, what version of PHP?
5
look into simplexml
ok, I hate dumping what I already have lol.
much easier
it's one of the other m8\
just pull the pants down and get over with it tbh
that's an obscure way to say "you get a -- instead of a
++"
lol yes yes, I lose a point
and ++ to lig for the help
brb gonna see if that will work.
for ($i = 0; $i sizeof($arr); $i++) if (some cond)
unset($arr[$i]);
does the sizeof() get recalculated?
so I got it outputting the selected tags
how do I loop it and save it as a usable array?
I tried
$value) {
echo $head.$value.'br /';
}
sorry thought it would go on oneline...
I'm trying to create a database export function like phpmyadmin.
I have a binary (blob) field and phpmyadmin exports it as the hex
string "0x21b14ea77222531a5103a7255dd7aad1". The function doing the
conversion is $values[] = '0x' . bin2hex($row[$j]), however when I
try this function on the same field, I get
0x2b7217ed723c62960db9cf8b566f011a. Would it be using a different
character set before the conversion? If so, how would I alter it to
get the same result?
good morning bots
morning
why are you doing this? It's a waste of time
MikeSeth, how so?
when I make an array using foreach...how do I know what to
call it in my var dump
don't understand the question
if you need to move a database, you have mysqldump. If you need to
export data you have SELECT INTO OUTFILE
Well I have an XML doc.... with 8 elements in it. SimpleXML
works fine getting the data, I just don't know how to make a
foreach loop to turn it into an array
turn what into array, an element?
can I PM you...I don't everyone to have my XML acccess
key.
MikeSeth, i'm just trying to make it so that if i lose my
database I can just paste into phpmyadmin and if I have binary data
it may not save correctly
MikeSeth, which is why I want to save it as a hex
representation
no, pastebin instead
you have pack()
MikeSeth, unpack() produces the same result as above
pastebin would thwart the idea of me pm'in you....im just pm'ing
you a link to protect my sys id
but ill just a make a paste bin
with the xml
MikeSeth, I tried unpack('H*', $entry[$n]); and unpack('h*',
$entry[$n]);... they are just swapping every second character with
the next, but still not the right result
http://video.google.com/videoplay?docid=9006414844032752909
http://pastebin.ca/573594
There yea mike that should clearup what I was trying to say
any thoughts
Hi all, how I set the expiration time of a session in
php5?
http://www.phpfreaks.com/tutorials/77/0.php
might be worth a look
care.
we were saying? i was kinda away
I need to take the XML found here http://pastebin.ca/573594 and using
SimpleXML make it a useable array.
so I can store it in my db
okay. You know SimpleXML has type coercion tricks right?
I don't hardly anything about it....I just know that all I
want to do it take this stupid XML thats been a PITA and make is
usable lol.
errr wait what are you doing
$xml = new SimpleXMLElement($xmlfile);
wtf is this
who told you to do that?
manual
what's wrong with that?
he has a -document-
er wait. Does he?
nope
http://xoap.weather.com/weather/local/60660?cc=*&dayf=7&link=xoap&prod=xoap&par=1041664096&key=f994b09b54a50df8
my offsite XML
yes, he does.
not from file_getg
oops
not from file_get_contents
http://il.php.net/manual/en/function.simplexml-load-file.php
hi
i want use pointer in php
it is possible?
either way, you get back a SimpleXMLElement object.
there are no pointers in PHP
but the &$var ?
I am getting them not
Those are references.
now*
But they are NOT pointers.
dexter_man that's not a pointer.
I can get individual tags from an echo
I can even vardump things
what I need to do is take tha data
ok, lemme actually look at your code
and save it to my db
who are you refering to?
you, apparently
pl
ok*
oh. I see what the problem is.
SimpleXMLElement is a tree. You are only scanning the innermost
part of that tree.
http://pastebin.ca/573620
Right that I understand, and I have not problems with that, its
trying to get the data that I can access from a var_dump,
saved....
what is the run time of insert and select for associative array
$foo['bar'] = 1; echo $foo['bar'];
yes. I think SimpleXML may not be your best solution here.
on the other hand, SimpleXML has xpath support. You should use
it
Not important. That's what it is.
This is becoming over complicating and stupid.....all I need to
do it loop through and external XML file and save the array
data....didn't think it was going to be this much hassle
SimpleXML is nice when you have to fetch a few values, but if
you need to retrieve contents of the entire document, you'll have
to write a lot of code
well, loop through what? the entire file? a particualr section?
if you want the whole of it, well, do this: $array = (array)
domxml_load_file($xml);
I think its a bad idea. But, well.
All I need to do is save that file on a hourly basis in my sql
as an array to call it back out.
So I don't get sued for hammering the weather.com's severs lol
servers*
then you are most certainly overcomplicating matters, because
it's something that wget + cron can do
again, arrays are linear, SQL tables are linear, and XML is a
tree.
so.....
I should write a cron
to save the xml file to my db
Well, no. You should write one to store it into a
file
kuja, heh?
ok
and then just use simplexml to pull the data I need?
You can, yes. I dont know what youre doing with the data.
Most likely I'd use XSLT or dom + xpath to translate it to what I
need
yea, I need to work on figuring this whole XML thing
out....there are a ton of places that provide content that
way
well, then most certainly you should read about XSLT and
XPath
hay dav7
will do
thanks for the help
hey MikeSeth
welcome
sup dav7
hmm.
not alot
I actually gave up on that notes thing because I can't figure
out authentication for all I'm worth
and I really don't have the motivation to go and figure it out on
the net
*eyeroll*
so yes, another... thing... added to the trash heap
^ michlemken
oops
^ MikeSeth
lulz
right now... I'm enjoying listening to an, uh, *checks* XM
through my SB16 with the bass like [-------------------#] that
XDXD
^ MikeSeth
re
so nobody knows ther runtime of php associative array
operations?
nuh me :P
The runtime of php associative array operations? You're going to
have to clarify that.
4.5 seconds
How long is a piece of string?
etc.
you cant figure authentication of what?
the number of operations O(N) amortized O(logN) O(N*m) N=size of
array m=average letters per word
hi
oh, just login/logout etc. It's beyond me, as is saving/loading
of files. So I just gave up xD
well. Poke me when you change your mind
(that's the truth)
personally, I don't know. You can ask Pollita, TML or other
gods if they're around
lmao
go learn lisp then
NOO.
Okay.
hi. if i have an array indexed numerically like
$ship[1][ship_id][ship_name] is it possible to remove the numeric
keys so that it is just an associative array?
my_haz just off the top of my head it's probably going to be
O(N+a) a=average # of entries in each bucket
codeCowboy, and do what with them? combine them? how, you would
get colliding data
Class 'Zend_Search_Lucene_Document' not found, any ideas what im
missing?
I tried to include /Zend, /Zend/Search, and
../Zend/Search/Lucene
I suppose, class Zend_Search_Lucene_Document
ZFW doesnt have autoloading?
According to the install doc i have to put it in
include_path
i have code like this
I dont know, I don't use ZFW, and this is not a support channel
for it, ask ZFW people
script type="text/javascript" src="=$_SERVER['DOCUMENT_ROOT'] .
"/incldue/js/ewp.js ?"/script
when i see page source
it will show full path
how can i get path from include/..../
full *filesystem* path
edman007, i have two arrays. one contains reviews, the other
just ship_ids and ship_names. the reviews array only contains ship
ids so i want to use the $ships array as a kind of lookup table. i
wasnt able to get the data out of mysql as i wanted it as its in
two separate databases so i'd like to try it this way.
i do not get you
basically i am not a programmer :$
then, hire someone who is
errr
come on man
come on man what? You don't expect a free half an hour
lecture introducing you to the basics of web technologies, do
you?
codeCowboy, so your data is stored in the keys? well change that
and you won't have a problem
ok
you want *URL* location, not filesystem path. See
$_SERVER['PHP_SELF'] and HTML BASE tag
thanks buddy for pointing me
edman, would it be ok to PM you a URL where you can see the
array output?
pastebin
edman007, ^^
!+pastebin
Submit your text to http://hashphp.org/pastebin or
http://cpp.sourceforge.net
or http://pastebin.ca then tell us
the URL and a summary of the problem. Don't flood by pasting in the
channel.
a little warning - PHP_SELF is vulnerable to
injection...SCRIPT_URL may be better
codeCowboy, pastebin.ca
k one sec
bah. Agavi solves that problem for me, so I start forgetting
things
heh...yus i know what you mean
prepared statements make me forget to escape when i really have
to
by the way mike, how would you rate agavi against say the zend
framework?
edman007, array 1 snippet http://hashphp.org/pastebin?pid=23000
i'm thinking of adopting zend but the orm isn't exactly
great...shame because the rest of it is
edman007, array2 snippet
http://hashphp.org/pastebin.php?pid=23001
So
mike
quick question
edman007, that is the way cakePHP formats the data coming
back.
I saved this to my server and weather.xml.....http://xoap.weather.com/weather/local/60660?cc=*&dayf=7&link=xoap&prod=xoap&par=1041664096&key=f994b09b54a50df8
I kinda meant $i-=2; instead of 1 -- ^^
is hat the wrong extensin becuase my server doesn't like
it
any ideas?
codeCowboy, so what data is going to be used to link the
arrays?
edman007, hopefully, the link is [id] in the $ships
array(array2) and [ship] in the $reviews array
'\n' is not the same as "\n"
MikeSeth, eh why not? and how can I fix I just want it to
work
wget 'http://url' - note the
quotes
sounds like you should just reformat the incoming arrays so
the ids are a key (at least for one array), then loop through the
other and copy the data to the right spot
print '\n' prints literally a backslash and n. "\n" prints a
new line.
MikeSeth, I have no control if it is ' or " it just is
MikeSeth, its from a form
sanmarcos, then pass a literal new line char
so again, are you certain that these are new lines and not
combinations of backslash and n?
how?
edman007, first array is rreviews, second array is ships. [ship]
in the reviews array is the ship id from the ships table. [id] in
the ships array is also the ship id from the ships table so i
figures i should be able to somehow build a new reviews array but
with the ship id replaced with the ship name?
you know what, Ill just do my own str_replace to. nl2br shouldnt
care if its newlines or literal characters. I see what the problem
is now MikeSeth
codeCowboy, loop through the one with ship_name, and create a
new array $ship[$id] = $ship_name;, then loop through the review
array and copy $ship[$id] into it
i'll give that a try - thanks.
what kind of language treats stuff different in ' and "?
wtf
many
sanmarcos, C, C++, Java, bash and just about everything i can
think of
i see
:-]
god I like fixed font width
i have used this code script type="text/javascript" src="php
echo $_SERVER['PHP_SELF'] . "/include/js/ewp.js" ?"/script
and when i taking source i got this script type="text/javascript"
src="/new.php/include/js/ewp.js"/script
that makes sense
L|NUX, PHP_SELF is bad. Use SCRIPT_NAME instead.
basically what i am trying to do
i am including file using php like java script or other files and i
do not want user to see absolute path
(nice nickname btw) : =dirname($_SERVER['SCRIPT_NAME']) .
"/include/js/ewp.js"?
let me try this
should \r\n expand correctly?
on windows it should
edman007, this just creates an array with one entry (presumably
it keeps overwriting itself). http://hashphp.org/pastebin.php?pid=23002.
can you expand on creating the new array? thanks!
no, you're missing the point. You should set a BASE href to
point at the URL root, and specify the rest of links to resources
as relative
Dynom, I am printing it like PRINT EOF
textarea$string/textarea
ok
codeCowboy, looking...
works
no spuprise there (-;
suprise even
you could get double '/'`s btw
codeCowboy, like this http://hashphp.org/pastebin.php?pid=23003
would be prettiest I think
ok
thanks buddy
edman007, of course! was being a dunce. thanks very much!
edman007, i forgot that you could create the key dynamically like
that
why would it need trimming?
Hello, I have installed php5 and using phpinfo(); I see under
the extension_dir is /usr/local/lib/php/20060613 however this path
does not exist on the box but /usr/local/lib/php/20050922 does -
have I done something wrong? should I create the dir that is in
phpinfo
what's the easiest way to grab server headers, i.e. apache1.3,
php5.2.1, mod_security from a web(httpd)server remotely?
create that folder
raar_, there is an extension "Live Headers" for firefox that does
it
to avoid a possible '//'
edman007, thanks
will rtrim remove /'s?
is it possible to revert zend-encryption?
if you tell it to... rtrim('pew/', '/');
ah cool, thanks!
Btw regarding the Zend framework from earlier, Zend framework
doesn't work like an extension, putting it in include_path isn't
enough, one must require the relevant scripts in his
script
Azrael_-, no, its compiled as well, so its not going to work
even if you have the encryption keys
anyone mind helping ? http://pastebin.ca/573828
aa^way, are those functions right next to each other as you
show?
yep
exactly like that
well, its not that I have exactly high hopes for ZFW
MikeSeth, how come
aa^way, are those part of a class definition (as in they are
methods, not functions), if they are not then what code are they
inside?
people who write general purpose, aimless PHP code don't
understand PHP execution model
they appear indented so i assume they are not in the
unconditional flow of the script
aa^way : array_map(array($this,"sol2ar"),$keis)
or to call it statically, use Array(__CLASS__, 'sol2ar'
)
thanks
Hi, I want to create a script which will find any hyperlinks
which refer to an external page and add 'rel="external" to the link
which will in turn be used to open the link in a new window, how
should I go about this?
with an html parser
always a start
from there, it's easy, you just snag all the A tags, and add the
extra attribute to them
then re-generate the html and write it all back out
edman007, sorry, being a dunce again. how should i be copying
the value into my reviews array? http://hashphp.org/pastebin.php?pid=23006
yeah, the what i understand, i'm just not sure on the how
what functions are involved?
codeCowboy, are you on PHP5?
hello, is there any way in PHP to perform pattern matching like
Perl does, in terms of using (.+?) ?
frazz123, preg_*() are the perl regex funcs
they are the pcre functions, not the perl regex
functions
...well its compatible
.oO{ why isn't it pcre_replace? }
it's Like Perl But Different, actually
ok, thank you, i will have a look at those functions
http://hashphp.org/pastebin.php?pid=23008
edman - yes php5
ok, well then use the first one, and its print_r($reviews);
you forgot the s
edman007, awesome - thanks very much.
cat data/testdata.txt | awk -F, '{ print $1 }' | ../bin/grep -i
$PLACE$ | awk '{ print "item"$0"/item" }'
edman007, what is the php5 one doing with the &?
neat
itemWARDHANNAPET/item
itemKAWARDHA/item
Neat ?
Now, I want to print the output of this sting.
So I write:
do it all in php, instead of with the shell
Parse error: syntax error, unexpected
T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or
T_NUM_STRING in
syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting
T_STRING or T_VARIABLE or T_NUM_STRING in/u
you messed up the quotes
In the place of $PLACE$ in that command, I want to use
$_GET['name']
codeCowboy, by default php copies the array and loops on the
copy, this prevents writes to the array from staying, adding the
& only works in php5 but it prevents the copy behavior which
helps speed it up a bit and makes the code shorter when you need to
modify the data
Oops.. OK Let me paste what I wrote in the pastebin.
http://pastebin.ca/573857
Whats wrong in that ?
do it with php, use open and so on
edman - kind of like the OOP reference and copy behaviour
beteen the two versions?
no, the problem is that that grep is my own file.. How do I
call it in php ?
codeCowboy, somewhat i suppose, but they did not change the
default behavior
ok. Got it. Thanks codeCowBoy.
open the file with php, read the lines, and check if the string
is part of each line
ok Thanks.
edman. ok thanks again for your help. this has made what is
going to be a very stressful day slightly less so.
oops. I cant do that. The grep utility is not the standard one
and my custom utilty which does some complex matching based on edit
distances... I cant simply go thru each record and do a simple
match.
I need to run that command from php itself.
tell me, why is it called grep?
http://pastebin.ca/573861 Assume
its some utility that takes in some input and produce some output.
Now whats wrong in that code ?
parse error right?
syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting
T_STRING or T_VARIABLE or T_NUM_STRING
$_GET['place'] = {$_GET['place']}
or $_GET[place] if you like to annoy me
actually, $_GET[place] probably wont work in `
$_GET[$_GET[$GLOBALS['test']]] = null;
did i mention that you messed up your quotes?
NoParse, whats that ?
God only knows
funny, running that code after i fixed it made windows
error
Why wont it work ? I can access $_GET['place'] in the
code.
wrap it in {}
I wrapped it and it gave me null results.
well that's probably not php
perhaps you should compose the whole command, and just print the
command out, until you figure out what's interpolating
where
Actually, for the same string as that in $_GET['place']
value, I get results on command line. The $str should contain that
string. But that $str is comming empty.
also, be sure to extract only good (friendly) stuff from the
user input with a regex or something
don't use backticks? +_+
nix the backticks
then ? How do I execute the command and get the results
?
but it takes alot of functions to get what passthru
returns
exec
ob_start(); passthru($cmd); $str = ob_get_contents();
ob_end_clean();
no
I have an algorithm that produces 4 totally unique 10-digit
numbers each time the script is run then adds them all to a
database and if they are used it stops script execution. This is to
prevent automatic browser refreshers.
ok, thanks
exec($cmd, $return); iirc
shell_Exec is my favorite
oh damn, i've been using that all this time
I hate highres images, they allways fuckup my browser
.oO{ why doesn't shell_exec take individual arguments to the
command? }
you using lynx or something?
lynx wouldn't have a problem
shell_Exec does just that, executes the command with a shell
and so does all other functions
but it does not take individual arguments to the command
it takes a single string
true
hello
run_stuff( 'ls', '-al' ); # for example
but it is up to the shell to break out the parameters
look, no quoting needed
how can I find out the hostname of the computer where a
script is running?
that's the point... letting the shell do it makes the user
passing | or & very unsafe
RedShift-, check _SERVER
Hello
it's from the commandline
f00li5h, well, if you have a method that bypasses the shell,
let me know
there isn't one, that's my point
I would only allow it by using a pre-set of commands
I knew that
preset what now?
switch ($switch) { case 'ls': $cmd = 'ls -hal'; break; ..etc..
}
if you need arguments, php got not just one, but two functions
that deals with this precise situation
run_stuff( 'ls', '-al', $_GET['user_input'] ); # this should be
safe
exactly, so don't :-]
about 10 feet to your left, you'll see my point
-_-
i want to finish and release my forum but i have nowhere to
host an update server
run_stuff is to external execution as prepared queries with
placeholders are to database queries
update server?
meh, it's small
but saves people going to my site every few weeks to get an
update
you could end this mess by writing a new function for this
job and send it to a dev
http://update.yourdomain.com/
1. i don't have a domain 2. if it did i dont have anywhere to
point it to XD
i happen to know (be) a cheap hosting company
3. i don't have any internet money
try free add-ads-to-my-site servers
i don't trust free web hosts with something like that
they edit the phz file and replace a file with a backdoor one,
everyone goes to update
THEN YOU HAVE NOWHERE TO HOST YOU
i should get a wireless router, then buy a laptop and hide it
under a couch
you can't pay $70/year for hosting, but you're going to get a
lappy and a wifi card to leave at someone else's house
Domains / hosting is cheap now
i have no way to get my money onto the internet
how hard have you tried?
i don't try
...
there you go, that's why YOU FAIL
I don't need the money on them internets for my hosting. I
just pay the paper bill every year.
hey
not just hosted on your ADSL then?
Yeah, right.
I have never paid for hosting in my life.
anyone good at finding exploits?
Yet I own 3 sites
your unit tests should be
unit.. tests?
yes, unit tests
closest thing i have to a test is the databae tests in the
installer =\
uclosest thing i have to a test is the databae tests in the
installer =\/u
uuclosest thing i have to a test is the databae tests in the
installer =\/u/u
well, apart from DoSing my dialup, http://sausage.no-ip.org:88/dev/FORUM010/
if anyone wants to try
ahahahaha L3
there was a php command that echos a variable
something along the lines of %=
=$var?
=function()?
$var
WOAH!
WHAT!
That needs to be downsized stat.
what?
downsize as in...
aint no down sizing /this/
!!
The text is mammoth
never do that.
sorry ._.
if you don't like it and want to go blind
make your fonts smaller _
php print .... ?
do not use and =
= isnt a short_tag right?
it is, and it is discouraged from use
MikeSeth why not
i thought and % were
There was somentone here, that developed a flat-forum, with the
home-made encryption and plain-text passwords. I was so happy, I
could hit him with a baseball bat.
because it will go away in PHP6
i have lots of data to output to different parts of a
table
php6 sucks anyway XD
It does?
= is easier to use
is there a factoid on short tags?
TehSausage; a word of advice though seriously, don't follow
phpBB & Invision's path by adding big bulky useless crap. Keep
it nice and simple.
!+short tags
Short tags are or %, and should never be used. They are
scheduled for removal from PHP6, and are configuration dependant.
Use php, period.
i didnt add anything useless
you ze man
hell, i havent even implemented an edit page yet theres no
time XD
still work
:o
No.
=$var?
My forum is only 500 lines long total. It is fully developed
with admin controls and the works...
NO, php print $var; ?
mine is made to be easy to make though
php= was discusssed for inclusion in PHP6, but was
dropped.
heres afew lines from somewhere
ok fine!
Those tags are so crap.
$forum-Forum-desc = "Default forum";
$forum-Forum-topics = array();
I think I use like... 1 array in my whole script.
i dont even use that array i think
it reads all that from the index file
Arrays are good, if you know what you're using them for
...
arrays in php are awesome though
They are?
quite
howv so?
an array in C
ouch
I would really hate to be a game programmer.
oh yeah, = is a short tag
They do 85-hour weeks.
http://au2.php.net/manual/en/language.basic-syntax.php
What about it?
just saying, always thought it wasnt
another thing i'm not sure about
using more than one __halt_compiler() in the same execution
it causes an error, but if you ignore it it carrys on
fine
is that invalid?
!+enter
Don't use the enter key as punctuation. Think in complete
thoughts, then type.
heh, funny, i always whinge at people that do that
Yes. So don't do it.
well, all my data is in files like this "php fseek($f =
fopen(__FILE__,'rb'),__COMPILER_HALT_OFFSET__); return
unserialize(gzinflate(stream_get_contents($f)));
__halt_compiler();###################"
real men type a letter a line
its easier to just forget about escaping
Real men get banned really quickly, then
o_o
So what about the arrays in C?
I have created the correct command in the string $str
i thought i saw a bug about the "__COMPILER_HALT_OFFSET__"
error
Hi there - wondering if anyone can help me. I'm tryin to post
XML to a server using cURL but it doesnt appear to be liking
it.
Can anyone see anything wrong with this; http://pastebin.com/931244
TehSausage, what's your issue about it ?
I want to use that command. The command string also has
pipes.
so I do a $str = `$cmd`;
"This bug has been fixed in CVS."
wtf
okay so it is valid by the looks of it XD
but it does not return any string. I execute the same on shell,
it executes and gives desired results.
i just havent updated from 5.2.0-rc5 yet
why does it give no result in php ?
Where is curl_init?
5.2.0...
my cat thought it would be a goood idea to sit on my lap while
im coding
im guessing thats where im going wrong
what a twat i am
thanks Wolfpaws
np
boredom kicks in..
i'll write a brainfuck interperator
that sounds interesting
another one?
jeez, i chose this because i didnt think i'd have to google
it
but then it hits things like what do i do when i use when the
pointer is 0
oh cool, 'undefined'
Unfortunately my script gives correct result on command line but
no result thru web server. What can e wront ? Script: http://pastebin.ca/573930
akhilesh, have you checked the source ?
yes. It works on command line: http://pastebin.ca/573931
How can I create extension that will add categories to a page
where extension hook are?
returned.
i don't want to sound like an idiot, but can the apache user
access the bin folder and execute commands?
yes, unless safe mode is on then the commands you can use may
be severly restricted or execution disabled alltogether
I believe yes because it executed other commands like
"ls"
you therE?
I can execute ls and grep in system folders, but not
executables my home dir thru webserver.
unable to unpack ... when trying to install pear packages
any ideas?
Is it possible to add article to a sertent categorie using PHP
code? Or how can I add articleA to a categorie B using PHP
?
ow my brain cells
you can't have tooth ache if you don't have teath
... what?
i'll tell you later
you'll want to use a database of some sort, see: MySQL or
SQLite
HarryR yes my wiki runs on mysql but what does it have to do
with cetegories?
Oh sorry, I read your question out of context
I dont think we can offer any help for 3rd party apps,
especially when I have no idea what you're using
is there such a thing as "php sessions"? or is that JSP
also?
sessions as in..
sessions... like for user management and tracking
yeah
session_start(); then use the $_SESSION superglobal
I really dont want to put links all over my site from the log
in page for a mamber (which is what i'm doing now)
if by session you mean the serverside collection of variabled
identified by a session id stored as a cookie in the users browser
._.
you wouldn't happen to have a link to a tutorial on sessions
would you? the only ones i'm finding are JSP based... and i dont
like to mix and match
try http://php.net/session
php.net/anything will find what you want 99% of the time
good
i spend more time trying to find stuff then actually
programming
or scripting... whatever its called
php is advanced enough to be called programming, especially
now theres compilers too
which is better (easier) for user management, cookies ||
sessions?
whichever, cookies are editable by the user, sessions can only
be deleted by the user
they are for different use
cuz yeah... i'm extreme php newb.... and I dont understand
what the php.net/sessions page is trying to explain to me
.
session is a file saved in a server
ok, well since i need it to hold whether or not a user has admin
privies... sessions it is
yes
session_start();
$_SESSION["admin"] = true;
have done almost all
but how do i specify what user to give that session to? on
the loginto page do i just use the if() block... put
session_start();$_SESSION["admin_2"]=true;...and then it will keep
that info on any page inside the site they visit?
it isnt given to a 'user' it's given to a browser
ok, browser
but yeah, once you set a session variable it lasts for that
user until they clear there cookies
j2daosh, session_start() will prepare to send a certain
session id (key) to the client. The client will send it back
through cookies/url when requesting another page so session_start()
will be able to load the data corresponding to the user
hi; if something i am requiring redirects then is there any way
I can catch or buffer or cancel that redirect and maintain control
within my script?
and no, the duration of a session is not only determined by
the user cookie.
well, you can always unset the session, but it should be
obvious
will that session follow the browser to whatever page he goes
to? (how would it know that browser has a admin session and can go
to registered and admin pages instead of just registered
pages?).
yes
Narada redirect is a header only
session_start will automatically destroy old session, even if
the session id is provided.
sorry if i ask so many questions, this is my first attempt at
user management
I know I just wondered if I can intercept that in any
way
session_start() doesnt kill any sessions =\ or none of my
sites would work right now
TehSausage, it does.
you call it to accept the cookie
and set the $_SESSION variables
what TehSausage said
session_start() is also responsible for cleaning tasks.
Narada your code still runs....until the end or
exit()...
only after the gc period surely?
prophile, yep
it certainly doesn't destroy sessions all the time
that would be silly
who said that?
XD
Narada maybe you can resend a new header
i was just wondering what it does with old sessions
it destroys them, if they're old enough
will i need to use a "$_get" to keep the session going from page
to page?
TehSausage heh you may talk a look at your session
folder
:P
or a $_post
no
by the way, this is explained on the manual, so in any case,
read it
session_start(); will set everything up
its just going to automagically follow the browser like a
lost puppy looking for a someone to pet it eh...
you may try print_r($_SESSION); and set some values on it
yes, fun?
interesting to say the least
yeah, session_start() sets a cookie
as long as the browser has that cookie php will recognize it as
the owner of that session
it depends on the _settings_
but there is a time limit before you puppy leaves you
don't make generalisations like that
theyre usually right
well thank you all very much for the information. it has been
very informative. I'm off to read the php.net/sessions page
now
session_start() tries to initialize a session according to 1)
the current session handler 2) the current settings in
place
i can't find my php session folder
lol don't go no where... i have a feeling i will have about
15 more questions by 3pm today
blol don't go no where... i have a feeling i will have about 15
more questions by 3pm today/b
what questions?
TehSausage, again, php.net/session will tell you that
lol