LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 07-05-2011, 11:21 AM   #1
Xeratul
Senior Member
 
Registered: Jun 2006
Location: UNIX
Distribution: FreeBSD
Posts: 2,658

Rep: Reputation: 255Reputation: 255Reputation: 255
How to make an online PHP contact / phone book with simple PHP (no database)?


Hello,

I would like to unzip a simple PHP code files, to have a online PHP contact / phone book. Simply, slow, and not database oriented over complicated setups into settings.

I have a PHP / web provider (free), not apache.


WITHOUT SQL (like before it may exists) Please

something like this http://php-addressbook.sourceforge.net/demo/

Any help welcome,

Happy Tux

Last edited by Xeratul; 07-05-2011 at 02:35 PM.
 
Old 07-05-2011, 01:09 PM   #2
dogpatch
Member
 
Registered: Nov 2005
Location: Central America
Distribution: Mepis, Android
Posts: 490
Blog Entries: 4

Rep: Reputation: 238Reputation: 238Reputation: 238
How far have you gotten with the sourceforge package? Or do you prefer to roll your own, from scratch?
 
Old 07-05-2011, 02:36 PM   #3
Xeratul
Senior Member
 
Registered: Jun 2006
Location: UNIX
Distribution: FreeBSD
Posts: 2,658

Original Poster
Rep: Reputation: 255Reputation: 255Reputation: 255
Quote:
Originally Posted by dogpatch View Post
How far have you gotten with the sourceforge package? Or do you prefer to roll your own, from scratch?
I would be glad to have a solution that would work without need of SQL. Could it be possible?

It would be slow and so on, but fairly nice solution as well... for me.
 
Old 07-05-2011, 02:40 PM   #4
dugan
LQ Guru
 
Registered: Nov 2003
Location: Canada
Distribution: distro hopper
Posts: 11,235

Rep: Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320
DokuWiki doesn't use SQL. It can also (obviously) be used as a contact manager.

Last edited by dugan; 07-05-2011 at 02:46 PM.
 
Old 07-05-2011, 03:06 PM   #5
Xeratul
Senior Member
 
Registered: Jun 2006
Location: UNIX
Distribution: FreeBSD
Posts: 2,658

Original Poster
Rep: Reputation: 255Reputation: 255Reputation: 255
Quote:
Originally Posted by dugan View Post
DokuWiki doesn't use SQL. It can also (obviously) be used as a contact manager.
thank you. sounds good wihout SQL. As a contact manager ? http://systemsboy.com/wp-content/upl...6/dokuwiki.png
I am wondering bit how , ... and it is bit heavy stuff. a contact manager would be easy to find for php, but in practice I havent found ... thanks
 
Old 07-05-2011, 07:50 PM   #6
AnanthaP
Member
 
Registered: Jul 2004
Location: Chennai, India
Posts: 952

Rep: Reputation: 217Reputation: 217Reputation: 217
Quote:
PHP-addressbook Version 6.x

requirements | installation | licence | disclaimer
Download:

For the most recent version of "PHP-addressbook" see: https://sourceforge.net/project/show...roup_id=157964.

Requirements:

You will need a webserver which has installed PHP 4/5, and mySQL version 3.2 upwards.

Installation:
I went through the URL, logged in and got the sample. On the LHS, the second URL is a link to the notes. ( http://php-addressbook.sourceforge.net/demo/notes.htm ). I draw your attention to the fact that it uses mySQL (a database).

My suggestion is that if you really want to do it without a database, then use cookies - which are also another form of persistent storage. Of course, it would now be non-portable and non-scalable.

OK

Last edited by AnanthaP; 07-05-2011 at 07:54 PM.
 
Old 07-05-2011, 09:25 PM   #7
Xeratul
Senior Member
 
Registered: Jun 2006
Location: UNIX
Distribution: FreeBSD
Posts: 2,658

Original Poster
Rep: Reputation: 255Reputation: 255Reputation: 255
Quote:
Originally Posted by AnanthaP View Post
I went through the URL, logged in and got the sample. On the LHS, the second URL is a link to the notes. ( http://php-addressbook.sourceforge.net/demo/notes.htm ). I draw your attention to the fact that it uses mySQL (a database).

My suggestion is that if you really want to do it without a database, then use cookies - which are also another form of persistent storage. Of course, it would now be non-portable and non-scalable.

OK
what about the idea of dbf or dbase? Some years ago (many) that was explained and leading for databases...

DBF Editor/viewer but it is not a PHP

Last edited by Xeratul; 07-05-2011 at 09:29 PM.
 
Old 07-06-2011, 04:36 AM   #8
Nominal Animal
Senior Member
 
Registered: Dec 2010
Location: Finland
Distribution: Xubuntu, CentOS, LFS
Posts: 1,723
Blog Entries: 3

Rep: Reputation: 948Reputation: 948Reputation: 948Reputation: 948Reputation: 948Reputation: 948Reputation: 948Reputation: 948
Quote:
Originally Posted by Xeratul View Post
[..] online PHP contact / phone book [..] WITHOUT SQL
I actually did some research a while ago in PHP, and it turns out smallish flat files (up to a few kilobytes at least) are much faster than any SQL queries, on an x86_64 Linux server. This is because of the SQL connection overhead and query construction in PHP takes longer than reading and processing a smallish flat file. For a contact or phone book, this means a flat file will be faster than any SQL solution for up to a couple of hundred contacts (assuming only names and contact information is stored).

The tricky bit is the file locking. In fact, it is so tricky most won't even try. Many hosting providers use NFS with broken file locking. PHP uses a braindead implementation of flock() which silently fails with NFS on *BSDs, and on Linux prior to 2.6.12 -- i.e. RHEL 4, CentOS 4, and that era; it will silently fail on any server using NFS with incomplete file locking support. For example, the ezPublish developers gave up on trying to get the file locking issues solved, and use an SQL database instead for the file metadata, basically just for file locking.

If your server does NOT use Windows, there is a locking procedure which is known to work (as a serialising exclusive lock). In this case, a variant where readers do not need to do any locking but modifications do and are relatively slower, should work well.

All this means that although a PHP contact list or phone book with flat file data storage is quite feasible for up to a few tens of thousand entries, it would not be portable between Windows and non-Windows servers. Most view using an SQL server as a better alternative.

Thus, you are unlikely to find such a thing, unless you write it yourself, or commission someone to do it for you.
 
Old 07-06-2011, 02:51 PM   #9
Xeratul
Senior Member
 
Registered: Jun 2006
Location: UNIX
Distribution: FreeBSD
Posts: 2,658

Original Poster
Rep: Reputation: 255Reputation: 255Reputation: 255
Quote:
Originally Posted by Nominal Animal View Post
I actually did some research a while ago in PHP, and it turns out smallish flat files (up to a few kilobytes at least) are much faster than any SQL queries, on an x86_64 Linux server. This is because of the SQL connection overhead and query construction in PHP takes longer than reading and processing a smallish flat file. For a contact or phone book, this means a flat file will be faster than any SQL solution for up to a couple of hundred contacts (assuming only names and contact information is stored).

The tricky bit is the file locking. In fact, it is so tricky most won't even try. Many hosting providers use NFS with broken file locking. PHP uses a braindead implementation of flock() which silently fails with NFS on *BSDs, and on Linux prior to 2.6.12 -- i.e. RHEL 4, CentOS 4, and that era; it will silently fail on any server using NFS with incomplete file locking support. For example, the ezPublish developers gave up on trying to get the file locking issues solved, and use an SQL database instead for the file metadata, basically just for file locking.

If your server does NOT use Windows, there is a locking procedure which is known to work (as a serialising exclusive lock). In this case, a variant where readers do not need to do any locking but modifications do and are relatively slower, should work well.

All this means that although a PHP contact list or phone book with flat file data storage is quite feasible for up to a few tens of thousand entries, it would not be portable between Windows and non-Windows servers. Most view using an SQL server as a better alternative.

Thus, you are unlikely to find such a thing, unless you write it yourself, or commission someone to do it for you.
It is too bad that there are not solution. Would someone join the efforts with me to code something?

- I really need it. I am bright in coding if I know the commands. You give me few commands and I make it for you guys. However I have no time to really learn well PHP. I have at least 30min a day for coding max + reading all included.
 
Old 07-06-2011, 04:30 PM   #10
John VV
LQ Muse
 
Registered: Aug 2005
Location: A2 area Mi.
Posts: 17,627

Rep: Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651
if you are not going to use a db
use perl to write text files you can access
 
Old 07-06-2011, 06:41 PM   #11
Xeratul
Senior Member
 
Registered: Jun 2006
Location: UNIX
Distribution: FreeBSD
Posts: 2,658

Original Poster
Rep: Reputation: 255Reputation: 255Reputation: 255
Quote:
Originally Posted by John VV View Post
if you are not going to use a db
use perl to write text files you can access
Why not in PHP actually? I am not sure that the host web provider allows perl. It is not apache or I do not know what.


In PHP, as nothign exists, so I make it and would be glad of your inputs...

OK. So the first Draft of code looks like this. I created this file: "phpaddressbooktodbf.php". I need to have more fields and do not know how to link the field to a dbf field.

Code:
<?
function get_dbf_header($dbfname) {
   $fdbf = fopen($dbfname,'r');

   $dbfhdrarr = array();
   $buff32 = array();
   $i = 1;
   $goon = true;

   while ($goon) {
      if (!feof($fdbf)) {
         $buff32 = fread($fdbf,32);
         if ($i > 1) {
            if (substr($buff32,0,1) == chr(13)) {
               $goon = false;
            } else {
               $pos = strpos(substr($buff32,0,10),chr(0));
               $pos = ($pos == 0?10:$pos);

               $fieldname = substr($buff32,0,$pos);
               $fieldtype = substr($buff32,11,1);
               $fieldlen = ord(substr($buff32,16,1));
               $fielddec = ord(substr($buff32,17,1));

array_push($dbfhdrarr, array($fieldname,$fieldtype,$fieldlen,$fielddec));

            }
         }
         $i++;
      } else {
         $goon = false;
      }
   }

   fclose($fdbf);
   return($dbfhdrarr);
}

$arr = get_dbf_header('/data/file.dbf');
print_r($arr);


?>


<html><head><title>Contact : Please fow the name, address, telnr, notes fields below.</title></head><body>
<center><table width=400><tr><td style='border: 2px dashed #003b53; padding:10px; font-family:verdana; font-size:10px; color: #003b53;' align='center'>
<br><br>
<form action='<?=$PHP_SELF?>?file=<?=$file?>' method='post'>


<form action='<?=$PHP_SELF?>?file=<?=$file?>' method='post'>
<textarea name='body'  rows="25" cols="100"  style="font-family: Verdana; padding: 5px; background-color: LightYellow"   ><?
if (file_exists($file))
    readfile($file);
else
    $message = "The file ".$file." does not exist<br><br>";
?></textarea><br><br>
<?=$message?> 


<FORM action="phpaddressbooktodbf.php" method="post">
    <INPUT type="submit" name="bsubmit" value="Save">
</FORM>

</form>
</td></tr></table></center>
</body></html>

Ref:
-- PHP coding Dbf:
Link: http://php.net/manual/en/ref.dbase.php

Last edited by Xeratul; 07-06-2011 at 06:44 PM.
 
Old 07-09-2011, 04:08 AM   #12
Xeratul
Senior Member
 
Registered: Jun 2006
Location: UNIX
Distribution: FreeBSD
Posts: 2,658

Original Poster
Rep: Reputation: 255Reputation: 255Reputation: 255
HI,

Or another idea, I could do use it as TXT
and use if ; then

and display it over HTML code, no?
Attached Thumbnails
Click image for larger version

Name:	lotus_notes_address_book_conversion-125419-1.jpeg
Views:	239
Size:	77.0 KB
ID:	7529  
 
Old 07-09-2011, 04:32 AM   #13
Wim Sturkenboom
Senior Member
 
Registered: Jan 2005
Location: Roodepoort, South Africa
Distribution: Ubuntu 12.04, Antix19.3
Posts: 3,794

Rep: Reputation: 282Reputation: 282Reputation: 282
Do you want to maintain locally and read from the web? My first thought would be csv. Might do the trick if you don't have 'one-to-many' relationships. You probably can export your contacts to csv and ftp them to the web. php has support for csv (fgetcsv (read) from version 4, fputcsv (write) from version 5.1.0).

Just be cautious: make sure that the whole world isn't able to access your address book. I for one will not be very amused if 'my' phone number or email address can be pulled from your addressbook and is going to be used for spam. '.htaccess' can help to limit access and I strongly suggest https so info can't be sniffed (but OK, I'm paranoid).
 
Old 07-09-2011, 11:35 AM   #14
Xeratul
Senior Member
 
Registered: Jun 2006
Location: UNIX
Distribution: FreeBSD
Posts: 2,658

Original Poster
Rep: Reputation: 255Reputation: 255Reputation: 255
Quote:
Originally Posted by Wim Sturkenboom View Post
Do you want to maintain locally and read from the web? My first thought would be csv. Might do the trick if you don't have 'one-to-many' relationships. You probably can export your contacts to csv and ftp them to the web. php has support for csv (fgetcsv (read) from version 4, fputcsv (write) from version 5.1.0).

Just be cautious: make sure that the whole world isn't able to access your address book. I for one will not be very amused if 'my' phone number or email address can be pulled from your addressbook and is going to be used for spam. '.htaccess' can help to limit access and I strongly suggest https so info can't be sniffed (but OK, I'm paranoid).
CVS is indeed a really cool idea ! indeed... I gonna check if maybe there are already some programs made for such a web contact book google my friend
 
Old 07-09-2011, 01:09 PM   #15
ta0kira
Senior Member
 
Registered: Sep 2004
Distribution: FreeBSD 9.1, Kubuntu 12.10
Posts: 3,078

Rep: Reputation: Disabled
You might also work with a directory of vCard files and index them by label in a CSV. From a text-processing perspective, that would take very little work in PHP.
Kevin Barry
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Contact form using PHP is not working in IE but works in FF. jamesmage Programming 3 09-21-2009 10:24 AM
PHP apps unable to contact non-local database? jnojr Linux - Server 4 07-13-2009 06:06 PM
php simple example make me mad tanoatlq Programming 7 04-21-2008 07:43 AM
Looking for PHP Contact Importer that works with yahoo, hotmail, gmail , more michaeljoser Programming 1 12-27-2007 11:48 AM
Do PHP can make a user base update web site whitout Database? explorer1979 Programming 3 01-05-2005 09:52 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 09:02 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration