News:

Bored?  Looking to kill some time?  Want to chat with other SMF users?  Join us in IRC chat or Discord

Main Menu

Copy directory code, Valid??

Started by capabmx, December 20, 2009, 11:59:02 AM

Previous topic - Next topic

capabmx

Hey, working on my new media gallery mod still lol, trying to make all the extra functions work. So anyways, just wanted to test this code in SMG first, to see if it will work in mine.

So from what I've seen, everytime an album is created a copy of index.php is inserted for protection. Well for my playlist generator script, a folder "playlist" would need to be copied as well.

@copy($mgalSettings['data_dir_path'] . '/albums/index.php', $path_to_album . '/' . $newDirName . '/index.php'); that's the code to copy index.php.

What I'm wondering is, underneath I'd like to place a code to copy the playlist folder as well, anyone know how I'd go about this?

@copy(['data_dir_path'] . '/albums/playlist/', $path_to_album . '/ . $newDirName . '/playlist/');

Would that work? Trying to copy a whole folder, instead of single files, and place the folder in the album.
Always looking to take on a web design/ programming job :], PM me if interested.

Arantor

copy doesn't handle folders, simple as that - http://php.net/copy

There are some suggestions there on a recursive function however that will descend into folders.
Holder of controversial views, all of which my own.


capabmx

Ahhh I see, thank you very much for the response, may I ask, would you find it more practical to just make it create the playlist directory within the album directory, and copy the individual files? Or use the recursive function? Just because I know how to copy the individual files, would just be a few lines of copy, and a

$makedir = smg_mkdir($path_to_album . '/' . $newDirName, 0777); (media gallerys code to create new album)

What would I add to this to create a playlist directory within the new directory? Thanks so much for the help. I have a few other questions as well, but I'll wait :]
Always looking to take on a web design/ programming job :], PM me if interested.

Arantor

A recursive copy function would probably be easier later on for maintenance, it's easier to understand the logic of a single copy-directory statement in the main code than to figure out why it does multiple individual statements.

Do whatever feels more right to you - neither is 'right' or 'wrong' really, in absence of an in-built directory management function.

In a mod's package-info.xml file, for example, there is require-dir which does it all, thus require-dir there would be preferable to create-dir and a ton of require-file blocks.
Holder of controversial views, all of which my own.


capabmx

Ah ok, I've checked the recursive, and it looks not too complicated thank you very much. I'm going to first do the single files just so I can test this, and I'll use the recursive in my mod. My next question is, If I wanted a certain file to be executed, such as xspf.autogen, because to simply explain, the way the auto playlist generator works is this file needs to be accessed via browser, it then searches the directory it's in and creates the file xspf.dir, which is their playlist.

Then I'd like to add a permission to their profile, which is basically a dropdown, of their album names, and when clicked outputs the object embed code into their mymedia section. Example would be my profile I've manually placed my playlist embed code:

<object type="application/x-shockwave-flash" height="200" width="500" data="[s]http://www.thehangoutspot.com/mgal_data/player/player.swf[/s]">
<param name="allowScriptAccess" value="never" />
<param name="allowNetworking" value="internal" />
<param name="movie" value="[s]http://www.thehangoutspot.com/mgal_data/player/player.swf[/s]" />
<param name="wmode" value="transparent" />
<param name="bgcolor" value="#ffffff" />
<param name="flashvars" value="file=[s]http://www.thehangoutspot.com/mgal_data/xspf.php[/s]  &amp;playlist=bottom&amp;volume=20&amp;frontcolor=ffffff&amp;lightcolor=cc9900  &amp;backcolor=000000&amp;frontcolor=ffffff" />
</object>


The links with strikes through are the links that would be variabled. The first one:
Would be http://www.thehangoutspot.com/mgal_data/theiralbum/playlist/player/player.swf The variable would be "theiralbum" depending upon which album they click in the drop down list.

The second would be the same.

The third would be: http://www.thehangoutspot.com/mgal_data/theiralbum/playlist/xspf.php

Again the "theiralbum" would be the variable changed upon the album they choose in the drop down. Basically I just need a drop down code, and I'm not sure how to make it output my data into their mymedia. Thanks again for your help :]
Always looking to take on a web design/ programming job :], PM me if interested.

Arantor

I don't really understand what you're trying to accomplish, nor even what environment you're trying to do this dropdown in - is it basic HTML, Javascript+HTML or something in Flash?
Holder of controversial views, all of which my own.


capabmx

smiple html, basically what I have going on is I'm testing a playlist generator I'm adding into smf media gallery, and also jovanT's ultimate profile mod. So the dropdown would be in their edit profile pretty much, and relay their personal albums.
The way the playlsit generator works is a file called xspf.autogen, basically puts the values into the output code, and relays that playlist in xspf.dir file. Basically I just need the dropdown to choose between their playlists, and then output it to their mymedia box, which is a custom box in ultimate profile mod where you can put html, and css code in. I basically need to figure out how to make the dropdown do what's done on this site only the one drop down will be their albums, and output the embed code either to a new page, or directly into their mymedia box. I'm sorry for the confusion and I thank you very much for your help
Always looking to take on a web design/ programming job :], PM me if interested.

Arantor

That's not exactly simple HTML, that's Javascript based. Look up examples on "AJAX double dropdown" to explain how to do it.
Holder of controversial views, all of which my own.


capabmx

#8
Had to edit, yeah that was a rough sketch of the parts mashed up, and the original code from the site I linked for it's drop down, I got it figure out now :] thanks.
Always looking to take on a web design/ programming job :], PM me if interested.

Arantor

That isn't even remotely legal PHP.

I really don't understand what you're trying to do.
Holder of controversial views, all of which my own.


Advertisement: