Jump to content

Ruzzas

Members
  • Posts

    180
  • Joined

  • Last visited

    Never

Everything posted by Ruzzas

  1. No errors, I'm having trouble spotting the errors because of such a slow website.
  2. Uhmm, I do not understand why this was moved here because I coded this myself, Its just implemented with Joomla. If you could move it back, thanks!
  3. If you guys noticed, He's trying to update not insert...
  4. I am trying to make a file upload to a directory and then just simply upload it to a remote connection. The problem is, Well... I honestly don't know... I'm good with PHP overall but when it comes to Joomla, I turn into a curious monkey. function UploadToRemote($tempFile,$targetPath,$targetFile){ global $jlistConfig; ignore_user_abort(true); set_time_limit(3600); $conn = ftp_connect($jlistConfig['ftp.address']) or die('FTP Connection failed'); $login = ftp_login($conn,$jlistConfig['ftp.username'],$jlistConfig['ftp.password']) or die('FTP Login failed'); if(!ftp_chdir($conn,$targetPath)){ if(ftp_mkdir($conn,$targetPath)){ ftp_chdir($conn,$targetPath); }else{ $success = 0; } if(ftp_put($conn,$targetFile,$tempFile,FTP_BINARY)){ $success = 1; }else{ die('Failed uploading the file...'); } } ftp_close($conn); return $success; } //datei upload bearbeiten if($file_upload['tmp_name']!=''){ // replace special chars in filename $filename_new = checkFileName($file_upload['name']); $upload_dir = '/'.$jlistConfig['files.uploaddir'].'/'.$mark_catdir.'/'; $ftp_dir = '/'.$jlistConfig['ftp.folder'].'/'.$mark_catdir.'/'; $dir_and_filename = str_replace('/'.$jlistConfig['files.uploaddir'].'/', '', $upload_dir.$filename_new); $target_path = JPATH_SITE.$upload_dir.$filename_new; // upload only when the file not exist in the directory if(!is_file($target_path)){ if(@move_uploaded_file($file_upload['tmp_name'], $target_path)){ $Upload = UploadToRemote($file_upload['tmp_name'], $jlistConfig['ftp.folder'].'/'.$mark_catdir.'/', $jlistConfig['ftp.folder'].'/'.$mark_catdir.'/'.$filename_new) or die('Failed to upload...'); // get filesize $size = fsize($target_path); // get filedate $date_added = JHTML::_('date', 'now', '%Y-%m-%d %H:%M:%S' ); $url_download = basename($target_path); $url_download = utf8_encode($url_download); // auto publish ? if($jlistConfig['upload.auto.publish']){ $publish = 1; setAUPPointsUploads($submitted_by, $filetitle); $set_aup_points = 0; }else{ $set_aup_points = 1; $publish = 0; } $file_extension = strtolower(substr(strrchr($url_download,"."),1)); $filepfad = JPATH_SITE.'/images/jdownloads/fileimages/'.$file_extension.'.png'; if(file_exists(JPATH_SITE.'/images/jdownloads/fileimages/'.$file_extension.'.png')){ $filepic = $file_extension.'.png'; }else{ $filepic = $jlistConfig['file.pic.default.filename']; } $database->setQuery("INSERT INTO #__jdownloads_files (`file_id`, `file_title`, `file_alias`,`description`, `description_long`, `file_pic`, `thumbnail`, `thumbnail2`, `thumbnail3`, `price`, `release`, `language`, `system`, `license`, `url_license`, `size`, `date_added`, `file_date`, `url_download`, `url_home`, `author`, `url_author`, `created_by`, `created_mail`, `modified_by`, `modified_date`, `submitted_by`, `set_aup_points`, `downloads`, `cat_id`, `ordering`, `published`, `checked_out`, `checked_out_time`) VALUES (NULL, '$filetitle', '$file_alias', '$description', '$description_long', '$filepic', '$thumbnail', '$thumbnail2', '$thumbnail3', '$price', '$version', '$language_sel', '$system_sel', '$license_sel', '', '$size', '$date_added', '', '$url_download', '$author_url', '$author', '', '$name', '$mail', '', '0000-00-00 00:00:00', '$submitted_by', '$set_aup_points', '0', '$catlist_sel', '0', '$publish', '0', '0000-00-00 00:00:00')"); if(!$database->query()){ // fehler beim erstellen in DB echo $database->stderr(); exit; } // alles OK! if(!$msg){ $msg = '<div>'.$upload_ok_pic.'<font color="green"> ' .JText::_('JLIST_FRONTEND_UPLOAD_OK'). '</font><br /> </div>'; $html_form = str_replace('{form}', '{msg}{form}', $html_form); // send email wenn aktiviert if($jlistConfig['send.mailto.option.upload']){ sendMailUploads($name, $mail, $url_download, $filetitle, $description); } } }else{ // fehler beim verschieben $msg = '<div>'.$upload_stop_pic.'<font color="red"> ' .JText::_('JLIST_FRONTEND_UPLOAD_ERROR_MOVE_FILE'). '</font><br /> </div>'; $html_form = str_replace('{form}', '{msg}{form}', $html_form); } }else{ // file exist with the same name $msg = '<div>'.$upload_stop_pic.'<font color="red"> ' .JText::_('JLIST_FRONTEND_UPLOAD_ERROR_FILE_EXISTS'). '</font><br /> </div>'; $html_form = str_replace('{form}', '{msg}{form}', $html_form); } } Please help me!
  5. I did not know this, Thank you Mr wildteen88.
  6. Yes indeedy, What is this? $Module['Core'] = new panel_core();
  7. It's a printf problem, Without it, it seems to work fine. But I want it with printf so I can chuck it in my settings for easy configuration.
  8. Try class bot_restart { function __construct( ) { $ServersReturned = mysql_query("SELECT * FROM xhost_boxs"); $CurrentServers = mysql_fetch_array($ServersReturned); while($CurrentServers !== false) { echo $CurrentServers['box_id']; } } }
  9. If you read the code: <?php print_r($Log); ?>
  10. Yeah... Didn't make no difference, Whatsoever Also: <td>Freshly downloaded: PewPew revision: 038</td> Array ( [Name] => PewPew [TimeStamp] => 1280744518 [Revision1] => 0 [Revision2] => 376 ) </tr> if($Log['Revision1']&&$Log['Revision2']){ $Message = 'Updated %1$s from revision: %3$s to revision: %4$d'; }else{ $Message = 'Freshly downloaded: %1$s revision: %3$d'; }
  11. whoops, found it: short_open_tag http://php.net/manual/en/ini.core.php
  12. I believe its a certain setting in PHP. I haven't any clue which one though.
  13. $loadLast100JokesSQL = 'SELECT * from jokes_en ORDER BY joke_posting_date LIMIT 1,100 DESC'; That should load you're last 100 jokes inside the mysql server plus, I'm sure you need capitals for SELECT, ORDER BY, LIMIT and DESC
  14. Use print_r(mysql_fetch_array(mysql_query("SELECT * FROM xhost_boxs")); to show your full array and make sure that doesn't loop either, if it does then it may be the class. I'm not that good with classes, just custom functions
  15. http://php.net/manual/en/function.fopen.php http://php.net/manual/en/function.fread.php http://php.net/manual/en/function.preg-match.php
  16. Hello, Well let me explain my problem to you guys. I am using a printf function with an array, a custom function which i got off php.net Anyways, Everytime I use it, It seems to leave random numbers at the end of the string for no reason at all. Here is the result in source: <td><a href="?page=download&name=DarkRP">DarkRP</a></td> <td>08:10:17 AM 07/08/2010</td> <td>Updated DarkRP from revision: 670 to revision: 67150</td> Array ( [Name] => DarkRP [TimeStamp] => 1281186617 [Revision1] => 670 [Revision2] => 671 ) </tr> It is mean't to show Updated DarkRP from revision: 670 to revision 671 but instead it has the random number 50 at the end for no reason... Anyways heres the echoing code: <?php foreach($Logs as $Log){ $Time = TimeToDate($Log['TimeStamp']); if($Log['Revision1']&$Log['Revision2']){ $Message = 'Updated %1$s from revision: %3$s to revision: %4$d'; }else{ $Message = 'Freshly downloaded: %1$s revision: %3$d'; } ?> <tr> <td><?php echo '<a href="?page=download&name='. $Log['Name'] .'">'. $Log['Name'] .'</a>'; ?></td> <td><?php echo $Time['Time'] .' '. $Time['Date']; ?></td> <td><?php echo printf_array($Message, $Log); ?></td> <?php print_r($Log); ?> </tr> <?php } ?> </table> <br /> Functions: function MySQLGetLogs(){ global $Connection; if($Connection){ $Query = sprintf('SELECT name, timestamp, revision1, revision2 FROM update_logs ORDER BY timestamp DESC;'); if($Result = mysql_query($Query)){ $Array = array(); while($Row = mysql_fetch_array($Result)){ $Array2 = array(array( 'Name' => $Row['name'], 'TimeStamp' => $Row['timestamp'], 'Revision1' => $Row['revision1'], 'Revision2' => $Row['revision2'] ) ); $Array = array_merge($Array, $Array2); } mysql_free_result($Result); return $Array; } } } function printf_array($Format, $Array) { return call_user_func_array('printf', array_merge((array)$Format, $Array)); } Also, I got the same issue with printf alone instead of the custom array function above.
  17. I have included some of your code in my script: function CheckRemoteRevision($Name){ if($Name){ if($Query = MySQLQuery('SELECT name, url, sv_revision FROM data WHERE name="'. $Name .'";')){ if($XMLFile = shell_exec('svn info "'. $Query['url'] .'" --username anonsvn --password anonsvn --xml')){ if($DCheck = explode(' ', $XMLFile)){ if($DCheck[0] == 'svn:'){ $Revision = '0'; $Result = MySQLQuery('UPDATE data SET sv_revision="'. $Revision .'" WHERE name="'. $Query['name'] .'";'); return False; } } if($XML = simplexml_load_string($XMLFile)){ $XML = new SimpleXMLElement($XMLFile); foreach($XML->entry as $Attribute){ $Revision = $Attribute['revision']; } if($Query['sv_revision'] < $Revision || $Query["sv_revision"] != $Revision){ $Result = MySQLQuery('UPDATE data SET sv_revision="'. $Revision .'" WHERE name="'. $Query['name'] .'";'); } }else{ echo "[". CurTime() ."] Addon \"". $Name ."\" seemed to have suffered an XML error. Retrying...\n"; CheckRemoteRevision($Name); } return $Revision; }else{ return False; } }else{ return False; } }else{ return False; } } I can't test it until it errors itself if it does. Thanks for the help though. Hope that fixes my stupid problem!
  18. Is there a way to find if its legit XML and stop it there before erroring and re-run it so it continues with the script without any problems?
  19. I have no idea why you didnt use one table and your $id can be used for sql injection.
  20. Hello, I'm in need of help. Sometimes my PHP reads XML from a ssh and it tends to fail at times. Heres my complete error: [04-Aug-2010 18:03:16] PHP Warning: SimpleXMLElement::__construct() [<a href='simplexmlelement.--construct'>simplexmlelement.--construct</a>]: Entity: line 3: parser error : Premature end of data in tag info line 2 in /home/nmdgamin/public_html/private/includes/functions/revision.php on line 69 [04-Aug-2010 18:03:16] PHP Warning: SimpleXMLElement::__construct() [<a href='simplexmlelement.--construct'>simplexmlelement.--construct</a>]: in /home/nmdgamin/public_html/private/includes/functions/revision.php on line 69 [04-Aug-2010 18:03:16] PHP Warning: SimpleXMLElement::__construct() [<a href='simplexmlelement.--construct'>simplexmlelement.--construct</a>]: ^ in /home/nmdgamin/public_html/private/includes/functions/revision.php on line 69 [04-Aug-2010 18:03:16] PHP Fatal error: Uncaught exception 'Exception' with message 'String could not be parsed as XML' in /home/nmdgamin/public_html/private/includes/functions/revision.php:69 Stack trace: #0 /home/nmdgamin/public_html/private/includes/functions/revision.php(69): SimpleXMLElement->__construct('<?xml version="...') #1 /home/nmdgamin/public_html/private/includes/functions/update.php(16): CheckRemoteRevision('SpaceBuild') #2 /home/nmdgamin/public_html/prv_updater.php(13): Update() #3 {main} thrown in /home/nmdgamin/public_html/private/includes/functions/revision.php on line 69 Remote function: function CheckRemoteRevision($Name){ if($Name){ if($Query = MySQLQuery('SELECT name, url, sv_revision FROM data WHERE name=\''. $Name .'\';')){ if($XMLFile = shell_exec('svn info \''. $Query['url'] .'\' --username anonsvn --password anonsvn --xml')){ if($DCheck = explode(' ', $XMLFile)){ if($DCheck[0] == 'svn:'){ $Revision = '0'; $Result = MySQLQuery('UPDATE data SET sv_revision=\''. $Revision .'\' WHERE name=\''. $Query['name'] .'\';'); return False; } } $XML = new SimpleXMLElement($XMLFile); foreach($XML->entry as $Attribute){ $Revision = $Attribute['revision']; } if($Query['sv_revision'] < $Revision || $Query["sv_revision"] != $Revision){ $Result = MySQLQuery('UPDATE data SET sv_revision=\''. $Revision .'\' WHERE name=\''. $Query['name'] .'\';'); } return $Revision; }else{ return False; } }else{ return False; } }else{ return False; } } How would I full proof this from getting this error again, It seems to happen at completely random times. I'm not very good with XML in PHP Thanks!
  21. Gosh that is the most uncleaned code ive ever seen. I dont understand how you work with that.
  22. You could make a messy folder look clean by using this, Hacks wouldn't know your folder/file names. Basically Just keeping shit clean and making sure they can't find where your source is located. (Don't give it away in the source code like iframes and such) I don't know anymore... sorry
  23. I've got two functions. One which lists the folders/files in a folder (remotely) One which downloads all them (recursively) I need you guys to help me make: The downloader (mkdir) folders if they arn't already on the local drive, and to keep checking if there's a folder, If so check inside and make sure it empty, else add the files from that to the download list. The remote lister could probably be rewritten a little cleaner. But I'm going to leave it up to you guys. I'm confused on doing this and would appreciate it if you could give a few minutes to help me. Code: function RemoteListDirectory($Directory, $Array = array(), $First = True){ global $Server; global $Connection; if($Connection){ if($First){ ftp_chdir($Connection, $Directory); } if(ftp_size($Connection, $Directory) != -1){ if($First){ return False; } $Array[] = $Directory; return $Array; }else{ $Contents = ftp_nlist($Connection, $Directory); if(!count($Contents)){ $Array[] = $Directory; return $Array; } foreach($Contents as $File){ $Array[] = RemoteListDirectory($File, $Array, False); } if($Array = Strip($Server['RDirectory'], ".", $Array)){ return $Array; }else{ return False; } } }else{ return False; } } function Download($Array = array(), $Recursive = False){ global $Connection; if($Connection){ for($I=0;$I<count($Array);$I++){ if($Array[$I] != ""){ if($ftp_size($Connection, $Array[$I] == -1)){ $Array = array_merge($Array, Download($Array[$I], True)); }else{ ftp_get($Connection,$Array[$I],$Array[$I],FTP_BINARY); } if($Recursive){ $Directory = ftp_pwd($Connection); $Array[] = "$Directory/$Array[$I]"; }else{ $Array[] = $Array[$I]; } } } }else{ return False; } return $Array; }
×
×
  • 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.