PHP - Load Content If Operating System Is Everything But Linux
Hi,
I am trying to load a block of code for all operating systems except Linux. I have the following code. Does it look ok?- I am not too sure what to put in the IF statement.
Thanks! Similar TutorialsI happened to come across an article leading me to Mesosphere Datacenter Operating System the other day.
The Mesosphere Datacenter Operating System (DCOS) is a new kind of operating system. It spans all the servers in your datacenter or cloud.
Looks promising to me and the video is impressive.
https://www.youtube....h?v=UgJMlHdZEx4
Some perks
Datacenter services include Apache Spark, Apache Cassandra, Apache Kafka, Apache Hadoop, Apache YARN, Apache HDFS, Google’s Kubernetes, and more.
The Mesosphere DCOS supports all modern versions of Linux including: CoreOS, CentOS, Ubuntu and RedHat. It runs on-premise on bare metal or in a virtualized private cloud, such as with VMware or OpenStack. It also runs on all the major public cloud services, including Amazon Web Services, Google Compute Engine, Digital Ocean, Microsoft Azure, Rackspace and VMware vCloud Air.
hello dear php-experts i run opensuse 13-2 and i am very very happy the time does not get displayed correct. it falls back to UTC all day. What can i do. i have had look at the documents here https://en.opensuse....uring_the_clock https://tr.opensuse....T_Date_and_Time how to set up correct to the local time - note i live in GERMANY near francfurt hello and good day dear Linux-experts, i want to install a new opensuse linux on a notebook. i want to upgrade is the following: this one: Akoya P 6512 15" OpenSuse 13.1: AMD Athlon X2 P320, 2,10 GHz, 4 GB 320 GB hdd-drive what is wanted: i want to do a total fresh installation i want to have not tooo much partitions! i only want to run opensuse 13.2 i want to have some kind of native linux partitions - such as ext 4 - # what do you suggest - should go with the new default BTRFS file system?!? well to begin with the beginning: i applied the following commands a. lsblk b. fdisk -l see the results,,,, ; linux-c5sz:/home/martin # lsblk NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT sda 8:0 0 465,8G 0 disk ├─sda1 8:1 0 4G 0 part [SWAP] ├─sda2 8:2 0 102M 0 part ├─sda4 8:4 0 1K 0 part ├─sda5 8:5 0 2G 0 part ├─sda6 8:6 0 4G 0 part ├─sda7 8:7 0 10G 0 part ├─sda8 8:8 0 20G 0 part / └─sda9 8:9 0 389,6G 0 part /home sr0 11:0 1 1024M 0 rom and the following fdisk -l linux-c5sz:/home/martin # fdisk -l Disk /dev/sda: 500.1 GB, 500107862016 bytes, 976773168 sectors Units = Sektoren of 1 * 512 = 512 byte Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk label type: dos Disk identifier: 0xb8fa3ecd Gerät boot. Anfang Ende Blöcke Id System /dev/sda1 63 8385929 4192933+ 82 Linux swap / Solaris /dev/sda2 8385930 8594774 104422+ 83 Linux /dev/sda4 * 8803620 976768064 483982222+ 5 Extended /dev/sda5 8803683 12996584 2096451 83 Linux /dev/sda6 12996648 21382514 4192933+ 83 Linux /dev/sda7 21382578 42347339 10482381 83 Linux /dev/sda8 117821440 159766527 20972544 83 Linux /dev/sda9 159768576 976766975 408499200 83 Linux linux-c5sz:/home/martin # subsequently the questions; which partition logic should i choose. what is wanted: i want to have not tooo much partitions! i only want to run opensuse 13.2 note: i want to erase all the existing partition logic /(that is currently existing) i do this with Gparted. which partitions should i take? which file system ? i am curious to get to know your ideas well good moring dear folks - hope you are all right and everythings is fine across the atlantic today i have a question regarding server-paths - and the absolute and relative in a linux-[opensuse 11.4] lampp-system well i just installed something in to my Lampp on openSuse 11.4 while setting up this application - (it is a joomla 1.7.3 ) i wonder how i name the paths public $unicodeslugs = '0'; public $feed_limit = '10'; public $log_path = 'D:\\Xammp\\xampp\\htdocs\\pre1/logs'; public $tmp_path = 'D:\\Xammp\\xampp\\htdocs\\pre1/tmp'; public $lifetime = '15'; public $session_handler = 'database'; what cou you thinks how shoud i name the paths well you see above this was a windows box where the pahts originally were taken from love to hear from you Hey, all! I posted a thread before about a content management system for my news, and so far the php script works fine. I would like to add additional features to this system, though, and was wondering if anyone could help. Here's the code for all the files needed for the news content management system to work... 1.) First, is the mysql table, called "mynews" with the fields: "id" - primary key; auto-increment. "title" - the title of the news article. "user" - the person who posted the article (would be me in all cases) "message" - the body of the article; this would contain the actual news. "url" - the url to the full article. "time" - time and date the article was posted, or added to database. "type" - the type of news, like 'update', or 'random'. 2.) Next, is the code to connect to the database in mysql, called "dbconnect.php": Code: [Select] <?php $username = "your username"; //your username $password = "your password"; //your password $host = "your hostname"; //your mySQL server $database = "your database name"; //The name of the database your table is in mysql_connect($host,$username,$password) or die("Error connecting to Database!<br>" . mysql_error()); //connect, but if there is a problem, display an error message telling why there is a problem mysql_select_db($database) or die("Cannot select database!<br>" . mysql_error()); //Choose the database from your mySQL server, but if there is a problem, display an error telling why ?> 3.) Third, is the forms for posting new articles, called "postnews.php": Code: [Select] <form action="process.php" method="post" id="news"> <h1>Post New Article</h1> <p>Please fill out all of the following fields:</p> <table width="100%" border="0" cellpadding="0" cellspacing="0"> <tr> <td class="cmsNewsformText">Type*:</td> <td><font size="1"> <input name="type" type="text" class="cmsNewforms" size="50" /> </font></td> </tr> <tr> <td class="cmsNewsformText">News Topic/Title*: </td> <td><font size="1"> <input name="title" type="text" class="cmsNewforms" value="enter title of article" size="50" /> </font></td> </tr> <tr> <td class="cmsNewsformText">Username*:</td> <td><font size="1"> <input name="user" type="text" class="cmsNewforms" value="enter username" size="50" /> </font></td> </tr> <tr> <td class="cmsNewsformText">Url*:</td> <td><font size="1"> <input name="url" type="text" class="cmsNewforms" value="enter url of news article" size="50" /> </font></td> </tr> <tr> <td class="cmsNewsformText">Message*:</td> <td><font size="1"> <textarea name="message" cols="43" rows="10" class="cmsNewforms">enter body of article </textarea> </font></td> </tr> </table> <p> <font size="1"> <input name="Submit" type="submit" class="Button1" value="Submit" /> </font> </p> </form> 4.) Fourth, is process.php. This script sends the data entered by the administrator (me) on "postnews.php" to the database, and displays a message saying that the information was sent successfully. Code: [Select] <?php $user=$_POST['user']; $title=$_POST['title']; $message=$_POST['message']; $type=$_POST['type']; $url=$_POST['url']; mysql_connect("your hostname", "your database name", "your password") or die(mysql_error()); mysql_select_db("cmsnewsacp") or die(mysql_error()); $sql = sprintf("INSERT INTO mynews (user, title, message, type, url) VALUES ('%s', '%s', '%s', '%s', '%s')", mysql_real_escape_string($user), mysql_real_escape_string($title), mysql_real_escape_string($message), mysql_real_escape_string($type), mysql_real_escape_string($url)); $result = mysql_query($sql); Print "The article has successfully been posted"; ?> 5.) And lastly, here's the script for displaying the news on the home page: Code: [Select] <? include("dbconnect.php"); //include the file to connect to the database $getnews = mysql_query("SELECT * FROM mynews ORDER BY id DESC"); //query the database for all of the news while($r=mysql_fetch_array($getnews)){ //while there are rows in the table extract($r); //remove the $r so its just $variable echo(" <span class=NewsID>$type</span> <span class=h2>$title</span><br><br> <em>posted by <strong>$user</strong> on $time</em><br> <span class$message<br><br /> <font color=0099FF><a href=$url>Read more - $url</a></font><br><br><p>"); } ?> Now that you've got all the code, let's take a look back at the table "mynews" with its fields. See "url"? This variable would contain the url I type in the forms on "postnews.php" and would be called to form a "Read more" link at the end of each article displayed on the home page. The question I have here, is how can I modify this script to where everytime a new 'article' is added to the database, a new page is created with the article and the url I specified? Also, I want to limit the amount of characters of the article, so that it'll only display a little bit on the home page, with a "read more" link that takes them to that page. Now last but not least, how in the bloody fudge do I script pagination into this script? I've made a site for a client and they like it. They asked me who does the updates me or them? So I know they want to make the updates themselves. Do anyone know the best place I can learn how to create a CMS? I would prefer video tutorials. Thanks. Hello, the below validator keeps saying invalid email, can you notice any issues: <form name="input" action="check.php" method="post"> Username: <input type="text" id="email" name="email" /> <input type="submit" value="Submit" /> </form> Check.php <?php if (isset($_REQUEST['email'])) { $email = trim($_POST['email']); if(!checkEmail($email)) { echo 'Invalid email address!'; } else { echo 'Email address is valid'; } } function checkEmail($email) { if(preg_match("/^( [a-zA-Z0-9] )+( [a-zA-Z0-9\._-] )*@( [a-zA-Z0-9_-] )+( [a-zA-Z0-9\._-] +)+$/" , $email)) { list($username,$domain)=split('@',$email); if(!checkdnsrr($domain, 'MX')) { return false; } if(!fsockopen($domain,25,$errno,$errstr,30)) { return false; } return true; } return false; } ?> Many thanks Hi All,
Am hoping someone can point out my perhaps obvious issue here.
I've a series of links that are dynamically created:
<a class="team-link" rel="<?php the_ID(); ?>" href="#">When a link is clicked, I'm trying to get content to load into this DIV: <div id="single-post-container"></div>I have the following jquery: <script> $(document).ready(function(){ $.ajaxSetup({cache:false}); $(".team-link").click(function(){ var post_id = $(this).attr("rel"); $.ajax({ url : "http://www.domain.co.uk/wp-content/themes/name/loop.php", data : {"the_team": post_id }, type : "POST", dataType : "html", success: function(response) { $("#single-post-container").html(response); } return false; }); }); </script>This is my loop.php file: require_once('../../../wp-load.php'); // Our variables $the_team = (isset($_GET['post_id'])) ? $_GET['post_id'] : 0; echo $the_team; query_posts(array( 'post_type' => 'work', 'meta_key' => 'author_name', 'meta_value' => $the_team )); // our loop if (have_posts()) { while (have_posts()){ the_post(); ?> <h1><?php the_title(); ?></h1> <?php the_content(); ?> <hr /> <?php } } wp_reset_query();However, when you click the link, nothing happens. I know loop.php works as I can specify a value and manually browse to it to see the content. I feel I'm missing something obvious as I'm new to AJAX. Your help/patience is very much appreciated (not sure if this should be in php or javascript section) I am trying to create a dropdown list that loads content according to the option chosen.. The idea is that you select from 4 or so dropdown boxes, which then selects the appropriate content that the user picked Pretty much like http://www.cooldiamonds.com/ (after you click enter) This is what I've got so far: Option.html Code: [Select] <script src="http://code.jquery.com/jquery-latest.js" type="text/javascript"></script><br> <script type="text/javascript"> $(document).ready(function(){ $('.select').change(function() { var option = $(this).val(); $.get('option.php', {select:option}, function(data) { $('#result').html(data).hide().fadeIn(1000); }); }); }); </script> </head> <body> <p> Selection 1</p> <select name="select" id="select" class="select"> <option value="">Select</option> <option value="option1">Option 1</option> <option value="option2">Option 2</option> </select> <p> Selection 2</p> <select name="select2" id="select2" class="select"> <option value="">Select</option> <option value="option3">Option 3</option> <option value="option4">Option 4</option> </select> <p> Selection 3</p> <select name="select3" id="select3" class="select"> <option value="">Select</option> <option value="option5">Option 5</option> <option value="option6">Option 6</option> </select> <p> Selection 4</p> <select name="select3" id="select3" class="select"> <option value="">Select</option> <option value="option7">Option 7</option> <option value="option8">Option 8</option> </select> <div id="result" style="border:1px solid #000;padding:10px;color:#ff0000;display:none;"></div> option.php Code: [Select] <?php // Multiple Selections if ($_GET['select'] == 'option1' && $_GET['select2'] == 'option3') { echo 'the option you have chosen is 1 and 3';} elseif ($_GET['select2'] == 'option4' && $_GET['select3'] == 'option5' && $_GET['select4'] == 'option7') { echo 'the option you have chosen is 4, 5 and 7';} // and so on //Selection 1 elseif($_GET['select'] == 'option1') { echo 'the option you have chosen is 1';} elseif($_GET['select'] == 'option2') { echo 'the option you have chosen is 2';} //Selection 2 elseif($_GET['select2'] == 'option3') { echo 'the option you have chosen is 3';} elseif($_GET['select2'] == 'option4') { echo 'the option you have chosen is 4';} //Selection 3 elseif($_GET['select3'] == 'option5') { echo 'the option you have chosen is 5';} elseif($_GET['select3'] == 'option6') { echo 'the option you have chosen is 6';} // Selection 4 elseif($_GET['select4'] == 'option7') { echo 'the option you have chosen is 7';} elseif($_GET['select4'] == 'option8') { echo 'the option you have chosen is 8';} ?> You can view it he http://adamwatkin.com/option.html As you can see selection 1 works fine, but the other selections do not work and neither does multiple selections. Its almost certainty theres errors in the code, does anyone have any idea what the problem is? Any help will be appreciated Cheers hello dear PHP-Fans - greetings to you - and a happy new year!! i set up a WAMP-System on my openSuse 11.4 system. In order to learn as much as i can bout PHP i want to do some tests and write some scripts. Well the WAMP is allready up and running. Now i try to give the writing access to the folder mkdir /srv/www/ where the php-scripts should go in... i want to give write permission to all to all files in /srv/www As root I generally: mkdir /srv/www/ chown <webmaster usrername> /srv/www/ /srv/www/ should be readable and traversable by all, but only writeable by it's owner (the user designated as the webmaster.) can i do this like mentioned above,... Love to hear from you greetings db1 I'm having a problem and need an answer to why its happening and how to prevent it. Scenario: I begin load my home page which starts with a session_start(); .... Before it FULLY completes loading I try to navigate to another page and BOOM, that page will not load and any other page that begins with session_start(); will not load unless I close and restart the entire browser or wait about 10 minutes.... I will note my website makes ajax calls every 5 seconds or so, but I use setTimeout for them. Any help??? Thanks ahead! Hi all, I like to write scripts for my Aastra IP phone. 480i. I have done all my scripts with Apache on windows. I thought I would try it on Linux with the AsteriskNOW FreePBX 1.4 load. Phone system software for those that do not know. So my code is below something very simple to display on the screen. Ignore the $textmenu code that works fine. The problem is it does not open a file and do something then write the file. On my Windows / Apache box the screen will display on the phone and open the file and do whatever. On my Linux box it will display the screen fine but will not open that file. Why would it be ingnoreing those PHP file commands? Any ideas? It file commands work if I run it with php script.php but not when I use my phone to launch that script. Now keep in mind Windows/Apache is fine no problem. I thought maybe it was a php.ini setting on the linux box? <?php $textmenu = "<AastraIPPhoneTextMenu style = \"numbered\">\n"; $textmenu .= "<Title>------- Test -------</Title>\n"; $textmenu .= "<MenuItem>\n"; $textmenu .= "<Prompt>Applications</Prompt>\n"; $textmenu .= "<URI>http://65.205.71.13/xml/menu/menu.php?source=all</URI>\n"; $textmenu .= "</MenuItem>\n"; $textmenu .= "<SoftKey index = \"1\">\n"; $textmenu .= "<Label>Select</Label>\n"; $textmenu .= "<URI>SoftKey:Select</URI>\n"; $textmenu .= "</SoftKey>\n"; $textmenu .= "<SoftKey index = \"6\">\n"; $textmenu .= "<Label>Exit</Label>\n"; $textmenu .= "<URI>SoftKey:Exit</URI>\n"; $textmenu .= "</SoftKey>\n"; $textmenu .= "</AastraIPPhoneTextMenu>\n"; echo $textmenu; $fp=fopen("/var/www/html/aastra/awa-det/conference/test.txt","w+"); fwrite($fp); fclose($fp); ?> Hi, I am trying to use php to pass some commands to my linux box.From my webpage I am using the shell_exec function which is working OK but for some administrative tasks in linux I must have root access. As I am sending the commands from the webpage the apache user is used and so I am not allowed to do several tasks. I have also tried to use a bash script to pass the commands but with no result. Any ideas ? Hi Guys I am struggling with a shell_exec command in the long run, but I am trying to work down the root cause. The error I am getting with shell_exec is a file not found error, so I thought I would start with getting to the right folder. I have this Code: [Select] $sym_dir = "/root/"; $cwd = getcwd(); echo getcwd()."\n"; chdir ($sym_dir); echo getcwd()."\n"; Which in theory should 1st display '/var/www' as it does and then display the contents of root, at least that is my understanding! However my return is this /var/www /var/www Why cannot I move outside the web root? Cheers Dave I am using shared hosting at HostGator. I am trying to execute flare (a command line actionscript decompiler) via PHP. According to phpinfo() my System is Linux gator1854.hostgator.com 3.2.13 #4 SMP Thu Mar 29 19:22:42 CDT 2012 x86_64 In my public_html, I have a folder named "zachafer" and inside that folder, I have a folder named "flare". Inside the flare folder, I have the flare command line version, named "flare" and a file named movie.swf. The flare website says that I need to run "./flare somepath/somename.swf" Here is my code: <?PHP error_reporting(-1); $swf = 'movie'; chdir("/home/infamous/public_html/zachafer/flare"); $cmd = "./flare $swf.swf"; shell_exec($cmd); echo "Cmd: $cmd\n"; echo "File: ".file_get_contents("$swf.flr"); ?> Thank you. Hello, I'm working with Zend Framework on Linux, and I'm trying to generate a CAPTCHA using Zend_Form_Element_Captcha. Whenever the CAPTCHA page loads I get this error: [12-Jan-2011 18:14:54] PHP Warning: imagepng() [<a href='function.imagepng'>function.imagepng</a>]: Unable to open '/var/www/square/application/../public/captcha/ebf44d292149b3ebda05571c54c463a8.png' for writing: Permission denied in /usr/local/zend/share/ZendFramework/library/Zend/Captcha/Image.php on line 563 Here's my code for generating the CAPTCHA: // create captcha $captcha = new Zend_Form_Element_Captcha('captcha', array( 'captcha' => array( 'captcha' => 'Image', 'wordLen' => 6, 'timeout' => 300, 'width' => 300, 'height' => 100, 'imgUrl' => '/captcha', 'imgDir' => APPLICATION_PATH . '/../public/captcha', 'font' => APPLICATION_PATH . '/../public/fonts/LiberationSansRegular.ttf', ) )); I've checked permissions, and all directories mentioned above are accessible to root. Has anyone had a similar problem or have an idea how I can fix this? Kind Regards, Mike This topic has been moved to Installation on Linux. http://www.phpfreaks.com/forums/index.php?topic=321601.0 Hello, Can I set the priority on my scripts relating to swap? Something like set_swap(10); would mean that it will be first to go into swap and set_swap(1) means it will go as a last resort and set_swap(5) being the default ? Kind of like the proc_nice() but for memory ? Thanks, David My IDE (Nusphere's PhpED) runs on Windows but is configured so that both the web server as well as all project files are located on a development Linux server. Since the project files are located on the Linux server, the git repository is located there as well and not on my PC. Every now again, my IDE complains that content was externally modified and whether I wish to reload the file. Also, I was recently asked to set git's core.autocrlf to true on a project I was collaborating on which prevented me from adding any changes to git (git complained that LF will be replaced by CRLF). The IDE allows file encoding to be changed (system default, UTF-8, Windows-1252, or ISO-8859-01) as well as the default file format (Unix, Windows, Mac, or autodetect). Any recommendations on how best to configure git and these ide settings? Thanks What are your feelings regarding Linux desktop distros, and their ability to break through to mainstream usage? I started using Ubuntu about 6 or 7 years ago, and have fooled around with some other distros, but at least for me Ubuntu always seemed the best. I've got my 65 year old mom using it, and my 11 year old son playing with Kubuntu (and learning python!). I don't really consider us normal though; normal being almost too dumb to do more than check email and get on the internet.
I've managed to fully switch over to Ubuntu on all of my computers, with the exception of running Windows in a VM for Photoshop and Illustrator. Since I don't use those programs every day, there are a lot of days where I don't see Windows. I never really had a problem with Windows, except for Windows 3.1 was kind of a drag. Getting on the internet on a 56K modem on Windows 95 wasn't any fun either, but that wasn't Windows' fault. I never had the crashes and bad experiences people like to claim makes Windows suck. My main reason for abandoning Windows is just to be more involved with Linux, and hopefully reach Linux guru status someday.
I really never liked Macs. I bought one 3 or 4 years ago, and it just felt like I was paying a lot of money for a glorified (and over-hyped) linux distro. I really never liked the feel of the Finder. At the time there was no awesome text editor, and I bought a couple just to test out what I could find. Unlike Windows and Linux, it seemed like nothing is free in the Mac world. I eventually gave the Mac away. We couldn't be friends.
I'd really like to see Linux become the dominant OS. It's exciting to see how far Ubuntu has come in the years that I've used it, and I evangelize for Linux/Ubuntu quite a bit. Even still, it can sometimes seem that I am a stranger in a strange world. Do you think we can count on Linux being a bigger part of mainstream computing? One of the problems I see is that there are so many distros that a person investigating Linux may be a little overwhelmed. What do you think is keeping the masses from using Linux desktops?
|