Jump to content

htaccess


bhawap

Recommended Posts

ok i have a mobile downloads site my issue is the mime typs this is what i have but some how it tells the users invalid content yet its valid content

 

function Get_Htaccess() {
$Br = "
";
$Result = "RewriteBase /".$Br;
$Result .= $Br;
$Result .= "addtype application/vnd.nok-s40theme nth".$Br;
$Result .= "addtype application/vnd.eri.thm thm".$Br;
        $Result .= "addtype application/vnd.symbian.install sis".$Br;
$Result .= "addtype application/symbian sisx".$Br;
        $Result .= "AddType x-epoc/x-sisx-app sisx".$Br;
        

$Result .= "addtype audio/x-aac aac".$Br;
$Result .= "addtype audio/midi mid".$Br;
$Result .= "addtype audio/amr amr".$Br;
$Result .= "AddType video/mp4 mp4".$Br;
$Result .= "addtype video/3gpp 3gp".$Br;
        $Result .= "addtype audio/mpeg mp3".$Br;

	$Result .= "addtype application/java jad".$Br;
$Result .= "addtype application/java jar".$Br;

$Result .= $Br;
$Result .= "# supress php errors".$Br;
$Result .= "php_flag display_startup_errors off".$Br;
$Result .= "php_flag display_errors off".$Br;
$Result .= "php_flag html_errors off".$Br;
$Result .= "php_value docref_root 0".$Br;
$Result .= "php_value docref_ext 0".$Br;
$Result .= $Br;
$Result .= "<Files .htaccess>".$Br;
$Result .= "order allow,deny".$Br;
$Result .= "deny from all".$Br;
$Result .= "</Files>".$Br;
$Result .= $Br;
$Result .= "# disable directory browsing".$Br;
$Result .= "Options All -Indexes".$Br;
$Result .= $Br;
$Result .= 'ErrorDocument 403 "Error - Access Denied."'.$Br;
$Result .= 'ErrorDocument 404 "Error - Page not found."';

return $Result;
}

Link to comment
Share on other sites

It looks like this function is attempting to create an .htaccess format string.  Why you are doing this, and to what end, we can only guess.  We also have no idea what your problem is.  You aren't going to get help without providing detailed information about what you are trying to do and SPECIFICALLY what errors or problems you are having.

Link to comment
Share on other sites

ok hi , firstly i am new here so please forgive me if i some how do something wrong, now my site was built by a friend and b4 he left me he said it has issues with the mime typs i can put the whole page here if that will help,

 

<?php
function Item_Get_Type($Item_Path) {
$Item_IsFile = "False"; if(@is_file($Item_Path)) { $Item_IsFile = "True";}
$Item_IsDir = "False"; if(@is_dir($Item_Path)) { $Item_IsDir = "True";}
$Item_Type = "File"; if ($Item_IsDir == "True") { $Item_Type = "Directory";}
return $Item_Type;
}
function Item_Get_Size($Item_Path) {
$Item_Size = filesize($Item_Path);
if ($Item_Size > 1000) { 
	if ($Item_Size > 1000000) { 
		$Item_Size = round($Item_Size / 1000000,2);
		$Item_Size .= "mb";
	} else {
		$Item_Size = round($Item_Size / 1000,2);
		$Item_Size .= "kb";
	}
} else {
	$Item_Size = round($Item_Size / 1000,2);
	$Item_Size .= "kb";
}
return $Item_Size;
}
function Item_Get_ModDate($Item_Path) {
$RawDate =  @filemtime($Item_Path);
$Mod =@date("d/m/Y",$RawDate);
$Mod = str_replace('/', '**', $Mod);
return $Mod;
}
function Item_Get_Extension($Filename)  {
$Ext = strtolower(substr(strrchr($Filename, "."), 1));
return $Ext;
}

function Item_Trim_Filename($Filename)  {  
$Ext = Item_Get_Extension($Filename);  
$Ext = ".".$Ext;

$NewName = str_replace($Ext,'',$Filename);
return $NewName;
}
function Get_BackLink($Dir_Path) {
$Result = "";
if ($Dir_Path == $GLOBALS["Root_Directory"]) {
	$Result = "Home";
} else {
	$DirStr = str_replace('/', '==', $Dir_Path);
	$Dirs = split("==",$DirStr);
	$DirCnt = 0;
	foreach ($Dirs as $Dir) {
		$DirCnt++;
	}

	$BkName = "";
	$BkLink = "";
	$i = 0;
	$DirCnt = $DirCnt -1;
	while ($i < $DirCnt) {
		$BkLink .= $Dirs[$i];

		$DirBEnd = $DirCnt -1;
		if ($i != $DirBEnd) {
			$BkLink .= "/";
		} else {
			$BkName = "==".$Dirs[$i];
		}
		$i++;
	}
	if ($BkLink == "") { $BkLink = "Home"; }

	if ($BkLink == $GLOBALS["Root_Directory"]) {
		$Result = "Catagories";
	} else {
		$Result = md5($BkLink).$BkName;
	}

}
return $Result;
}
function Directory_CountFiles($Dir_Path) {
$FileCount = 0;
$Dir_Items = scandir($Dir_Path);
$Dir_List[0] = "";
$i=0;
foreach($Dir_Items as $Dir_Item) {
	$Item_Path = $Dir_Path."/".$Dir_Item;
	if ($Dir_Item != "." && $Dir_Item != ".." && $Dir_Item != "Dir.Info" && $Dir_Item != ".htaccess") {
		$D_Type = Item_Get_Type($Item_Path);
		if ($D_Type == "Directory") {
			$FileCount = $FileCount + Directory_CountFiles($Item_Path);
		} else {
			$FileCount++;
		}
		$i++;
	}
}
return $FileCount;
}

function Read_DirInfo($Dir_Path) {
$Info_Path = $Dir_Path."/Dir.Info";
$Data = "False";
if (file_exists($Info_Path)) {
	$handle = fopen($Info_Path,"a+"); //mind the + this means to write AND read
	$Data = fread($handle,filesize($Info_Path));
	fclose($handle);
}
if ($Data != "False") {
	$Hits= ReadHeaders($Data,'#Hits==','#');
	return $Hits[0];
} else {
	return "0";
}
}
function Write_DirInfo($Dir_Path, $Hits) {
$Info_Path = $Dir_Path."/Dir.Info";

if (file_exists($Info_Path)) {
	DeleteFile($Info_Path);
}

$fh = fopen($Info_Path, 'w');
$Data = "#Hits==$Hits#";
fwrite($fh, $Data);
}
function Write_Htaccess($Dir_Path) {
$Htaccess_Path = $Dir_Path."/.htaccess";

if (file_exists($Htaccess_Path)) {
	DeleteFile($Htaccess_Path);
}
$fh = fopen($Htaccess_Path, 'w');
$Data = Get_Htaccess();
fwrite($fh, $Data);
}

function Get_Htaccess() {
$Br = "
";
$Result = "RewriteBase /".$Br;
$Result .= $Br;
$Result .= "addtype application/vnd.nok-s40theme nth".$Br;
$Result .= "addtype application/vnd.eri.thm thm".$Br;
        $Result .= "addtype application/vnd.symbian.install sis".$Br;
$Result .= "addtype application/symbian sisx".$Br;
        $Result .= "AddType x-epoc/x-sisx-app sisx".$Br;
        

$Result .= "addtype audio/x-aac aac".$Br;
$Result .= "addtype audio/midi mid".$Br;
$Result .= "addtype audio/amr amr".$Br;
$Result .= "AddType video/mp4 mp4".$Br;
$Result .= "addtype video/3gpp 3gp".$Br;
        $Result .= "addtype audio/mpeg mp3".$Br;

	$Result .= "addtype application/java jad".$Br;
$Result .= "addtype application/java jar".$Br;

$Result .= $Br;
$Result .= "# supress php errors".$Br;
$Result .= "php_flag display_startup_errors off".$Br;
$Result .= "php_flag display_errors off".$Br;
$Result .= "php_flag html_errors off".$Br;
$Result .= "php_value docref_root 0".$Br;
$Result .= "php_value docref_ext 0".$Br;
$Result .= $Br;
$Result .= "<Files .htaccess>".$Br;
$Result .= "order allow,deny".$Br;
$Result .= "deny from all".$Br;
$Result .= "</Files>".$Br;
$Result .= $Br;
$Result .= "# disable directory browsing".$Br;
$Result .= "Options All -Indexes".$Br;
$Result .= $Br;
$Result .= 'ErrorDocument 403 "Error - Access Denied."'.$Br;
$Result .= 'ErrorDocument 404 "Error - Page not found."';

return $Result;
}

function ReadHeaders($text, $openingMarker, $closingMarker) {    
$openingMarkerLength = strlen($openingMarker);    
$closingMarkerLength = strlen($closingMarker);     
$result = array();    
$position = 0;    
while (($position = strpos($text, $openingMarker, $position)) !== false) {      
	$position += $openingMarkerLength;      
	if (($closingMarkerPosition = strpos($text, $closingMarker, $position)) !== false) {       
		$result[] = substr($text, $position, $closingMarkerPosition - $position);        
		$position = $closingMarkerPosition + $closingMarkerLength;      
     		}    
}    
return $result;  
}

?>

Link to comment
Share on other sites

You still haven't indicated what your problem is.

 

:(

 

I'm going to throw out a few general comments.

 

- You seem to have a routine where the goal is to write out an htaccess file at some point.  That htaccess has a bunch of apache mod_mime addType statements.

- addTypes are part of mod_mime, and simply associate a file extension with a Mime type and ideally apache handler.

 

If you have "Mime type problems" then I would assume it is related to an understanding of apache's MOD_MIME module, the addType directive, MIME types in general, and/or some combination of these items. 

 

Please do some of your own research given the information I've given you.  If you can't explain what your problem is we can't help.

 

PLEASE NOTE: NO WE DON'T WANT TO SEE A BUNCH MORE OF CODE YOU HAVEN'T WRITTEN AND DON'T UNDERSTAND YOURSELF!!!!

 

Please read the forum posting rules and TOS if you're unclear about how to approach things:  http://www.phpfreaks.com/page/rules-and-terms-of-service

 

 

Link to comment
Share on other sites

my problem is when someone tries to download an item like A jar file to the mobile it says invalid content but if i had to use a direct like to that jar file it downloads fine and works 100%, mp3s download fine just the jar,jad,sis,nth files are were i am having this issue, i did some research and found that my problem could be the mime typs on my site, i realy do not know alot about how php works and mime typs i am sorry again for asking for help i was told this was the best site to come for help i tought by posting the whole php doc will help u understand what my problem was, clearly i was wrong ,anyways thanks for your help i did not mean to break any rules of this forum

 

Zainul owner of www.bhawap.com

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.