FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » randomly sorting files in php
Show: Today's Messages :: Polls :: Message Navigator
Switch to threaded view of this topic Create a new topic Submit Reply
Re: getting perl and php to talk to each other [message #180719 is a reply to message #180626] Thu, 14 March 2013 10:41 Go to previous messageGo to next message
Cal Dershowitz is currently offline  Cal Dershowitz
Messages: 36
Registered: February 2013
Karma: 0
Member
On 03/07/2013 05:17 AM, Jerry Stuckle wrote:
> On 3/7/2013 3:52 AM, Cal Dershowitz wrote:
>> On 03/06/2013 10:57 PM, Ben Morrow wrote:
>>>
>>> Quoth Cal Dershowitz <cal(at)example(dot)invalid>:
>>>>
>>>> I've chosen this rather arbitrary task just to see what I can do with
>>>> this syntax which is new to me, php, as opposed to what a person can do
>>>> with, perl, which I have previously used to give me a webpage.
>>>
>>> Cal, please, try to learn one language properly before wildly
>>> introducing more languages to the equation. It *really* isn't going to
>>> help.
>>
>> Help what? Are you certain that it's completely impossible that a file
>> could go missing from me that I would need to do this, and that there
>> would be every reason in this fascist world world to keep me from
>> getting a decent web capability?
>>
>
> There are hundreds of millions of web sites which have "decent web
> capabilities" but don't try to mix languages. I agree with Ben - learn
> one language first.
>
> And if you want help, I *highly* suggest you change your attitude.
> Calling people facists does not endear ANYONE.

People like me just fine. Fuck off.
--
Cal
Re: getting perl and php to talk to each other [message #180720 is a reply to message #180717] Thu, 14 March 2013 10:51 Go to previous messageGo to next message
SwissCheese is currently offline  SwissCheese
Messages: 17
Registered: December 2012
Karma: 0
Junior Member
On 03/14/2013 06:28 AM, Cal Dershowitz wrote:
> On 03/07/2013 03:28 AM, SwissCheese wrote:
>> On 03/07/2013 01:53 AM, Cal Dershowitz wrote:
>>> On 03/05/2013 02:06 PM, Ben Morrow wrote:
>>>>
>>>> Quoth Cal Dershowitz <cal(at)example(dot)invalid>:
>>>> > [x-posted to clp.misc]
>>>> [...]
>>>> >
>>>> > This article has me convinced that I want perl and php able to deal
>>>> > with
>>>> > each other:
>>>> >
>>>> > http://www.linuxjournal.com/article/9282?page=0,1
>>>>
>>>> Why on Earth would you want to do that? Seriously, I can't think of any
>>>> situation where mixing PHP and Perl is easier than just writing in Perl
>>>> in the first place.
>>>>
>>>> Note that the Perl in that article (or at least, the first page, which
>>>> was all I read) is pretty bad:
>>>>
>>>> - use of global filehandles, unnecessary since 2000,
>>>> - use of Thread.pm, deprecated since 2002,
>>>> - use of threads at all for such a trivial problem,
>>>> - using rindex and substr rather than pattern matching,
>>>> - using backticks instead of system(),
>>>> - using PHP to talk to a database, when Perl's DBI module is
>>>> considerably better than PHP's rather random database functions.
>>>>
>>>> I don't know PHP well enough to comment on it, but I wouldn't be
>>>> surprised if the PHP code was just as bad (for instance, I understand
>>>> PHP has a saner database interface these days; I don't know if it
>>>> existed in 2007, though).
>>>>
>>>> > so far so good, and then this thing which I've seen in the literature:
>>>> >
>>>> > using php_config 'php-config'
>>>> > Can't exec "php-config": No such file or directory at Makefile.PL
>>>> > line 55.
>>>> > Failed to find the 'php-config' executable. Make sure you have PHP and
>>>> > PHP sources installed, and that 'php-config' is in PATH. at
>>>> > Makefile.PL
>>>> > line 55.
>>>> > ...
>>>> >
>>>> > bla bla bla do not pass Go. Right now I have a default installation.
>>>> >
>>>> > Simple question: What types of things can I get configured with
>>>> > php-config? envelope data available? ftp data?
>>>>
>>>> php-config is a program installed with php, which tells other programs
>>>> how php was installed. For instance, on my system
>>>>
>>>> ~% php-config --libs
>>>> -lcrypt -lcrypt -lpcre -lm -lxml2 -lz -liconv -lm -lcrypt -lcrypt
>>>> ~% php-config --includes
>>>> -I/usr/local/include/php -I/usr/local/include/php/main
>>>> -I/usr/local/include/php/TSRM -I/usr/local/include/php/Zend
>>>> -I/usr/local/include/php/ext -I/usr/local/include/php/ext/date/lib
>>>> ~%
>>>>
>>>> and so on. If you've installed php properly (including any required
>>>> development packages, if you're using a package system), you should
>>>> have
>>>> a php-config executable somewhere. Make sure it's in your PATH before
>>>> running Makefile.PL.
>>>
>>> Struggling.
>>>
>>> $ php-config --libs
>>> No command 'php-config' found, did you mean:
>>> Command 'pdp-config' from package 'pd-pdp' (universe)
>>> Command 'php-config5' from package 'php5-dev' (main)
>>> php-config: command not found
>>> $
>>
>> Try php-config5 as php-config is a link to php-config5. Here they
>> both reside in /usr/bin. If you are missing php-config link (it appears
>> so) then create it.
>>
>
> swiss,
>
> Can you elaborate?

The file 'php-config' is a pointer (hard/soft link) to 'php-config5'.
Running 'php-config' actually runs 'php-config5'. Run the command:

man ln

....to read up on how to use them. At worst you could just make a copy of
'php-config5' and rename it 'php-config' but I would have to say
creating the link is the proper thing to do.

--
Norman
Registered Linux user #461062
-Have you been to www.php.net yet?-
Re: where to put the binaries was Re: getting perl and php to talk to each other [message #180721 is a reply to message #180716] Thu, 14 March 2013 11:12 Go to previous messageGo to next message
The Natural Philosoph is currently offline  The Natural Philosoph
Messages: 993
Registered: September 2010
Karma: 0
Senior Member
On 14/03/13 10:11, Cal Dershowitz wrote:

> Q1) How do I design a website where the binaries aren't there for the
> taking unless php thinks you have done some act of authentication to see
> them?
>
Two standard ways.

1/. put them all in different directories and pop a .htaccess and
password file in each one so that APACHE denies access without a login.

This is pure Apache and nothing to do with PHP at all. If apache is
coinfigured to respect this method teh general form is

..htaccess
==========

AuthType Basic
AuthName "My Private Picture access"
AuthUserFile /var/www.mysite.com/this_directory/.htpasswd
Require valid-user

That tells apache to deny unauthorised access, and look in
/var/www.mysite.com/this_directory/.htpasswd

for name:password pairs.
..htpasswd
==========
rufus:OMtQ1VFqr!2dY

This contains a user name and a hashed password and is created using teh
htpasswd utility that comes with apache.

http://httpd.apache.org/docs/2.2/programs/htpasswd.html

If you have access to the total apache installation, this is trivial,
less so if you are merely uploading files to someone else's


2/. use cookies (sessions) in (php) via a login page: That essentially
sets a php variable to reflect the users session. So you if the user
attempts to access the page, and he is not logged in, the php should
present him with a login page, and name and password (are filled in and
submitted to the same page, these are then used to set the cookie, and
all subsequent invocation's of that page with the cookie set will allow
access to the directory via the PHP script.

You set and read cookies either using sessions, or doirectly

e.g.

$_COOKIE["K9PA70634H"]=$cookie;
Cookies are an array of name=>value pairs in PHP global space.
"K9PA70634H" is just an arbitrary string.
AS is what's in $cookie...in my application every time a user logs in I
look in a database to see if he has the right password, and if he has,
generate a random cookie and store that in the database. If he comes
back with the cookie still set, then that's a match and access is
seamless. If the cookie has timed out or its different from that in the
database, he gets to login again.

i.e. a not especially relevant code snippet..user may have set name and
password in $_POST['name'] and $_POST['password']: $_POST['persistent']
i sset if he wants to stay logged in forever..

$result=mysql_query(sprintf("select id, password, email from people
where familiar='%s'",$_POST['name']));
if( $result && mysql_numrows($result)>0) // user at least exists
{
if($_POST['password'] != mysql_result($result,0,'password'))
{
$error="Incorrect password";
$email=mysql_result($result,0,'email');
display_login($error);
}
else // by golly we have a match!
{
if(!isset($_POST['persistent']))
$_POST['persistent']='no';
$id=mysql_result($result,0,'id');
// generate a cookie and store it and echo it back to the users browser.
$cookie=randomstring(10);
mysql_query(sprintf("update people set cookie='%s', timeout='%s'
where id = '%d'",$cookie, $_POST['persistent'],$id));
// pretend we already HAVE a valid cookie from the browser..so that
when getlogname is called it all 'works' and a new cookie will get issued
$_COOKIE["K9PA70634H"]=$cookie;
display_success();
}
}
else
{
$error="No such name is registered";
display_login($error,$email);
}
}

So that's how the name password gets stuck in the DB and a cookie is
attached.

This function checks the cookie is valid, and CHANGES IT EVERY TIME THE
USER READS A PAGE.

Additional security so that even if - say some hacker knows what the
cookie was last time, it wont work if the user has accessed the page again

function getlogname()
{
global $logname; // system wide for the duration
$id=0; // set default of not found
if(isset($_COOKIE["K9PA70634H"]))
{
$cookie=$_COOKIE["K9PA70634H"];
if(strlen($cookie)>8)
{
$query=sprintf("select id , familiar, timeout from people where
cookie ='%s'",$cookie);
$result=mysql_query($query);
if ($result && mysql_num_rows($result)==1)
{
$id=mysql_result($result,0, 'id');
$logname=mysql_result($result,0, 'familiar');
$persistent=mysql_result($result,0, 'timeout');
$cookie=randomstring(10); // generate new cookie so stolen cookies
wont work..this also means using a new machine will wipe out stored cookies
if($persistent=='yes')
setcookie("K9PA70634H",$cookie,time() + (86400 * 365)); // give em
a year before it expires.
else
setcookie("K9PA70634H",$cookie); // issue session only cookie
// now update access time and ip address
$query=sprintf("update people set last_ip='%s',cookie='%s',
last_accessed='%s' where id='%d'",$ipaddr=$_SERVER['REMOTE_ADDR']
,$cookie, date("Y-m-d H:i:s"), $id);
mysql_query($query);
}
}
}
return $id;
}



Getlogname in my case is called every page that has access to 'sensitive
data' and checks that either the cookie is set, or invites the user to
log in before proceeding.


If you went that sort of route you would probably hold a set of
directories or pictures that user was allowed to access in the database.

Going the PHP route and using cookies and or databases is probably the
slicker neater and vastly more complex way to do what the .htaccess
files will do anyway.




> Q2) What's a good first book for php?
PHP is so much a stock procedural language with a bolt on OO part that
its hardly worth having a 'first' book in PHP. Essentially if you have
programmed in anything else, PHP is pretty much like C or Pascal in
terms of its structure. The differences are subtle, in the (lack of)
typing and in what libraries are available, and here the online manual
is the best resource of all, especially user contributed solutions and
issues.


--
Ineptocracy

(in-ep-toc’-ra-cy) – a system of government where the least capable to
lead are elected by the least capable of producing, and where the
members of society least likely to sustain themselves or succeed, are
rewarded with goods and services paid for by the confiscated wealth of a
diminishing number of producers.
Re: getting perl and php to talk to each other [message #180722 is a reply to message #180719] Thu, 14 March 2013 11:14 Go to previous messageGo to next message
The Natural Philosoph is currently offline  The Natural Philosoph
Messages: 993
Registered: September 2010
Karma: 0
Senior Member
On 14/03/13 10:41, Cal Dershowitz wrote:
> On 03/07/2013 05:17 AM, Jerry Stuckle wrote:
>> On 3/7/2013 3:52 AM, Cal Dershowitz wrote:
>>> On 03/06/2013 10:57 PM, Ben Morrow wrote:
>>>>
>>>> Quoth Cal Dershowitz <cal(at)example(dot)invalid>:
>>>> >
>>>> > I've chosen this rather arbitrary task just to see what I can do with
>>>> > this syntax which is new to me, php, as opposed to what a person
>>>> > can do
>>>> > with, perl, which I have previously used to give me a webpage.
>>>>
>>>> Cal, please, try to learn one language properly before wildly
>>>> introducing more languages to the equation. It *really* isn't going to
>>>> help.
>>>
>>> Help what? Are you certain that it's completely impossible that a file
>>> could go missing from me that I would need to do this, and that there
>>> would be every reason in this fascist world world to keep me from
>>> getting a decent web capability?
>>>
>>
>> There are hundreds of millions of web sites which have "decent web
>> capabilities" but don't try to mix languages. I agree with Ben - learn
>> one language first.
>>
>> And if you want help, I *highly* suggest you change your attitude.
>> Calling people facists does not endear ANYONE.
>
> People like me just fine. Fuck off.

For a quiet life, just killfile jerry.

Unless you are a humble and very ignorant noob, he has nothing to teach
you. Worse a lot of what he says is plain wrong.



--
Ineptocracy

(in-ep-toc’-ra-cy) – a system of government where the least capable to
lead are elected by the least capable of producing, and where the
members of society least likely to sustain themselves or succeed, are
rewarded with goods and services paid for by the confiscated wealth of a
diminishing number of producers.
Re: getting perl and php to talk to each other [message #180723 is a reply to message #180719] Thu, 14 March 2013 11:18 Go to previous messageGo to next message
Jrgen Exner is currently offline  Jrgen Exner
Messages: 14
Registered: March 2013
Karma: 0
Junior Member
Cal Dershowitz <cal(at)example(dot)invalid> wrote:
> On 03/07/2013 05:17 AM, Jerry Stuckle wrote:
[...]
>>>> Cal, please, try to learn one language properly before wildly
>>>> introducing more languages to the equation. It *really* isn't going to
>>>> help.
>>>
>>> Help what? Are you certain that it's completely impossible that a file
>>> could go missing from me that I would need to do this, and that there
>>> would be every reason in this fascist world world to keep me from
>>> getting a decent web capability?
>>>
>>
>> There are hundreds of millions of web sites which have "decent web
>> capabilities" but don't try to mix languages. I agree with Ben - learn
>> one language first.
>>
>> And if you want help, I *highly* suggest you change your attitude.
>> Calling people facists does not endear ANYONE.
>
> People like me just fine. Fuck off.

Your wish is my command: ***PLONK***

jue
Re: getting perl and php to talk to each other [message #180724 is a reply to message #180714] Thu, 14 March 2013 11:55 Go to previous messageGo to next message
Jerry Stuckle is currently offline  Jerry Stuckle
Messages: 2598
Registered: September 2010
Karma: 0
Senior Member
On 3/14/2013 5:19 AM, Cal Dershowitz wrote:
> On 03/07/2013 04:45 PM, Jerry Stuckle wrote:
>> On 3/7/2013 3:43 PM, The Natural Philosopher wrote:
>>> On 07/03/13 19:09, alexd wrote:
>>>> Cal Dershowitz (for it is he) wrote:
>>>>
>>>> > Struggling.
>>>> >
>>>> > $ php-config --libs
>>>> > No command 'php-config' found, did you mean:
>>>> > Command 'pdp-config' from package 'pd-pdp' (universe)
>>>> > Command 'php-config5' from package 'php5-dev' (main)
>>>> > php-config: command not found
>>>>
>>>> I should think that anybody with a passing familiarity with package
>>>> management would be able to work out what this output is telling them.
>>>>
>>> a passing familiarity with package management is not a requirement for
>>> running PHP or posting in this NG.
>>>
>>> NOr is installation of php development files and utilities a requirement
>>> fora basic LAMP setup.
>>>
>>>
>>
>> No, but trying to get two different languages working together takes
>> more expertise than just installing LAMP. Of course, it's nothing a
>> troll like you would understand.
>>
>
> Get the motherfuck off my thread.
>

You really do know how to win friends and influence people, don't you?
Well, you're not going to get much help here with that attitude.

But then idiots never are very smart.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex(at)attglobal(dot)net
==================
Re: where to put the binaries was Re: getting perl and php to talk to each other [message #180725 is a reply to message #180716] Thu, 14 March 2013 12:04 Go to previous messageGo to next message
Jerry Stuckle is currently offline  Jerry Stuckle
Messages: 2598
Registered: September 2010
Karma: 0
Senior Member
On 3/14/2013 6:11 AM, Cal Dershowitz wrote:
> On 03/07/2013 12:43 PM, The Natural Philosopher wrote:
>
>> a passing familiarity with package management is not a requirement for
>> running PHP or posting in this NG.
>>
>> NOr is installation of php development files and utilities a requirement
>> fora basic LAMP setup.
>>
>>
>
> NP, I've been reading you for a while now. Did you give me the name of
> a newsgroup where they consider webstuff ontopic?
>

comp.lang.php is on topic for PHP, which drives a lot of websites. But
we already know you're an idiot.


> I'm rather convinced that scripting languages are my meal ticket this
> month, so much so that I'm making it happen with my rudimentary
> webtools. This is what I call output:
>

No, scripting languages seen to be beyond your level of comprehension.
You're in the same league as TNP.

> http://merrillpjensen.com/food_4.html
>
> This is a powerful medium, where one can intermix binaries and text. My
> problem now is that it's not a discrete medium without me attending
> endlessly to obfuscations with files that I would much just rather have
> as themselves, and the only way you can see them is if php lets you with
> an authentication level equal to my level of give a crap.
>

Obfuscation is not security!

<snip unrelated crap from an idiot>

>
> This has so far been my home-cooked perl version of static web dev, but
> I want to see if php can obviate all the go***a%n filing-about that you
> have to do to maintain the privacies of the the binaries shown. These
> images are my shack so I don't care so much anymore. I also use this
> tool chain to lay down the law with people a bit; it's a very direct
> medium:
>

Sure you can do it with PHP. But you can do it with perl, also, without
all the crap. You just need to understand some basic concepts.

> http://merrillpjensen.com/cleaning_1.html
>
> Q1) How do I design a website where the binaries aren't there for the
> taking unless php thinks you have done some act of authentication to see
> them?
>

Security measures will prevent users from accessing the files. But
you've already said you don't want help, so why do you continue posting?

> Q2) What's a good first book for php?

Dick and Jane Create a Web Site would be about your speed.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex(at)attglobal(dot)net
==================
Re: getting perl and php to talk to each other [message #180726 is a reply to message #180722] Thu, 14 March 2013 12:06 Go to previous messageGo to next message
Jerry Stuckle is currently offline  Jerry Stuckle
Messages: 2598
Registered: September 2010
Karma: 0
Senior Member
On 3/14/2013 7:14 AM, The Natural Philosopher wrote:
> On 14/03/13 10:41, Cal Dershowitz wrote:
>> On 03/07/2013 05:17 AM, Jerry Stuckle wrote:
>>> On 3/7/2013 3:52 AM, Cal Dershowitz wrote:
>>>> On 03/06/2013 10:57 PM, Ben Morrow wrote:
>>>> >
>>>> > Quoth Cal Dershowitz <cal(at)example(dot)invalid>:
>>>> >>
>>>> >> I've chosen this rather arbitrary task just to see what I can do with
>>>> >> this syntax which is new to me, php, as opposed to what a person
>>>> >> can do
>>>> >> with, perl, which I have previously used to give me a webpage.
>>>> >
>>>> > Cal, please, try to learn one language properly before wildly
>>>> > introducing more languages to the equation. It *really* isn't going to
>>>> > help.
>>>>
>>>> Help what? Are you certain that it's completely impossible that a file
>>>> could go missing from me that I would need to do this, and that there
>>>> would be every reason in this fascist world world to keep me from
>>>> getting a decent web capability?
>>>>
>>>
>>> There are hundreds of millions of web sites which have "decent web
>>> capabilities" but don't try to mix languages. I agree with Ben - learn
>>> one language first.
>>>
>>> And if you want help, I *highly* suggest you change your attitude.
>>> Calling people facists does not endear ANYONE.
>>
>> People like me just fine. Fuck off.
>
> For a quiet life, just killfile jerry.
>
> Unless you are a humble and very ignorant noob, he has nothing to teach
> you. Worse a lot of what he says is plain wrong.
>
>
>

Ah, yes, the troll has to have his say. We already know you're neither
the programmer nor the electrical engineer you claim to be. No wonder
you post under a 'nym. You don't want people to know you're an out of
work ditch digger who can't figure out which end of the shovel to use.

If I was as stoopid as you, I'd be ashamed to use my real name, also.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex(at)attglobal(dot)net
==================
Re: getting perl and php to talk to each other [message #180727 is a reply to message #180723] Thu, 14 March 2013 12:38 Go to previous messageGo to next message
Scott Johnson is currently offline  Scott Johnson
Messages: 196
Registered: January 2012
Karma: 0
Senior Member
On 3/14/2013 4:18 AM, Jürgen Exner wrote:
> Cal Dershowitz <cal(at)example(dot)invalid> wrote:
>> On 03/07/2013 05:17 AM, Jerry Stuckle wrote:
> [...]
>>>> > Cal, please, try to learn one language properly before wildly
>>>> > introducing more languages to the equation. It *really* isn't going to
>>>> > help.
>>>>
>>>> Help what? Are you certain that it's completely impossible that a file
>>>> could go missing from me that I would need to do this, and that there
>>>> would be every reason in this fascist world world to keep me from
>>>> getting a decent web capability?
>>>>
>>>
>>> There are hundreds of millions of web sites which have "decent web
>>> capabilities" but don't try to mix languages. I agree with Ben - learn
>>> one language first.
>>>
>>> And if you want help, I *highly* suggest you change your attitude.
>>> Calling people facists does not endear ANYONE.
>>
>> People like me just fine. Fuck off.
>
> Your wish is my command: ***PLONK***
>
> jue
>
Ditto
Re: getting perl and php to talk to each other [message #180776 is a reply to message #180720] Mon, 18 March 2013 11:54 Go to previous messageGo to next message
Thomas 'PointedEars'  is currently offline  Thomas 'PointedEars'
Messages: 701
Registered: October 2010
Karma: 0
Senior Member
SwissCheese wrote:
^^^^^^^^^^^
Please put your real name there. And stop crossposting without Followup-To
(F'up2).

> The file 'php-config' is a pointer (hard/soft link) to 'php-config5'.

Most likely it is not a hardlink, but a symlink.


F'up2 .php

PointedEars
--
Use any version of Microsoft Frontpage to create your site.
(This won't prevent people from viewing your source, but no one
will want to steal it.)
-- from <http://www.vortex-webdesign.com/help/hidesource.htm> (404-comp.)
Re: getting perl and php to talk to each other [message #180785 is a reply to message #180776] Tue, 19 March 2013 00:23 Go to previous message
SwissCheese is currently offline  SwissCheese
Messages: 17
Registered: December 2012
Karma: 0
Junior Member
On 03/18/2013 07:54 AM, Thomas 'PointedEars' Lahn wrote:
> SwissCheese wrote:
> ^^^^^^^^^^^
> Please put your real name there. And stop crossposting without Followup-To
> (F'up2).
>

My real name is in my sig...

>> The file 'php-config' is a pointer (hard/soft link) to 'php-config5'.
>
> Most likely it is not a hardlink, but a symlink.
>
>

I'm no master at all the different types of links, that's why I
suggested he 'man ln' as well as telling him 'basically' what was going on.

--
Norman
Registered Linux user #461062
-Have you been to www.php.net yet?-
Pages (2): [ «    1  2]  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: How to avoid the use of session variables in this script
Next Topic: all done
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Sun Nov 24 02:02:08 GMT 2024

Total time taken to generate the page: 0.02945 seconds