0

I am unable run an PHP application locally which is based on postgresql

The project is open source on Github , it is an online visual link bookmarker and image scraper which I have downloaded from this link https://github.com/Openpoint/Imager

The Installation Instructions says : Create a new empty Postgresql database with UTF8 encoding & Point your browser to your imager URL

In Postgresql I don't see any option to create empty database , what I have done is creating a new database and running the below script for creating tables and database given in project :

SET statement_timeout = 0;
SET client_encoding = 'UTF8';
SET standard_conforming_strings = on;
SET check_function_bodies = false;
SET client_min_messages = warning;

CREATE EXTENSION IF NOT EXISTS plpgsql WITH SCHEMA pg_catalog;

COMMENT ON EXTENSION plpgsql IS 'PL/pgSQL procedural language';

SET search_path = public, pg_catalog;
SET default_tablespace = '';

SET default_with_oids = false;

CREATE TABLE pages (
id integer NOT NULL,
url text,
image character varying(256),
title character varying(256),
sfw boolean,
biggest integer DEFAULT 0
);

ALTER TABLE public.pages OWNER TO _dbowner_;

CREATE SEQUENCE pages_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;

ALTER TABLE public.pages_id_seq OWNER TO _dbowner_;
ALTER SEQUENCE pages_id_seq OWNED BY pages.id;


CREATE TABLE users (
id integer NOT NULL,
username text NOT NULL,
hash text NOT NULL,
salt text NOT NULL,
authtoken character varying(50),
email text NOT NULL,
role character varying(256) NOT NULL,
realname character varying(256),
invitedby character varying(256),
status character varying(10) DEFAULT 'Invited'::character varying,
date date
);

ALTER TABLE public.users OWNER TO _dbowner_;

CREATE SEQUENCE users_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;

ALTER TABLE public.users_id_seq OWNER TO _dbowner_;

ALTER SEQUENCE users_id_seq OWNED BY users.id;

ALTER TABLE ONLY pages ALTER COLUMN id SET DEFAULT nextval('pages_id_seq'::regclass);


ALTER TABLE ONLY users ALTER COLUMN id SET DEFAULT nextval('users_id_seq'::regclass);

ALTER TABLE ONLY pages
ADD CONSTRAINT pages_pkey PRIMARY KEY (id);

ALTER TABLE ONLY users
ADD CONSTRAINT users_pkey PRIMARY KEY (id);

REVOKE ALL ON SCHEMA public FROM PUBLIC;
REVOKE ALL ON SCHEMA public FROM postgres;
GRANT ALL ON SCHEMA public TO postgres;
GRANT ALL ON SCHEMA public TO PUBLIC;

Also in settings.php I have this codes for connection :

$settings->dbase=array(
'username'=>'',
'password'=>'',
'db_name'=>'',
'host'=>'',
'port'=>''
);
$settings->installfile='/install.php'; //The location of your install hook file

And in install.php these codes are given :

class install {
function install($dbase,$settings) {
    $this->dbase=$dbase;
    $this->settings=$settings;
}



public function checkdb($external){
    $sql="select 1 from users";
    $response=$this->dbase->query($sql,null);   

    if(!$this->dbase->success){
        if($external){
            echo 'false';
            return false;
        }else{          
            return false;
        }
    }else{
        if($external){
            echo 'true';
            return true;
        }else{          
            return true;
        }
    }       
}

public function checkfinished(){
    $sql="SELECT COUNT(*) FROM users";
    $response=$this->dbase->query($sql,null);   
    $response=$response->fetchAll();
    if($response[0]['count'] > 0){
        return true;
    }else{
        return false;           
    }   

}
public function makedb(){

    $sql=file_get_contents($_SERVER['DOCUMENT_ROOT'].'/user_mod/install/dbase.sql');
    $sql=str_replace ( '_dbowner_' , $this->settings->dbase['username'] , $sql );
    $response=$this->dbase->query($sql,null);
    $response=$response->fetchAll();        
} `}`



if (!empty($_POST)){
if($_POST['method'] == 'checkdb'){
    require_once($_SERVER['DOCUMENT_ROOT']."/user_mod/settings.php");
    require_once($_SERVER['DOCUMENT_ROOT'].'/user_mod/database.php');
    $dbase = new dbase($dbh);
    $install = new install($dbase,$settings);
    $install->checkdb(true);    
}
if($_POST['blinduser'] == 'connect'){
    if($handle = file($_SERVER['DOCUMENT_ROOT']."/user_mod/settings.php")){
        $foo;
        foreach($handle as $line){
            if(strpos($line,"'username'=>") !== false){
                $line="    'username'=>'".$_POST['dbusername']."',\n";
            }
            if(strpos($line,"'password'=>") !== false){
                $line="    'password'=>'".$_POST['dbpword']."',\n";
            }
            if(strpos($line,"'db_name'=>") !== false){
                $line="    'db_name'=>'".$_POST['dbname']."',\n";
            }
            if(strpos($line,"'host'=>") !== false){
                $line="    'host'=>'".$_POST['dbhost']."',\n";
            }
            if(strpos($line,"'port'=>") !== false){
                $line="    'port'=>'".$_POST['dbport']."'\n";
            }
            $foo=$foo.$line;
        }
    }
    file_put_contents($_SERVER['DOCUMENT_ROOT']."/user_mod/settings.php", $foo);    
}   
}
?>

After creating the Database running the application on localhost it is asking me to fill the forms like

Your Database Name:     plpgsql

Your Database host:     localhost

Your Database Port:     5432

Your Database Username:       postgres

Your Database Password:     password

And after filling the above database correctly and clicking on process button as shown on below screenshot it is giving me The Authentication Required Message Error :

enter image description here

Am I missing something or syntax issue for pointing database to connect it.

I am using visual studio 2015 running the php project , its difficult to debug as its not giving me any code error unlike ASP.NET language when we run a .NET project with Visual Studio it would gives us line by line and syntaxes error.

Can you please guide me how I can run app on localhost using windows 7 .

Please help and guide me if something is missing to run the software locally.

I would also like to know how mysql or MS SQL can be run or used as an alternative for Postgresql on this project

1 Answer 1

1

Firstly - "Imager" is an experiment in very Alpha stage and I have not tested it at all on a local installation or in a non-linux hosting environment.

From your Stackoverflow post, the "Authentication Required" pop-up you are getting has nothing to do with connecting to the database - it is something to do with permissions on you local web server (Try checking Apache logs). I find the easiest way to set up a new PGsql database is to use the GUI of PhpPgadmin .

You can also try filling in the database connection details manually (https://github.com/Openpoint/Imager/blob/master/user_mod/settings.php) - line 30 onwards. Edit the file and save.

Sorry that I cannot give you support for this Alpha experimental project. If all you are interested in is the image scraping aspect, have a look at the code in (https://github.com/Openpoint/Imager/blob/master/php/process.php) and see if it helps to fit it into your project.

Sign up to request clarification or add additional context in comments.

4 Comments

Do you have any online link to test your software live as the given link in github imager.buzz is not working
I just renewed imager.buzz as the domain had expired. It should be back online within 24 hours.
The imager.buzz is awesome indeed !! I would like to ask we can get same result as shown on given link " imager.buzz " from the source project at Github github.com/Openpoint/Imager ?
The Github code is the same code that is running on imager.buzz . This is ALPHA code and I do not have the resources to manage it for all environments. It is running on Ubuntu 14.04 with Apache and PostGresql server.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.