PHP - Can You Style The Context That Appears From The Php Code, If So How?
I have php code that searched for results of properties from my MYSQL database, but how can i position it and style it with font and colours etc? any help will be appreciated,thanks.
Similar TutorialsWhen I run this code every time it is run in a firefox browser it seems to run twice and it records 2 entires, I have tried different machines and also different versions of FF but each time I run this. in my log file I see the following Quote Time: 27th February 2012 10:55:09 am IP Address: 173.195.xxx.xxx Browser: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:9.0.1) Gecko/20100101 Firefox/9.0.1 Time: 27th February 2012 10:55:10 am IP Address: 173.195.xxx.xxx Browser: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:9.0.1) Gecko/20100101 Firefox/9.0.1 In Chrome and IE I just get a single entry in my log.html file Code: [Select] <?php // Create a new image instance $im = imagecreatetruecolor(70, 20); // Make the background white imagefilledrectangle($im, 0, 0, 70, 20, 0xFFFFFF); $font = imageloadfont('arial.gdf'); // Draw a text string on the image imagestring($im, $font, 0, 0, 'Hello World', 0x000000); // Output the image to browser header('Content-Type: image/gif'); imagegif($im); imagedestroy($im); // Get server variables $address = $_SERVER['REMOTE_ADDR']; $referer = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : ''; $browser = $_SERVER['HTTP_USER_AGENT']; // Do not log the full IP address replace the last 2 octets $address = preg_replace('/\.\d+\.\d+$/', '.xxx.xxx', $address); //Set time zone and date format date_default_timezone_set('Australia/Sydney'); $accessTime = date("jS F Y g:i:s a"); //Open log file $file = fopen("log.html",'a'); //write collected data to file fwrite($file, "<b>Time:</b> $accessTime<br />"); if( $address != null) fwrite($file,"<b>IP Address:</b> $address<br />"); if($referer != null) fwrite($file,"<b>Referer:<b> $referer<br />"); fwrite($file,"<b>Browser:</b> $browser<hr>"); // save file and close fclose($file); ?> I have a website that has definitions and articles. I need a code that craws the php content pulled from my database, finds a specified word and replaced that word with a link. For example If "car" appears replace with <a href="http://www.website.com/car.php">car</a> Thanks Todd I basically would like to style the third and fourth echo, could i give it a ID then style it in css, how would i do this? any help is appreciated. my php code: Code: [Select] { $i = 0; echo '<div style="font-family:helvetica; font-size:15px; padding-left:15px; padding-top:20px;">'; while($row = mysql_fetch_array($result)) { // Loop through results $i++; echo '<img class="image1" src="'. $row['images'] .'" />'; //image echo "Displaying record $i<br>\n"; echo "<b>" . $row['id'] . "</b><br>\n"; // Where 'id' is the column/field title in the database echo "Location: ". $row['Location'] . "<br>\n"; // Where 'location' is the column/field title in the database echo "Property Type: ". $row['Property_type'] . "<br>\n"; // as above echo "Bedrooms: ". $row['Number_of_bedrooms'] . "<br>\n"; // .. echo "Purchase Type: ". $row['Purchase_type'] . "<br>\n"; // .. echo "Price: ". $row['Price_range'] . "<br>\n"; // .. } example : Code: [Select] <?php code; ?> how to change CSS (i guess this is the method) using php or javascript to organize text/code like <code></code> here ! i did a search and didnt found anything useful! I have finally gotten my registration form to work on my website but i have another question! When for example someone registers at my website and type in the wrong email address, i've set php to give out an error message like "Please enter a valid email address". But that message shows up at the verry top-left corner of my page and makes some objekts move around on my page and you can't click in the <input> fields anymore . How could i make those error messages show up above my registration form at the top of my site and maybe style them with a border and maybe make the text red and so that it doesnt change anything on my page? could i use css for that somehow or what? This is how i show the error messages right now: public function show_errors() { echo "<h3>Errors</h3>"; foreach($this->errors as $key=>$value) echo $value."<br>"; } public function valid_data() { if($this->user_exists()) $this->errors[] = 'Username already taken, choose another one!'; if(empty($this->username)) $this->errors[] = 'Please enter a valid username!'; if(empty($this->first_name)) Hello. I am now dumbfounded (once again). I am using $this inside a class. I honestly have no idea what is going on. If anyone could give me a pointer that would be brilliant. Code: [Select] /* * List of functions in this class in order (construct and destruct are the only functions not in alphabetical order) * Construct * BooleanValue * BuildColumns * Connect * Clean * Delete * Disconnect * EndTransaction * Error * Insert * IsConnected * Kill * LastInsertID * Log * Query * RollbackTransaction * RowCount * Select * StartTransaction * Update * Where * Destruct */ class MySQL extends MySQLi { private $host = HOST; private $user = USER; private $pass = PASS; private $data = DATA; private $port = PORT; private $charset = CHARSET; const quote = "'"; // what quote to use /* Internal vars */ private $lastID = ""; private $lastResult = ""; private $queries = ""; private $link = 0; private $timeStart = 0; private $timeEnd = 0; private $timeTotal = 0; private $errorString = ""; private $errorNo = 0; private $in_transaction = false; private $queryQueue = ""; /* * Construct * Starts the connection unless autoconnect = false */ public function __construct($autoconnect = true) { $autoconnect === true ? $this->Connect() : false; } /* * End construct ***************************************************************************************************/ /* * BooleanValue * Determins whether the input is a boolean value, or can be converted into a boolean value */ static function BooleanValue($value) { $value = self::Clean($value); if(gettype($value) == "boolean") { if($value == true) { return true; } else { return false; } } elseif(is_numeric($value)) { if($value > 0) { return true; } else { return false; } } else { $str = strtoupper(mysqli_real_escape_string($this->link, trim($value))); if($str == "ON" || $str == "SELECTED" || $str == "CHECKED" || $str == "YES" || $str == "Y" || $str == "TRUE" || $str == "T") { return true; } else { return false; } } } /* * End BooleanValue ***************************************************************************************************/ /* * BuildColumns * Builds columns for use with SQL statements */ static function BuildColumns($columns, $addQuotes = true, $showAlias = true) { if($addQuotes) { $quote = self::quote; } else { $quote = ""; } switch(gettype($columns)) { case "array": $sql = ""; $i = 0; foreach($columns as $key => $value) { $key = self::Clean($key); $value = self::Clean($value); if($i == 0) { $sql = $quote.$value.$quote; $i = 1; } else { $sql .= ", ".$quote.$value.$quote; } if($showAlias && is_string($key) && (!empty($key))) { $sql .= " AS ".$quote.$key.$quote."'"; } } break; case "string": $columns = self::Clean($columns); return $quote.$columns.$string; break; default; return false; break; } return $sql; } /* * End BuildColumns ***************************************************************************************************/ /* * Connect * Connects to the database */ public function Connect() { $this->link = @mysqli_connect($this->host, $this->user, $this->pass, $this->data, $this->port); $this->IsConnected(); } /* * End Connect ***************************************************************************************************/ /* * Clean * Cleans input */ static function Clean($value) { $this->IsConnected(); $value = ltrim($value); $value = rtrim($value); $value = mysqli_real_escape_string($this->link, $value); return $value; } /* * End Clean ***************************************************************************************************/ /* * Delete * Deletes a record from the database */ public function Delete($table, $whereArray) { $sql = "DELETE FROM ".$table; $sql .= self::Where($whereArray); } /* * End Delete ***************************************************************************************************/ /* * Disconnect * Disconnects from the database */ public function Disconnect() { if($this->IsConnected()) { mysqli_close($this->link); } } /* * End disconnect ***************************************************************************************************/ /* * EndTransaction * Ends the transaction, saving all data to the database */ public function EndTransaction() { $this->IsConnected(); if($this->in_transaction) { if(!mysqli_query($this->link, "COMMIT")) { $this->RollbackTransaction(); } else { $this->in_transaction = false; return true; } } else { $this->Error("Not in a transaction", -1); return false; } } /* * End EndTransaction ***************************************************************************************************/ /* * Error * Handles Errors */ public function Error($errstr = "", $errno = 0) { try { if(strlen($errstr) > 0) { $this->errorString = $errstr; } else { $this->errorString = @mysqli_error($this->link); if(!strlen($this->errorString) > 0) { $this->errorString = "Unknown error"; } } if($errno <> 0) { $this->errorNo = $errno; } else { $this->errorNo = @mysqli_errno($this->link); } } catch(Exception $e) { $this->errorString = $e->getMessage(); $this->errorNo = -999; } $this->Kill(); } /* * End Error ***************************************************************************************************/ /* * Insert * Inserts a record into the database */ public function Insert($table, $valuesArray) { $columns = self::BuildColumns(array_keys($valuesArray), false); $values = self::BuildColumns($valuesArray, true, false); $sql = "INSERT INTO ".$table." (".$columns.") VALUES (".$values.")"; $this->queryQueue .= $sql; } /* * End Insert ***************************************************************************************************/ /* * IsConnected * Checks if there is a connection */ public function IsConnected() { if(@mysqli_ping($this->link)) { return true; } else { $this->Error(); return false; $this->RollbackTransaction(); $this->Kill("No connection present"); } } /* * End IsConnected ***************************************************************************************************/ /* * Kill * Rollsback anychanges and kills the script */ public function Kill() { $this->RollbackTransaction(); if(!$this->errorString) { $this->errorString = "Unknown"; } if(!$this->errorNo) { $this->errorNo = -999; } die("<br /><br /><strong>An error has occured.<br />".$this->errorString."<br />".$this->errorNo); } /* * End Kill ***************************************************************************************************/ /* * LastInsertID * Returns the last inserted ID */ public function LastInsertID() { return $this->lastID; } /* * End LastInsertID ***************************************************************************************************/ /* * Log * Logs all MySQL queries */ static function Log($page, $utime, $wtime, $mysql_time, $sphinx_time, $mysql_count_queries, $mysql_queries) { /*$table = "mysql-".date("Ymd"); $sql = "INSERT DELAYED INTO ".$table." (ip, page, utime, wtime, mysql_time, sphinx_time, mysql_count_queries, mysql_queries, user_agent) VALUES ("self::quote.$_SERVER['REMOTE_ADDR'].self::quote.", ".self::quote.$page.self::quote.", */ } /* * End Log ***************************************************************************************************/ /* * Query * Exectues all queries */ public function Query($sql) { $this->IsConnected(); $this->timeStart = microtime(true); $this->queries = $sql; $this->StartTransaction(); $this->lastResult = @mysqli_query($this->link, $sql); if(!$this->lastResult) { $this->RollbackTransaction(); $this->Error(); } $this->EndTransaction(); if(strpos(strtolower($sql), "insert") === 0) { $this->lastID = mysqli_insert_id($this->link); if($this->lastID === false) { $this->Error(); } else { return $this->lastResult; //$this->queryQueue = ""; } } elseif(strpos(strtolower($sql), "select") === 0) { $this->LastID = 0; } $this->timeEnd = microtime(true); $this->timeTotal = ($this->timeEnd - $this->timeStart); $removeE = explode('E', $this->timeTotal); $this->timeTotal = $removeE[0]; echo $this->queryQueue; } /* * End Query ***************************************************************************************************/ /* * RollbackTransaction * Un-does the changes made */ private function RollbackTransaction() { $this->IsConnected(); if(!mysqli_query($this->link, "ROLLBACK")) { $this->Error("Rollback failed. Manual cleanup required"); return false; } else { $this->in_transaction = false; return true; } } /* * End RollbackTransaction ***************************************************************************************************/ /* * RowCount * Returns the amount of rows effected from the last query */ public function RowCount() { return mysqli_num_rows($this->lastResult); } /* * End RowCount ***************************************************************************************************/ /* * Select * Selects rows * USAGE: * $result = $sql->Select("users", array("username" => "james")); * while($row = mysqli_fetch_array($result)) { * echo $row['password']; * } */ public function Select($table, $whereArray = null, $columns = null, $sortColumns = null, $sortAscending = true, $limit = null) { if(!is_null($columns)) { $sql = self::BuildColumns($columns); } else { $sql = "*"; } $sql = "SELECT ".$sql." FROM ".$table; if(is_array($whereArray)) { $sql .= self::Where($whereArray); } if(!is_null($sortColumns)) { $sql .= " ORDER BY ".self::BuildColumns($sortColumns, true, false). " ".($sortAscending ? "ASC" : "DESC"); } if(!is_null($limit)) { $sql .= " LIMIT ".$limit; } self::Query($sql); $return = ""; return $this->lastResult; } /* * End Select ***************************************************************************************************/ /* * StartTransaction * Starts the transaction */ private function StartTransaction() { if(!$this->IsConnected()) { die(); } if(!$this->in_transaction) { if(!mysqli_query($this->link, "START TRANSACTION")) { $this->Error(); return false; } else { $this->in_transaction = true; return true; } } else { $this->Error("Already in a transaction"); } } /* * End StartTransaction ***************************************************************************************************/ /* * Update * Updates the rows */ public function Update($table, $valuesArray, $whereArray = null) { $sql = ""; $i = 0; foreach($valuesArray as $key => $value) { $key = self::Clean($key); $value = self::Clean($value); if($i == 0) { $sql = $key." = ".self::quote.$value.self::quote; $i = 1; } else { $sql .= ", ".$key." = ".self::quote.$value.self::quote; } } $sql = "UPDATE ".$table." SET ".$sql; if(is_array($whereArray)) { $sql .= self::Where($whereArray); } self::Query($sql); return $this->lastResult; } /* * End Update ***************************************************************************************************/ /* * Where * Select rows where X */ public function Where($whereArray) { $where = ""; foreach($whereArray as $key => $value) { $key = self::Clean($key); $value = self::Clean($value); if(strlen($where == 0)) { if(is_string($key)) { $where = " WHERE ".$key." = ".self::quote.$value.self::quote; } else { $where = " WHERE ".self::quote.$value.self::quote; } } else { if(is_string($key)) { $where .= " AND ".$key." = ".self::quote.$value.self::quote; } else { $where .= " AND ".self::quote.$value.self::quote; } } } return $where; } /* * End where ***************************************************************************************************/ /* * Destruct * Closes the connection and cleans up */ public function __destruct() { if($this->queryQueue) { $this->Query($this->queryQueue); } $this->Disconnect(); } /* * End destruct ***************************************************************************************************/ } The code I am using to get the error is this: Code: [Select] $sql = new Mysql; $sql->Insert("users", array("username" => "James")); $sql->Insert("users", array("username" => "fds")); $sql->Insert("users", array("username" => "le")); Thanks. EDIT: Added code to call the error. Hello! This is my code: $postdata = http_build_query( array( 'version' => '1.0', 'username' => 'YBthebest', 'password' => 'MYPASSWORD' ) ); $username = 'YBthebest'; $opts = array( 'http'=>array( 'method'=>"POST", 'header'=>"User-Agent: APIClient:YBthebest\r\n" ) ); $context = stream_context_create($opts); $result = file_get_contents('https://ocrterminal.com/api/user.cgi', false, $context); Warning: file_get_contents(https://ocrterminal.com/api/user.cgi): failed to open stream: HTTP request failed! I get that error! What is failing? And yes, I need to send my username through User_agent !( // User Agent string userAgent = "APIClient:" + username;, taken from C example) Thanks ! [Edit: Sorry I found my answer by searching for "period", then finding out that it is a string operator, then read about that. Doesn't seem easy to search for ".=" in Google. Thanks] I got some help here earlier, and I can pretty much understand everything, except I don't understand why there is Code: [Select] $recordOptions .= "<option value=\"{$row['id']}\">"; $recordOptions .= " {$row['firstname']} {$row['lastname']}, {$row['gender']}, {$row['dob']}"; $recordOptions .= "</option>\n"; Why does this whole thing break without .= ? I am new to PHP so, sorry if the answer is really obvious. Code: [Select] $recordOptions = ''; $query = "SELECT * FROM people"; $result = mysql_query($query); if(!$result) { $recordOptions = "<option>Error Retrieving Records</option>\n";; } else { while($row=mysql_fetch_assoc($result)) { $recordOptions .= "<option value=\"{$row['id']}\">"; $recordOptions .= " {$row['firstname']} {$row['lastname']}, {$row['gender']}, {$row['dob']}"; $recordOptions .= "</option>\n"; } } ?> <html> <body> <?php echo $confirmMsg; ?><br /> <form action ='' method='post'> I'm trying to build a Wordpress plugin where all the archives are nicely listed in a tabular form. I'm reading the book Wordpress Plugin Development - A Beginner's Guide And I'm having an error when trying to call the function to display the archives on a separate page. Here's the function: function display() { global $wpdb; // these variables store the current year, month and date // processed $curyear=''; $curmonth=''; $curday=''; // the beginning of our output $result=' <div class="snazzy"> <table cellspacing="15" cellpadding="0" border="0"> <tbody> <tr>'; // query to get all published posts $query= "SELECT * FROM $wpdb->posts WHERE post_status = 'publish' AND post_password='' ORDER BY post_date_gmt DESC "; $posts = $wpdb->get_results($query); foreach ($posts as $post) { // retrieve post information we need $title = $post->post_title; $excerpt= $this->get_excerpt($post->post_content); $url=get_permalink($post->ID); $date = strtotime($post->post_date); // format the date $day = date('d', $date); $month = date('M', $date); $year = date('Y', $date); // look for image in the post content $imageurl=""; preg_match('/<\s*img [^\>]*src\s*=\s*[\""\']?([^\""\'>]*) /i' , $post->post_content, $matches); $imageurl=$matches[1]; // get comments for this post $comcount = $wpdb->get_var(" SELECT COUNT(*) FROM $wpdb->comments WHERE comment_approved = '1' AND comment_post_ID=$post->ID AND NOT (comment_type = 'pingback' OR comment_type = 'trackback')"); // additional formatiing if ($year!=$curyear) { // close the previous day/month if ($curday) $result.="</div></div></td>"; $curday=''; $curmonth=''; // year start in a new column (<td>) $result.= '<td valign="top"><div class="sz_date_yr">' .$year.'</div><div class="sz_cont">'; $result.= '</div></td>'; $curyear=$year; } if ($month!=$curmonth) { // close the previous day/month if ($curday) $result.="</div></div></td>"; $curday=''; // month starts in a new column (<td>) $result.= '<td valign="top"><div class="sz_date_mon">' .$month.'</div><div class="sz_month">'; $curmonth=$month; } if ($day!=$curday) { // close previous day if ($curday) $result.="</div>"; $result.= '<div class="sz_date_day">'.$day.' </div><div class="sz_day">'; $curday=$day; } // retrieve the archive entry representation ob_start(); include('snazzy-layout-1.php'); $output = ob_get_contents(); ob_end_clean(); $result.=$output; } // close the previous day/month if ($curday) $result.="</div></div></td>"; // close the main page elements $result.="</tr></tbody></table></div>"; // return the result return $result; } This is the part to which the error message is referring to: // retrieve post information we need $title = $post->post_title; $excerpt= $this->get_excerpt($post->post_content); $url=get_permalink($post->ID); $date = strtotime($post->post_date); // format the date $day = date('d', $date); $month = date('M', $date); $year = date('Y', $date); The error message says that I'm using $this when not in "object context". The part where $this is used is needed to display an excerpt of the post content. This is the same way how it's shown in the book, for some reason it doesn't work for me. What would be an alternative way that I could do to make it work, any ideas? I get the error code "Fatal error: Using $this when not in object context in /home/feenetwo/public_html/language/english/mails/sale_third_party_notification.php on line 7" when I complete the form from the link in the screenshot atached... the site is feenetwork.com and im getting really fustrated with it.... Can anyone help? Hi, I have some strange issues with my code: Code: [Select] <?PHP session_start(); $loginid = $_SESSION["valid_id"]; // First check if we are guest or user. if (!$_SESSION["valid_email"]) { $visitor = "yes"; } else { $visitor = "no"; $email = $_SESSION['valid_email']; $userid = $_SESSION['valid_id']; } //Load Header (blue menu) require("./inc/header.php"); //Load Sub-acc (silver account menu) require("./inc/sub-group.php"); //Load nav-group (Tabs) require("./inc/nav-group.php"); //Load Config file require("./inc/config.php"); //Set & get profile ID $getid = $_GET["id"]; //check ID $result = mysql_query("SELECT * FROM profiles WHERE id=('$getid') LIMIT 1"); $row = mysql_fetch_array($result); IF (mysql_num_rows($result) != 1) { exit("Invalid ID"); } //If we are guest, do we allow anon access to the profile IF ($row["privacy"] <= 10 && $visitor = "yes") { exit("You may not view this profile as a visitor, due to the users privacy settings"); } //Let's check if we are friends ELSEIF ($visitor = "no") { $result2 = mysql_query("SELECT * FROM profiles_friends WHERE user=('$getid') AND target=('$loginid') LIMIT 1"); $row2 = mysql_fetch_array($result2); $friends = $row2["status"]; if (mysql_num_rows($result2) = 0) { $friends = "no"; } } //If we are friend, do we allow access to the profile IF ($row["privacy"] >= 9 && $friends != 1) { exit("You may not view this profile because of the privacy settings."); } $row = mysql_fetch_array($result); $memgroup = $row["group"]; IF ($row["activated"] != 1) { exit("This account is suspended and cannot be viewed."); } //Check what group member is in. $result2 = mysql_query("SELECT * FROM profiles_groups WHERE id=('$memgroup') LIMIT 1"); $row2 = mysql_fetch_array($result); ?> Alright, so the error: Fatal error: Can't use function return value in write context in C:\xampp\htdocs\prog\profile.php on line 45 Code: [Select] 42. $result2 = mysql_query("SELECT * FROM profiles_friends WHERE user=('$getid') AND target=('$loginid') LIMIT 1"); 43. $row2 = mysql_fetch_array($result2); 44. $friends = $row2["status"]; 45. if (mysql_num_rows($result2) = 0) Alright, this is one thing that bothers me, the other is: Code: [Select] //check ID $result = mysql_query("SELECT * FROM profiles WHERE id=('$getid') LIMIT 1"); $row = mysql_fetch_array($result); IF (mysql_num_rows($result) != 1) { exit("Invalid ID"); I tried to put an invalid ID, and already here the script should have died/exited before executing the parts of the code that doesn't work. I tested my code on another page and it works flawlessly, perhaps this error is just generated before it actually exists i dunno.. Any way, any help is much appreciated } First i will show the code that activates the error: Code: [Select] if($current_host != null) { print_r2("1"); print_r2($current_host); print_r2($current_foundResult); print_r2("2"); $current_host::addFoundResult($current_foundResult); } this is the output: Quote 1 Host Object ( [hostname] => www.google.nl [foundResults] => Array ( ) ) FoundResult Object ( [url] => [title] => [visits] => ) 2 Fatal error: Using $this when not in object context in ~~~~~~~~~~~~~ on line 385 the error comes from this line: $this->foundResults[] = $foundResult; Code: [Select] class Host { public $hostname; public $foundResults; public function __construct($hostname) { $this->hostname = $hostname; $this->foundResults = array(); } public function addFoundResult($foundResult) { $this->foundResults[] = $foundResult; } } what i don't get about it is that both the Host Object and the FoundResult Object exist... This is my error: Code: [Select] Fatal error: Can't use function return value in write context in /home/a8152576/public_html/SecretSanta.html on line 41 confused about why. This is the line 41: if(isset($_POST('submit')){ this is the php of my page (without the mysql data): <?php class functions{ public static function chooseGiftee($SS){ $done = false; while($done=false){ $sqllink= mysql_connect($mysql_host,$mysql_user,$mysql_password); if(!$sqllink){ echo "Could not connect! Please Try Again"; mysql_close($sqllink); } else { $selectGiftee = "SELECT * FROM SecretSantas ORDER BY RAND() LIMIT 0,10;"; while($row=mysql_fetch_array($result)){ $results = mysql_query($selectGiftee); if(!$row['Gifter']=''){ $done=false; } else { $gifteeResults = $row['Name']; $addSS = "INSERT INTO SecretSantas (Gifter) VALUES ('" .$SS. "')"; $done=true; return $gifteeResults; } } } mysql_close($sqllink); } } } if(isset($_POST('submit')){ $echoName = functions::chooseGiftee($_POST['gifterName']); echo $echoName; } ?> This is html: <form id="form1" name="form1" method="post" action=""> <p> <label>Your Name: <input type="text" name="gifterName" id="gifterName" /> </label> <input type="submit" name="submit" id="submit" value="Submit" /> </p> <p> </p> </form> Confused about the issue, first time using functions. Thanks in advance, Brandon Any thoughts as to why I'm getting an error for this line of code? Code: [Select] if (isset($this->input->post('bcc[]'))) Error reads: Fatal error: Can't use method return value in write context If someone knows can they explain it to me so I understand it please. This is a long post, but most of it is backup information, and I hope I don't scare you away.
I created a self signed signature as follows: # Create the key openssl genpkey -algorithm RSA -pkeyopt rsa_keygen_bits:3072 -aes-128-cbc -out key.pem # Create the certificate signing request openssl req -new -key key.pem -sha256 -days 365 -out csr.pem # Remove pass-phrase from the key cp key.pem key.pem.tmp openssl rsa -in key.pem.tmp -out key.pem rm -f key.pem.tmp # Sign the certificate. openssl x509 -req -in csr.pem -signkey key.pem -sha256 -days 365 -out crt.pem cp key.pem /etc/pki/tls/private/key.pem cp csr.pem /etc/pki/tls/private/csr.pem cp crt.pem /etc/pki/tls/certs/crt.pem rm -f key.pem rm -f csr.pem rm -f crt.pemI've since gotten a Class 2 certificate from StartSSL so I will not need the above created crt.pem. I used the content in csr.pem above, and saved it as /etc/pki/tls/certs/startssl.crt. I set it up using example.com as the primary domain and *.example.com as the secondary domain. /etc/httpd/conf.d/ssl.conf includes more, but for discussion purposes, includes the following: LoadModule ssl_module modules/mod_ssl.so Listen 443 <VirtualHost _default_:443> SSLEngine on SSLProtocol all -SSLv2 SSLCipherSuite ALL:!ADH:!EXPORT:!SSLv2:RC4+RSA:+HIGH:+MEDIUM:+LOW SSLCertificateKeyFile /etc/pki/tls/private/key.pem #SSLCertificateFile /etc/pki/tls/certs/crt.pem SSLCertificateFile /etc/pki/tls/certs/startssl.crt SSLCertificateChainFile /etc/pki/tls/certs/sub.class2.server.ca.pem SSLCACertificateFile /etc/pki/tls/certs/startssl.crt </VirtualHost>/etc/httpd/conf/httpd.conf includes the following: ... ServerName example.com ... NameVirtualHost *:443 <VirtualHost *:443> SSLEngine on SSLCipherSuite SSLv3:TLSv1:+HIGH:!SSLv2:!MD5:!MEDIUM:!LOW:!EXP:!ADH:!eNULL:!aNULL #SSLCertificateFile /etc/pki/tls/certs/crt.pem SSLCertificateFile /etc/pki/tls/certs/startssl.crt SSLCACertificateFile /etc/pki/tls/certs/startssl.crt SSLCertificateKeyFile /etc/pki/tls/private/key.pem SSLCertificateChainFile /etc/pki/tls/certs/sub.class2.server.ca.pem ServerName example.com ServerAlias *.example.com DocumentRoot /var/www/html </VirtualHost>When I restart httpd, I get the following: [root@vps tls]# service httpd restart Stopping httpd: [ OK ] Starting httpd: [ OK ] [root@vps tls]# tail /var/log/httpd/error_log [Thu Jan 22 12:25:24 2015] [notice] caught SIGTERM, shutting down [Thu Jan 22 12:25:24 2015] [notice] suEXEC mechanism enabled (wrapper: /usr/sbin/suexec) [Thu Jan 22 12:25:24 2015] [warn] Init: Name-based SSL virtual hosts only work for clients with TLS server name indication support (RFC 4366) [Thu Jan 22 12:25:24 2015] [notice] Digest: generating secret for digest authentication ... [Thu Jan 22 12:25:24 2015] [notice] Digest: done [Thu Jan 22 12:25:24 2015] [warn] Init: Name-based SSL virtual hosts only work for clients with TLS server name indication support (RFC 4366) [Thu Jan 22 12:25:24 2015] [notice] Apache/2.2.15 (Unix) DAV/2 PHP/5.5.18 mod_ssl/2.2.15 OpenSSL/1.0.1e-fips configured -- resuming normal operations [root@vps tls]# tail /var/log/httpd/ssl_error_log [Thu Jan 22 12:25:24 2015] [warn] RSA server certificate wildcard CommonName (CN) `*.example.com' does NOT match server name!? [Thu Jan 22 12:25:24 2015] [warn] RSA server certificate wildcard CommonName (CN) `*.example.com' does NOT match server name!? [root@vps tls]#When I access the site, the browser states: This Connection is Untrusted Questions... Does not the actual VirtualHost extend the _default_ VirtualHost? Why is SSLEngine on required in both (seems to have error when I remove it in the actual VirtualHost)? Should the keys be in the _default_ VirtualHost, or the actual one, or both? Seems like some of the directives needs to be in both which surprised me as I thought one was extended off the other. When is SSLCertificateFile and SSLCACertificateFile required? Why the difference? Why the errors and untrusted connection? Thank you Hello dears, Let say we have the following form code Code: [Select] <form action="post" method="post" name="form"> Your Name : <input name="name" type="text" id="name"> <input type="submit" name="Submit" value="Submit"> </form> what if i want it to be viewed as image Why ! in fact i've text-area where i will put some HTML codes and i want the output of that code appears normally as web-browser view but as image , means no way to click on it or operate just appears as image I do not know if it possible or not but i wonder it it can be and here is example for exactly how this forms i wants to appears output of the html codes appears as image so any method any help any function or class can do like this ?! Thanks Hint : someone told me this way Put and transparent block element over it (position: absolute and so on) but i'm not sure if it right or not and how to do it , can anyone point to me simple example ! Would you know why the bottom border appears on the nested ul's (line 36) instead of the parent ul (line 10)?
THANKS!
* { margin: 0; padding: 0; } body { background: black; } nav ul { list-style: none; border-bottom: 1px solid #404040; } nav li { position: relative; float: left; /* Width for About, Graphic Design & Contact */ width: 15%; } /* Width for Mobile Apps & Web */ nav li:nth-of-type(3), nav li:nth-of-type(4) { width: 27.5%; } nav a { color: #404040; font-size: 1.5em; font-weight: bold; text-decoration: none; display: block; } nav ul ul { /*display: none;*/ position: absolute; z-index: 99; } nav li li { width: inherit; float: none; } nav li li a { font-size: 1.25em; } <!DOCTYPE HTML> <html> <head> <title>PowerON Technologies - San Diego-Based Graphic Design, Mobile App & Web Development Firm</title> <!-- HTML5Shiv helps older browsers display HTML 5 elements. --> <!--[if lt IE9]> <script src="_js/html5shiv.js"></script> <![endif]--> <!-- /HTML5Shiv --> <!-- CSS --> <!-- Normalize.css makes tags look the same in all browsers --> <link href="_css/normalize.css" type="text/css" rel="stylesheet"> <link href="_css/styles.css" type="text/css" rel="stylesheet"> <!-- /CSS --> <!-- JavaScript --> <script src="_js/jQuery.js" type="text/javascript"></script> <script src="_js/scripts.js" type="text/javascript"></script> <!-- /JavaScript --> </head> <body> <!-- NAV BAR --> <nav> <ul> <li><a href="#">About</a></li> <li> <a href="#">Graphics</a> <ul> <li><a href="#">SAIC</a></li> <li><a href="#">YouthBuild</a></li> </ul> </li> <li> <a href="#">Mobile Apps</a> <ul> <li><a href="#">Big Brothers Big Sisters</a></li> <li><a href="#">YMCA</a></li> </ul> </li> <li> <a href="#">Web</a> <ul> <li><a href="#">Challenged Athletes Foundation</a></li> <li><a href="#">Make-A-Wish Foundation</a></li> <li><a href="#">Turning The Hearts Center</a></li> </ul> </li> <li><a href="#">Contact</a></li> </ul> </nav> <!-- /NAV BAR --> </body> </html>Attached Files index.zip 3.72KB 0 downloads I'm working on a pair of scripts that (among other tasks) download a file to the user's browser. It's not working right, and I'm having trouble figuring out why. The overall design is: the first script (I'll call it one.php) contains a form which displays a list of radio buttons representing actions that the site can perform. The user clicks a radio button, then a "submit" button. This loads two.php, which determines what action the the user selected, performs the action, and loads a page that contains another form. This form has a couple of "submit" buttons; one reloads one.php, and the other goes elsewhere. Everything works right except when the user selects the "download a file" option. In that case two.php downloads the file (and that part works perfectly), then -- nothing. The page defined in two.php never appears. The browser just sits displaying the page from one.php as it was when the submit button was clicked. I played with the code and found that if I comment out all of the download headers, so that the browser gets the raw contents of the downloaded file followed by an HTML page, the browser does just what I'd expect: it displays the file (represented as a stream of semi-binary garbage), followed by an HTML page. Something in the download headers is upsetting it... but I can't figure out what. Here is the code that sends the headers: Code: [Select] header('Content-Description: File Transfer'); header('Content-Type: application/octet-stream'); header('Content-Disposition: attachment; filename=' . basename($file) ); header('Content-Transfer-Encoding: binary'); header('Expires: 0'); header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); header('Pragma: public'); header('Content-Length: ' . filesize($file) ); if (ob_get_length() > 0) { ob_clean(); } flush(); readfile($file); flush(); Following that, the script includes a file that contains another block of PHP code, then the <!DOCTYPE> tag, with no intervening characters outside the PHP. (BTW, the PHP block contains nothing but comments!) Can anyone suggest what's going wrong here? I have been working with PHP & CSS for a few months, and want to develop a drop-down menu that appears when mousing over a list item. The menu would display the contents of a MySQL query. What is the easiest way to do this? Could you provide sample code? And, is JavaSript absolutely necessary? Thanks. |