Jump to content

semperfi

Members
  • Posts

    39
  • Joined

  • Last visited

Everything posted by semperfi

  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
  16. Hi I am trying to learn to clean coding and learning to clean old coding for any vulnerabilities. Can anyone help me with this code and see what I missed. I know theres a lot can anyone help so I can someday be able to do this myself easily please. Thanks for any and all help... <? include("connect.php"); include("mail.php"); include("config.php"); function SendCounterMail($butlerstat1, $updatestat1) { $content1 = ''; $content1 .= "<font style='font-size: 10px;font-family: Arial, Helvetica, sans-serif;color: #333333;'>". "</font><br>"."<br>". "<p align='center' style='font-size: 14px;font-family: Arial, Helvetica, sans-serif;font-weight:bold;'>Counter Information</p>". "<br>"."<table border='0' cellpadding='3' cellspacing='0' width='100%' align='center' class='style13'>"; if ( $butlerstat1 ) $content1 .= "<tr style='font-size: 10px;font-family: Arial, Helvetica, sans-serif;color: #333333;'>". "<td>Butler file is not running so it is now running by this process.</td></tr>"; if ( $updatestat1 ) $content1 .= "<tr style='font-size: 10px;font-family: Arial, Helvetica, sans-serif;color: #333333;'>". "<td>Records file is not running so it is now running by this process.</td></tr>"; $content1 .= "<tr style='font-size: 10px;font-family: Arial, Helvetica, sans-serif;color: #333333;'>". "<td>This mail is testing for check file running in.</td></tr></table>"; $subject = "Counter Information"; $from=$adminemailadd;//= "newuser@thissite.com"; $email = $adminemailadd; //SendHTMLMail($email, $subject, $content1, $from); } $butlerstat = FALSE; $updatestat = FALSE; $ressel = mysql_query("select referral_bids from auction_pause_management where id=3"); if ( mysql_num_rows($ressel) == 0 ) { mysql_free_result($ressel); mysql_query("Insert into auction_pause_management (referral_bids) values (1)"); $ressel = mysql_query("select referral_bids from auction_pause_management where id=3"); } $oldvalue1 = mysql_result($ressel, 0); mysql_free_result($ressel); $ressel = mysql_query("select referral_bids from auction_pause_management where id=4"); if ( mysql_num_rows($ressel) == 0 ) { mysql_free_result($ressel); mysql_query("Insert into auction_pause_management (referral_bids) values (1)"); $ressel = mysql_query("select referral_bids from auction_pause_management where id=4"); } $oldvalue = mysql_result($ressel, 0); mysql_free_result($ressel); sleep(2); $ressel = mysql_query("select referral_bids from auction_pause_management where id=3"); $newvalue1 = mysql_result($ressel, 0); mysql_free_result($ressel); $ressel = mysql_query("select referral_bids from auction_pause_management where id=4"); $newvalue = mysql_result($ressel, 0); mysql_free_result($ressel); //if ( $oldvalue1 == $newvalue1 ) { $output1 = exec("php ".getcwd()."/update_butler.php >/dev/null &"); $butlerstat = TRUE; //} //if ( $oldvalue == $newvalue ) { $output = exec("php ".getcwd()."/update_records.php >/dev/null &"); $updatestat = TRUE; //} //SendCounterMail($butlerstat, $updatestat); //mysql_close($db); ?>
  17. Hi I found a php file ( http://www.howtocreate.co.uk/php/dnld.php?file=6&action=1 ) that acts as a fake push server and I am trying to make it work by actually pushing a another php file with no success yet. This PHP script provides a simple function to enable server push. All you need to do is tell it what file to serve, and update that file whenever a new version is available. See link for the code can anyone help please? What i want to do is to have it push ex. data.php file every x seconds but have yet to make it work. If I am not mistaking in the head or somewhere on the page add this line ( stated from there example ) require('serverpush.php'); doServerPush('some_image.jpg','image/jpeg',1000); I changed some_image.jpg to data.php and delete 'image/jpeg', ( still tinkering ) but that caused errors tried other ways but errors again. can anyone help me like I said I would like to have this file push data.php if anyone can help I would be grateful. Thanks in advance for any help and remember I am a beginner and still learning.
  18. Hi can anybody help I need to export and download tables from a database into a excel sheet. I have this code and it works what I need is to export specific fields and not just the whole table can anyone help modifying the code to export certain fields within the table please? Here is the code... <?php $host = 'localhost'; $user = 'user'; $pass = 'password'; $db = 'qdbname'; $table = 'tablename'; $file = 'export'; $link = mysql_connect($host, $user, $pass) or die("Can not connect." . mysql_error()); mysql_select_db($db) or die("Can not connect."); $result = mysql_query("SHOW COLUMNS FROM ".$table.""); $i = 0; if (mysql_num_rows($result) > 0) { while ($row = mysql_fetch_assoc($result)) { $csv_output .= $row['Field']."; "; $i++; } } $csv_output .= "\n"; $values = mysql_query("SELECT * FROM ".$table.""); while ($rowr = mysql_fetch_row($values)) { for ($j=0;$j<$i;$j++) { $csv_output .= $rowr[$j]."; "; } $csv_output .= "\n"; } $filename = $file."_".date("Y-m-d_H-i",time()); header("Content-type: application/vnd.ms-excel"); header("Content-disposition: csv" . date("Y-m-d") . ".csv"); header( "Content-disposition: filename=".$filename.".csv"); print $csv_output; exit; ?>
  19. Sorry new to this! and you are right about the differences between errors and Notices (My mistake). In regards to Where is $SITE_URL defined? It is defined in the config file <? php $SITE_URL='http://mysite.com/'; ?> Also in regard to the RRP and More**** amongst other things they are defined from another file that gets updated via a cron job. Again new to this and if there is anymore info you need please let me know and thanks for your help. Only have this issue when I place the offline file into the site the offline when activated works great its just when turning it off the offline thats when I get the Notices. If I remove the php offline file everything works perfect. I know I am doing something wrong or not placing it in the right spot or the right way.
  20. Here is the code and in bold is the php include file that is working when set offline but causing all kinds of DB errors when not set to offline. <link rel="shortcut icon" type="image/x-icon" href="favicon.ico" /> <link rel="icon" href="animated_favicon.gif" type="image/gif" > <link rel="apple-touch-icon" href="apple-touch-icon.png"> <div style="display: none"> </div> <script language="javascript" type="text/javascript"> var CurrencySymbol='<?php echo $Currency; ?>'; function _delete_login_fields(_field, _default, _current) { if (_default == _current) { _field.value=''; } } function onBeforeUnloadAction() { $.ajax({ type: "GET", url: "*******.php", success: function(responseData){ } }); } window.onbeforeunload = function(f) { if (!f) f = window.event; if (typeof f.pageX == "number") { X = f.pageX; Y = f.pageY; } else { X = f.clientX; Y = f.clientY; }; if((X<0) || (Y<0)) { return onBeforeUnloadAction(); } } function UpdateLoginLogout() { $.ajax({ type: "GET", url: "*******.php", success: function(responseData){ } }); } </script> <? if ( isset($_SESSION['url']) && $_SESSION['url'] != $SITE_URL ) { session_destroy(); ?> <?php include("offline.php"); ?> <script language="javascript">window.location.href="index.php";</script> <? exit; } function checkaucstatus($status) { if ( $status == "2" ) { $qryauc = "select count(*) from auction a left join auc_due_table adt on a.auctionID=adt.auction_id where adt.auc_due_time!=0 and auc_status='$status'"; } elseif ( $status == 3 ) { $qryauc = "select count(*) from auction where auc_status='$status' and auc_final_end_date>='".CreateSelEndDate()."' and auc_final_end_date<='".date("Y-m-d")." 23:59:59'"; } else { $qryauc = "select count(*) from auction where auc_status='$status'"; } $rsauc = mysql_query($qryauc); $totalauc = mysql_result($rsauc, 0); mysql_free_result($rsauc); return $totalauc; } ?> <div id="header"> <!--<div id="login-area">--> <div id=""> </div><!-- /login-area --> </div><!-- /header --> <script language='javascript'>UpdateLoginLogout();</script> I tried every way with the <? php ?> without it even tried every where on the page and still get the error. Any help now would be greatly appreciated. Thank you
  21. Thank you This is one of many errors when I include the php file. It has to do with the session start putting it after but when i do I still get the same errors. I am sure that i am place the php file in the wrong place or need to change something simple to make it work. Notice: Use of undefined constant RRP - assumed 'RRP' in /home/content/01/******/html/index.php on line 100 Notice: Use of undefined constant MORE_***** - assumed 'MORE_******' in /home/content/01/*****/html/index.php on line 143 This is only on the home page when I go to other pages in the site I get the undefined error in other places. Again thank you for your help.....
  22. Update This is the file I think were I should place the include file at and here is the code to the file. I tried every way and I still get errors same errors as above. <?php include 'config/connect.php'; include_once 'functions.php'; include_once 'include/advertisefunction.php'; $uid = (isset ($_SESSION['userid']) ? $_SESSION['userid'] : 0); $changeimage = 'home'; $pagename = 'index'; if ((!isset ($_SESSION['ipid']) AND !isset ($_SESSION['login_logout']))) { $_SESSION['ipid'] = date ('Y-m-d G:i:s'); $_SESSION['ipaddress'] = $_SERVER['REMOTE_ADDR']; $qryipins = 'Insert into login_logout (ipaddress,load_time) values(\'' . $_SESSION['ipaddress'] . '\', \'' . $_SESSION['ipid'] . '\')'; if (!(mysql_query ($qryipins))) { exit (mysql_error ()); (bool)true; } } $qryauc = 'select a.auctionID, adt.auc_due_price, price,adt.auc_due_time, p.name, p.picture1, p.productID from auction a ' . 'left join products p on a.productID=p.productID left join auc_due_table adt on a.auctionID=adt.auction_id ' . 'where adt.auc_due_time!=0 and a.auc_status=\'2\' order by adt.auc_due_time limit 0, 8'; $resauc = mysql_query ($qryauc); $totalauc = mysql_num_rows ($resauc); ?>
  23. Hi everyone I am pretty new to php but have been playing around with it for awhile. I have been trying to include a offline script from codecanyon located (http://codecanyon.net/item/web-construct/61643). The problem I am having is when I try to include the file as per the scripts instruction (<?php include("offline.php");?>) I get all sorts of errors on mysite (please see below for one error). I read his discussion section were one person is having the same problem I am having the script developers answers was (Place the webconstruct include after the session_start() line). I have tried that or think I did it right but still getting the same errors as before. Can someone please help me in getting this script installed? I will copy the session code below and if someone can point me to the right direction in how to resolve this issue I would be thankful. (error) Notice: Use of undefined constant (my session code) <? if ( isset($_SESSION['url']) && $_SESSION['url'] != $SITE_URL ) { session_destroy(); ?> <script language="javascript">window.location.href="index.php";</script> Thanks in advance for anyone's help!
×
×
  • 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.