Everything posted by CSN-UK
-
PHP explode/split string by HTML tags
If you want to reliabally grab anything in a html document or block of html, its best to treat it as html as such: $html = 'html contents or file <img src="smiley.gif" alt="Smiley face" height="42" width="42">'; $doc = new DOMDocument(); $doc->loadHTML($html); $tags = $doc->getElementsByTagName('img'); foreach ($tags as $tag) { echo $tag->getAttribute('src'); } This would loop and print out the src attribute of each image, hopefully helpfull, and easily modifiable for a first item, or other uses in future.
-
Duplicate of site on different domain with minor changes
Given the context, if it is purely a CSS/style based change then I would use a switch on the CSS served in the header, however I suspect over time there could be more deviation on the content/style at which point wp multi site or switch themes on the fly (rough example http://wordpress.stackexchange.com/questions/3761/switch-theme-on-fly). If you switch themes you could make use of child themes of the master, thus making change easier. There are also ways to allow a single WP install serve multiple domains (sites) by loading the DB and thus resources based on URL (using a switch statement).
-
Forum Error - serializer.php
Same error here (still ongoing), Seems to be intermittent on submitting a forum post/reply although when reporting a spam post it is continuous - so hopefully the report got through
-
Backing up Wordpress in it's Simplest form?
Hi Chris, The simple answer is indeed yes, so long as you have a copy of the files and indeed the database you will have the necessary files to re-install the site. There are however steps you would need to take if you were to migrate the site to an alternative domain however from such a backup. There are a few plugins for this and a quick google reveals this: http://wordpress.org/plugins/backwpup/ looks to have the features you are looking for and is indeed free .
-
Moan, Grumble, Whinge...
I suppose it’s about time to weigh in, this is probably more on the comical side Receiving a tech call from a company with a small coms centre on the recommendation of an old colleague. Following a brief run through of their systems, the problem and a two hour drive we arrive and followed up with the resident tech. Turned out the tech had never thought to check if the units where turned on, instead simply proceeded to show us “I usually come in and press this button [monitor power button] and the system is always there”. Lesson learned, always be specific when you ask “have you tried turning it off, and on again”
-
PHP and Visual Studio Express
I’d certainly have to side with Rallport against the use of Visual Studio for PHP, although understand that you will be tied to it for the C# and ASP end of the spectrum. Id perhaps take a look at PhpED by NuSphere if you’re looking for an alternative PHP IDE. As it certainly is as feature packed as VS, but with little overhead. A feature that will possibly be the most useful will be the debugger, as this is practically identical to that offered by VS for C# or other programming languages. With line-by-line execution, variable/data and environment usage etc both in a virtual or live environment and as such will feel very familiar. From memory there is a demo and indeed a student licence if (as i suspect you do) have a university .ac.uk email.
-
importing users into wordpress
Although I’ve never really tried it with WordPress it would make sense that if you where to locate the section in the old WordPress installation (if this is the case) in the wp-config.php that defines the Salt values/auth keys and copy and paste to the new install I couldn’t see why it wouldn’t work. The section looks like this: /**#@+ * Authentication Unique Keys and Salts. * * Change these to different unique phrases! * You can generate these using the {@link https://api.wordpress.org/secret-key/1.1/salt/ WordPress.org secret-key service} * You can change these at any point in time to invalidate all existing cookies. This will force all users to have to log in again. * * @since 2.6.0 */ define('AUTH_KEY', ' '); define('SECURE_AUTH_KEY', ' '); define('LOGGED_IN_KEY', ' '); define('NONCE_KEY', ' '); define('AUTH_SALT', ' '); define('SECURE_AUTH_SALT', ' '); define('LOGGED_IN_SALT', ' '); define('NONCE_SALT', ' ');
-
Warning: Cannot modify header information - headers already sent by ...
Hi Stallman, Looking over your code I can only see one real obvious point of call and that is your database, what would be the result if you were to comment out the line you have highlighted? Do you have display errors enabled in your PHP ini?
-
Automating Your Web Design Business - Tips & Tricks
Certainly a good idea to automate a lot of the contract generation, I have to admit we do something very similar, although through a modified/custom wiki software that pulls data from various places I.E git servers, server monitoring software api’s, the wiki itself and other places to generate a lot of overview type documents… certainly saves time. On the thought of Git or indeed SVN, we’ve seen and ourselves adopted the use of git to deploy/update 50/60 + WordPress installs simultaneously as we use a stock (custom) WordPress setup as our boiler plate and modify the appropriate .gitignore to push updates to both WP and plugins across rapidly. As for freshbooks, checkout Xero (UK) http://www.xero.com/ , We ourselves and a number of our clients use/ have used them. Their software is really feature rich whilst being perfectly intuitive whilst still keeping an accountant happy. Also good on a price front.
-
Wordpress Vs. Static HTML
It’s certainly interesting to see that the perception of a basic/flat HTML site has moved forward to the extent that they are now considered to be powered at least to some extent as a basic CMS. Which through good code practice/reuse to save time and increase maintenance certainly makes a great deal of sense, even at the basic end of the scale with PHP includes for common page elements (header/footer etc). I do however have an opposing thought as to the use of light CMS’s or in particular custom CMS’s as opposed to the likes of WordPress. Such that the power of WordPress or any other similar major CMS, is in its users… as we as humans will find something we like, that works and always invent new or additional features or additions. This is evident and greatly supported in WordPress among others with its community in particular providing a plethora of options premade with little to no cost or overhead. Some of the smaller light CMS’s certainly do have similar features and some support certain add-ons but not to the same extent. I quite like this idea of marshalling change as a counter to the use of such CMS’s as I’ve certainly seen what happens when a user gets a hold of a perfectly optimised and setup WordPress installation, however could this in most such CMS’s not be facilitated by providing the user an account with lesser administrative power (author) ? Alternatively perhaps having two versions of WordPress, light and standard… with slim line or primitive features In respect of the code/core through the use of the standard database structure which could/wold allow a full featured install to simply place over the top if/when needed? A Hybrid if you will? is it not light enough allready?
-
Foot firmly in mouth
I’d certainly throw my hat into the ring, very much a dab hand at coding but am more than experienced as a project manager and that side of things in general being a software engineer.. SCRUM would probably be a good for this kind of project alongside git etc.. also a notice board (card tool) called trello.com (free) is also particularly useful.
-
Speed freaks - post your scores
I might have to look into wp total cache again, as it certainly might benefit some of the sites we’ve recently developed… on a few basic tests across the network I also noticed quite a difference among some WordPress sites to others that had identical plugins and roughly similar content. The only main differentiation factor being the time at which the themes had been developed (or last updated) such that a theme lasted updated in 2008 achieved 88/100 - 36 - 2.73s - 294.8kB in comparison to the linked with a larger page size and number of requests. Certainly interesting what a clear difference the code or quality of the code to a lesser or greater extent is clearly playing it seems. Recently developed WP site. Pingdom link Wordpress CentOS CloudLinux environment - Apache
-
I need Help! I need a simple calculator for my website!
Hi Jimmy, Could you post your .html file code as you have it in Dreamweaver onto here for us to take a look at?, it will certainly help in getting you an answer both now and for future posts. Ensure you use the code option when posting (<> icon) though. Also I've made some slight modifications to the code Lyndsey provided to ensure the code runs when your page loads, as it appears JSfiddle was providing this for Lyndsey, you also need to include the other line below as jQuery is required. I've included a complete up-to-date example below that will work. Tip - You will notice the JavaScript is at the bottom of the page as opposed to the top, this is the best place for your JavaScript as it will allow your page to load more rapidly before loading the JavaScript and is often advised. Required to include jQuery in your file. <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script> Up-To-Date Version: <!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>Untitled Document</title> </head> <body> <select class="sel" id="sel1"> <option value=""> Select a Value... </option> <option value="10"> 10 </option> <option value="20"> 20 </option> </select> <select class="sel" id="sel2"> <option value=""> Select a Value... </option> <option value="70"> 70 </option> <option value="80"> 80 </option> </select> <input type="checkbox" value="50" name="myChk" id="myChk" /> Add Service (50) <br /> Total: <span id="total"> </span> </body> </html> <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script> <script type="application/javascript"> $(document).ready(function() { var totalElement = $('#total'); $('.sel').on('change', function() { totalElement.html( parseInt($('#sel1').val()) + parseInt($('#sel2').val()) ); }); $('#myChk').click(function() { if($(this).is(':checked')) { totalElement.html(parseInt(totalElement.html()) + parseInt($(this).val())); } else { totalElement.html(parseInt(totalElement.html()) - parseInt($(this).val())); }; }); }); </script> Hopefully that helps
- emailing php generated table
-
Parsing XML Response
As per the above and JordanC's rather apt tutorial I would use simpleXML, although as opposed to using cURL you can/could simply use the function shown in the tutorial simplexml_load_file() and insert your appropriate URI to the api and avoid the use of cURL entirely as it would be unnecessary. http://php.net/manual/en/function.simplexml-load-file.php
-
Wordpress Vs. Static HTML
For a long while now we’ve been watching the ever increasing numbers of WordPress sites being deployed and sign up with us, which has somewhat sparked a discussion that I’ve seen before and we’ve certainly had in the office, such that which is better Wordpress or a Static website? Obviously without bounds the discussion could/can go a number of ways as such consider three common scenarios we've seen: A site containing 15-30 pages that update infrequently, although a blog or similar (twitter, rss etc) is present for news/company developments. A site containing 5-15 pages updating frequently although the content is mainly using a wide number of differing page layouts (marketing style, splash pages, tabular data etc) specific to certain items or content. A static site 5-15 pages, accompanying a WordPress blog in addition to a forum, ecommerce or similar system… all themed appropriately. In respect to each scenario consider the following and share your thoughts: Performance (inclusive of SEO and optimisation), usability, reliability, maintainability, portability. Discuss? Fit for purpose? Ideas?
-
HTTP Error Codes
Hi Jordan, Personally I wouldn't and have never seen anyone return a http 200 codes directly outside of some more obscure API setups where data isn't being received from the request HTTP POST from a desktop application as an example. As such I would suggest you'd not need it, however I would perhaps advise depending on the scope of your project that you consider more detailed error responses (html page) as to more gracefully deal with issues such as the one you have provided.
-
php, how to recieve data from client application
It looks as though you are looking for a REST API, this is where you have a specific URI or a number or URI’s for different functions (sending different data etc) and you utilise them through HTTP POST and GET requests. An example would be https://mysite.com/add/client , https://mysite.com/add/update/client , https://mysite.com/add/delete/client As such you would POST your data as variable name -> value pairs to a PHP script that would determine the action (add/update/delete) from the URL and will then use the data to perform the action. In PHP you will be interested in $_POST to retrieve the data. In C++ there are various libraries I’m sure... though my C++ is a little rusty, I believe libCurl is quite common based on a quick Google. You must however consider security, such that … what stops someone impersonating your application or listening in on the data you post as such I would recommend OAuth 2.0 and necessitate SSL for all communication. Some useful links: http://www.w3schools.com/php/php_post.asp < PHP http://www.restapitutorial.com/ < a useful what is rest guide http://oauth.net/ < OAuth
-
PHP with Dreamweaver CS6
The Best PHP IDE I’ve ever come across to date has to be NuSphere’s PhpED, it’s capabilities, features support for tools and particularly debugging is very impressive and on par with what I expect from IDE’s such as Microsoft ultimate visual studio for executable applications. It is also very intuitive and will aid you no end with debugging errors, there are free alternatives such as netbeans or eclipse with PHP support although I would not rate them as highly. It looks as though NuSphere also have an aptly timed sale on also http://www.nusphere.com/products/phped.htm
-
Twitter names
Can’t say this Twitter has made much of an impact we me, though I was strong armed into it a while back by my team and members of another forum…. Not sure I've gone quite as far as a wooden peg yet though Feel free to follow if you like random techy ramblings or if you ever have a question @CSN_UK
-
PHP Application stress test
I think Rallport has made some good points with, caching, unit testing and being responsible with quires and just general good practices as these are always a good start, though running a looped insert script is somewhat self-fulfilling as it unfortunately proves very little. The insert itself performed by a single client repetitively is quite unlikely to cause any damage, it is concurrency in terms of the multiples of TCP/IP, MySQL, PHP and IO requests that can take their toll on performance and stability but this very much depends on the scale you are considering. The easiest of test is perhaps the unobvious, which is a DDOS attack against your own service which essentially mimicks a very specific user request concurrently and repeatedly. If I were to quantify that just a tad, consider a recent attack peaking at 300gb/s being recorded and sustained by a company.. (http://www.bbc.co.uk/news/technology-21954636) that is certainly impressive. - Though please talk to your provider or preferably test on equivalent hardware on a local network. There are numerous strategies but it really is project specific, the general rule however is to provide and cache client side as larger a chunk of data (necessary) as possible (where appropriate) to avoid repetitive calls (costly both in time and resource) and choose the appropriate saleable service provider. A lot of this centres around Service Oriented Architecture (SOA) and particularly Web Orientated Architecture (WOA) and depending on the application and or data even ultra-large-scale systems, all of which are worth looking into and a read if you intend to work on larger scale projects. There are some very interesting projects however going on in and around this area as the problem of scale and distribution on the web is still very much cutting edge considering research by Blair and Grace (2012) proposing that we are now "facing a second software crisis, brought about by increasing complexity in distributed systems”. Things that are worth looking into though are Google’s App Engine and BigQuery (https://developers.google.com/cloud/)… and perhaps read about their caching … I was fortunate to take part of a talk recently regarding it, really quite impressive. Even Hiphop by Facebook and some of their open source tools are extremely powerful at providing optimisation and scalability. http://developers.facebook.com/opensource/ Hopefully useful + some background info
-
JS jQuery Process xml?
Bit of an update for the benefit of those whom may in future experience a similar issue, It was DNS related, the localhost (LAMP/WAMP) server could not be found by $.get as it appeared to be querying the network DNS rather than considering the local DNS /localhost, thus returning a 404 file not found, works perfectly in a live environment however with the appropriate public URLs.
-
JS jQuery Process xml?
Unfortunately JS and jQuery, past the necessities has never been much of my strong point and I've hit a bit of a snag attempting to output the XML produced from the typical "REST service I made earlier", having tried a number of solutions I'm at my wits end... A sample data set and example JS is below, though this would typically be returned based on the provided url, it seems any attempt to use a url or external XML file fail. $(document).ready(function() { $.get('http://localdev/books/course/CC150/xml', function(d){ $('body').append('<h1> Recommended Web Development Books </h1>'); $('body').append('<dl>'); $(d).find('book').each(function(){ var $book = $(this); var id = $book.attr("id"); var title = $book.attr("title"); var isbn = $book.attr("isbn"); var borrowedcount = $book.attr("borrowedcount"); var html = '<dd><p> ' + id + '</p>' ; html += '<p> ' + title + '</p>' ; html += '<p> ' + isbn + '</p>' ; html += '<p> ' + borrowedcount + '</p>' ; html += '</dd>'; $('dl').append($(html)); $('.loadingPic').fadeOut(1400); }); }); }); <?xml version="1.0" encoding="UTF-8"?> <results> <course>CC150</course> <books> <book id="370955" title="Schaum's outline of UML" isbn="77096738" borrowedcount="212"/> <book id="422148" title="Human-computer interaction" isbn="130461091" borrowedcount="210"/> <book id="228015" title="Computer networks" isbn="133942481" borrowedcount="197"/> .......... </books> </results>
-
Skype Contacts :)
my personal Skype is aragon_202_ (I know ), Have a few added here already and always open for anything development, programming or server related in most languages, methodologies and flavours under the sun
-
PC or MAC?
This is based on the discussions with numerous professional in both photography and graphics as well as embedded systems developers and other non web based computer or software engineers. In terms of the technology being adopted as "retina" I'm yet to see, or hear of anyone outside of apple use or even make inroads to its use in standard LCD panels for monitors or TV production as it is only beneficial at a certain close distances. That said the idea of greater pixel density however is and has been around long before apple coined it Retina and is and always has been prevalent, however that is not the problem it is the rendering of the images on retina displays that make the colours and image super imposed and inaccurate to other monitors that is the problem, not their pixel density. To debate on the theory of multi tasking or threading is something that would have any number of computer scientists or like myself a software engineer laughing, as despite what you may perceive as mutli tasking or threading it is in fact not, as we're yet to solve that problem.. the scheduler still only allows 1 process to have its time on the processor at a time. Both work similarly with Mac using a derivative of roundrobin, with preloading or queuing of other threads/processes where as windows is priority based with pre-emptive scheduling. Both have their problems and advantages with nether being perfect, which I'll leave you to discover those. The point however is that their ability to multi task is comparative with a potentially sway towards the windows I would hazard from most professionals/academics, as for the virtual desktops, that is a feature of the GUI and is suited for the scheduler type. Windows doesn't have virtual separate desktops in the same respect but does not need them, with programs and tasks being stacked with live previews on the task bar, it's more a feature with each OS implementing the same thing slightly differently than a comparative point (matter of opinion). Though you could add this to windows if necessary. As for things windows can do and mac cannot, the vast majority of peripherals (specifically speciality fields) are windows only, think manufacture or office based, gaming still (though lessening), still a vast majority of software and drivers that are unavailable , lack of customisation, specifically UI and for developers, uninviting platform for developers .. the list goes on...