Facebook  Twitter 

SMFHacks.com

+- +-

SMFHacks.com

+- User Information

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

+- Forum Stats

Members
Total Members: 12349
Latest: SUCCESSForum
New This Month: 1
New This Week: 1
New Today: 0
Stats
Total Posts: 40048
Total Topics: 7051
Most Online Today: 76
Most Online Ever: 2482
(April 09, 2011, 07:02:45 pm)
Users Online
Members: 0
Guests: 43
Total: 43

Author Topic: Extreme coding help  (Read 2547 times)

0 Members and 1 Guest are viewing this topic.

Offline shuban

  • Hero Member
  • *****
  • Posts: 653
    • View Profile
    • Homework Clinic - Your Academic Lifeline
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: 15029
    • 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: 653
    • View Profile
    • Homework Clinic - Your Academic Lifeline
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: 653
    • View Profile
    • Homework Clinic - Your Academic Lifeline
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: 15029
    • 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: 653
    • View Profile
    • Homework Clinic - Your Academic Lifeline
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: 15029
    • 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: 653
    • View Profile
    • Homework Clinic - Your Academic Lifeline
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: 15029
    • 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: 653
    • View Profile
    • Homework Clinic - Your Academic Lifeline
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: 15029
    • 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: 653
    • View Profile
    • Homework Clinic - Your Academic Lifeline
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: 653
    • View Profile
    • Homework Clinic - Your Academic Lifeline
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: 653
    • View Profile
    • Homework Clinic - Your Academic Lifeline
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: 15029
    • 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
10332 Views
Last post February 07, 2007, 11:04:17 am
by bopla
0 Replies
2232 Views
Last post May 30, 2009, 12:58:57 pm
by menew
1 Replies
2502 Views
Last post November 14, 2009, 07:55:22 pm
by SMFHacks
21 Replies
8680 Views
Last post December 05, 2012, 08:29:05 pm
by SMFHacks
0 Replies
2352 Views
Last post August 06, 2016, 01:43:18 am
by shuban

+- Recent Topics

[Mod]Avatars Display Integration by SMFHacks
February 15, 2020, 07:30:47 pm

[Mod]BBC Message Boxes 1.0 by SMFHacks
February 15, 2020, 07:26:46 pm

[Mod]Stack Trace by live627 by SMFHacks
February 15, 2020, 07:21:33 pm

Stripe Integration by SMFHacks
February 08, 2020, 10:55:29 pm

SMF Store 4.0 Released by SMFHacks
January 26, 2020, 12:11:56 pm

Order of photos by D4611001
January 21, 2020, 12:06:36 pm

Cannot install by SMFHacks
January 18, 2020, 09:40:56 pm

Call to undefined function mysql_query() by SMFHacks
January 18, 2020, 02:06:47 pm

English British Translation file by HAL9000
January 17, 2020, 05:44:28 pm

Characters dispayed as boxes by SMFHacks
January 16, 2020, 07:21:51 am

Powered by EzPortal