Jump to content

caspert_ghost

Members
  • Posts

    20
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

caspert_ghost's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Hello, ~hope this is the right place~ I am designing a music section for my site to allow members to share their musical talents. I am able to set up the site manually and hard card everything but it is taking forever. What I would like to do is use a php script that uploads the mp3 file to the server. The output of the page will be a table with a row for each uploaded mp3. I am using a flash player (here is where I need the help) and want to have 10 rows per page (using pagination) the code for embedding the flash player: <div id="flashPlayer"> This text will be replaced by the flash music player. </div> <script type="text/javascript"> var so = new SWFObject("playerMini.swf", "mymovie", "75", "30", "7", "#FFFFFF"); so.addVariable("autoPlay", "no"); so.addVariable("soundPath", "song.mp3"); so.write("flashPlayer"); </script> in order for me to have multiple instances of this player I must change: <div id="flashPlayer"> and so.write("flashPlayer"); ie: when I hard code it I make the following: flashplayer0 for the first one flashplayer1 for the second and so on. Is there a way to have php add the change for me and use php to upload and create the tables via the database rather than hard coding each one (which requires the users to email me their files)? Thank you in advance
  2. read the next paragraph of that same page: The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Library General Public License instead.) You can apply it to your programs, too.
  3. That my friend is the licensce/ you may distribute the "license" but may not make changes to the "license" The code IS however OPENSOURCE which MAY be changed and altered.
  4. the script is a third party script and all of it is released under the gnu license so changing altering the code is ok. the above code is the only section that refers to the link buttons (as tabs) and I want to hide the one tab. There is no (at the moment) any way to delete the photos once uploaded. I want to add a button to delete for admin only for now and will work on user delete later.
  5. Below you will find the code for a photo album, the designer does not have a forum or email for answering questions and I need help on this. In this code there is a section called "tabs" this section creates the tabs: Browse (index.php), My Albums (if user has an album), Hot, recent, views, upload... If user has an album it will show "My Albums", if not it hides this button. I would like to hide "upload" unless user is a member of a specific group. Also there is no way to delete photos which to me is not a good idea, so if someone who knows how to code could assist with: 1: how to hide the "upload" tab 2: how to add a delete button so the user who uploaded may delete AND the admin has the ability to delete any. thank you Full information and download for the complete code can be found at: http://www.phpbb.com/community/viewtopic.php?f=70&t=579254&st=0&sk=t&sd=a This is only a partial code script, this is installed with phpbb boards. <?php /** * * @package Gallery * @version $Id: gallery.php v0.1.0 12.09.2007 17:52:03 danieLs Exp $ * @copyright (c) danieLs - http://www.safereaction.ro * @license http://opensource.org/licenses/gpl-license.php GNU Public License * */ class Gallery { var $config; function load_config() { global $db; $sql = 'SELECT * FROM ' . GALLERY_CONFIG_TABLE; $result = $db->sql_query($sql); if ($row = $db->sql_fetchrow($result)) { do { $this->config[ $row['config_name'] ] = (int) $row['config_value']; } while ($row = $db->sql_fetchrow($result)); } $db->sql_freeresult($result); } function get_config($name) { return $this->config[$name]; } function generate_menu($page = GALLERY_PAGE_BROWSE) { global $template, $phpEx, $user, $db; $template->assign_block_vars('tabs', array( 'S_SELECTED' => ($page == GALLERY_PAGE_BROWSE ? true : false), 'U_TITLE' => "index.{$phpEx}", 'L_TITLE' => $user->lang['GALLERY_MENU_BROWSE'] ) ); if ($user->data['is_registered']) { $sql = 'SELECT album_id FROM ' . GALLERY_ALBUMS_TABLE . ' WHERE album_user_id = ' . $user->data['user_id']; $result = $db->sql_query($sql); if ($row = $db->sql_fetchrow($result)) { $template->assign_block_vars('tabs', array( 'S_SELECTED' => ($page == GALLERY_PAGE_MYALBUM ? true : false), 'U_TITLE' => append_sid("index.{$phpEx}", '?gallery=members&album_id=' . $row['album_id']), 'L_TITLE' => $user->lang['GALLERY_MENU_MYALBUM'] ) ); } $db->sql_freeresult($result); } $template->assign_block_vars('tabs', array( 'S_SELECTED' => ($page == GALLERY_PAGE_HOT ? true : false), 'U_TITLE' => append_sid("hot.{$phpEx}"), 'L_TITLE' => $user->lang['GALLERY_MENU_HOT'] ) ); $template->assign_block_vars('tabs', array( 'S_SELECTED' => ($page == GALLERY_PAGE_RECENT ? true : false), 'U_TITLE' => append_sid("recent.{$phpEx}"), 'L_TITLE' => $user->lang['GALLERY_MENU_RECENT'] ) ); $template->assign_block_vars('tabs', array( 'S_SELECTED' => ($page == GALLERY_PAGE_VIEWS ? true : false), 'U_TITLE' => append_sid("views.{$phpEx}"), 'L_TITLE' => $user->lang['GALLERY_MENU_VIEWS'] ) ); $template->assign_block_vars('tabs', array( 'S_SELECTED' => ($page == GALLERY_PAGE_UPLOAD ? true : false), 'U_TITLE' => append_sid("upload.{$phpEx}"), 'L_TITLE' => $user->lang['GALLERY_MENU_UPLOAD'] ) ); } function get_albums() { global $db, $user; $sql = 'SELECT album_id, album_name FROM ' . GALLERY_ALBUMS_TABLE . ' WHERE album_parent_id = 0 AND album_user_id = 0'; $result = $db->sql_query($sql); $options = '<option value="0">' . $user->lang['GALLERY_PERSONAL_ALBUM'] . '</option> <option value="-1" disabled="disabled">------------------------------</option>'; $albums = array(); if ($row = $db->sql_fetchrow($result)) { do { $albums[] = array( 'album_id' => $row['album_id'], 'album_name' => $row['album_name'] ); } while ($row = $db->sql_fetchrow($result)); } $db->sql_freeresult($result); foreach ($albums as $item) { $options .= '<option value="' . $item['album_id'] . '">|--' . $item['album_name'] . '</option>'; $sql = 'SELECT album_id, album_name FROM ' . GALLERY_ALBUMS_TABLE . ' WHERE album_parent_id = ' . $item['album_id'] . ' AND album_user_id = 0'; $result = $db->sql_query($sql); if ($row = $db->sql_fetchrow($result)) { do { $options .= '<option value="' . $row['album_id'] . '">| |--' . $row['album_name'] . '</option>'; } while ($row = $db->sql_fetchrow($result)); } } $db->sql_freeresult($result); return $options; } function handle_upload($form_name = 'fileupload') { global $phpbb_root_path, $phpEx, $user; $filedata = array( 'error' => array() ); $upload = new fileupload(); $filedata['post_attach'] = ($upload->is_valid($form_name)) ? true : false; if (!$filedata['post_attach']) { $filedata['error'][] = $user->lang['NO_UPLOAD_FORM_FOUND']; return $filedata; } $extensions = array(); if ( (int) $this->config['jpg_allowed'] == 1 ) { $extensions[] = 'jpg'; $extensions[] = 'jpeg'; } if ( (int) $this->config['gif_allowed'] == 1 ) { $extensions[] = 'gif'; } if ( (int) $this->config['gif_allowed'] == 1 ) { $extensions[] = 'png'; } $upload->set_allowed_extensions($extensions); $file = $upload->form_upload($form_name); if ($file->init_error) { $filedata['post_attach'] = false; return $filedata; } if (!$file->is_image()) { $file->remove(); $filedata['error'][] = $user->lang['ATTACHED_IMAGE_NOT_IMAGE']; return $filedata; } if((int) $this->config['bigger_allowed'] == 0) { $file->upload->set_allowed_dimensions(0, 0, (int) $this->config['max_width'], (int) $this->config['max_height']); } $file->clean_filename('unique'); $file->move_file('gallery/upload/pics', false, false); if (sizeof($file->error)) { $file->remove(); $filedata['error'][] = $file->error; $filedata['post_attach'] = false; return $filedata; } if((int) $this->config['bigger_allowed'] == 1) { if ($file->get('height') > (int) $this->config['max_width'] || $file->get('width') > (int) $this->config['max_height']) { $destination = $source = $file->get('destination_file'); if (!$this->create_thumbnail($source, $destination, $file->get('mimetype'))) { $file->remove(); $filedata['error'][] = $user->lang['GALLERY_ERROR_RESIZEING_PIC']; $filedata['post_attach'] = false; return $filedata; } } } $filedata['filesize'] = $file->get('filesize'); $filedata['physical_filename'] = $file->get('realname'); $filedata['real_filename'] = $file->get('uploadname'); $filedata['filetime'] = time(); $filedata['mimetype'] = $file->get('mimetype'); // Check free disk space if ($free_space = @disk_free_space($phpbb_root_path . $config['upload_path'])) { if ($free_space <= $file->get('filesize')) { $filedata['error'][] = $user->lang['ATTACH_QUOTA_REACHED']; $filedata['post_attach'] = false; $file->remove(); return $filedata; } } return $filedata; } function create_thumbnail($source, $destination, $mimetype, $size = 'large') { global $config; $min_filesize = (int) $config['img_min_thumb_filesize']; $img_filesize = (file_exists($source)) ? @filesize($source) : false; if (!$img_filesize || $img_filesize <= $min_filesize) { return false; } $dimension = @getimagesize($source); if ($dimension === false) { return false; } list($width, $height) = $dimension; if ($size == 'small') { $max_width = 128; $max_height = 128; } else if ($size == 'med') { $max_width = 640; $max_height = 480; } else { $max_width = (int) $this->config['max_width']; $max_height = (int) $this->config['max_height']; } if (empty($width) || empty($height)) { return false; } if ($width > $height) { $new_width = round($width * ($max_width / $width)); $new_height = round($height * ($max_width / $width)); } else { $new_width = round($width * ($max_width / $height)); $new_height = round($height * ($max_width / $height)); } // Do not create a thumbnail if the resulting width/height is bigger than the original one if ($new_width > $width && $new_height > $height) { $new_width = $width; $new_height = $height; } switch ($mimetype) { case 'image/gif': $image = @imagecreatefromgif($source); break; case 'image/jpg': case 'image/jpeg': $image = @imagecreatefromjpeg($source); break; case 'image/png': $image = @imagecreatefrompng($source); break; } if (function_exists('imagecreatetruecolor')) { $new_image = imagecreatetruecolor($new_width, $new_height); if ($new_image === false) { return false; } imagecopyresampled($new_image, $image, 0, 0, 0, 0, $new_width, $new_height, $width, $height); } else { $new_image = imagecreate($new_width, $new_height); if ($new_image === false) { return false; } imagecopyresized($new_image, $image, 0, 0, 0, 0, $new_width, $new_height, $width, $height); } // If we are in safe mode create the destination file prior to using the gd functions to circumvent a PHP bug if (@ini_get('safe_mode') || @strtolower(ini_get('safe_mode')) == 'on') { @touch($destination); } switch ($mimetype) { case 'image/gif': imagegif($new_image, $destination); break; case 'image/jpg': case 'image/jpeg': $image_quality = ($size == 'small' || $size = 'med') ? (int) $this->config['thumbnail_quality'] : 100; imagejpeg($new_image, $destination, $image_quality); break; case 'image/png': imagepng($new_image, $destination); break; } imagedestroy($new_image); if (!file_exists($destination)) { return false; } @chmod($destination, 0666); return true; } function redirect($meta_url, $message, $delay) { meta_refresh($delay, $meta_url); trigger_error($message); } } ?>
  6. bump, still need assistance with this please.
  7. This is driving me nutz.. why couldnt they make php 5 backward compatible.
  8. try changing global $bcURL; to global $b_cURL; or global $cURL; or remove global $bcURL;
  9. Well unfortunatly I must return to this issue as moving is now not an option for us at this time. A re glimps of what has aspired thus far. I have a script that is written in php 5 and I need some help in re writing it for php 4. The original code is: rss_feeds.php <?php class OnlyHellRssFeed { private $nr_news=10; private $rss_channel = array(); private $currently_writing = ""; private $main = ""; private $item_counter = 0; private $template; private $feedname; private $url; function __construct($feedname, $url) { $this->feedname = $feedname; $this->url = $url; } function startElement($parser, $name, $attrs) { switch($name) { case "RSS": case "RDF:RDF": case "ITEMS": $this->currently_writing = ""; break; case "CHANNEL": $this->main = "CHANNEL"; break; case "IMAGE": $this->main = "IMAGE"; $this->rss_channel["IMAGE"] = array(); break; case "ITEM": $this->main = "ITEMS"; break; default: $this->currently_writing = $name; break; } } function endElement($parser, $name) { $this->currently_writing = ""; if ($name == "ITEM") { $this->item_counter++; } } function characterData($parser, $data) { if ($this->currently_writing != "") { switch($this->main) { case "ITEMS": if (isset($this->rss_channel[$this->main][$this->item_counter][$this->currently_writing])) { $this->rss_channel[$this->main][$this->item_counter][$this->currently_writing] .= $data; } else { //print ("rss_channel[$main][$item_counter][$currently_writing] = $data<br>"); $this->rss_channel[$this->main][$this->item_counter][$this->currently_writing] = $data; } break; } } } function get_data(&$template) { $xml_parser = xml_parser_create(); xml_set_element_handler( $xml_parser, array($this, 'startElement'), array($this, 'endElement') ); xml_set_character_data_handler( $xml_parser, array($this, 'characterData') ); $data = self::curl_string($this->url); xml_parse($xml_parser,$data); xml_parser_free($xml_parser); // putting in array $news=array(); if (isset($this->rss_channel["ITEMS"])) { if (count($this->rss_channel["ITEMS"]) > 0) for($i = 0;$i < count($this->rss_channel["ITEMS"]);$i++) $news[]=$this->rss_channel["ITEMS"][$i]; } $c=0; foreach($news as $key=>$val) { if($c<$this->nr_news) { $template->assign_block_vars($this->feedname, array( 'LINK' => $val['LINK'], 'TITLE' => $val['TITLE'], 'DESC' => $val['DESCRIPTION']) ); } $c++; } } private static function curl_string ($url,$user_agent='Mozilla 4.0'){ $ch = curl_init(); curl_setopt ($ch, CURLOPT_URL, $url); curl_setopt ($ch, CURLOPT_USERAGENT, $user_agent); curl_setopt ($ch, CURLOPT_HEADER, 0); curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt ($ch, CURLOPT_FOLLOWLOCATION, 1); curl_setopt ($ch, CURLOPT_TIMEOUT, 120); $result = curl_exec ($ch); curl_close($ch); return $result; } } ?> This gave the error: Parse error: syntax error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /home/admin/public_html/bb3portal/block/rss_feeds.php on line 9 When I change: private $nr_news=10; private $rss_channel = array(); private $currently_writing = ""; private $main = ""; private $item_counter = 0; private $template; private $feedname; private $url; private static function curl_string ($url,$user_agent='Mozilla 4.0'){ to: (removing the "private" code) var $nr_news=10; var $rss_channel = array(); var $currently_writing = ""; var $main = ""; var $item_counter = 0; var $template; var $feedname; var $url; var static function curl_string ($url,$user_agent='Mozilla 4.0'){ Parse error: syntax error, unexpected T_STATIC, expecting T_VARIABLE in /home/admin/public_html/bb3portal/block/rss_feeds.php on line 106 It was then said to remove "var static" and leave only function curl_string the new error: Fatal error: Undefined class name 'self' in /home/admin/public_html/bb3portal/block/rss_feeds.php on line 80 so I searched and found only 1 reference to self:: and changed it to $this-> now I get no errors but the list is not showing up as it should in my block. there are 2 more files that go with this: rss_feedlist.php <?php $feeds = array( 'mtgbks' => 'http://www.wizards.com/rss.asp?x=books', 'mtgdnd' => 'http://www.wizards.com/rss.asp?x=dnd', 'mtgd20' => 'http://www.wizards.com/rss.asp?x=d20modern', 'mtgebr' => 'http://www.wizards.com/rss.asp?x=eberron', 'mtgfr' => 'http://www.wizards.com/rss.asp?x=forgottenrealms', 'mtgmtg' => 'http://www.wizards.com/rss.asp?x=magic', 'mtgswrpg' => 'http://www.wizards.com/rss.asp?x=starwars-rpg', ); foreach ($feeds as $feed_name => $url) { $feed = new OnlyHellRssFeed($feed_name, $url); $feed->get_data($template); } ?> and rss_feeds.html which is the output page. if you could please look closley at this code and help with a rewrite for php 4 I would be gratly appreciative. Thank you
  10. I decided this is just too much re coding so I will ask them again to update and if they refuse I will move to another host that offers up to date php and sql. Thank you all for your help in this matter.
  11. great so far so good. I got no errors however the feeds are not showing up... the feeds are in another php file called feedlist.php after changing (there was only one) self:: to $this-> So I am wondering if I should combine the feeds and feedlist php's into 1 php file.
  12. with removing "static" and leaving function (getting closer) Fatal error: Undefined class name 'self' in /home/admin/public_html/bb3portal/block/rss_feeds.php on line 80
  13. code as it is now (this site wont allow edits so I must create new post ) rss_feeds.php <?php // rss_feeds.php written by Static & Penagate @ http://staticfx.com // this file goes in the /bb3portal/block/ directory class OnlyHellRssFeed { var $nr_news=10; var $rss_channel = array(); var $currently_writing = ""; var $main = ""; var $item_counter = 0; var $template; var $feedname; var $url; function __construct($feedname, $url) { $this->feedname = $feedname; $this->url = $url; } function startElement($parser, $name, $attrs) { switch($name) { case "RSS": case "RDF:RDF": case "ITEMS": $this->currently_writing = ""; break; case "CHANNEL": $this->main = "CHANNEL"; break; case "IMAGE": $this->main = "IMAGE"; $this->rss_channel["IMAGE"] = array(); break; case "ITEM": $this->main = "ITEMS"; break; default: $this->currently_writing = $name; break; } } function endElement($parser, $name) { $this->currently_writing = ""; if ($name == "ITEM") { $this->item_counter++; } } function characterData($parser, $data) { if ($this->currently_writing != "") { switch($this->main) { case "ITEMS": if (isset($this->rss_channel[$this->main][$this->item_counter][$this->currently_writing])) { $this->rss_channel[$this->main][$this->item_counter][$this->currently_writing] .= $data; } else { //print ("rss_channel[$main][$item_counter][$currently_writing] = $data<br>"); $this->rss_channel[$this->main][$this->item_counter][$this->currently_writing] = $data; } break; } } } function get_data(&$template) { $xml_parser = xml_parser_create(); xml_set_element_handler( $xml_parser, array($this, 'startElement'), array($this, 'endElement') ); xml_set_character_data_handler( $xml_parser, array($this, 'characterData') ); $data = self::curl_string($this->url); xml_parse($xml_parser,$data); xml_parser_free($xml_parser); // putting in array $news=array(); if (isset($this->rss_channel["ITEMS"])) { if (count($this->rss_channel["ITEMS"]) > 0) for($i = 0;$i < count($this->rss_channel["ITEMS"]);$i++) $news[]=$this->rss_channel["ITEMS"][$i]; } $c=0; foreach($news as $key=>$val) { if($c<$this->nr_news) { $template->assign_block_vars($this->feedname, array( 'LINK' => $val['LINK'], 'TITLE' => $val['TITLE'], 'DESC' => $val['DESCRIPTION']) ); } $c++; } } var static function curl_string ($url,$user_agent='Mozilla 4.0'){ $ch = curl_init(); curl_setopt ($ch, CURLOPT_URL, $url); curl_setopt ($ch, CURLOPT_USERAGENT, $user_agent); curl_setopt ($ch, CURLOPT_HEADER, 0); curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt ($ch, CURLOPT_FOLLOWLOCATION, 1); curl_setopt ($ch, CURLOPT_TIMEOUT, 120); $result = curl_exec ($ch); curl_close($ch); return $result; } } ?> with these changes I get a new error: Parse error: syntax error, unexpected T_STATIC, expecting T_VARIABLE in /home/admin/public_html/bb3portal/block/rss_feeds.php on line 106
  14. so function OnlyHellRssFeed NOT class OnlyHellRssFeed
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.