Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Old 11-11-2008, 03:09 PM Adding php code
Super Talker

Posts: 113
Name: Paul
Trades: 0
Im tryig to add some php code to my php script, this is for a domain license but every time I add the code I get an error, the trouble is I dont know what the error is, I hope you dont mind helpng me out with this:

This is the original php code,

<?php

class VidRipScript
{
function VidRipScript()
{
$this->Smarty =& GetInstance('Smarty');
$this->PluginController =& GetInstance('PluginController');
require('config.php');
$this->Config = $Config;
return true;
}

// rip url
function Rip($url)
{
if(!$url || !parse_url($url))
{
$this->Smarty->assign('RIP_FAILED', true);
return false;
}

if($this->Config['Pipe'])
{
$pipe = ' | ' . $this->Config['Pipe'];
}

switch($this->Config['downloader'])
{
case 'curl':
$download_cmd = $this->Config['curl_path'] . ' -L';
break;
case 'wget':
$download_cmd = $this->Config['wget_path'] . ' -O -';
break;
default:
$download_cmd = $this->Config['downloader'];
}

ob_start();

// before ripping
$this->PluginController->RunEvent('BeforeRipping');
passthru(sprintf('%s "%s" | %s -f flv -i - -f mp3 -title "%s" -author "%s" -comment "%s" -%s', $download_cmd, $url, $this->Config['ffmpeg_path'], $this->Config['title'], $this->Config['author'], $this->Config['comment'], $pipe));

// after ripping
$this->PluginController->RunEvent('AfterRipping');
header('Pragma: public');
header('Expires: 0');
header('Content-Type: audio/mpeg');
header(sprintf('Content-Disposition: attachment; filename="%s-%s.mp3"', $this->Config['filename_prefix'], time()));
ob_end_flush();

// after download
$this->PluginController->RunEvent('AfterDownload');
exit;
}

// find FLV
function FindFLV($url)
{
$URLInfo = parse_url($url);
$host = explode('.', $URLInfo['host']);
$host = strtolower($host[count($host) -2]);
if(file_exists('modules/' . $host . '.def.php'))
{
require_once('modules/' . $host . '.def.php');
return RunModule($url);
}
$this->Smarty->assign('NOT_SUPPORTED', true);
return false;
}
}
?>



This is the domain license code and it needs to be inserted into an important file like the one above:

// PLEASE DO NOT EDIT BELOW
// PLEASE DO NOT EDIT BELOW
// PLEASE DO NOT EDIT BELOW

function p($b,$e,$m) {
$a = 1;
$i = 0;
$b2 = $b;
while (($e >> $i)>0) {
if ((($e >> $i) & 1) == 1) {
$a = mo(($a * $b2) , $m);
}
$b2 = mo(($b2 * $b2) , $m);
$i++;
}
return $a;
}

function mo ($g, $l) {
return $g - ($l * floor ($g/$l));
}

function d($c, $d, $n) {
$da = split(" ", $c);
for ($u=0; $u<count ($da); $u++) {
if ($da[$u] == "") {
array_splice($da, $u, 1);
}
}

for ($u=0; $u< count($da); $u++) {
$rm = p($da[$u], $d, $n);
$de.= substr ($rm, 1, strlen($rm)-2);
}

for ($u=0; $u<strlen($de); $u+=2) {
$rd .= chr(substr ($de, $u, 2) + 30);
}
return $rd;
}

// YOU CAN EDIT THE TEXT BELOW
// YOU CAN EDIT THE TEXT BELOW
// YOU CAN EDIT THE TEXT BELOW


$E = array("Your license has expired! Please contact the vendor to purchase a script or resolve any issues.","You don't have a license for this script! Please contact the vendor to purchase a script or resolve any issues.","The activation could not be contacted. Please check that your server has access to external HTTP servers, or contact issues@licensescript.com with your site's URL and the name of the product and vendor.");


// PLEASE DO NOT EDIT BELOW
// PLEASE DO NOT EDIT BELOW
// PLEASE DO NOT EDIT BELOW

$n=52975669;
$k=27617379;

$v=15;
$p=56;

$h = str_replace("www.","",$_SERVER["HTTP_HOST"]);
if(file_exists($v."_".$p.".key"))
{
$f=fopen($v."_".$p.".key","r");
fseek($f,0);
$data = d(fread($f,1000),$k,$n);
fclose($f);
}
else
{
$data = "";
}

$dm = substr($data,0,32);
$time = intval(substr($data,32));


if(time()-date("Z",time()) > $time || md5($h) != $dm)
{
$cu=curl_init("http://www.vidripscript.com/validate.php/$h/$v/$p");
curl_setopt($cu,CURLOPT_RETURNTRANSFER, 1);
$newkey = curl_exec($cu);
if($newkey == "EXPIRED")
{
$licerror = $E[0];
}
elseif($newkey == "INVALID")
{
$licerror = $E[1];
}

if(!$licerror)
{
$f=fopen("$v"."_$p.key","w");
fwrite($f,$newkey);
}
}

if($licerror)
{
die($licerror);
}




This is the error I get when I insert the code:


Warning: fopen(15_56.key) [function.fopen]: failed to open stream: Permission denied in /home/vidrip/public_html/electrifire/vidrip/VidRipScript.class.php on line 96

Warning: fwrite(): supplied argument is not a valid stream resource in /home/vidrip/public_html/electrifire/vidrip/VidRipScript.class.php on line 97



The domain license code needs to be inserted within the php tags and I believe it should be at the top of the php code but what is te error?


Sorry for the lengthly post but really stuck
fattony is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 11-11-2008, 05:35 PM Re: Adding php code
lothop's Avatar
Ultra Talker

Posts: 303
Trades: 0
$f=fopen("$v"."_$p.key","w");
fwrite($f,$newkey);
}

Seems to be the problem
Its being denied permission. Using "w" - if the file does not exist, attempt to create it. Does the file exist? Does it have permission to create it if it doesnt exist?

"If you fopen() a handle, you also have to obligation to fclose() it again."
$f=fopen("$v"."_$p.key","w");
fwrite($f,$newkey);
fclose($f);
}

Search fopen and fwrite at php.net
Might find some answers
__________________
Websites Created;
warscope.com
ratepayers.org.nz

Last edited by lothop; 11-11-2008 at 05:39 PM..
lothop is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Adding php code
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.21783 seconds with 12 queries