Jump to content

semperfi

Members
  • Posts

    39
  • Joined

  • Last visited

Profile Information

  • Gender
    Male

semperfi's Achievements

Member

Member (2/5)

0

Reputation

  1. Again sorry should show the db structure. TABLE `interested` ( `id` bigint(20) NOT NULL AUTO_INCREMENT, `email` varchar(1000) NOT NULL, `hash` varchar( NOT NULL, `invites` int(20) NOT NULL, PRIMARY KEY (`id`), UNIQUE KEY `hash` (`hash`) Thanks for any help.
  2. Thank you for your help tried the above and it didnt work. I also should have mentioned the $user. This is in the head of the page for db connection etc. <?php include "config_db.php"; $user = mysql_query("SELECT * FROM `interested`"); ?> Again thank you for your help in trying to get this working been at it for a few more hours and got close but not there yet any more help would be greatly appreciated.
  3. Hi still learning php mysql etc and ran into a little issue and haven't been about to figure it out. trying to get/display the invite count for each email her is the php code <?php $i = 1; while($data = mysql_fetch_array($user)){ $count = mysql_fetch_array(mysql_query("SELECT COUNT( * ) FROM `interested` WHERE `invites` = '".$invites['invites']."'")); ?> <tr> <td><?php echo $i; ?></td> <td><?php echo $data['email']; ?></td> <td><?php echo $count['COUNT( * )']; ?></td> <td><?php echo $data['signup_time']; ?></td> <td><?php echo $data['signup_date']; ?></td> </tr> <?php $i++; } ?> Everything displays email etc and the invite count displays the total of the highest email that has invited for example joe@j.com has 3 invites and john@j.com has none and so on joe having the most invites at 3 the table displays 3 for all emails (hope that makes sense). Any help is much appreciated also any better way to write/refactor the code.
  4. Figured that out now with some of the tutorials I read. Now how to display them to specific pages or section of the page is my issue.
  5. I completely agree with what you said. I only like to know how this can be done and learn from the experience. I already have a cms in place which is for the most part secure and will continuously make it more secure when I see any holes or poor coding. Thanks to Maq for the search terms I have found a few tutorials but there tutorials are about making a full or semi full admin panel and all I need is to upload images to the img dir and have it stored in the db and the code to have it display on (for example) the header. I am still looking but have not found one that explains what i want for the most part I found uploading images and storing them into the db but nowhere how to display the stored images to pages as of yet. To put it simply I just want to add this functionality to the admin panel currently in place and not have to make the necessary image changes manually.
  6. Hi Looking for some pointers or a tutorial on coding where I can upload an image from a admin/control panel and have it display on certain pages. Something like all the major and minor scripts like wordpress etc. the image I want to upload is the site logo and currently I have to manually change the logo from the css I like to have it where this can be done from the admin/cms panel of my site. I know that tables will have to be created code placed on the front and back end where this needs to be done. but like I said I am a rookie and would like to view a tutorial on how this is done so I can learn. Please excuse me I have yet to know the exact wording to ask since I am learning PHP as of know.
  7. Sorry should of mentioned that it is for a unsubscribe input field where the user inputs his email address for unsubscribing ( delete his/her email from DB ). So which should I use delete or update?
  8. I am trying to delete multiple fields from a single table. Here are the fields in the table; signups_id signup_email_address signup_date signup_time Here is my code where I delete the data from the 'signup_email_address' and works with no issues but the other data is still there. I tried different quires but keep getting errors can someone please help with my code? if(isset($_POST["unsub"]) and !empty($_POST["unsub"])) { $query="delete from signups where signup_email_address='$_POST[unsub]'"; if(mysql_query($query,$conn)) {
  9. Hi I am trying to mask the url link and have not found a way to do that yet can anyone help please. The reason I want to mask the url is because it is for a users profile page when logged in. The individual users profile page sections is broken up to multiple pages within multiple tabs and each tab content is requested via ajax. So when i hover over each tab it displays the url link eg: http://example.com/user/profilepage1.php etc. Is their a way where i can have it display just nothing when hovering over the tabs. Below is the basic structure for the tabs links if anyone can help I would greatly appreciate it been at this for a coupe of hours and trying to avoid using javascript if possible. <ul class="nav"> <li><a href="content1.php"><span>tab1</span></a></li> <li><a href="content2.php"><span>tab2</span></a></li> <li><a href="content3.php"><span>tab3</span></a></li> <li><a href="content4.php"><span>tab4</span></a></li> <li><a href="content5.php"><span>tab5</span></a></li> </ul>
  10. Thanks overlooked the table in the DB was looking at auction_run_status instead of auction_running table (dont know how i missed that) and added the correct field into the table and now everything is working...
  11. I keep getting this error "Unknown column 'stop_status' in 'field list'" here's what I have can someone please let me know whats the problem and how to resolve it? I tried single and double quote. if($order!="") { $query = "select a.auctionID,a.productID as productID,a.categoryID as categoryID,auc_start_price,auc_final_price,auc_start_date,auc_end_date,auc_start_time,auc_end_time,auc_status,auc_type,auc_recurr,buy_user, auc_fixed_price,fixedpriceauction,pennyauction,nailbiterauction,offauction,nightauction,openauction,ftsauction,{$sqlFields3}time_duration,auc_final_end_date,total_time,ar.stop_status,ar.pause_status,shipping_id,future_tstamp,recurr_count,auction_min_price,min_win_price, use_free,allowbuynow,buynowprice,reverseauction,uniqueauction,halfbackauction,seatauction,bidpack,tax1,tax2,bidpack_name,bidpack_price,p.name,price,username from auction a left join (SELECT auctionID, stop_status, pause_status FROM auction_running) ar on a.auctionID = ar.auctionID left join products p on a.productID=p.productID left join registration r on r.id=a.buy_user left join bidpack b on b.id=a.productID where p.name like '$order%'"; } else { $query = "select a.auctionID,a.productID as productID,a.categoryID as categoryID,auc_start_price,auc_final_price,auc_start_date,auc_end_date,auc_start_time,auc_end_time,auc_status,auc_type,auc_recurr,buy_user, auc_fixed_price,fixedpriceauction,pennyauction,nailbiterauction,offauction,nightauction,openauction,ftsauction,{$sqlFields3}time_duration,auc_final_end_date,total_time,ar.stop_status,ar.pause_status,shipping_id,future_tstamp,recurr_count,auction_min_price,min_win_price, use_free,allowbuynow,buynowprice,reverseauction,uniqueauction,halfbackauction,seatauction,bidpack,tax1,tax2,bidpack_name,bidpack_price,p.name,price,username from auction a left join (SELECT auctionID, stop_status, pause_status FROM auction_running) ar on a.auctionID = ar.auctionID left join products p on a.productID=p.productID left join registration r on r.id=a.buy_user left join bidpack b on b.id=a.productID "; } <?php for($i=0;$i<$total;$i++) { if($PageNo>1) { $srno = ($PageNo-1)*$PRODUCTSPERPAGE+$i+1; } else { $srno = $i+1; } $row = mysql_fetch_object($result); $id=$row->auctionID; $pname=$row->bidpack?stripslashes($row->bidpack_name): stripslashes($row->name); $fprice=$row->auc_final_price; $status=$row->auc_status; $pause=$row->pause_status; $stop=$row->stop_status; $auctype = $row->auc_type; ?>
  12. Yes I have that on. Its when i try to remove the portion of code that contains the login and success section thats when i get a blank page. I know i am doing something wrong but can not figure it out. I made some changes before to it and received errors and corrected my mistakes but removing large portions of the code is whats getting me.
  13. The file works by including it to any page like header, footer etc and when activated it redirects to a offline template so I can do maintenance etc. I want to integrate it into my CMS but the file has its own login section and I want to remove the login section of the code and also remove the success part of the code. Basically I just want to have the section where I can activate and deactivate the site. I have tired with no success all i get is a blank page no errors. I would appreciate any help. <?php if (!isset($_SESSION)){session_start();} $page_offline = TRUE; $page_offline_title = "Coming Soon | Under Construction"; $page_offline_message = "There are some problems with our server. Nothing too serious, but it causes some downtime."; $admin_ip = "IP address"; $page_offline_message = "There are some problems with our server. Nothing too serious, but it causes some downtime."; $page_offline_template = "templates/example1/index.html"; $page_offline_foradmin = TRUE; $admin_password = "431301000c51954230c969f2e04c3add"; $page_offline_template = "templates/example1/index.html"; $page_offline_foradmin = TRUE; error_reporting(E_ALL); $page = strstr($_SERVER['PHP_SELF'], "offline.php") ? "admin" : "website"; get_template_list(); // Try login $login_error = FALSE; if(isset($_POST['txtpassword'])){ if(md5($_POST['txtpassword']) == $admin_password){ $_SESSION['offline_admin'] = TRUE; }else{ $login_error = TRUE; } } // Save config settings $offline = $page_offline ? 'checked="checked"' : ""; $title = $page_offline_title; $message = $page_offline_message; $saved = FALSE; $template = $page_offline_template; $adminoffline = $page_offline_foradmin ? 'checked="checked"' : ""; if(isset($_POST['btnsave']) && $_SESSION['offline_admin']){ $val_offline = isset($_POST['chkoffline']) && ($_POST['chkoffline'] == "true") ? TRUE : FALSE; $val_title = htmlspecialchars($_POST['txttitle']); $val_message = htmlspecialchars($_POST['txtmessage']); $val_template = htmlspecialchars($_POST['txttemplate']); $val_password = htmlspecialchars($_POST['txtpassword']); $val_adminoffline = isset($_POST['chkconstruct']) && ($_POST['chkconstruct'] == "true") ? TRUE : FALSE; $offline = $val_offline ? 'checked="checked"' : ""; $title = $val_title; $message = $val_message; $template = $val_template; $adminoffline = $val_adminoffline ? 'checked="checked"' : ""; if(empty($val_password)){ page_offline_save($val_offline, $val_title, $val_message, $val_template, $adminoffline); }else{ page_offline_save($val_offline, $val_title, $val_message, $val_template, $adminoffline, $val_password); } $saved = TRUE; } // Templates $admin_style_tpl = <<<ADMINSTYLETPL body{ font-family:Arial, Helvetica, sans-serif; font-size:11px; text-align: center; background-color:#F9F9F9; color:#555555; } #wrapper{ width:400px; padding:20px; margin: 0 auto; border:1px solid #DADADA; background-color: #FFF; text-align: left; } h2{ margin: 0px 0px 10px 0px; padding: 0px; font-size: 24px; color:#464646; font-family:Georgia,"Times New Roman",Times,serif; font-style: italic; font-weight: normal; } label{ display: block; width: 150px; font-weight: bold; padding: 14px 0px 3px 0px; } input{ -moz-border-radius-bottomleft:3px; -moz-border-radius-bottomright:3px; -moz-border-radius-topleft:3px; -moz-border-radius-topright:3px; width: 300px; background:#F5F5F5 none repeat scroll 0 0; border:1px solid #CCCCCC; color:#666666; padding: 4px 8px; } #chkoffline, #chkconstruct{ width: 20px; } .error{ border: solid 1px #CC0000; } ADMINSTYLETPL; $admin_login_tpl = <<<ADMINLOGINTEMPLATE <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>WebConstruct Login</title> <style> %s </style> </head> <body> <div id="wrapper"> <h2>WebConstruct Login</h2> <form id="form1" name="form1" method="post" action=""> <label for="txtpassword">Password</label> <input type="password" name="txtpassword" %s id="txtpassword" /><br /><br /> <input name="btnlogin" type="submit" value="Login" /> </form> </div> </body> </html> ADMINLOGINTEMPLATE; $admin_config_tpl = <<<ADMINCONFIGTEMPLATE <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>WebConstruct Admin</title> <style> %s </style> </head> <body> <div id="wrapper"> <h2>WebConstruct Admin</h2> <form id="frmadmin" name="frmadmin" method="post" action=""> <label for="chkoffline">Offline</label> <input name="chkoffline" id="chkoffline" %s type="checkbox" value="true" /> <label for="chkconstruct">Show offline to admin</label> <input name="chkconstruct" id="chkconstruct" %s type="checkbox" value="true" /> <label for="txttitle">Title</label> <input type="text" name="txttitle" value="%s" id="txttitle" /> <label for="txtmessage">Message</label> <input type="text" name="txtmessage" value="%s" id="txtmessage" /> <label for="txttemplate">Template</label> %s <label for="txtpassword">Admin password</label> <input type="password" name="txtpassword" id="txtpassword" /> <br /> Leave this field empty if you don't want to change the admin password. <br /><br /> <input name="btnsave" type="submit" value="Save" /> </form> </div> </body> </html> ADMINCONFIGTEMPLATE; $admin_saved_tpl = <<<ADMINSAVEDTEMPLATE <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Offline Admin</title> <style> %s </style> </head> <body> <div id="wrapper"> <h2>Configuration saved</h2> The configuration is saved succesfully. You can continue to <a href="offline.php">config</a> or go to your <a href="index.php">website</a>. </div> </body> </html> ADMINSAVEDTEMPLATE; if($page == "admin"){ // If user not is loggedin then show login screen if(!isset($_SESSION['offline_admin']) || !$_SESSION['offline_admin']){ echo sprintf($admin_login_tpl, $admin_style_tpl, ($login_error) ? 'class="error"' : ''); }else{ if(!$saved){ echo sprintf($admin_config_tpl, $admin_style_tpl, $offline, $adminoffline, $title, $message, html_select('txttemplate', 'txttemplate', $template, get_template_list())); }else{ echo sprintf($admin_saved_tpl, $admin_style_tpl); } } exit(); }else{ if($page_offline && (($_SERVER['REMOTE_ADDR'] != $admin_ip) || $page_offline_foradmin)){ ob_start(); include($page_offline_template); $template = ob_get_contents(); ob_end_clean(); // Replace variables $template = str_replace(array("{TITLE}", "{MESSAGE}"), array($page_offline_title, $page_offline_message), $template); // Show template echo $template; exit(); } } // Write settings to file function page_offline_save($offline, $title, $message, $template, $adminoffline, $password=""){ $lines = explode("\n", file_get_contents("offline.php")); // Set configuration $offline_state = ($offline) ? "TRUE" : "FALSE"; $lines[2] = '$page_offline = ' . $offline_state . ';'; $lines[3] = '$page_offline_title = "' . $title . '";'; $lines[4] = '$page_offline_message = "' . $message . '";'; $lines[5] = '$admin_ip = "' . $_SERVER['REMOTE_ADDR'] . '";'; $lines[7] = '$page_offline_template = "' . $template . '";'; $adminoffline_state = ($adminoffline) ? "TRUE" : "FALSE"; $lines[8] = '$page_offline_foradmin = ' . $adminoffline_state . ';'; if(!empty($password)){ $lines[6] = '$admin_password = "' . md5($password) . '";'; } // Save to file file_put_contents("offline.php", implode("\n", $lines)); } // Make list of templates function get_template_list(){ $templates = array(); if ($handle = opendir(dirname(__FILE__) . '/templates/')) { while (false !== ($file = readdir($handle))) { if($file != '.' && $file != '..' && !strstr($file, '.')){ $templates['templates/' . $file . '/index.html'] = ucfirst($file); } } } return $templates; } /** * Generate select element * * @param string $id * @param string $name * @param string $selected * @param array $values * @param array $extra * @return string */ function html_select($id, $name, $selected, $values){ $options = ''; foreach($values as $key => $value){ $selected_string = ($selected == $value) || ($selected == $key) ? 'selected="selected"' : ''; $options .= sprintf('<option value="%s" %s>%s</option>', $key, $selected_string, $value); } return sprintf('<select id="%s" name="%s">%s</select>', $id, $name, $options); }
  14. Hi i have a online/offline script that works great no issues at all. In order to change the html, php file to display when offline I need to point it to that file via input field. What i would like is to change the input filed and have a dropdown that list all the folders and subfolders within the the directory where all the templates are located. I have found a php snippet on the forum that does exactly what i want. The issue is now is to remove the input filed in the script and insert the snippet found here and thats where the issue comes. I'm hoping some guru here can easily help me out . please see below for the code online/offline code ( input filed i would like to replace with dropdown selector <input type="text" name="txttemplate" value="%s" id="txttemplate" />) <?php session_start(); $page_offline = TRUE; $page_offline_title = " "; $page_offline_message = " Offline"; $admin_ip = "1.1.1.1"; $admin_password = "*****************"; $page_offline_template = "template/path/index.php"; $page_offline_foradmin = TRUE; ini_set("display_errors", "0"); error_reporting(E_COMPILE_ERROR|E_ERROR|E_CORE_ERROR); $page = strstr($_SERVER['PHP_SELF'], "off.php") ? "admin" : "website"; // Try login $login_error = FALSE; if(isset($_POST['txtpassword'])){ if(md5($_POST['txtpassword']) == $admin_password){ $_SESSION['offline_admin'] = TRUE; }else{ $login_error = TRUE; } } // Save config settings $offline = $page_offline ? 'checked="checked"' : ""; $title = $page_offline_title; $message = $page_offline_message; $saved = FALSE; $template = $page_offline_template; $adminoffline = $page_offline_foradmin ? 'checked="checked"' : ""; if(isset($_POST['btnsave']) && $_SESSION['offline_admin']){ $val_offline = isset($_POST['chkoffline']) && ($_POST['chkoffline'] == "true") ? TRUE : FALSE; $val_title = htmlspecialchars($_POST['txttitle']); $val_message = htmlspecialchars($_POST['txtmessage']); $val_template = htmlspecialchars($_POST['txttemplate']); $val_password = htmlspecialchars($_POST['txtpassword']); $val_adminoffline = isset($_POST['chkconstruct']) && ($_POST['chkconstruct'] == "true") ? TRUE : FALSE; $offline = $val_offline ? 'checked="checked"' : ""; $title = $val_title; $message = $val_message; $template = $val_template; $adminoffline = $val_adminoffline ? 'checked="checked"' : ""; if(empty($val_password)){ page_offline_save($val_offline, $val_title, $val_message, $val_template, $adminoffline); }else{ page_offline_save($val_offline, $val_title, $val_message, $val_template, $adminoffline, $val_password); } $saved = TRUE; } // Templates $admin_style_tpl = <<<ADMINSTYLETPL body{ font-family:Arial, Helvetica, sans-serif; font-size:11px; text-align: center; background-color:#F9F9F9; color:#555555; } #wrapper{ width:400px; padding:20px; margin: 0 auto; border:1px solid #DADADA; background-color: #FFF; text-align: left; } h2{ margin: 0px 0px 10px 0px; padding: 0px; font-size: 24px; color:#464646; font-family:Georgia,"Times New Roman",Times,serif; font-style: italic; font-weight: normal; } label{ display: block; width: 150px; font-weight: bold; padding: 14px 0px 3px 0px; } input{ -moz-border-radius-bottomleft:3px; -moz-border-radius-bottomright:3px; -moz-border-radius-topleft:3px; -moz-border-radius-topright:3px; width: 300px; background:#F5F5F5 none repeat scroll 0 0; border:1px solid #CCCCCC; color:#666666; padding: 4px 8px; } #chkoffline, #chkconstruct{ width: 20px; } .error{ border: solid 1px #CC0000; } ADMINSTYLETPL; $admin_login_tpl = <<<ADMINLOGINTEMPLATE <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Login</title> <style> %s </style> </head> <body> <div id="wrapper"> <h2>Login</h2> <form id="form1" name="form1" method="post" action=""> <label for="txtpassword">Password</label> <input type="password" name="txtpassword" %s id="txtpassword" /><br /><br /> <input name="btnlogin" type="submit" value="Login" /> </form> </div> </body> </html> ADMINLOGINTEMPLATE; $admin_config_tpl = <<<ADMINCONFIGTEMPLATE <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title></title> <style> %s </style> </head> <body> <div id="wrapper"> <h2></h2> <form id="frmadmin" name="frmadmin" method="post" action=""> <label for="chkoffline">Offline</label> <input name="chkoffline" id="chkoffline" %s type="checkbox" value="true" /> <label for="chkconstruct">Show offline to admin</label> <input name="chkconstruct" id="chkconstruct" %s type="checkbox" value="true" /> <label for="txttitle">Title</label> <input type="text" name="txttitle" value="%s" id="txttitle" /> <label for="txtmessage">Message</label> <input type="text" name="txtmessage" value="%s" id="txtmessage" /> <label for="txttemplate">Template</label> <input type="text" name="txttemplate" value="%s" id="txttemplate" /> <label for="txtpassword">Admin password</label> <input type="password" name="txtpassword" id="txtpassword" /> <br /> Leave this field empty if you don't want to change the admin password. <br /><br /> <input name="btnsave" type="submit" value="Save" /> </form> </div> </body> </html> ADMINCONFIGTEMPLATE; $admin_saved_tpl = <<<ADMINSAVEDTEMPLATE <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Offline Admin</title> <style> %s </style> </head> <body> <div id="wrapper"> <h2>Configuration saved</h2> The configuration is saved succesfully. You can continue to <a href="off.php">config</a> or go to your <a href="../">Homepage</a> or back to <a href="index.php">admin panel</a>. </div> </body> </html> ADMINSAVEDTEMPLATE; if($page == "admin"){ // If user not is loggedin then show login screen if(!isset($_SESSION['offline_admin']) || !$_SESSION['offline_admin']){ echo sprintf($admin_login_tpl, $admin_style_tpl, ($login_error) ? 'class="error"' : ''); }else{ if(!$saved){ echo sprintf($admin_config_tpl, $admin_style_tpl, $offline, $adminoffline, $title, $message, $template); }else{ echo sprintf($admin_saved_tpl, $admin_style_tpl); } } exit(); }else{ if($page_offline && (($_SERVER['REMOTE_ADDR'] != $admin_ip) || $page_offline_foradmin)){ ob_start(); include($page_offline_template); $template = ob_get_contents(); ob_end_clean(); // Replace variables $template = str_replace(array("{TITLE}", "{MESSAGE}"), array($page_offline_title, $page_offline_message), $template); // Show template echo $template; exit(); } } // Write settings to file function page_offline_save($offline, $title, $message, $template, $adminoffline, $password=""){ $lines = explode("\n", file_get_contents("offline.php")); // Set configuration $offline_state = ($offline) ? "TRUE" : "FALSE"; $lines[2] = '$page_offline = ' . $offline_state . ';'; $lines[3] = '$page_offline_title = "' . $title . '";'; $lines[4] = '$page_offline_message = "' . $message . '";'; $lines[5] = '$admin_ip = "' . $_SERVER['REMOTE_ADDR'] . '";'; $lines[7] = '$page_offline_template = "' . $template . '";'; $adminoffline_state = ($adminoffline) ? "TRUE" : "FALSE"; $lines[8] = '$page_offline_foradmin = ' . $adminoffline_state . ';'; if(!empty($password)){ $lines[6] = '$admin_password = "' . md5($password) . '";'; } // Save to file file_put_contents("off.php", implode("\n", $lines)); } ?> snippet found here on the forum <?php $parent_directory = 'path/to/directory'; $file_types = 'html,htm,php,etc'; //===================================================// // FUNCTION: directoryToArray // // // // Parameters: // // - $root: The directory to process // // - $to_return: f=files, d=directories, b=both // // - $file_types: the extensions of file types to // // to return if files selected // //===================================================// function directoryToArray($root, $to_return='b', $file_types=false) { $array_items = array(); if ($file_types) { $file_types=explode(',',$file_types); } if ($handle = opendir($root)) { while (false !== ($file = readdir($handle))) { if ($file != "." && $file != "..") { $add_item = false; $type = (is_dir($root. "/" . $file))?'d':'f'; $name = preg_replace("/\/\//si", "/", $file); if ($type=='d' && ($to_return=='b' || $to_return=='d') ) { $add_item = true; } if ($type=='f' && ($to_return=='b' || $to_return=='f') ) { $ext = end(explode('.',$name)); if ( !$file_types || in_array($ext, $file_types) ) { $add_item = true; } } if ($add_item) { $array_items[] = array ( 'name'=>$name, 'type'=>$type, 'root'=>$root); } } } // End While closedir($handle); } // End If return $array_items; } if (isset($_POST[pickfile])) { // User has selected a file take whatever action you want based // upon the values for folder and file } else { echo ' <html> <head> <script type="text/javascript"> function changeFolder(folder) { document.pickFile.submit(); } </script> </head> <body>'; echo "<form name=\"pickFile\" method=\"POST\">\n"; $directoryList = directoryToArray($parent_directory,'d'); echo "<select name=\"folder\" onchange=\"changeFolder(this.value);\">\n"; foreach ($directoryList as $folder) { $selected = ($_POST[folder]==$folder[name])? 'selected' : ''; echo "<option value=\"$folder[name]\" $selected>$folder[name]</option>\n"; } echo '</select><br><br>'; $working_folder = ($_POST[folder]) ? $_POST[folder] : $directoryList[0][name]; $fileList = directoryToArray($parent_directory.'/'.$working_folder,'f',$file_types); echo "<select name=\"file\">\n"; foreach ($fileList as $file) { echo "<option value=\"$file[name]\">$file[name]</option>\n"; } echo '</select><br><br>'; echo "<button type=\"submit\" name=\"pickfile\">Submit</button>\n"; echo "</form>\n"; echo "</body>\n"; echo "</html>\n"; } ?> Thank you in advance for any help...
  15. Those numbers are Magical and yes I do have it documented/commented just stripped it for posting. Thank you I tried to make it easy to read I guess it worked
×
×
  • 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.