Facebook  Twitter 

SMFHacks.com

+-

SMFHacks.com

+- User Information

Welcome, Guest.
Please login or register.
 
 
 
Forgot your password?

+- Forum Stats

Members
Total Members: 4255
Latest: andreios
New This Month: 3
New This Week: 1
New Today: 0
Stats
Total Posts: 43259
Total Topics: 7518
Most Online Today: 201
Most Online Ever: 2482
(April 09, 2011, 07:02:45 pm)
Users Online
Members: 1
Guests: 183
Total: 184

Author Topic: Extreme coding help  (Read 4807 times)

0 Members and 1 Guest are viewing this topic.

Offline shuban

  • Hero Member
  • *****
  • Posts: 665
    • View Profile
    • Biology Forums
Extreme coding help
« on: March 21, 2017, 05:49:30 pm »
I'm trying to execute a program that converts documents into plain text.

http://silvercoders.com/en/products/doctotext/

I've tried contacting the developer, but offers no help. My test server is on my Windows PC:

I would like to run the program in PHP. Here's what I have so far

Code: [Select]
<?php

$location 
'C:\\xampp\\htdocs\\test_doc.docx';

$output exec("C:\\doctotext\\doctotext.exe /c $location");

echo 
'The output: '.$output;

?>

Could someone steer me in the right direction? There are absolutely no examples on the internet using this free, powerful program.

Offline SMFHacks

  • Administrator
  • Hero Member
  • *****
  • Posts: 16436
    • View Profile
Re: Extreme coding help
« Reply #1 on: March 21, 2017, 07:57:29 pm »
You have to make sure the webserver has permission to execute the program doctotext.exe
You should give Apache access to that whole folder.

I would do this as well
$location = '"C:\\xampp\\htdocs\\test_doc.docx"';
Get your Forum Ranked! at https://www.forumrankings.net - find out how your forum compares with others!

Like What I do? Support me at https://www.patreon.com/vbgamer45/

Offline shuban

  • Hero Member
  • *****
  • Posts: 665
    • View Profile
    • Biology Forums
Re: Extreme coding help
« Reply #2 on: March 21, 2017, 11:18:05 pm »
I'm using XAMPP. Not sure how to do what you recommended. I wish I could get someone to try this out on their server, really stuck.

Offline shuban

  • Hero Member
  • *****
  • Posts: 665
    • View Profile
    • Biology Forums
Re: Extreme coding help
« Reply #3 on: March 22, 2017, 12:41:46 pm »
Good news, I got it working on my Windows based server:

Code: [Select]
<?php 

$file 
'C:\xampp\htdocs\SMF\sdsdssss.docx';

$content exec'C:\xampp\htdocs\SMF\doctotext\doctotext.exe /c '$file $output );

echo 
'output of the file after read by doctotex.exe: ' ;
echo 
nl2br("\n");
print_r$output );

echo 
nl2br("\n");

$string '';

foreach ( 
$output as $o ) {
    
$string .= $o;
}

echo 
nl2br("\n");

However, how would I get this to work on my Centos server? Obviously I'd have to download the Linux version of the software, but how do the codes change?

Offline SMFHacks

  • Administrator
  • Hero Member
  • *****
  • Posts: 16436
    • View Profile
Re: Extreme coding help
« Reply #4 on: March 22, 2017, 12:49:29 pm »
It would be a different path to binary file.
Get your Forum Ranked! at https://www.forumrankings.net - find out how your forum compares with others!

Like What I do? Support me at https://www.patreon.com/vbgamer45/

Offline shuban

  • Hero Member
  • *****
  • Posts: 665
    • View Profile
    • Biology Forums
Re: Extreme coding help
« Reply #5 on: March 22, 2017, 12:55:44 pm »
Please advice, I placed doctotext into:

Code: [Select]
/home/***/public_html/doctotext
and the file:

Code: [Select]
/home/***/public_html/downloads/test_doc.docx

Offline SMFHacks

  • Administrator
  • Hero Member
  • *****
  • Posts: 16436
    • View Profile
Re: Extreme coding help
« Reply #6 on: March 22, 2017, 12:57:47 pm »
That would do it.
You would need to check the file permissions on doctext maybe try giving it 777
Get your Forum Ranked! at https://www.forumrankings.net - find out how your forum compares with others!

Like What I do? Support me at https://www.patreon.com/vbgamer45/

Offline shuban

  • Hero Member
  • *****
  • Posts: 665
    • View Profile
    • Biology Forums
Re: Extreme coding help
« Reply #7 on: March 22, 2017, 01:01:43 pm »
That would do it.
You would need to check the file permissions on doctext maybe try giving it 777

On the folder or the file itself? Should I do it recursively so that everything inside gets 777?

Code: [Select]
$file = '/home/***/public_html/downloads/test_doc.docx';

$content = exec( '/home/***/public_html/doctotext/doctotext \c '. $file , $output );

This didn't work...
« Last Edit: March 22, 2017, 01:05:02 pm by shuban »

Offline SMFHacks

  • Administrator
  • Hero Member
  • *****
  • Posts: 16436
    • View Profile
Re: Extreme coding help
« Reply #8 on: March 22, 2017, 01:14:39 pm »
Make sure it is part of the same user group as apache/webserver
Also make sure the file has excute permissions.

The program for sure. Maybe the whole directory if it is saving information to that folder.
Get your Forum Ranked! at https://www.forumrankings.net - find out how your forum compares with others!

Like What I do? Support me at https://www.patreon.com/vbgamer45/

Offline shuban

  • Hero Member
  • *****
  • Posts: 665
    • View Profile
    • Biology Forums
Re: Extreme coding help
« Reply #9 on: March 22, 2017, 01:25:11 pm »
The owner and group is both root.

I tried making everything 777, didn't help.

How would I check logs for this? Do logs even exist?

Offline SMFHacks

  • Administrator
  • Hero Member
  • *****
  • Posts: 16436
    • View Profile
Re: Extreme coding help
« Reply #10 on: March 22, 2017, 01:31:43 pm »
You could see if $content contains anything that is returned.
Get your Forum Ranked! at https://www.forumrankings.net - find out how your forum compares with others!

Like What I do? Support me at https://www.patreon.com/vbgamer45/

Offline shuban

  • Hero Member
  • *****
  • Posts: 665
    • View Profile
    • Biology Forums
Re: Extreme coding help
« Reply #11 on: March 22, 2017, 05:27:54 pm »
I checked and it doesn't return anything unforunately

Offline shuban

  • Hero Member
  • *****
  • Posts: 665
    • View Profile
    • Biology Forums
Re: Extreme coding help
« Reply #12 on: March 22, 2017, 11:42:44 pm »
The command is wrong. The fact I'm using /c means it's incorrect.

Offline shuban

  • Hero Member
  • *****
  • Posts: 665
    • View Profile
    • Biology Forums
Re: Extreme coding help
« Reply #13 on: March 23, 2017, 02:11:33 pm »
Do you have any other suggestions?

I asked this on Stack overflow, and got this response: http://stackoverflow.com/questions/42967583/executing-a-linux-program-from-php/42970170?noredirect=1#comment73058411_42970170

I think I'm running out of ideas

Offline SMFHacks

  • Administrator
  • Hero Member
  • *****
  • Posts: 16436
    • View Profile
Re: Extreme coding help
« Reply #14 on: March 23, 2017, 08:37:58 pm »
Not really stackoverflow is a good place though those people who reply to questions are experts.
Get your Forum Ranked! at https://www.forumrankings.net - find out how your forum compares with others!

Like What I do? Support me at https://www.patreon.com/vbgamer45/

 

Related Topics

  Subject / Started by Replies Last post
6 Replies
12313 Views
Last post February 07, 2007, 11:04:17 am
by bopla
0 Replies
3037 Views
Last post May 30, 2009, 12:58:57 pm
by menew
1 Replies
3574 Views
Last post November 14, 2009, 07:55:22 pm
by SMFHacks
21 Replies
11100 Views
Last post December 05, 2012, 08:29:05 pm
by SMFHacks
0 Replies
3795 Views
Last post August 06, 2016, 01:43:18 am
by shuban

+- Recent Topics

No thumbnails on new uploads by SMFHacks
March 27, 2024, 02:10:41 pm

Display the Contact Page for guests by SMFHacks
March 27, 2024, 10:55:43 am

is it possible to add support for odysee.com by fvlog19
March 21, 2024, 08:47:51 am

Request for admin notification by davejo
March 10, 2024, 01:31:59 am

I need help with torrent upload by Ineedsmfhelp
March 09, 2024, 10:01:13 pm

an idea for new mod (( content type with different display )) by SMFHacks
February 27, 2024, 01:36:27 pm

[Mod] RSS Feed Poster by SMFHacks
February 27, 2024, 11:57:18 am

find duplicate pictures by fvlog19
February 14, 2024, 02:22:40 pm

Error uploading video. by SMFHacks
February 08, 2024, 02:04:16 pm

Gallery icon as last added image by fvlog19
February 01, 2024, 01:04:56 pm

Powered by EzPortal