Jump to content


gizmola

Member Since 06 May 2003
Offline Last Active Yesterday, 08:53 PM

Posts I've Made

In Topic: Check data / Write Data to a text file

09 September 2017 - 09:06 AM

It's really not that complicated -- a small addition to your existing code:

 

$filename = 'emails.txt';
if(isset($_POST['submit']))
{
    $email = trim($_POST['email']);
    $fileString = file_get_contents($filename);
 
    // Check to see if email is already in file. 
    if (false === stristr($fileString, $email)) {
 
        $file = fopen($filename, "a+");
        fwrite($file, $email . PHP_EOL);
        fclose($file);
        echo "Added Email: $email to the system";
        
    } else {
        echo "Email: $email already exists in the system.\n";
    }
}
?>

In Topic: Php page image with text rewritten to function but...

28 August 2017 - 07:21 PM

You should not be outputting an image header in a script that is simply creating an image and writing it to disk. Remove the

Header ("Content-type: image/jpeg");
The other thing to look into is the path:

imagejpeg($image, 'vda-images/'.$n1.'.jpg', 80);
Make sure that whatever process is running this php code has rights to rwx the vda-images directory.

In Topic: XML Help (API Script)

19 August 2017 - 02:03 AM

No worries. I don't have an api key so I could only provide a general take on it, that probably works. There are sometimes issues opening a url as a file, and sometimes people need to use curl, or in the case of the component I linked, they used guzzle.

I can tell you conclusively, that when you have the json option, you want to take advantage of it.

The sample output you pasted above is Json. XML looks a lot like html -- in fact html is a subset of the xml spec. There are DTD's, attributes as in html like this:

<sometag  item="foo" otheritem="bar">Some Data</sometag>
And in general a lot of potential complexity that is complete overkill for a simple REST api like this one. Obviously the data from each is the same, so why not use the one that is easier to navigate?

Although you only provided a small snippet of the original data, I took the json and wrote a little code to show how easy it is to work with converted into a php array: https://3v4l.org/E7ZA5

In Topic: I need some help with features for a forum.

18 August 2017 - 10:27 PM

I'm not sure where the idea came from that you could use php with an asp app. Maybe by "php elements" he means that you could script up an independent url that is served from a php script, but I wouldn't advise that, nor do I see here how that would accomplish adding functionality to your existing forum.

Stick with the platform you have, which is asp. You need an asp developer to add those features. There are some polyglots here who work with ASP from time to time, but I don't happen to be one of them. There's a slight chance someone will weigh in on this, but overall my advice is to find a dev forum focused on asp development.

Just to reiterate, there's nothing special about asp either in regards to adding functionality to your site. Someone is going to have to code it. You indicate you have a programmer already, so my advice would be to simply provide the requirements to your programmer in some form, and have them go to it.

If that person really doesn't know ASP, and/or doesn't know how to proceed with this, then you need to find a different programmer.

In Topic: I need some help with features for a forum.

18 August 2017 - 08:54 PM

It looks from the basis of your questions that you are not a programmer yourself. Sometimes people seem to get the idea that programming is like a giant erector set, where you can go down to the store and get an "Image integration dohickey" and plug it into socket somehow, and suddenly the software has image support.

Things don't work that way. Your forum is written in some language. Whether or not your server supports PHP (and really as in the case of just about every computer language, all languages can work on all computer systems) doesn't mean that the forum is written in PHP. If it is written in PHP then there are component libraries available these days which can provide tremendous productivity gains and shorten development time, often with better overall quality if the component is well documented and covered by extensive and complete unit tests.

However, until you are sure that your forum (sounds like it's custom) was written in PHP any further discussion is a waste of time. If it is for example written in Ruby or Python, php components are of no value to you.

Let's assume that your forum was written in PHP, but it was developed as a customization to wordpress or drupal (doesn't sound like it, as those CMS/Blog platforms have all the things you are describing built in) but in that case, those platforms have certain ways of doing things, and may be incompatible with modern component libraries.

Again, first step is really getting an understanding of your codebase and the language it was developed in.