From: Kevin Miller on
houghi wrote:
> Kevin Miller wrote:
>> Well, I'll be developing it on openSUSE. And I think my ISP is running
>> some flavor of LInux. But yeah, strictly speaking it's a bit OT. On
>> the other hand, half the posts here are threads that have degraded into
>> flame wars with nothing to do with openSUSE, Linux, or even computers.
>
> Almost the same excuse is used by people posting everything about
> computers in a newsgroup about providers "But I use a provider to access
> the Internet, so my question should be on topic there."
>
> And the fact that some trolls do something does not mean you should as
> well.

Point taken.

>> Thanks. Nice tutorial. I took a quick glance at it, and plan on
>> printing it, comparing it to page source to see how you've enhanced the
>> basics you describe then going from there. If I have a question or two
>> can I ping you off list? Some folks get there knickers in a bind if you
>> email them directly so I figured I'd ask first...
>
> You can, but then you will have only my limited experience and not the
> experience of people who know what they are doing. Best is to look up a
> group, tell what group it is and then I will join there.

I was thinking of specific things in your site that you did - when I was
looking at the page source code there were a couple things in there that
I wasn't sure about. General questions will be posted more appropriately.

Thanks again...

....Kevin
--
Kevin Miller
Juneau, Alaska
http://www.alaska.net/~atftb
In a recent poll, seven out of ten hard drives preferred Linux.
From: David Bolt on
On Monday 04 Jan 2010 20:56, while playing with a tin of spray paint,
houghi painted this mural:

> Use http://localhost to see if it is running.
>
> The directory everything is in is /srv/www/htdocs As a standard user you
> won't have access there. Sevral options are available on what to do.
> What I do is chown it so my user is owner of that directory (and the
> group root still)

Using your own public_html directory does mean not having to mess with
the main server directory, and introduces some small amount of
protection. Even if your firewall is opened for port 80, unless those
on the outside know the user-name, they can't access the test pages.

> Now you can do anything you desire, test it first and see how things go
> before uploading. And now if something does not work (unless it is pure
> php) it will be on topic again. :-D

Unless it's purely web-related PHP, it could be on topic. After all,
this would be the php equivalent to the bash script written for Vahis
in the "batch renaming in a subfolder tree" thread:

#!/usr/bin/php
<?php
/*
* this is designed to run as a shell script. don't run it via a web server
*/
$source_dir=getcwd();

// one argument. The source path. If one isn't passed, use the current working directory
//
if($argc>2)
die("I only process one path at a time\n");
if($argc==2)
$source_dir=$argv[1];

$files=array();
exec("find '".$source_dir."' -type f -name '*.ogg'",$files);

if($files===FALSE) // none found
die("Nothing to convert.\n"); // so quit

foreach($files as $file)
{
// skip unreadable files
//
if(!(is_readable($file)))
continue;

// change '_' to ' '
//
$name=str_replace("_"," ",basename($file,"ogg"));

// construct the output filename
//
$output=dirname($file)."/".$name."mp3";

// bit of feedback while doing the conversion
// lets the user know the script hasn't crashed
//
printf("Converting %s\n",$file);

// then get sox to do the conversion
//
passthru("sox '".$file."' '".$output."'",$ret_val);

// if sox converts the file successfully
//
if(!$ret_val)
unlink($file); // delete the original
}

die("Converted ".count($files)." files\n");
?>


Regards,
David Bolt

--
Team Acorn: www.distributed.net OGR-NG @ ~100Mnodes RC5-72 @ ~1Mkeys/s
openSUSE 11.0 32b | | openSUSE 11.2 32b |
openSUSE 11.0 64b | openSUSE 11.1 64b | openSUSE 11.2 64b |
TOS 4.02 | openSUSE 11.1 PPC | RISC OS 4.02 | RISC OS 3.11
From: Kevin Miller on
On 01/04/2010 11:56 AM, houghi wrote:
> Kevin Miller wrote:
>> Learn something new every day! Looks like that's an option after all:
>
> Be carefull/

No doubt. I've toyed with Joomla! on my home box and visited their
forums. There's no end of 'Help, I've been hacked!' posts. One of the
hazards of using php.


> Looks promising, but first make a page info.php with the following
> content:
> <?php
> phpinfo();
> ?>
>
> It should show you a LOT of information. Best NOT to share it with the
> world, so give it another name. The reason is that it might contain
> information that you better not make public.

Yup, lots of info there. I've used php a little bit with phpMyAdmin to
manage mySQL databases, and with Mailwatch for MailScanner. I've used
the ol' info.php trick before locally, but it's been a while and I'd
forgotten about it.

(As an aside, MailScanner is a great antispam/antivirus management
wrapper (similar to Amavis) which I use at work to keep the nonsense out
of my users mailboxes. MailWatch is a nice web based interface (LAMP
stack) for monitoring and reporting.)

> Some page as what you should see:
> http://example.com.customers.tigertech.net/phpinfo.php
> If you like, you can email me the correct URL and I can take a look at
> it.

Yup, mine looks pretty similar.

> If that does not work, it might be that php is disabled. Try it with
> info.html and the same content. You never know.
>
> If you see the php info content, you will be able to use the include. To
> test that, make another page test.php in the same directory with the
> content:
> <?php
> echo "<h1>Hello World</h1>";
> include '(info.php)';
> ?>
>
> You should be able to see the same info and some more as well.

Rats. I got this:
Hello World

Warning: include((info.php)) [function.include]: failed to open stream:
No such file or directory in /home/alaska.net/atftb/www/******.php on line 3

Warning: include() [function.include]: Failed opening '(info.php)' for
inclusion (include_path='.:/usr/local/share/pear') in
/home/alaska.net/atftb/www/******.php on line 3

******.php was the name of the pre-HelloWorld test. It worked on it's own.

(I obfuscated the .php filename & have since deleted them, this being a
public forum.)

I think I'll play w/it on my home box, then worry about it on the remote
hosts.

> OK, this must be getting on-topic again.
>
> So once you know you are able to use php, what you can start doing is
> build and test the pages on your own machine.

Ayup.

> Install Apache and php using YaST. Use YaST to launch apache and see
> that it is launched each and every time. As long as your firewall is not
> open on port 80, nobody will be able to see anything.
> If you want access to the outside world, there are other steps needed.
>
> Use http://localhost to see if it is running.

I generally add apache, mysql, and such when I build a new box so I can
play - I'll have to turn the services on (I use chkconfig for that
generally) but

> The directory everything is in is /srv/www/htdocs As a standard user you
> won't have access there. Sevral options are available on what to do.
> What I do is chown it so my user is owner of that directory (and the
> group root still)

Right. Anybody but www. Or use ~/public_html. Actually I often use
both, that way I can make a tweak in one and compare the results.

> Now you can do anything you desire, test it first and see how things go
> before uploading. And now if something does not work (unless it is pure
> php) it will be on topic again. :-D

Oh good. I'll sleep easier tonight. Thanks for the pointers...

....Kevin
--
Kevin Miller - http://www.alaska.net/~atftb
Juneau, Alaska
In a recent survey, 7 out of 10 hard drives preferred Linux
Registered Linux User No: 307357, http://counter.li.org
From: David Bolt on
On Monday 04 Jan 2010 23:08, while playing with a tin of spray paint,
houghi painted this mural:

> David Bolt wrote:
>> Using your own public_html directory does mean not having to mess with
>> the main server directory, and introduces some small amount of
>> protection. Even if your firewall is opened for port 80, unless those
>> on the outside know the user-name, they can't access the test pages.
>
> Yeah. I keep forgetting that. I am too lazy to type houghi.eu/~houghi
> (How does this delete button work anyway?)

What delete button?

>> Unless it's purely web-related PHP, it could be on topic. After all,
>> this would be the php equivalent to the bash script written for Vahis
>> in the "batch renaming in a subfolder tree" thread:
>
> LOL.

I was actually fairly serious there. I've written a few shell scripts
to use PHP instead of bash because what I've wanted to achieve was
easier in a PHP script rather than bash script.

For instance, one script is one I use for package building. It checks
the checksum of each spec file and then queries a MySQL database to
find out if the package is known or not, whether the checksum matches
the one stored and so if it needs to be rebuilt or not. If it hasn't
changed since the last build attempt, successful or not, it won't
bother to build the package again, unless I pass an option to force it
to do so. If there's been a change of checksum, it marks the package
for rebuilding in all the releases for which I do test builds and then
tries to build it. If the package isn't known, it adds the package to
my database and then tries to build it. After the build script has
finished, it stores the results, successful or not, ready for the next
time it's run.

It also accepts arguments on the command line so, as well as building
against the various released versions of openSUSE, it can also build
against my mirrors of the Packman packages, VideoLan, and/or the
updates. On top of that, I can build against packages I'm building so
I can satisfy dependencies that none of the main repos provide.

It's also capable of building for different architectures, e.g. when
running on a 64bit system, it can build 32 or 64bit packages. The only
"issue" I have is that it has to be run as root because the build
script, which builds packages in a chroot environment, won't run as a
normal user.

Then there's the one I use for batch trimming image files, while
optionally maintaining aspect ratios. That comes in very useful for
cropping images for my last script.

The last major script I wrote was one I use for batch converting images
ready for use as desktop wallpapers. That one uses much the same
technique as the script in my last reply to recursively re-size an
image to fit my desktop (1920x1080) while adding a background when the
image dimensions won't quite fit[0]. It goes through the directory
structure, using identity to get the file size and image type, it
creates a new name from the path the image was stored in, and then
creates the correct command line for convert, which it uses to do the
actual conversion.

The only ones scripts I won't try writing in PHP are those that are
interactive, and that's purely because I've not yet learnt how to have
a script read from a console while it's running. Once I've learnt that,
I'll have fun implementing them in both bash script and PHP, just to
see which is easier and/or shorter. My guess is that the bash scripts
will be a little shorter, but the PHP scripts won't have to call as
many external programs to do the same job.


[0] For portrait images, the image is flush to the right with the
background filling the area to the left. If the image is square or
landscape, it's centred and the outside edges are filled with the
background colour.

Regards,
David Bolt

--
Team Acorn: www.distributed.net OGR-NG @ ~100Mnodes RC5-72 @ ~1Mkeys/s
openSUSE 11.0 32b | | openSUSE 11.2 32b |
openSUSE 11.0 64b | openSUSE 11.1 64b | openSUSE 11.2 64b |
TOS 4.02 | openSUSE 11.1 PPC | RISC OS 4.02 | RISC OS 3.11
From: Kevin Miller on
David Bolt wrote:
>
> Unless it's purely web-related PHP, it could be on topic. After all,
> this would be the php equivalent to the bash script written for Vahis
> in the "batch renaming in a subfolder tree" thread:

Oh hey, good point! I mean, it's not like someone's posting about
wearing onions on their belt! ;-D

....Kevin
--
Kevin Miller
Juneau, Alaska
http://www.alaska.net/~atftb
In a recent poll, seven out of ten hard drives preferred Linux.