imarockstar Posted December 2, 2008 Share Posted December 2, 2008 I am getting this error .. but I am not sure what it means .. warning: mkdir() [function.mkdir]: permission denied in /home/franklin/public_html/sites/rssdeploy/deploy.php on line 138 warning: fopen(deploy_231202302/index.html) [function.fopen]: failed to open stream: no such file or directory in /home/franklin/public_html/sites/rssdeploy/deploy.php on line 298 here are the lines of code : lines 125 - 147 - if($session !== '' && $session !== 'hd82Dha1LL' && $session !== '1c3dD8320C'){ //Check for default and blank values. $project_name = $session; //Project name is what they named it. $safe_name = str_replace(' ', '_', $project_name); //System safe filename. } else { $project_name = "deploy"; //Default project name $safe_name = "deploy"; } if(isset($_GET['misc_options_exe'])) { //If they chose to have a php file in the misc options $deploy_file = "index.php"; } mkdir($deploy_download); //make the new directory $html_doctype = $_GET['html_version']; //Get the html/xhtml DOCTYPE if($html_doctype == 'xhtml_s' || $html_doctype == 'xhtml_t' ){ $html_attr = 'xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"'; //If it's an XHTML document } elseif($html_doctype == 'html_s' || $html_doctype == 'html_t') { $html_attr = 'lang="en"'; //If its an HTML document } lines 273 - 300 - if($project_name !== 'deploy'){ //If the name was NOT defaulted to deploy above... $html_title = $project_name; //...Then it will be what the named } else { $html_title = 'Title'; //...If it was, then <title> in the <head> will be simply be Title } //Create the html file $html_temp = ''.$html_doctype.' <html '.$html_attr.'> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> <title>'.$html_title.'</title> '.$jquery.' '.$jquery_script.' '.$css.' '.$jquery_css_link.' </head> <body> <h1><a href="http://projectdeploy.org">deploy*</a></h1> </body> </html> '; $fh = fopen($deploy_download.'/'.$deploy_file, 'w') or die("can't open file"); //Open the new file fwrite($fh, $html_temp); //write the file fclose($fh); //close the file any ideas ??? Link to comment https://forums.phpfreaks.com/topic/135217-permission-error-help/ Share on other sites More sharing options...
rhodesa Posted December 2, 2008 Share Posted December 2, 2008 can you post the whole thing? where does $deploy_download get set? Link to comment https://forums.phpfreaks.com/topic/135217-permission-error-help/#findComment-704264 Share on other sites More sharing options...
imarockstar Posted December 2, 2008 Author Share Posted December 2, 2008 here is the whole file ... there is a "deploy" directory that i have set to 777 ... but i still get the error ... <?php /**************************************************************************************** * BEWARE! * The file below contains most of all the deploy* power and magic. * Edit at your own risk! * If you make updates to the code which make it cleaner, faster, whatever email me. * I would enjoy someone else making improvements greatly. =] ****************************************************************************************/ //Boomarkable Title $b_html = $_GET['html_version']; switch ($b_html) { case 'xhtml_s': //XHTML Strict DOCTYPE $b_html = 'XHTML Strict 1'; break; case 'xhtml_t': //XHTML Transitional DOCTYPE $b_html = 'XHTML Transitional 1'; break; case 'html_s': //HTML Strict DOCTYPE $b_html = 'HTML Strict 4.01'; break; case 'html_t': //HTML Transitional DOCTYPE $b_html = 'HTML Transitional 4.01'; break; } $css_post = $_GET['css']; if($css_post == 'css_yes'){ $b_css = $_GET['css']; //If the user picks to create a CSS file... if(isset($_GET['css_options'])){ $b_css_options = $_GET['css_options']; switch($b_css_options) { case 'css_resets': $b_css = 'Style Sheet and Resets'; case 'css_blank': $b_css = 'Blank Style Sheet'; break; default: $b_css = 'CSS Directory'; break; } } } else{ $b_css = 'No CSS Directory or Style Sheet'; } if(isset($_GET['jquery'])) { $b_j_compression = $_GET['jquery']; switch($b_j_compression) { case 'jquery_min': $b_j_compression = 'jQuery Minified'; break; case 'jquery_pack': $b_j_compression = 'jQuery Packed'; break; case 'jquery_un': $b_j_compression = 'jQuery Uncompressed'; break; } } else { $b_j_compression = 'No jQuery Library'; } if(isset($_GET['misc_options_images'])){ $b_image_dir = ' Image Directory '; } else { $b_image_dir = ''; } if(isset($_GET['misc_options_includes'])){ $b_includes_dir = ' Includes Directory '; } else { $b_includes_dir = ''; } if(isset($_GET['misc_options_flash'])){ $b_flash_dir = ' Flash Directory '; } else { $b_flash_dir = ''; } if(isset($_GET['misc_options_exe'])) { //If they chose to have a php file in the misc options $b_deploy_file = "PHP"; } else { $b_deploy_file = 'HTML'; } $page_title = 'Deploy* | '.$b_html.' in '.$b_deploy_file.' format with a '.$b_css.' and '.$b_j_compression.' along with an'.$b_image_dir.$b_includes_dir.$b_flash_dir; //End getting title ////////////////////////// //Give them the download if(isset($_GET['fluid'])){ $fluid = 'set'; } require_once('includes/head.php'); if($session == 'n0t53t'){ $welcome = 'direct_return_user'; //Feature for the future! } $sys_folder = 'deploys'; //What folder all the deploys are in $deploy_download = 'deploy_'.date('smd').rand(1,999); //What the folders will be named $deploy_dir = $sys_folder.'/'.$deploy_download; //directory where deploy, deploys $deploy_file = "index.html"; //Name of the index.html files. This can be anything ////// FIX IT TO MAKE INDEX.HTML A VAR SO THAT IT CAN BE CHANGED THROUGH THE ENTIRE DOCUMENT \\\\\\\\ /* FYI: hd82Dha1LL = a blank file name inputted by the user 1c3dD8320C = a blank value because it was either not entered or returned directly from a bookmark */ if($session !== '' && $session !== 'hd82Dha1LL' && $session !== '1c3dD8320C'){ //Check for default and blank values. $project_name = $session; //Project name is what they named it. $safe_name = str_replace(' ', '_', $project_name); //System safe filename. } else { $project_name = "deploy"; //Default project name $safe_name = "deploy"; } if(isset($_GET['misc_options_exe'])) { //If they chose to have a php file in the misc options $deploy_file = "index.php"; } mkdir($deploy_download); //make the new directory $html_doctype = $_GET['html_version']; //Get the html/xhtml DOCTYPE if($html_doctype == 'xhtml_s' || $html_doctype == 'xhtml_t' ){ $html_attr = 'xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"'; //If it's an XHTML document } elseif($html_doctype == 'html_s' || $html_doctype == 'html_t') { $html_attr = 'lang="en"'; //If its an HTML document } //Give the user the chosen html version switch ($html_doctype) { case 'xhtml_s': //XHTML Strict DOCTYPE $html_doctype = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">'; break; case 'xhtml_t': //XHTML Transitional DOCTYPE $html_doctype = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">'; break; case 'html_s': //HTML Strict DOCTYPE $html_doctype = '<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">'; break; case 'html_t': //HTML Transitional DOCTYPE $html_doctype = '<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">'; break; } //If the user wants CSS go through the options and make a css folder $css_post = $_GET['css']; if($css_post == 'css_yes') { $css = '<link rel="stylesheet" href="css/style.css" type="text/css" media="screen" title="no title" charset="utf-8" />'; //Put this in the template mkdir($deploy_download.'/css'); //Create the CSS directory } else{ $css = ''; } //If the user picks to create a CSS file... if(isset($_GET['css_options'])){ $css_options = $_GET['css_options']; switch($css_options) { case 'css_resets': //... and chooses the reset option, copy the reset file to the new location exec("cp -r files/CSS/reset.css ".$deploy_download."/css/style.css"); break; case 'css_blank': //... ane chooses the blank option open the folder and create a new file named style.css $fh = fopen($deploy_download.'/css/style.css', 'w') or die("can't open file"); fclose($fh); //close the file break; default: $css = ''; break; } } //jQuery section $j_version = '1.2.6'; //Update with new releases of jQuery! if(isset($_GET['jquery'])) { $j_compression = $_GET['jquery']; $jquery_post = $_GET['jquery_choice']; switch($j_compression) { case 'jquery_min': $j_compression = '.min'; break; case 'jquery_pack': $j_compression = '.pack'; break; case 'jquery_un': $j_compression = ''; break; } //If the user wants jQuery put a script tag in the head, and make a js folder with the jQuery file inside. if ($jquery_post == 'jquery_yes'){ $jquery = '<script type="text/javascript" src="js/jquery-'.$j_version.$j_compression.'.js"></script>'; mkdir($deploy_download.'/js'); exec('cp -r files/JavaScript/jQuery/jquery-'.$j_version.$j_compression.'.js '.$deploy_download.'/js/jquery-'.$j_version.$j_compression.'.js'); } else { $jquery = ''; } } else { $jquery = ''; } //This following if else is completely for the plugins. It uses the plugins.xml data. if(isset($jquery)) { $jquery_script = ''; $jquery_css_link = ''; foreach($pluginData->plugin as $plugin){ $plugin_name = $plugin->name; if(isset($_GET['jquery_plugin_'.$plugin_name])){ $plugin_dir = $plugin->dir; $filename = $plugin->name['filename']; $jquery_script = $jquery_script.'<script type="text/javascript" src="js/'.$filename.'"></script>'."\n\t"; exec("cp -r files/JavaScript/jQuery/plugins/$plugin_dir/$filename $deploy_download/js/$filename"); //Execute a copy if($plugin->stylesheets){ if(!is_dir($deploy_download.'/css')){ // ...and they haven't chosen to include a CSS directory above... mkdir($deploy_download.'/css'); //...then make one. } foreach($plugin->stylesheets->css as $jquery_css){ //echo '--'.$jquery_css.'<br />'; $jquery_css_link = $jquery_css_link.'<link rel="stylesheet" href="css/'.$jquery_css.'" type="text/css" />'; exec("cp -r files/JavaScript/jQuery/plugins/$plugin_dir/$jquery_css $deploy_download/css/$jquery_css");//Execute a copy } } if($plugin->images){ if(!is_dir($deploy_download.'/images')){ //...and the user never selected an images folder in the misc options... mkdir($deploy_download.'/images'); // ...create one for them } foreach($plugin->images->image as $jquery_image){ exec("cp -r files/JavaScript/jQuery/plugins/$plugin_dir/$jquery_image $deploy_download/images/$jquery_image");// Copy it to the images folder //echo '--'.$jquery_image.'<br />'; } } } else{ //echo '<span style="color:red;">'.$plugin->name.'_plugin</span><br />'; } } } if($project_name !== 'deploy'){ //If the name was NOT defaulted to deploy above... $html_title = $project_name; //...Then it will be what the named } else { $html_title = 'Title'; //...If it was, then <title> in the <head> will be simply be Title } //Create the html file $html_temp = ''.$html_doctype.' <html '.$html_attr.'> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> <title>'.$html_title.'</title> '.$jquery.' '.$jquery_script.' '.$css.' '.$jquery_css_link.' </head> <body> <h1><a href="http://projectdeploy.org">deploy*</a></h1> </body> </html> '; $fh = fopen($deploy_download.'/'.$deploy_file, 'w') or die("can't open file"); //Open the new file fwrite($fh, $html_temp); //write the file fclose($fh); //close the file //Make some additional folders before it's too late if the user checked the following options. if(isset($_GET['misc_options_images'])){ if(!is_dir($deploy_download.'/images')){ mkdir($deploy_download.'/images'); } } if(isset($_GET['misc_options_includes'])){ mkdir($deploy_download.'/includes'); } if(isset($_GET['misc_options_flash'])){ mkdir($deploy_download.'/flash'); } exec('cp -r '.$deploy_download.' '.$deploy_dir.''); //Copy the temp directory with contents to the new location remove_dir($deploy_download); //Remove the temp folder and files exec('cp -r '.$sys_folder.'/'.$deploy_download.' '.$deploy_dir.'/'.$safe_name.''); //Make a duplicate of the newly copied file, but rename it with their project name. remove_dir($deploy_dir.'/'.$safe_name.'/'.$safe_name); exec("cd $deploy_dir; zip -r $safe_name $safe_name"); //Change directories and then zip the safe name for download //Get rid of this project session session_destroy(); //HTML Page now starts ?> <div id="download_container"> <a class="download_btn" href="<?php echo $deploy_dir.'/'.$safe_name.'.zip'; ?>"></a> </div> <p id="remember">Don't forget to bookmark this page. By bookmarking this page you create a shortcut that will instantly give you a download rather than filling out the form for a second time!</p> <?php include('includes/footer.php'); ?> Link to comment https://forums.phpfreaks.com/topic/135217-permission-error-help/#findComment-704272 Share on other sites More sharing options...
rhodesa Posted December 2, 2008 Share Posted December 2, 2008 hum...seems like the script bounces back and forth between $deploy_download and $deploy_dir. When working with the real path to a file/folder, it should be $deploy_dir. Link to comment https://forums.phpfreaks.com/topic/135217-permission-error-help/#findComment-704279 Share on other sites More sharing options...
imarockstar Posted December 2, 2008 Author Share Posted December 2, 2008 this script is a tad bit over my head .. i was hoping to dissect it and learn from it ... lol .. but i cant get it to work ... how would i go about implementing your above post ? Link to comment https://forums.phpfreaks.com/topic/135217-permission-error-help/#findComment-704285 Share on other sites More sharing options...
rhodesa Posted December 2, 2008 Share Posted December 2, 2008 for just the mkdir part...here is the issue i see: $sys_folder = 'deploys'; //What folder all the deploys are in $deploy_download = 'deploy_'.date('smd').rand(1,999); //What the folders will be named $deploy_dir = $sys_folder.'/'.$deploy_download; //directory where deploy, deploys $deploy_file = "index.html"; //Name of the index.html files. This can be anything ...bunch of other code here.... mkdir($deploy_download); //make the new directory $deploy_download is set to deploy_########. $deploy_dir is the one that is set to deploys/deploy_########. so, shouldn't the mkdir() be for $deploy_dir? Link to comment https://forums.phpfreaks.com/topic/135217-permission-error-help/#findComment-704319 Share on other sites More sharing options...
projectdeploy Posted December 3, 2008 Share Posted December 3, 2008 I tried emailing you and responding on http://projectdeploy.org/help link, but just incase: Deploy* creates a directory, goes through the process of building this directory and files and then after it's finished being created it moves it into the deploys directory. Once in there it takes the file contents of it and zips them and stores the zip inside of your deploy directory which would be like deploy12345... The reason I think it isn't working is a simple permissions error. It's trying to create the directory but can't and when it can't create the directory it can't copy it and if it doesn't get copied it can't be zipped. Now to fix this, try a 755 permisson on the root folder. Which when you download the code is deploy1_3. If you make this 755 and it still doesn't work try 777. I made sure and downloaded it and it worked on my UNIX(mac os x) set up and on my LAMP set up right out of the box. I think your server or computer reset the permissions when you uploaded it or extracted the files. The change the permissions on most FTP programs simply go to properties (windows) or get info(on mac) or something of the like to get the information of the directory. In Transmit (my FTP program) I right click on the directory or file, select get info, and then change the "octal" setting to 777 or 755 or check and un check the checkboxes until you get that number. 777 would be all the checkboxes. If you need more help please write back from my contact link at http://projectdeploy.org or go to the http://projectdeploy.org/help section and reply to your topic. Hope this helps Link to comment https://forums.phpfreaks.com/topic/135217-permission-error-help/#findComment-704586 Share on other sites More sharing options...
rhodesa Posted December 3, 2008 Share Posted December 3, 2008 Wow, two thumbs up for Project Deploy Link to comment https://forums.phpfreaks.com/topic/135217-permission-error-help/#findComment-704688 Share on other sites More sharing options...
projectdeploy Posted December 3, 2008 Share Posted December 3, 2008 OK, this is now fixed in 1.3.1. It now uses the chmod() function and corrects it's self More info on the error at: http://projectdeploy.org/blog/posts/the-permission-denied-error/ And the update at: http://projectdeploy.org/blog/posts/version-1_3_1/ Link to comment https://forums.phpfreaks.com/topic/135217-permission-error-help/#findComment-704779 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.