Not logged in. · Lost password · Register
Forum: General Help and Support Development RSS
[Solved] Is there a tool for viewing (or editing) files with serialized PHP data? (e.g. with *.ser extension)
Avatar
Michaelsy #1
Member since Jun 2015 · 745 posts · Location: Düsseldorf, Germany
Group memberships: Members
Show profile · Link to this post
Subject: [Solved] Is there a tool for viewing (or editing) files with serialized PHP data? (e.g. with *.ser extension)
In DokuWiki one sometimes finds files with the extension * .ser (which maybe means "serialized"). Is there somewhere a tool for viewing or editing this file format?

Thanks in advance - Michael Sy.

Edit: The metadata of the pages (* .meta files) are also stored in this format.
By Patreon.com a few eurons can be fed into the code phasers of
the DokuWiki engine. Besides, Andi's posts are worth reading.
This post was edited 3 times, last on 2019-01-12, 05:46 by Michaelsy.
Avatar
MartinR #2
Member since Jul 2015 · 129 posts · Location: UK
Group memberships: Members
Show profile · Link to this post
Hi Michael,

The only .ser file I could find in my DW is one generated by the epub plugin, so this response this is based on only one example.  serialize (and the reverse unserialize) are native PHP functions which convert an arbitrary value (such as a string, array or object) into a storable string.  Each line in the file is a single value, so in the case of an array the lines can be very long.  See https://secure.php.net/manual/en/function.serialize.php for the full details.  Reading the file is quite easy in vi, other editors may be less accommodating!

For the benefit of other readers of this thread, the file I mentioned can be easily visualised by adding linefeeds and spaces thus:
a:2:{
  s:32:"b015051af9addc4bcaf98035c718d631";s:30:"epub:rochester_cathedral_bells";
  s:13:"current_books";a:1:{
    s:32:"b015051af9addc4bcaf98035c718d631";a:2:{
      s:5:"title";s:25:"Rochester Cathedral bells";
      s:4:"epub";s:40:"epub:jmr:2018_september_21_01-34-45.epub";
    }
  }
}
Analysis
The value is a 2 element array (a:2:).  In array storage, each element is represented by a key;value; pair, so the first element has the key s:32:"b015051af9addc4bcaf98035c718d631" and value s:30:"epub:rochester_cathedral_bells".  These are both strings (s) with a length (32 or 30) respectively.  The second element has the key "current books" and is itself an array.

The next array inwards has one element with key s:32:"b015051af9addc4bcaf98035c718d631" and the value is a two element array.

The innermost array defines strings; the title and an "epub" string giving the source file.
Avatar
turnermm (Moderator) #3
Member since Oct 2009 · 4544 posts · Location: Canada
Group memberships: Global Moderators, Members, Super Mods
Show profile · Link to this post
In reply to post #1
Attached is a tool I've been using for a long time. Unzipped it is get_inf.php. If you are on a linux machine and have this in a bin directory that is in your path (and php is in your bin directory, which it should be),  then you can just type at your command line:
    get_inf.php file.ser
Otherwise:
   php get_inf.php file.ser

If you bother to inspect the script, ignore the .gz stuff; I must have been using it for something once that I can no longer recall.
Myron Turner
github: https://github.com/turnermm
plugins, templates: http://www.mturner.org/devel
The author has attached one file to this post:
get_inf.zip 532 Bytes
You have no permission to open this file.
Avatar
Michaelsy #4
Member since Jun 2015 · 745 posts · Location: Düsseldorf, Germany
Group memberships: Members
Show profile · Link to this post
Quote by turnermm:
   php get_inf.php file.ser

Thank you Myron,
Is there a way to execute your script on a windows machine? (What do I have to install?)

@MartinR: Thank you for your effort. Your explanations are interesting and helpful.
By Patreon.com a few eurons can be fed into the code phasers of
the DokuWiki engine. Besides, Andi's posts are worth reading.
Avatar
turnermm (Moderator) #5
Member since Oct 2009 · 4544 posts · Location: Canada
Group memberships: Global Moderators, Members, Super Mods
Show profile · Link to this post
put the script in the directory where you have the .ser file; open  a command prompt window.  Navigate to that directory and type
    php get_inf.php file.ser
Myron Turner
github: https://github.com/turnermm
plugins, templates: http://www.mturner.org/devel
Avatar
turnermm (Moderator) #6
Member since Oct 2009 · 4544 posts · Location: Canada
Group memberships: Global Moderators, Members, Super Mods
Show profile · Link to this post
The above assumes you have php on your windows machine; otherwise you will have to install it.
Myron Turner
github: https://github.com/turnermm
plugins, templates: http://www.mturner.org/devel
Avatar
MartinR #7
Member since Jul 2015 · 129 posts · Location: UK
Group memberships: Members
Show profile · Link to this post
Myron,
Unless I'm being incredibly dense, if you are running DW you must have PHP installed and running.
Avatar
Michaelsy #8
Member since Jun 2015 · 745 posts · Location: Düsseldorf, Germany
Group memberships: Members
Show profile · Link to this post
Quote by MartinR:
Unless I'm being incredibly dense, if you are running DW you must have PHP installed and running.

My DokuWikis are installed on a shared hosting server. There I have no access to a command line. At home I am so far working exclusively on Windows. (I plan to install DokuWiki on a Raspberry Pi, but that will take a while...)
By Patreon.com a few eurons can be fed into the code phasers of
the DokuWiki engine. Besides, Andi's posts are worth reading.
This post was edited on 2019-01-11, 21:23 by Michaelsy.
Avatar
turnermm (Moderator) #9
Member since Oct 2009 · 4544 posts · Location: Canada
Group memberships: Global Moderators, Members, Super Mods
Show profile · Link to this post
With this version of get_inf.php, you can place it on your server, put the .ser file in the same dir, and access it in your browser:
   http://your_server/get_inf.php?id=file.ser
It will print the output to the browser.
Myron Turner
github: https://github.com/turnermm
plugins, templates: http://www.mturner.org/devel
The author has attached one file to this post:
get_inf.zip 585 Bytes
You have no permission to open this file.
Avatar
Michaelsy #10
Member since Jun 2015 · 745 posts · Location: Düsseldorf, Germany
Group memberships: Members
Show profile · Link to this post
Quote by turnermm:
   http://your_server/get_inf.php?id=file.ser
Cool!  :cool:
By Patreon.com a few eurons can be fed into the code phasers of
the DokuWiki engine. Besides, Andi's posts are worth reading.
Close Smaller – Larger + Reply to this post:
Verification code: VeriCode Please enter the word from the image into the text field below. (Type the letters only, lower case is okay.)
Smileys: :-) ;-) :-D :-p :blush: :cool: :rolleyes: :huh: :-/ <_< :-( :'( :#: :scared: 8-( :nuts: :-O
Special characters:
Go to forum
Imprint
This board is powered by the Unclassified NewsBoard software, 20150713-dev, © 2003-2015 by Yves Goergen
Current time: 2019-03-20, 02:29:20 (UTC +01:00)