PHP - How Do I Make Subdomains With Php
Is there a way to dynamically create subdomains like so: http://sub.example.com ?
I can do it in cPanel, but I'm not sure how I would go about doing it in PHP. I know how to create http://example.com/sub, but that isn't what I want. I don't think it would work the same as http://sub.example.com.. - Vince Similar TutorialsI know PHP setcookie can set for all subdomains - by setting parameter 5 to something like ".domain.com". However, I have quite a lot of code that just leaves param 5 blank (so sets for the current subdomain of that server). Hopefully there'd be an easy way how to do this (a server setting?). I know you can use ini_set('session.cookie_domain','http://domain.com'); but that only seems to set the session cookie value, not ones set in PHP. I only really want it to ensure if someone accesses the site through both www.domain.com and domain.com that they use the same cookies. I have 2 subdomains - one for the main site app and one for administration app. Both of these need to work with the same directory - one to upload images and one to read them. So far I have it like this - the main domain is mounted to www_root. In www_root I created a folder for the admin application. The images folder is also directly in www_root. The problem is, I can't upload files through http. So how else can I access a directory that is above the root directory of the current app ? Or should I rather move the images dir to the admin directory ? hello, im looking for a way of maintaining a single session across sub-domains... for example. domain.com shop.domain.com each starts its own session, i need a way of preserving that session across both. any thoughts? Alright, So i want to pass a session from www.mysite.com to mobile.mysite.com And i'm doing so by calling this on the top of every page on each site: <?php session_set_cookie_params(360000, "/",".mysite.com"); session_start(); print_r($_SESSION); ?> yet, the session data that is set on one subdomain is NOT printed on the other subdomain. I've even tried destroying the sessions several times to start over. But it won't work. What could be up? Thanks Am currently trying to develop a SaaS, where each user gets their own subdomain with their application. Am wondering, though, with installation and subsequent updates:
What is the best way to initiate an installation? The project is currently in a git repository. Is it better to simply pull the master branch per installation; or is zipping up the master branch, copying it to the new subdomain, then running the installation a better (secure?) method?
What is the best way to initiate an update of code? If using the git repo, hat would deal with updated code, but not updated MySQL tables.
Should the user be allowed to choose to update (so much like W$, a popup shows up that says there's an update; user can choose to update or ignore); or should all updates be forced (such as at a certain time)?
I haven't seen much online with my searches, but I may be blind at this point. Any thoughts/comments appreciated!
Good Day, I'm using the following example script from http://php.net/manual/en/function.session-set-save-handler.php which I have placed in session-handler.php and is included at the top of my index.php file. I have multiple domain names for the same website, so naturally when a person logs into the site, I would like the session to be active across all the domains instead of them having to login again if say they go from mysite.com to mysite2.com. session-handler.php <?php function open($save_path, $session_name) { global $sess_save_path; $sess_save_path = $save_path; return(true); } function close() { return(true); } function read($id) { global $sess_save_path; $sess_file = "$sess_save_path/sess_$id"; return (string) @file_get_contents($sess_file); } function write($id, $sess_data) { global $sess_save_path; $sess_file = "$sess_save_path/sess_$id"; if ($fp = @fopen($sess_file, "w")) { $return = fwrite($fp, $sess_data); fclose($fp); return $return; } else { return(false); } } function destroy($id) { global $sess_save_path; $sess_file = "$sess_save_path/sess_$id"; return(@unlink($sess_file)); } function gc($maxlifetime) { global $sess_save_path; foreach (glob("$sess_save_path/sess_*") as $filename) { if (filemtime($filename) + $maxlifetime < time()) { @unlink($filename); } } return true; } session_set_save_handler("open", "close", "read", "write", "destroy", "gc"); session_start(); ?> The script above doesn't appear to be throwing any errors, and I can login like normal but it doesn't seem to be saving the sessions at all. So I still have to login to each separate domain. Any ideas? Thanks, Ace I tried many ways but unable to pass sessions to virtual subdomains on my site.. I edited ihi.ini file and included Code: [Select] session.cookie_domain = .mydomain.com I like to add that session is active on my main domain for www.mydomain.com only.. So how do I pass sessions for WWW to other subdomains ? Thanks n Advance Okay so my news script is set to view only 10 pieces of news. But I want it so that it starts a new page once I have more than 10 pieces of news. Code: [Select] <?php require("functions.php"); include("dbconnect.php"); session_start(); head1(); body1(); new_temp(); sotw(); navbar(); $start = 0; $display = 10; $query = "SELECT * FROM news ORDER BY id DESC LIMIT $start, $display"; $result = mysql_query( $query ); if ($result) { while( $row = @mysql_fetch_array( $result, MYSQL_ASSOC ) ) { news_box( $row['news'], $row['title'], $row['user'], $row['date'], $row['id'] ); } mysql_free_result($result); } else { news_box( 'Could not retrieve news entries!', 'Error', 'Error', 'Error'); } footer(); mysql_close($link); ?> I tried a few things but they failed....miserably. Hi there, As the question says i tried several things but i can't work it out and my knowledge about php isn't that well. $looponce = 1; foreach ($this->info as $k => $v) { if ( (($k == 'subject') && ($v['required'])) && (!$this->settings['customSubject'])) { for ($i = 0; $i <= 0; $i++) { $output[] = $this->display_errors('error_system_subject'); } } if ( (($k == 'name') && (!$v['required'])) || ((!array_key_exists("name", $this->info)) && ($looponce == 1)) ) { $output[] = $this->display_errors('error_system_name'); $looponce++; } } That is my loop that i check things in. What i'm more interested in is the name if statement. If currently checks for a name key in an array(below) and makes sure that it is set to required. If it's not set to required, print out a system error and die()'s. I'm looking for ways to remove the need for program errors and just change them to what is needed to run. What i know how to do is, get into the inner array, what i don't know is how to edit the data and put it back exactly as it was given to me. The inner array data can be put back in any order, but the outer array must be in exact order as it was given. above code $this->info = $formdata; $formdata = array( 'name' => array('name'=>"Full Name", 'required'=>false, 'type'=>'text'), # This needs to be required=>true, but i can't trust the user, which is why i have the error. 'telephone' => array('name'=>"Telephone", 'required'=>false, 'type'=>'phone'), ); Any help is greatly appreciated, also am i doing the foreach loop in the code above in an efficient manner or is there another way? Hi I just wanted to know how I can make this.... I want to write this in PHP, I dont know the best way to do this.... I am starting a software development company, Each time someone make a purchase of a software product I wan to include a cd key, I dont know how to include just one cd key... I want to place the cdkeys in a mysql db though which I know how to do, but just the fact of me taking only one cdkey out of it and it can't be used already... it has to go down the line how would I do this? Thanks ahead of time I have some code which i think is really inefficient especially as there will be more more conditions to be met. I was thinking about using s switch but don't know if this is possible or if it's best leaving as it is. Any ideas? if($parts[($i-1)]=="forum") { //do some code } else if($parts[($i-2)]=="forum") { //do code } else if (($parts[($i-1)]=="list-messages") && (isset($parts[($i+1)]))) { //do code } else { // do some code } So I'm trying to make a counter that counts how many times a record on mysql database has been viewed. Not a hit counter for a webpage. In other words I have a page that displays the info of that record from the mysql database and within that page I would like to display the amount of times it has been viewed. Would anyone know where I can begin or send me to a good tutorial? Thanks I have a MySql table full of records. id owner car location on my page i have these results in a table i want to set a filter up so the table will only show cars from eg location England. at the minute its just set to show cars that owner has but i want a location filter any help I am using this line of code my site Code: [Select] <?php echo (IMAGES_HEADER . "header_02.jpg" ?> I have a page defining all my directories, on that page I have this Code: [Select] define('IMAGES_HEADER', DIR_IMAGES . 'header/'); instead of showing the image, all I am getting is "IMAGES_HEADERheader_02.jpg" where the image should be. I am very new to PHP and trying to learn it, what in the world am I doing wrong?? Rab Hi I had it on my old site but forgot what I put in the index.php file. Basicly, I want something like this: http://site.com/index.php?go=home or: http://site.com/index.php?home Does anyone know what I put in the index.php file to specify link and where it redirects too? Thank you. ok I need to know how to do this say I have variables.. like so $a[] = 12345; $a[] = 23456; $a[] = 35424; what do I have to do to get those variables to combine the value? and make that a variable? so it would be like $aCompiled = 12345,23456,35424, puts them in a string then I can use the variable later on in the script.. Basically, All I want to do is save a .txt (doesn't have to be .txt) to my FTP and PHP simple echos it. The .txt is where a message is stored. But when I write the message my self like this: Hello This is a message. - And then upload it to my FTP, PHP echos it like this "HelloThis is a message". Is there anyway for PHP to notice the 'white space'? --OR-- If you know of a better way to make a message system, then also let me know Thanks, Ollie! Hi, We are currently making our thesis and part of it is make use of AT Hayes command, which i executed on hyper terminal. first you need to configure the port where your modem is connected, on my case its connected on com4, after configuring the ports you can now execute at hayes commands on the hyper terminal. i would like to ask if is it possible to execute at hayes commands using php to send and recieve messages form cellphone and file it on database I used this code $limit = 120; if (strlen($summary) > $limit) $summary = substr($summary, 0, strrpos(substr($summary, 0, $limit), ' . . .')); This code ok in English Language it counts letters fine but it is not work fine if I insert Arabic text. It counts Arabic encoding characters. |