Everything posted by Gary Newport
-
Coding Strategies for New Site
I may be developing a new site shortly, given that the replacement for the old site is not looking like it will be delivered. I intend on starting from scratch and so am already thinking of the coding strategies I should be putting in place. When I originally built the site I used a single index.php file, which connected to the database and held the SESSION START. Through a series of $_GET statements and a SWITCH, the index.php would load other pages as required. This meant that the structure of the site was hidden from visitors. I also used procedural PHP and not Object Orientated; avoiding the need at the time to get my head around the syntax. I am still not clear why I would want to use object-based programming here. So, my question(s) are: Is the single point of entry, multiple-loading index.php a good idea? Should I be going Object-based or does it simply depend upon the purpose of the site? If so, what type of site should be using objects? Sorry but I have no one else to ask. How sad!
-
Linux and XAMPP - INCLUDE failed to open stream
Interestingly it WAS the brackets! I avoid case issues by keeping to the old rule of everything lowercase, so I thought I'd try without the brackets and everything fell into place. Thanks for the help.
-
Linux and XAMPP - INCLUDE failed to open stream
I am currently testing out a laptop with Linux and as such have offered to develop a website I started on a Windows system on this new system. I therefore copied the files across without altering a single line of code; the site worked on the Windows system running XAMPP. I have installed XAMPP, have set up the HTDOCS with the correct permissions and copied the site across. When I run the code I get the following error messages: Warning: include_once(/opt/lampp/htdocs/jwnewport/functions/functions.php): failed to open stream: Permission denied in /opt/lampp/htdocs/jwnewport/index.php on line 11 Warning: include_once(): Failed opening '/opt/lampp/htdocs/jwnewport/functions/functions.php' for inclusion (include_path='.:/opt/lampp/lib/php') in /opt/lampp/htdocs/jwnewport/index.php on line 11 Both messages are connected. The line of code causing the error is: include_once("/functions/functions.php"); This worked fine on the Windows system but not on the Linux one. What should I be using that would mean it works on both units AND once transferred to a web server elsewhere?
-
CKEDITOR.replace and AJAX
Yes, I have noted Nillervision's earlier warning and have identified that I need to spend some time resolving this issue without using this methodology but currently would like to fix this and then explore. As I write this it feels illogical and poorly thought out; I will ponder other methodologies.
-
CKEDITOR.replace and AJAX
Thanks for replying and I not you have seen that the navigational onclicks work (as does the onclick within the admin.php, a page called via an onclick request and using AJAX). I only get a single warning in Chrome: Synchronous XMLHttpRequest on the main thread is deprecated because of its detrimental effects to the end user's experience. For more help, check http://xhr.spec.whatwg.org/. I receive no other warnings/errors at all.
-
CKEDITOR.replace and AJAX
Thanks for the reply; however I still get nothing. If it's okay I'll go through my methodology: My index.php page is this: <?php session_start(); include("functions/functions.php"); include("settings/settings.us"); include("includes/connect.php"); if (!isset($_GET['page'])) { $pageID = 1; ?> <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>JW Newport</title> <link rel="stylesheet" type="text/css" href="css/styling.css" media="screen"> <script type="text/javascript" src="scripts/CollapsibleLists.js"></script> <script src="//cdn.ckeditor.com/4.5.5/full/ckeditor.js"></script> <script> window.onload = function() { CollapsibleLists.apply() }; function loadPage(href) { var xmlhttp = new XMLHttpRequest(); xmlhttp.open("GET", href, false); xmlhttp.send(); return xmlhttp.responseText; } //You will have to execute this code after the content is loaded //Eg after your loadPage function var loadedScript = document.getElementById('build_content'); if (loadedScript != null) { //We will have to eval any script tags in the response text eval(loadedScript.innerHTML); //execute a js function nested in script tags in the responseText myEmbeddedFunction (); } </script> </head> <body> <div id="container"> <div id="banner"> <div id="logo"></div> <div id="login"> <?php include('includes/login.php'); ?> </div> <div style="clear: both"></div> </div> <?php include("includes/nav.php"); ?> <div id="content"> <?php include("includes/main.php"); ?> </div> <div style="clear: both;"></div> </div> </body> </html> <?php } else { $pageID = $_GET['page']; include("includes/main.php"); } Your script is placed at lines 35 to 45. This page 'builds' my content and the two includes worth noting are nav.php (navigation menu, within which lies the script to load content within the div with the id "content") and main.php: <?php if ($pageID == "A") { include('includes/admin.php'); } else { $sql = "SELECT * FROM tbl_page WHERE page_id=:pageID"; $stmt = $db->prepare($sql); $stmt->bindParam(':pageID', $pageID, PDO::PARAM_INT); $stmt->execute(); while ($row = $stmt->fetchObject()) { echo $row->page_content; } } ?> It's the page=A part at the top that loads the admin page (admin.php): <?php if (isset($_SESSION['authorised'])) { if ($_SESSION['authorised'] == true) { if (!isset($_GET['as'])) { ?> <p> </p> <ol style="list-style: none inside;"> <li class="navigate" onClick="document.getElementById('content').innerHTML = loadPage('index.php?page=A&as=ap');" title='Add new contents page'>Add new page </li> <li class="navigate" onClick="document.getElementById('content').innerHTML = loadPage('index.php?page=A&as=ep');" title='Edit or delete existing pages'>Edit existing page </li> <li class="navigate" onClick="document.getElementById('content').innerHTML = loadPage('index.php?page=A&as=on');" title='Alter the order of the navigational system'>Change navigation order </li> <li class="navigate" onClick="document.getElementById('content').innerHTML = loadPage('index.php?page=A&as=au');" title='Add new user accounts'>Create additional login accounts </li> <li class="navigate" onClick="document.getElementById('content').innerHTML = loadPage('index.php?page=A&as=ep');" title='View existing accounts and delete, if necessary'>View user accounts </li> </ol> <?php } else { switch($_GET['as']) { case 'ap': include('admin/ap.php'); break; case 'ep': break; case 'on': break; case 'au': break; case 'eu': break; default: header("location: index.php"); break; } } } else { header("location: index.php"); } } else { header("location: index.php"); } This in turn offers the user a menu system, currently with one single option active (add new page; the first one and given the code ap). When the relevant link is clicked this executes the switch command and then includes the ap.php page: <br/> <form> <table> <tr> <td>Page Title:</td> <td><input type="text" name="title" title="title"></td> </tr> <tr> <td>Description:</td> <td><input type="text" name="description" title="description"></td> </tr> <tr> <td>Contents:</td> <td><textarea name="content" title="content"></textarea></td> <script id="build_content"> function myEmbeddedFunction (){ CKEDITOR.replace('content'); } </script> </tr> <tr> <td>Parent:</td> <td> <select name="parent" title="parent"> <option value="1">HOME</option> <?php $option_stmt = $db->query("SELECT page_id FROM tbl_page WHERE parent=1 ORDER BY page_title"); $option_stmt->execute(); while ($option_row = $option_stmt->fetchObject()) { $id = $option_row->page_id; $string = option_structure($id, $db, 1); echo $string; } ?> </select> </td> </tr> </table> </form> You'll see your code at lines 15 to 19. Sorry for the lengthy code listings (especially since so much is unrelated) but I wanted to remove any confusion on my appraoch. Just for clarity; the index.php loads main.php and nav.php. Once logged in nav.php will list the ADMIN option and this in turn will load admin.php into the "content" div (as defined my main.php) once clicked. admin.php offers a sub-menu with the first option currently live Once clicked this first option will cause main.php to include admin.php that will include ap.php, which has the textarea I want ckeditor to replace. I truly hope that helps.
-
CKEDITOR.replace and AJAX
I am testing out an idea and have come across a problem I cannot resolve. The site is using javascript to change the main contents area: function loadPage(href) { var xmlhttp = new XMLHttpRequest(); xmlhttp.open("GET", href, true); xmlhttp.send(); return xmlhttp.responseText; } One page loaded in this way has a form with the textarea input box being replaced by CKEDITOR in normal times (it works as a standard webpage) but does not work when loaded via this script. The relevant parts of the webpage are: <td>Contents:</td> <td><textarea name="content" title="content"></textarea></td> <script> CKEDITOR.replace('content'); </script> whilst the prompt for the page change is: <li class="navigate" onClick="document.getElementById('content').innerHTML = loadPage('index.php?page=A&as=ap');" title='Add new contents page'>Add new page </li> Any ideas?
-
Curious issue when copying design
Ooo, I like that site, rbrtsmith! Not anywhere near ready for posting anything but will look at this in more detail later. Currently filling in spare time with experiments and playtime. As you'll see with the attached files earlier, I do single line layout in my CSS, it was simply to save space that I collected the terms on a single line. This was because the code was identical to the site and so the issue cannot, I assume, exist in my code directly but around my code in some way.
-
Curious issue when copying design
I thought I'd post the code files since this may help someone identify the curiosity here. index.html general.css
-
Curious issue when copying design
Thanks for the comments. A reset doesn't make any difference and since the browser that shows the correct result (on the site) is exactly the same browser that is showing the failure (my side) then either we share the same browser default settings or the site over-rides these; I cannot see any reason otherwise for the same code to generate differing results in the same browser. Given also that I have used the developer tools to check the inheritances for each object and can confirm that they are identical (aside from a font-family change that has no impact) then there cannot be, as far as I can see, an underlying CSS file hidden, somehow, from the View Source. As regards my code layout, I encountered a number of issues getting my post to work and changed my layout to reduce the length of my post. My actual code is far better presented using multiple lines and short coding segments throughout.
-
Curious issue when copying design
This is undoubtedly a silly problem but here goes... I am undertaking a new web design and so am exploring hexagonal concepts in CSS. As part of this I came across the following site: https://jtauber.github.io/articles/css-hexagon.html Around the mid-point of this article the author gives an example of the hexagonal design being tiled (look for the phrase "Both orientations of hexagons can easily be tiled.", which precedes the tiling representation). I decided I would use this as my starting point and so generated the following code: .hex-row {clear: left;} .hex-row.even {margin-left: 53px;} .hex {float: left; margin-left: 3px; margin-bottom: -26px;} .hex .top {width: 0; border-bottom: 30px solid #6C6; border-left: 52px solid transparent; border-right: 52px solid transparent;} .hex .middle {width: 104px; height: 60px; background: #6C6;} .hex .bottom {width: 0; border-top: 30px solid #6C6; border-left: 52px solid transparent; border-right: 52px solid transparent;} I then generated the HTML: <!DOCTYPE html> <html> <head> <link rel="stylesheet" type="text/css" href="css/general.css"> </head> <body> <div style="width: 400px; float: left;"> <div class="hex-row"> <div class="hex"><div class="top"></div><div class="middle"></div><div class="bottom"></div></div> <div class="hex"><div class="top"></div><div class="middle"></div><div class="bottom"></div></div> <div class="hex"><div class="top"></div><div class="middle"></div><div class="bottom"></div></div> </div> <div class="hex-row even"> <div class="hex"><div class="top"></div><div class="middle"></div><div class="bottom"></div></div> <div class="hex"><div class="top"></div><div class="middle"></div><div class="bottom"></div></div> </div> <div class="hex-row"> <div class="hex"><div class="top"></div><div class="middle"></div><div class="bottom"></div></div> <div class="hex"><div class="top"></div><div class="middle"></div><div class="bottom"></div></div> <div class="hex"><div class="top"></div><div class="middle"></div><div class="bottom"></div></div> </div> </div> </body> </html> However, my result is shown in the hexagon.png attached. I have checked through Developer Tools and cannot find a single difference between the two that would account for this discrepancy and yet it is driving me mad! I am using IE 11, which is not my browser of choice but since it works in this browser for one and not for the other the issue is pertinent. What am I missing?
-
Connection Warning Showing
Thanks Weedy, I was aware of what the errors were telling me. I'm not looking to solve the fault (I hadn't, by this time, even constructed the database) but wanted to find a method that would prevent any and all error messages being sent to the browser window. I recognise that I am using a developmental environment and as such my php.ini is set to show warnings but was wondering if there was a way of preventing even this. The concept was that any stray messages that may appear in the live system could be prevented using this desired methodology. However, I have already spent far too long on something that was an aside from the main task so will move on to what I should be working on. )
-
Connection Warning Showing
I would have assumed that the mysqli_error would have come after the ERROR: and not prior to? In fact, when I remove ". mysqli_error($connect)" from my code I still get: So, the second line is the ". mysqli_error($connect)" but the first?
-
Connection Warning Showing
Hi I know I can control the level of warning within my php.ini but I thought the following code would mean that I would generate my own error messaging and prevent the warnings from appearing. Where am I in error in my thinking? Class db_functions { public function __construct() { DEFINE ('DB_HOSTNAME', 'localhost'); DEFINE ('DB_DATABASE', 'db_running'); DEFINE ('DB_USERNAME', 'root'); DEFINE ('DB_PASSWORD', ''); echo "Database definitions implemented"; } function connect_db() { $connect = mysqli_connect(DB_HOSTNAME, DB_USERNAME, DB_PASSWORD, DB_DATABASE) or die("ERROR: " . mysqli_error($connect)); return $connect; } } I would have expected to have "ERROR: [some message]" echoed to the screen and yet I actually get:
-
Hiding File Path
Thanks for the reply Chris. I thought I would explore your idea but am having an issue with the actual playing. The player does not appear in Firefox, which implies it cannot find the file or what is being returned is incorrect. This is what I have used: echo "<h2>$title</h2><audio controls>"; echo "<source src=\"media.php?file=$song&ext=mp3\" type=\"audio/mpeg\">"; echo "<source src=\"media.php?file=$song&ext=ogg\" type=\"application/ogg\">"; echo "Sorry but you have an outdated browser that does not support HTML5 audio playback.</audio>"; And the media file is: <?php if (isset($_GET['file'])) { $location = "../resources/songs/1/"; if (isset($_GET['ext'])) { $extension = ""; if ($_GET['ext']=="mp3") {$extension = "mp3"; $mime_type = "audio/mpeg";} if ($_GET['ext']=="ogg") {$extension = "ogg"; $mime_type = "application/ogg";} if ($_GET['ext']=="mp4") {$extension = "mp4"; $mime_type = "video/mpeg";} if ($extension=="") {exit;} } $filename = $location . $_GET['file'] . $extension; if(file_exists($filename)) { header('Content-type: {$mime_type}'); header("Content-Length: ". (string)(filesize($filename)) .""); header('Content-Disposition: filename="' . $filename); header('X-Pad: avoid browser bug'); header('Cache-Control: no-cache'); readfile($filename); } } ?> Any ideas where I am going wrong? The file I am trying to lock on to currently is at resources/songs/1/1.mp3 or resources/songs/1/1.ogg
-
Cannot locate problem
I am working on this site and have a couple of errors that I cannot seem to solve. The faults are all on the same page at the present and depend on the browser being used. The link is http://version3.revisionrocks.co.uk/index.php?action=history&topic=1&type=5 In Internet Explorer you cannot click on the SONG images or the HOME button (top right). In Firefox the SAMPLE tracks work but when you close the PLAYER window that comes up the formating gets all messed up. Anyone able to spot where I have gone wrong?
-
Hiding File Path
I have a set of video and audio files that a registered user can access (and some sample audio and video files for non-registered users). I am redesigning the site away from Flash and using HTML5 etc. The issue I have at the present moment is that I do not want to have the path to each of the videos in the <source> tag. Since the videos are collected together into relevant folders and the videos are named 1, 2, 3 etc for ease of access, if the one file source is visible then the potential for all is considerable. I have stored pdfs in a database as blobs and so the path is hidden, since when the pdf is required a temporary file is created; overwriting the previous temporary file. This makes for a single location and file name and no way of finding the other files since they exist in the database. I understand the issue of using the database method for audio and video files but now cannot find another way of hiding the file's location. Any suggestions? Aside from using HTML5 and CSS3 I am using PHP 5+ and MySQL 5+.
-
Javascript for moving DIV (WARNING: Newbie Question!)
I told you it was a newbie question! Actually quite pleased because from that one answer I now have a much greater concept of where the calls belong. Thank you!
-
Javascript for moving DIV (WARNING: Newbie Question!)
Okay, this is a real newbie question and, believe me, I have delayed in posting since I am not, in most cases, such a novice but... I am finally trying to get my head around Javascript. The basic concept is easy and follows all programming languages I am already aware of and yet I cannot get a basic div to work. In fact no matter what I do I cannot get anything to work. This is really bugging me but I believe once the obvious has been stated I can then move on to more complex things. The HTML is basic: <!DOCTYPE html> <html> <head> <link rel="stylesheet" type="text/css" href="css/styling.css" /> <meta http-equiv="Content-Type" content="text/html;charset=UTF-8" /> <title>Test Site</title> <script type="text/javascript"> function movediv() { x = document.getElementById('banner').style.top + 200; document.getElementById('banner').style.top=x+"px"; } </script> </head> <body onload="movediv"> <div id="container"></div> <div id="banner"> <div id="banner_lside"></div> <div id="banner_centre"></div> <div id="banner_rside"></div> </div> </body> </html> And the CSS is easy: @charset "UTF-8"; html {height: 100%} body { height: 100%; width: 100%; background-color: #036; margin: 0; padding: 0; } #container { margin: auto; width: 80%; height: 100%; background-color: #fff; box-shadow: 0px 0px 10px 10px #333; border-left: 1px solid #ccc; border-right: 1px solid #ccc; } #banner { z-index: 1; position: absolute; top: 0px; height: 20px; width: 100%; background-color: #ccc; opacity:0.8; border-top: 1px solid #666; border-bottom: 1px solid #666; box-shadow: 0px 5px 10px 1px #444; } #banner_centre { position: relative; float: left; width: 80%; height: 100%; } #banner_lside { position: relative; float: left; width: 10%; height: 100%; box-shadow: -10px 5px 5px 1px #444; } #banner_rside { position: relative; float: left; width: 10%; height: 100%; box-shadow: 14px 5px 5px 1px #444; } I have written a very simple piece of code to demonstrate what I perceive as the concept required but I am obviously making a newbie error. Would someone be kind enough to point it out and put me out of my misery?
-
Overflow Issue
Hi everyone I am creating a side box for a website that will house their Twitter feed. It is constructed from a series of DIVs: An all-encompassing div called 'twitter' A div for the heading label (twit_top) A div to contain all elements of all of the tweets (twit_main) A div to contain all elements of the individual tweets (twit) Then the two elements: (twit_date and twit_text) The whole set is contained within a div called "right" which is floated to the right and this in turn is contained within a div called "main". Main is one of three key divs within a centralised collecting div called "container". I have set the overflow-y to scroll and the overflow-x to hidden for the "twit_main" so that, if the tweets exceed the space allocated to the Twitter Feed the user can scroll up and down. However, currently the whole system is expanding beyond the space allocated; it is not keeping to it's fixed height. The HTML is as follows: <body> <div id="container"> <div id="nav"></div> <div id="main"> <div class="left"></div> <div class="right"> <div id="twitter" class="right"> <div id="twit_top"></div> <div id="twit_main"> <div class="twit"> <div class="left"></div> <div class="twit_date"></div> <div class="clear"></div> <div class="twit_text"></div> </div> </div> </div> </div> <div class="clear"></div> </div> <div id="content_bottom"></div> </div> </body> Whilst the CSS is: @charset "utf-8"; #twitter { border: #7e58ac 1px solid; color: #7e58ac; font-weight: normal; font-size: 60%; margin-right: 2%; width: 25%; height: 60%; } #twit_top { background-color: #7e58ac; color: #fff; text-align: center; font-weight: bold; } #twit_main { overflow-y: scroll; overflow-x: hidden; text-align: center; } .twit { padding: 1.5% 1% 1% 1%; border-bottom: 1px solid #000; } .twit_date { text-align: right; color: #9475b9; } .twit_text { text-align: left; color: #7e58ac; } The Inspector in FireFox indicates that the relationships between each DIV is as I envisage but I cannot find the reason why I cannot lock the height of the Twitter Feed. Anyone have any idea?
-
XAMPP as multi-user
Hi, I am running an XAMPP server within a college and have about 10 students developing their sites using the XAMPP system and FTPing their files across. The issue I have is that they all use a common login to access the root site, they can all access each other's folders and the phpMyAdmin is also accessible to all. I would really like to create a personalised instance within XAMPP where a student can access their folder only, that they have their own instance of phpMyAdmin to create and control databases and that they may even have a control panel to gain further controls over their own environment (similar to a standard webs server client model). This is not essential but would be nice to have so my question is: is thias at all possible with XAMPP and, if so, how?
-
Need to edit and add pages
Hi Before I get flamed, I have read the CMS statement at the top of this section of the forum but it does not address the issue I have. I have created a small website for a friend that allows him to sell his CDs. The site is getting bigger and as such I want to be able to allow him the ability to edit the existing pages as well as add new pages. The site already exists so i do not wish to recreate it. I do not need user rights, nor user accounts, blogs, forums, etc. I need to allow him an admin area to add and edit pages. I did start using Cushy CMS but I had two issues with this: 1. You could not add a new page easily 2. The editor did not use standard HTML to create content and as such made very messy pages I have seen Instant Update but, at $57, this is a costly system that I am unsure can do what I want it to do. Anyone any ideas?
-
Footer DIV not behaving itself
Thanks Highway7 I needed that little direction to sort it all out and I have done so. Sometimes you spend far too long staring at a problem and miss the blatantly obvious solution in your face.
-
Footer DIV not behaving itself
SITE: www.garynewport.com I have a footer div at the base of my site but it refuses to work from the base. The div starts at the top and then folders down around other content. Easier to see than explain so I have switched on a red border to the offending div on the actual site. There is a container div that, as it's name suggests, contains the rest of the site: banner and main. Originally I had the footer outside the main div (so that the main div contained the navigation bar and a div called content that has it's content (see, very obvious names) changed using AJAX. However, this failed and so putting it inside gave a good response. However, the footer runs over the navbar and makes it not function. Also, I want the footer div to be only where it is meant to be; at the foot of the page. Anyone any ideas (I am thinking a missing clear:both?)?
-
CSS Navigation
Thanks for the help! I have used the CSS sprite concept (using a matrix for a sectional navigation menu seemed too complex and unnecessary). Really grateful for all the help, this is an area that I had no idea about and have learnt loads! System menu runs nicely.