tags:

views:

74

answers:

2

I have some coded strings in my database which reference the categories of my site.

They look like this

a:1:{i:0;s:12:"TVRFNE1EYz0=";}

I'm wondering what they are so I can create them all to use in a CSV file as creating them on my site is very time consuming.

Thanks

Oh actually I really don't think this is possible. It happens when I select a category on my blog then save. Then that is what is put into the database. I'm trying to figure out a way to create all the searlized codes for each category to use in a CSV file. I guess maybe impossible as I will need to know the structure of how it is made?

+2  A: 

That looks like a serialized string from PHP. You'll need to run unserialize to use it. Reference

Codeacula
Is there an online tool I can use to turn words into these strings?
Mark
Codeacula
Oh actually I really don't think this is possible. It happens when I select a category on my blog then save. Then that is what is put into the database. I'm trying to figure out a way to create all the searlized codes for each category to use in a CSV file. I guess maybe impossible as I will need to know the structure of how it is made?
Mark
You can unserialize the data, convert it to JSON, make changes and use that tool to serialize it again. Or, before it's serialized, write a little code to add/change something in it.
Codeacula
Reply to comment edit: Then you will need to query the database and run their function against the data being provided. It's likely doable, but without knowing specifics I can only say that you'll have to gather the data, make a version of the function your blog runs so that you can pass it the data and it returns the serialized string, and then save that to a CSV file.
Codeacula
If they're all this simple, they're trivial to construct. Given an input string ("11807" in the example), just wrap it in a serialized string like `a:1:{i:0;s:<encoded_length>:"<encoded>";}` and change the data and the length to the actual values (length of the resulting string value after two base 64 encodes etc).
bzlm
Okey sounds very tricky. I'm a complete noob. I guess I shall just have to keep doing this manually. All 600 of them :-( lol
Mark
@mark Au contraire. For each category you have, you construct a string using the template I provided, where you **base 64 encode the category number twice to get a string, and then in the template replace <encoded> with the string, and <encoded_length> with the number of characters in the string**. In PHP, I have no idea how to do it. I'd use Perl. :)
bzlm
+4  A: 

As @Codeacula said, it's PHP serialization at work:

a:1:{i:0;s:12:"TVRFNE1EYz0=";}

translates into: array of one element, containing an integer 0 and a string of 12 characters spelling "TVRFNE1EYz0=". It's quite human-readable.

Now, what "TVRFNE1EYz0=" is is anyone's guess. You should probably look into your application for the meaning of that.

To generate serialized strings, use PHP serialize function. Or, start counting letters in your strings. Or use this.

Amadan
The actual string data is doubly encoded Base 64. In this case, "TVRFNE1EYz0=" is "11807". :)
bzlm
Ah, cool. Did not check. :) BTW: double base64, WTF?
Amadan
Oh, this is so not cool. I'm telling my mother you took my answer and added more words. /upvote
Codeacula
Lol, here's a backvote. :) I did not intend to detract from your firsthood, just provide more details OP wanted.
Amadan