Jump to content

Check out our Community Blogs


Member Since 17 May 2007
Offline Last Active Aug 02 2007 02:43 PM

Topics I've Started

Downloading first n bytes of remote file

02 August 2007 - 02:43 PM

Hi there,

I need to download FIRST n bytes (n ~ 1024+^2) from remote file (located on the other server than mine). All must be done via fopen or similar functions and served to user via header function in binary mode. No redirection (Location via header allowed !

How's the best technique of that ?

It should be look like the code below. This code I'm using to retrieve data from the tail of the file :


	$name ='http://www.remoteserver.org/file.dat';
	$part_size = 1048576;

	$fp = @fopen($name, 'rb');
	@fseek($fp, -$part_size, SEEK_END);

	header("Content-Type: application/octet-stream");
	header('Content-Disposition: attachment; filename="file_part.dat"');
	header("Content-Length: ". $part_size);



Protection JPEG/DIR with session

19 July 2007 - 02:45 PM

I need some help/ideas with this : I'm using session for user's authorization and need to access "private" image data or access to some directory for authorized user only. My question is how to protect images (image file or directory) with session (I mean no HTTP basic authentication scheme is allowed) ?

I've tried something like this, but it doesn't work properly probably due to the directory rights.


function LoadJpeg($imgname)
    $im = @imagecreatefromjpeg($imgname);
    if (!$im) { /* See if it failed */

        /* Output an errmsg */

    return $im;

/* if (user logged in) */

header("Content-Type: image/jpeg");
$img = LoadJpeg("private/image.jpg");


Some ideas how it's done would be appreciated.

Symbol referencing errors + GCC + Solaris

21 May 2007 - 01:30 PM

i need some help with compilation. I wanted to compile the very simple program using some basic semaphore's operation:

#include <stdio.h>
#include <stdlib.h>
#include <pthread.h>
#include <semaphore.h>

sem_t Wait_for_A;

int main(int argc, char *argv[])
  printf("Semaphore testing start...\n");
  sem_init(&Wait_for_A, 0, 1);
  printf("Semaphore testing end...\n");
  return EXIT_SUCCESS;

But now when compiling it says:
elle@solaris:/home/elle/test-c>gcc sem.c -o sem
Undefined                       first referenced
 symbol                             in file
sem_destroy                         /var/tmp//ccQ4wx3D.o
sem_init                            /var/tmp//ccQ4wx3D.o
ld: fatal: Symbol referencing errors. No output written to sem
collect2: ld returned 1 exit status

Even when I'm compiling with options :
gcc sem.c -o sem -lpthread -ansi -Wall -pedantic

The problem still persists.

This is for the first time. Recently all worked fine. What's the problem ? Any idea ?

Thanks in advance

Finding non-standard sorting order via graph theory

17 May 2007 - 02:40 PM


i'd like to ask you for some help with my problem. I need to find non-standard sorting order within some words. What do I mean non-standard order ? Standard sorting order is A..Z or Z..A. Non-standard is for example C,H,K,L,..Z. The solution of the problem should lie under theory of graphs.

For example some input/output:

Input: deer,deerp,ee,ers,rrp,sz

So in the case of input above the output (found non-standard order) will be
DERPSZ. Input is sorted with "unknown" non-standard sorting order.

My rough solution is something like that: First enumerate all unique char in each word and next look for ancestor/descendant inside graph.

deer : DER
deerp : DERP
ee : E
ers : ERS
rrp : RP
sz : SZ

Any idea ? Or just tip for algorithm ? Thanks in advance

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download