2 require_once("boot.php");
3 require_once("include/text.php");
5 define('NEW_UPDATE_ROUTINE_VERSION', 1170);
8 * send the email and do what is needed to do on update fails
10 * @param update_id (int) number of failed update
11 * @param error_message (str) error message
13 function update_fail($update_id, $error_message){
14 //send the administrators an e-mail
15 $admin_mail_list = "'".implode("','", array_map(dbesc, explode(",", str_replace(" ", "", $a->config['admin_email']))))."'";
16 $adminlist = q("SELECT uid, language, email FROM user WHERE email IN (%s)",
20 // every admin could had different language
22 foreach ($adminlist as $admin) {
23 $lang = (($admin['language'])?$admin['language']:'en');
26 $preamble = deindent(t("
27 The friendica developers released update %s recently,
28 but when I tried to install it, something went terribly wrong.
29 This needs to be fixed soon and I can't do it alone. Please contact a
30 friendica developer if you can not help me on your own. My database might be invalid."));
31 $body = t("The error message is\n[pre]%s[/pre]");
32 $preamble = sprintf($preamble, $update_id);
33 $body = sprintf($body, $error_message);
36 'type' => "SYSTEM_EMAIL",
37 'to_email' => $admin['email'],
38 'preamble' => $preamble,
48 $email_tpl = get_intltext_template("update_fail_eml.tpl");
49 $email_msg = replace_macros($email_tpl, array(
50 '$sitename' => $a->config['sitename'],
51 '$siteurl' => $a->get_baseurl(),
52 '$update' => DB_UPDATE_VERSION,
53 '$error' => sprintf(t('Update %s failed. See error logs.'), DB_UPDATE_VERSION)
55 $subject=sprintf(t('Update Error at %s'), $a->get_baseurl());
56 require_once('include/email.php');
57 $subject = email_header_encode($subject,'UTF-8');
58 mail($a->config['admin_email'], $subject, $email_msg,
59 'From: ' . 'Administrator' . '@' . $_SERVER['SERVER_NAME']."\n"
60 .'Content-type: text/plain; charset=UTF-8'."\n"
61 .'Content-transfer-encoding: 8bit');
64 logger("CRITICAL: Database structure update failed: ".$retval);
69 function table_structure($table) {
70 $structures = q("DESCRIBE `%s`", $table);
72 $indexes = q("SHOW INDEX FROM `%s`", $table);
77 if (is_array($indexes))
78 foreach ($indexes AS $index) {
79 if ($index["Index_type"] == "FULLTEXT")
82 $column = $index["Column_name"];
83 if ($index["Sub_part"] != "")
84 $column .= "(".$index["Sub_part"].")";
86 $indexdata[$index["Key_name"]][] = $column;
89 if (is_array($structures)) {
90 foreach($structures AS $field) {
91 $fielddata[$field["Field"]]["type"] = $field["Type"];
92 if ($field["Null"] == "NO")
93 $fielddata[$field["Field"]]["not null"] = true;
95 if (isset($field["Default"]))
96 $fielddata[$field["Field"]]["default"] = $field["Default"];
98 if ($field["Extra"] != "")
99 $fielddata[$field["Field"]]["extra"] = $field["Extra"];
101 if ($field["Key"] == "PRI")
102 $fielddata[$field["Field"]]["primary"] = true;
105 return(array("fields"=>$fielddata, "indexes"=>$indexdata));
108 function print_structure($database) {
109 foreach ($database AS $name => $structure) {
110 echo "\t".'$database["'.$name."\"] = array(\n";
112 echo "\t\t\t".'"fields" => array('."\n";
113 foreach ($structure["fields"] AS $fieldname => $parameters) {
114 echo "\t\t\t\t\t".'"'.$fieldname.'" => array(';
117 foreach ($parameters AS $name => $value) {
120 $data .= '"'.$name.'" => "'.$value.'"';
125 echo "\t\t\t\t\t),\n";
126 echo "\t\t\t".'"indexes" => array('."\n";
127 foreach ($structure["indexes"] AS $indexname => $fieldnames) {
128 echo "\t\t\t\t\t".'"'.$indexname.'" => array("'.implode($fieldnames, '","').'"'."),\n";
130 echo "\t\t\t\t\t)\n";
135 function update_structure($verbose, $action) {
140 logger('updating structure', LOGGER_DEBUG);
142 // Get the current structure
145 $tables = q("show tables");
147 foreach ($tables AS $table) {
148 $table = current($table);
150 $database[$table] = table_structure($table);
153 // Get the definition
154 $definition = db_definition();
157 foreach ($definition AS $name => $structure) {
159 if (!isset($database[$name])) {
160 $r = db_create_table($name, $structure["fields"], $verbose, $action);
162 $errors .= t('Errors encountered creating database tables.').$name.EOL;
164 // Drop the index if it isn't present in the definition
165 foreach ($database[$name]["indexes"] AS $indexname => $fieldnames)
166 if (!isset($structure["indexes"][$indexname])) {
167 $sql2=db_drop_index($indexname);
169 $sql3 = "ALTER TABLE `".$name."` ".$sql2;
174 // Compare the field structure field by field
175 foreach ($structure["fields"] AS $fieldname => $parameters) {
176 if (!isset($database[$name]["fields"][$fieldname])) {
177 $sql2=db_add_table_field($fieldname, $parameters);
179 $sql3 = "ALTER TABLE `".$name."` ".$sql2;
183 // Compare the field definition
184 $current_field_definition = implode(",",$database[$name]["fields"][$fieldname]);
185 $new_field_definition = implode(",",$parameters);
186 if ($current_field_definition != $new_field_definition) {
187 $sql2=db_modify_table_field($fieldname, $parameters);
189 $sql3 = "ALTER TABLE `".$name."` ".$sql2;
199 foreach ($structure["indexes"] AS $indexname => $fieldnames) {
200 if (!isset($database[$name]["indexes"][$indexname])) {
201 $sql2=db_create_index($indexname, $fieldnames);
204 $sql3 = "ALTER TABLE `".$name."` ".$sql2;
220 $errors .= t('Errors encountered performing database changes.').$sql3.EOL;
228 function db_field_command($parameters, $create = true) {
229 $fieldstruct = $parameters["type"];
231 if ($parameters["not null"])
232 $fieldstruct .= " NOT NULL";
234 if (isset($parameters["default"]))
235 $fieldstruct .= " DEFAULT '".$parameters["default"]."'";
237 if ($parameters["extra"] != "")
238 $fieldstruct .= " ".$parameters["extra"];
240 if (($parameters["primary"] != "") AND $create)
241 $fieldstruct .= " PRIMARY KEY";
243 return($fieldstruct);
246 function db_create_table($name, $fields, $verbose, $action) {
252 foreach($fields AS $fieldname => $field) {
256 $sql .= "`".dbesc($fieldname)."` ".db_field_command($field);
259 $sql = sprintf("CREATE TABLE IF NOT EXISTS `%s` (\n", dbesc($name)).$sql."\n) DEFAULT CHARSET=utf8";
270 function db_add_table_field($fieldname, $parameters) {
271 $sql = sprintf("ADD `%s` %s", dbesc($fieldname), db_field_command($parameters));
275 function db_modify_table_field($fieldname, $parameters) {
276 $sql = sprintf("MODIFY `%s` %s", dbesc($fieldname), db_field_command($parameters, false));
280 function db_drop_index($indexname) {
281 $sql = sprintf("DROP INDEX `%s`", dbesc($indexname));
285 function db_create_index($indexname, $fieldnames) {
287 if ($indexname == "PRIMARY")
291 foreach ($fieldnames AS $fieldname) {
295 if (preg_match('|(.+)\((\d+)\)|', $fieldname, $matches))
296 $names .= "`".dbesc($matches[1])."`(".intval($matches[2]).")";
298 $names .= "`".dbesc($fieldname)."`";
301 $sql = sprintf("ADD INDEX `%s` (%s)", dbesc($indexname), $names);
305 function db_definition() {
309 $database["addon"] = array(
311 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
312 "name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
313 "version" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
314 "installed" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
315 "hidden" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
316 "timestamp" => array("type" => "bigint(20)", "not null" => "1", "default" => "0"),
317 "plugin_admin" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
320 "PRIMARY" => array("id"),
323 $database["attach"] = array(
325 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
326 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
327 "hash" => array("type" => "varchar(64)", "not null" => "1", "default" => ""),
328 "filename" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
329 "filetype" => array("type" => "varchar(64)", "not null" => "1", "default" => ""),
330 "filesize" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
331 "data" => array("type" => "longblob", "not null" => "1"),
332 "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
333 "edited" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
334 "allow_cid" => array("type" => "mediumtext", "not null" => "1"),
335 "allow_gid" => array("type" => "mediumtext", "not null" => "1"),
336 "deny_cid" => array("type" => "mediumtext", "not null" => "1"),
337 "deny_gid" => array("type" => "mediumtext", "not null" => "1"),
340 "PRIMARY" => array("id"),
343 $database["auth_codes"] = array(
345 "id" => array("type" => "varchar(40)", "not null" => "1", "primary" => "1"),
346 "client_id" => array("type" => "varchar(20)", "not null" => "1", "default" => ""),
347 "redirect_uri" => array("type" => "varchar(200)", "not null" => "1", "default" => ""),
348 "expires" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
349 "scope" => array("type" => "varchar(250)", "not null" => "1", "default" => ""),
352 "PRIMARY" => array("id"),
355 $database["cache"] = array(
357 "k" => array("type" => "varchar(255)", "not null" => "1", "primary" => "1"),
358 "v" => array("type" => "text", "not null" => "1"),
359 "updated" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
362 "PRIMARY" => array("k"),
363 "updated" => array("updated"),
366 $database["challenge"] = array(
368 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
369 "challenge" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
370 "dfrn-id" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
371 "expire" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
372 "type" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
373 "last_update" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
376 "PRIMARY" => array("id"),
379 $database["clients"] = array(
381 "client_id" => array("type" => "varchar(20)", "not null" => "1", "primary" => "1"),
382 "pw" => array("type" => "varchar(20)", "not null" => "1", "default" => ""),
383 "redirect_uri" => array("type" => "varchar(200)", "not null" => "1", "default" => ""),
384 "name" => array("type" => "text"),
385 "icon" => array("type" => "text"),
386 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
389 "PRIMARY" => array("client_id"),
392 $database["config"] = array(
394 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
395 "cat" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
396 "k" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
397 "v" => array("type" => "text", "not null" => "1"),
400 "PRIMARY" => array("id"),
401 "cat_k" => array("cat(30)","k(30)"),
404 $database["contact"] = array(
406 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
407 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
408 "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
409 "self" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
410 "remote_self" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
411 "rel" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
412 "duplex" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
413 "network" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
414 "name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
415 "nick" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
416 "location" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
417 "about" => array("type" => "text", "not null" => "1"),
418 "attag" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
419 "photo" => array("type" => "text", "not null" => "1"),
420 "thumb" => array("type" => "text", "not null" => "1"),
421 "micro" => array("type" => "text", "not null" => "1"),
422 "site-pubkey" => array("type" => "text", "not null" => "1"),
423 "issued-id" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
424 "dfrn-id" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
425 "url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
426 "nurl" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
427 "addr" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
428 "alias" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
429 "pubkey" => array("type" => "text", "not null" => "1"),
430 "prvkey" => array("type" => "text", "not null" => "1"),
431 "batch" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
432 "request" => array("type" => "text", "not null" => "1"),
433 "notify" => array("type" => "text", "not null" => "1"),
434 "poll" => array("type" => "text", "not null" => "1"),
435 "confirm" => array("type" => "text", "not null" => "1"),
436 "poco" => array("type" => "text", "not null" => "1"),
437 "aes_allow" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
438 "ret-aes" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
439 "usehub" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
440 "subhub" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
441 "hub-verify" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
442 "last-update" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
443 "success_update" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
444 "name-date" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
445 "uri-date" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
446 "avatar-date" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
447 "term-date" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
448 "priority" => array("type" => "tinyint(3)", "not null" => "1", "default" => "0"),
449 "blocked" => array("type" => "tinyint(1)", "not null" => "1", "default" => "1"),
450 "readonly" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
451 "writable" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
452 "forum" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
453 "prv" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
454 "hidden" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
455 "archive" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
456 "pending" => array("type" => "tinyint(1)", "not null" => "1", "default" => "1"),
457 "rating" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
458 "reason" => array("type" => "text", "not null" => "1"),
459 "closeness" => array("type" => "tinyint(2)", "not null" => "1", "default" => "99"),
460 "info" => array("type" => "mediumtext", "not null" => "1"),
461 "profile-id" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
462 "bdyear" => array("type" => "varchar(4)", "not null" => "1", "default" => ""),
463 "bd" => array("type" => "date", "not null" => "1", "default" => "0000-00-00"),
464 "notify_new_posts" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
465 "fetch_further_information" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
466 "ffi_keyword_blacklist" => array("type" => "mediumtext", "not null" => "1"),
469 "PRIMARY" => array("id"),
470 "uid" => array("uid"),
473 $database["conv"] = array(
475 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
476 "guid" => array("type" => "varchar(64)", "not null" => "1", "default" => ""),
477 "recips" => array("type" => "mediumtext", "not null" => "1"),
478 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
479 "creator" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
480 "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
481 "updated" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
482 "subject" => array("type" => "mediumtext", "not null" => "1"),
485 "PRIMARY" => array("id"),
486 "uid" => array("uid"),
489 $database["deliverq"] = array(
491 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
492 "cmd" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
493 "item" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
494 "contact" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
497 "PRIMARY" => array("id"),
500 $database["dsprphotoq"] = array(
502 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
503 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
504 "msg" => array("type" => "mediumtext", "not null" => "1"),
505 "attempt" => array("type" => "tinyint(4)", "not null" => "1", "default" => "0"),
508 "PRIMARY" => array("id"),
511 $database["event"] = array(
513 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
514 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
515 "cid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
516 "uri" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
517 "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
518 "edited" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
519 "start" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
520 "finish" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
521 "summary" => array("type" => "text", "not null" => "1"),
522 "desc" => array("type" => "text", "not null" => "1"),
523 "location" => array("type" => "text", "not null" => "1"),
524 "type" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
525 "nofinish" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
526 "adjust" => array("type" => "tinyint(1)", "not null" => "1", "default" => "1"),
527 "ignore" => array("type" => "tinyint(1) unsigned", "not null" => "1", "default" => "0"),
528 "allow_cid" => array("type" => "mediumtext", "not null" => "1"),
529 "allow_gid" => array("type" => "mediumtext", "not null" => "1"),
530 "deny_cid" => array("type" => "mediumtext", "not null" => "1"),
531 "deny_gid" => array("type" => "mediumtext", "not null" => "1"),
534 "PRIMARY" => array("id"),
535 "uid" => array("uid"),
538 $database["fcontact"] = array(
540 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
541 "url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
542 "name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
543 "photo" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
544 "request" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
545 "nick" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
546 "addr" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
547 "batch" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
548 "notify" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
549 "poll" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
550 "confirm" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
551 "priority" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
552 "network" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
553 "alias" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
554 "pubkey" => array("type" => "text", "not null" => "1"),
555 "updated" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
558 "PRIMARY" => array("id"),
559 "addr" => array("addr"),
562 $database["ffinder"] = array(
564 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
565 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
566 "cid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
567 "fid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
570 "PRIMARY" => array("id"),
573 $database["fserver"] = array(
575 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
576 "server" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
577 "posturl" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
578 "key" => array("type" => "text", "not null" => "1"),
581 "PRIMARY" => array("id"),
582 "server" => array("server"),
585 $database["fsuggest"] = array(
587 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
588 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
589 "cid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
590 "name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
591 "url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
592 "request" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
593 "photo" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
594 "note" => array("type" => "text", "not null" => "1"),
595 "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
598 "PRIMARY" => array("id"),
601 $database["gcign"] = array(
603 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
604 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
605 "gcid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
608 "PRIMARY" => array("id"),
609 "uid" => array("uid"),
610 "gcid" => array("gcid"),
613 $database["gcontact"] = array(
615 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
616 "name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
617 "url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
618 "nurl" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
619 "photo" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
620 "connect" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
621 "updated" => array("type" => "datetime", "default" => "0000-00-00 00:00:00"),
622 "location" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
623 "about" => array("type" => "text", "not null" => "1"),
624 "network" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
627 "PRIMARY" => array("id"),
628 "nurl" => array("nurl"),
631 $database["glink"] = array(
633 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
634 "cid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
635 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
636 "gcid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
637 "zcid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
638 "updated" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
641 "PRIMARY" => array("id"),
642 "cid_uid_gcid_zcid" => array("cid","uid","gcid","zcid"),
643 "gcid" => array("gcid"),
644 "zcid" => array("zcid"),
647 $database["group"] = array(
649 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
650 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
651 "visible" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
652 "deleted" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
653 "name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
656 "PRIMARY" => array("id"),
657 "uid" => array("uid"),
660 $database["group_member"] = array(
662 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
663 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
664 "gid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
665 "contact-id" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
668 "PRIMARY" => array("id"),
669 "uid_gid_contactid" => array("uid","gid","contact-id"),
672 $database["guid"] = array(
674 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
675 "guid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
678 "PRIMARY" => array("id"),
679 "guid" => array("guid"),
682 $database["hook"] = array(
684 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
685 "hook" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
686 "file" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
687 "function" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
688 "priority" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"),
691 "PRIMARY" => array("id"),
692 "hook_file_function" => array("hook(30)","file(60)","function(30)"),
695 $database["intro"] = array(
697 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
698 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
699 "fid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
700 "contact-id" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
701 "knowyou" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
702 "duplex" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
703 "note" => array("type" => "text", "not null" => "1"),
704 "hash" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
705 "datetime" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
706 "blocked" => array("type" => "tinyint(1)", "not null" => "1", "default" => "1"),
707 "ignore" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
710 "PRIMARY" => array("id"),
713 $database["item"] = array(
715 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
716 "guid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
717 "uri" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
718 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
719 "contact-id" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
720 "type" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
721 "wall" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
722 "gravity" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
723 "parent" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
724 "parent-uri" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
725 "extid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
726 "thr-parent" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
727 "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
728 "edited" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
729 "commented" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
730 "received" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
731 "changed" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
732 "owner-name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
733 "owner-link" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
734 "owner-avatar" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
735 "author-name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
736 "author-link" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
737 "author-avatar" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
738 "title" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
739 "body" => array("type" => "mediumtext", "not null" => "1"),
740 "app" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
741 "verb" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
742 "object-type" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
743 "object" => array("type" => "text", "not null" => "1"),
744 "target-type" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
745 "target" => array("type" => "text", "not null" => "1"),
746 "postopts" => array("type" => "text", "not null" => "1"),
747 "plink" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
748 "resource-id" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
749 "event-id" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
750 "tag" => array("type" => "mediumtext", "not null" => "1"),
751 "attach" => array("type" => "mediumtext", "not null" => "1"),
752 "inform" => array("type" => "mediumtext", "not null" => "1"),
753 "file" => array("type" => "mediumtext", "not null" => "1"),
754 "location" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
755 "coord" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
756 "allow_cid" => array("type" => "mediumtext", "not null" => "1"),
757 "allow_gid" => array("type" => "mediumtext", "not null" => "1"),
758 "deny_cid" => array("type" => "mediumtext", "not null" => "1"),
759 "deny_gid" => array("type" => "mediumtext", "not null" => "1"),
760 "private" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
761 "pubmail" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
762 "moderated" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
763 "visible" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
764 "spam" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
765 "starred" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
766 "bookmark" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
767 "unseen" => array("type" => "tinyint(1)", "not null" => "1", "default" => "1"),
768 "deleted" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
769 "origin" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
770 "forum_mode" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
771 "last-child" => array("type" => "tinyint(1) unsigned", "not null" => "1", "default" => "1"),
772 "mention" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
773 "network" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
776 "PRIMARY" => array("id"),
777 "guid" => array("guid"),
778 "uri" => array("uri"),
779 "parent" => array("parent"),
780 "parent-uri" => array("parent-uri"),
781 "extid" => array("extid"),
782 "uid_id" => array("uid","id"),
783 "uid_created" => array("uid","created"),
784 "uid_unseen" => array("uid","unseen"),
785 "uid_network_received" => array("uid","network","received"),
786 "uid_received" => array("uid","received"),
787 "uid_network_commented" => array("uid","network","commented"),
788 "uid_commented" => array("uid","commented"),
789 "uid_title" => array("uid","title"),
790 "uid_thrparent" => array("uid","thr-parent"),
791 "uid_parenturi" => array("uid","parent-uri"),
792 "uid_contactid_created" => array("uid","contact-id","created"),
793 "wall_body" => array("wall","body(6)"),
794 "uid_visible_moderated_created" => array("uid","visible","moderated","created"),
795 "uid_uri" => array("uid","uri"),
796 "uid_wall_created" => array("uid","wall","created"),
797 "resource-id" => array("resource-id"),
798 "uid_type" => array("uid","type"),
799 "uid_starred" => array("uid","starred"),
800 "contactid_allowcid_allowpid_denycid_denygid" => array("contact-id","allow_cid(10)","allow_gid(10)","deny_cid(10)","deny_gid(10)"),
801 "uid_wall_parent_created" => array("uid","wall","parent","created"),
802 "uid_type_changed" => array("uid","type","changed"),
803 "contactid_verb" => array("contact-id","verb"),
804 "deleted_changed" => array("deleted","changed"),
805 "uid_wall_changed" => array("uid","wall","changed"),
806 "uid_eventid" => array("uid","event-id"),
807 "uid_authorlink" => array("uid","author-link"),
808 "uid_ownerlink" => array("uid","owner-link"),
811 $database["item_id"] = array(
813 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
814 "iid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
815 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
816 "sid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
817 "service" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
820 "PRIMARY" => array("id"),
821 "uid" => array("uid"),
822 "sid" => array("sid"),
823 "service" => array("service"),
824 "iid" => array("iid"),
827 $database["locks"] = array(
829 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
830 "name" => array("type" => "varchar(128)", "not null" => "1", "default" => ""),
831 "locked" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
832 "created" => array("type" => "datetime", "default" => "0000-00-00 00:00:00"),
835 "PRIMARY" => array("id"),
838 $database["mail"] = array(
840 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
841 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
842 "guid" => array("type" => "varchar(64)", "not null" => "1", "default" => ""),
843 "from-name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
844 "from-photo" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
845 "from-url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
846 "contact-id" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
847 "convid" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"),
848 "title" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
849 "body" => array("type" => "mediumtext", "not null" => "1"),
850 "seen" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
851 "reply" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
852 "replied" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
853 "unknown" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
854 "uri" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
855 "parent-uri" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
856 "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
859 "PRIMARY" => array("id"),
860 "uid" => array("uid"),
861 "guid" => array("guid"),
862 "convid" => array("convid"),
863 "reply" => array("reply"),
864 "uri" => array("uri"),
865 "parent-uri" => array("parent-uri"),
868 $database["mailacct"] = array(
870 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
871 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
872 "server" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
873 "port" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
874 "ssltype" => array("type" => "varchar(16)", "not null" => "1", "default" => ""),
875 "mailbox" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
876 "user" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
877 "pass" => array("type" => "text", "not null" => "1"),
878 "reply_to" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
879 "action" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
880 "movetofolder" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
881 "pubmail" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
882 "last_check" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
885 "PRIMARY" => array("id"),
888 $database["manage"] = array(
890 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
891 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
892 "mid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
895 "PRIMARY" => array("id"),
896 "uid_mid" => array("uid","mid"),
899 $database["notify"] = array(
901 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
902 "hash" => array("type" => "varchar(64)", "not null" => "1", "default" => ""),
903 "type" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
904 "name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
905 "url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
906 "photo" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
907 "date" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
908 "msg" => array("type" => "mediumtext", "not null" => "1"),
909 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
910 "link" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
911 "parent" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
912 "seen" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
913 "verb" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
914 "otype" => array("type" => "varchar(16)", "not null" => "1", "default" => ""),
917 "PRIMARY" => array("id"),
918 "uid" => array("uid"),
921 $database["notify-threads"] = array(
923 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
924 "notify-id" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
925 "master-parent-item" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
926 "parent-item" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
927 "receiver-uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
930 "PRIMARY" => array("id"),
931 "master-parent-item" => array("master-parent-item"),
932 "receiver-uid" => array("receiver-uid"),
935 $database["pconfig"] = array(
937 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
938 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
939 "cat" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
940 "k" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
941 "v" => array("type" => "mediumtext", "not null" => "1"),
944 "PRIMARY" => array("id"),
945 "uid_cat_k" => array("uid","cat(30)","k(30)"),
948 $database["photo"] = array(
950 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
951 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
952 "contact-id" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
953 "guid" => array("type" => "varchar(64)", "not null" => "1", "default" => ""),
954 "resource-id" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
955 "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
956 "edited" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
957 "title" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
958 "desc" => array("type" => "text", "not null" => "1"),
959 "album" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
960 "filename" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
961 "type" => array("type" => "varchar(128)", "not null" => "1", "default" => "image/jpeg"),
962 "height" => array("type" => "smallint(6)", "not null" => "1", "default" => "0"),
963 "width" => array("type" => "smallint(6)", "not null" => "1", "default" => "0"),
964 "datasize" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
965 "data" => array("type" => "mediumblob", "not null" => "1"),
966 "scale" => array("type" => "tinyint(3)", "not null" => "1", "default" => "0"),
967 "profile" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
968 "allow_cid" => array("type" => "mediumtext", "not null" => "1"),
969 "allow_gid" => array("type" => "mediumtext", "not null" => "1"),
970 "deny_cid" => array("type" => "mediumtext", "not null" => "1"),
971 "deny_gid" => array("type" => "mediumtext", "not null" => "1"),
974 "PRIMARY" => array("id"),
975 "uid" => array("uid"),
976 "resource-id" => array("resource-id"),
977 "guid" => array("guid"),
980 $database["poll"] = array(
982 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
983 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
984 "q0" => array("type" => "mediumtext", "not null" => "1"),
985 "q1" => array("type" => "mediumtext", "not null" => "1"),
986 "q2" => array("type" => "mediumtext", "not null" => "1"),
987 "q3" => array("type" => "mediumtext", "not null" => "1"),
988 "q4" => array("type" => "mediumtext", "not null" => "1"),
989 "q5" => array("type" => "mediumtext", "not null" => "1"),
990 "q6" => array("type" => "mediumtext", "not null" => "1"),
991 "q7" => array("type" => "mediumtext", "not null" => "1"),
992 "q8" => array("type" => "mediumtext", "not null" => "1"),
993 "q9" => array("type" => "mediumtext", "not null" => "1"),
996 "PRIMARY" => array("id"),
997 "uid" => array("uid"),
1000 $database["poll_result"] = array(
1002 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1003 "poll_id" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1004 "choice" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1007 "PRIMARY" => array("id"),
1008 "poll_id" => array("poll_id"),
1009 "choice" => array("choice"),
1012 $database["profile"] = array(
1014 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1015 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1016 "profile-name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1017 "is-default" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1018 "hide-friends" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1019 "name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1020 "pdesc" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1021 "dob" => array("type" => "varchar(32)", "not null" => "1", "default" => "0000-00-00"),
1022 "address" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1023 "locality" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1024 "region" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1025 "postal-code" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
1026 "country-name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1027 "hometown" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1028 "gender" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
1029 "marital" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1030 "with" => array("type" => "text", "not null" => "1"),
1031 "howlong" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1032 "sexual" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1033 "politic" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1034 "religion" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1035 "pub_keywords" => array("type" => "text", "not null" => "1"),
1036 "prv_keywords" => array("type" => "text", "not null" => "1"),
1037 "likes" => array("type" => "text", "not null" => "1"),
1038 "dislikes" => array("type" => "text", "not null" => "1"),
1039 "about" => array("type" => "text", "not null" => "1"),
1040 "summary" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1041 "music" => array("type" => "text", "not null" => "1"),
1042 "book" => array("type" => "text", "not null" => "1"),
1043 "tv" => array("type" => "text", "not null" => "1"),
1044 "film" => array("type" => "text", "not null" => "1"),
1045 "interest" => array("type" => "text", "not null" => "1"),
1046 "romance" => array("type" => "text", "not null" => "1"),
1047 "work" => array("type" => "text", "not null" => "1"),
1048 "education" => array("type" => "text", "not null" => "1"),
1049 "contact" => array("type" => "text", "not null" => "1"),
1050 "homepage" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1051 "photo" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1052 "thumb" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1053 "publish" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1054 "net-publish" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1057 "PRIMARY" => array("id"),
1058 "hometown" => array("hometown"),
1061 $database["profile_check"] = array(
1063 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1064 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1065 "cid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1066 "dfrn_id" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1067 "sec" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1068 "expire" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1071 "PRIMARY" => array("id"),
1074 $database["push_subscriber"] = array(
1076 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1077 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1078 "callback_url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1079 "topic" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1080 "nickname" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1081 "push" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1082 "last_update" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1083 "secret" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1086 "PRIMARY" => array("id"),
1089 $database["queue"] = array(
1091 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1092 "cid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1093 "network" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
1094 "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1095 "last" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1096 "content" => array("type" => "mediumtext", "not null" => "1"),
1097 "batch" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1100 "PRIMARY" => array("id"),
1101 "cid" => array("cid"),
1102 "created" => array("created"),
1103 "last" => array("last"),
1104 "network" => array("network"),
1105 "batch" => array("batch"),
1108 $database["register"] = array(
1110 "id" => array("type" => "int(11) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1111 "hash" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1112 "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1113 "uid" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"),
1114 "password" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1115 "language" => array("type" => "varchar(16)", "not null" => "1", "default" => ""),
1118 "PRIMARY" => array("id"),
1121 $database["search"] = array(
1123 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1124 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1125 "term" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1128 "PRIMARY" => array("id"),
1129 "uid" => array("uid"),
1130 "term" => array("term"),
1133 $database["session"] = array(
1135 "id" => array("type" => "bigint(20) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1136 "sid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1137 "data" => array("type" => "text", "not null" => "1"),
1138 "expire" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1141 "PRIMARY" => array("id"),
1142 "sid" => array("sid"),
1143 "expire" => array("expire"),
1146 $database["sign"] = array(
1148 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1149 "iid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1150 "retract_iid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1151 "signed_text" => array("type" => "mediumtext", "not null" => "1"),
1152 "signature" => array("type" => "text", "not null" => "1"),
1153 "signer" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1156 "PRIMARY" => array("id"),
1157 "iid" => array("iid"),
1158 "retract_iid" => array("retract_iid"),
1161 $database["spam"] = array(
1163 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1164 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1165 "spam" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1166 "ham" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1167 "term" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1168 "date" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1171 "PRIMARY" => array("id"),
1172 "uid" => array("uid"),
1173 "spam" => array("spam"),
1174 "ham" => array("ham"),
1175 "term" => array("term"),
1178 $database["term"] = array(
1180 "tid" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1181 "oid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1182 "otype" => array("type" => "tinyint(3) unsigned", "not null" => "1", "default" => "0"),
1183 "type" => array("type" => "tinyint(3) unsigned", "not null" => "1", "default" => "0"),
1184 "term" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1185 "url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1186 "aid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1187 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1190 "PRIMARY" => array("tid"),
1191 "oid_otype_type_term" => array("oid","otype","type","term"),
1192 "uid_term_tid" => array("uid","term","tid"),
1193 "type_term" => array("type","term"),
1194 "uid_otype_type_term_tid" => array("uid","otype","type","term","tid"),
1195 "otype_type_term_tid" => array("otype","type","term","tid"),
1198 $database["thread"] = array(
1200 "iid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0", "primary" => "1"),
1201 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1202 "contact-id" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"),
1203 "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1204 "edited" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1205 "commented" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1206 "received" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1207 "changed" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1208 "wall" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1209 "private" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1210 "pubmail" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1211 "moderated" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1212 "visible" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1213 "spam" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1214 "starred" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1215 "ignored" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1216 "bookmark" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1217 "unseen" => array("type" => "tinyint(1)", "not null" => "1", "default" => "1"),
1218 "deleted" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1219 "origin" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1220 "forum_mode" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1221 "mention" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1222 "network" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
1225 "PRIMARY" => array("iid"),
1226 "created" => array("created"),
1227 "commented" => array("commented"),
1228 "uid_network_commented" => array("uid","network","commented"),
1229 "uid_network_created" => array("uid","network","created"),
1230 "uid_contactid_commented" => array("uid","contact-id","commented"),
1231 "uid_contactid_created" => array("uid","contact-id","created"),
1232 "wall_private_received" => array("wall","private","received"),
1233 "uid_created" => array("uid","created"),
1234 "uid_commented" => array("uid","commented"),
1237 $database["tokens"] = array(
1239 "id" => array("type" => "varchar(40)", "not null" => "1", "primary" => "1"),
1240 "secret" => array("type" => "text", "not null" => "1"),
1241 "client_id" => array("type" => "varchar(20)", "not null" => "1", "default" => ""),
1242 "expires" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1243 "scope" => array("type" => "varchar(200)", "not null" => "1", "default" => ""),
1244 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1247 "PRIMARY" => array("id"),
1250 $database["unique_contacts"] = array(
1252 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1253 "url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1254 "nick" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1255 "name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1256 "avatar" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1257 "location" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1258 "about" => array("type" => "text", "not null" => "1"),
1261 "PRIMARY" => array("id"),
1262 "url" => array("url"),
1265 $database["user"] = array(
1267 "uid" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1268 "guid" => array("type" => "varchar(64)", "not null" => "1", "default" => ""),
1269 "username" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1270 "password" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1271 "nickname" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1272 "email" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1273 "openid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1274 "timezone" => array("type" => "varchar(128)", "not null" => "1", "default" => ""),
1275 "language" => array("type" => "varchar(32)", "not null" => "1", "default" => "en"),
1276 "register_date" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1277 "login_date" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1278 "default-location" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1279 "allow_location" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1280 "theme" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1281 "pubkey" => array("type" => "text", "not null" => "1"),
1282 "prvkey" => array("type" => "text", "not null" => "1"),
1283 "spubkey" => array("type" => "text", "not null" => "1"),
1284 "sprvkey" => array("type" => "text", "not null" => "1"),
1285 "verified" => array("type" => "tinyint(1) unsigned", "not null" => "1", "default" => "0"),
1286 "blocked" => array("type" => "tinyint(1) unsigned", "not null" => "1", "default" => "0"),
1287 "blockwall" => array("type" => "tinyint(1) unsigned", "not null" => "1", "default" => "0"),
1288 "hidewall" => array("type" => "tinyint(1) unsigned", "not null" => "1", "default" => "0"),
1289 "blocktags" => array("type" => "tinyint(1) unsigned", "not null" => "1", "default" => "0"),
1290 "unkmail" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1291 "cntunkmail" => array("type" => "int(11)", "not null" => "1", "default" => "10"),
1292 "notify-flags" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "65535"),
1293 "page-flags" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"),
1294 "prvnets" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1295 "pwdreset" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1296 "maxreq" => array("type" => "int(11)", "not null" => "1", "default" => "10"),
1297 "expire" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"),
1298 "account_removed" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1299 "account_expired" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1300 "account_expires_on" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1301 "expire_notification_sent" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1302 "service_class" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
1303 "def_gid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1304 "allow_cid" => array("type" => "mediumtext", "not null" => "1"),
1305 "allow_gid" => array("type" => "mediumtext", "not null" => "1"),
1306 "deny_cid" => array("type" => "mediumtext", "not null" => "1"),
1307 "deny_gid" => array("type" => "mediumtext", "not null" => "1"),
1308 "openidserver" => array("type" => "text", "not null" => "1"),
1311 "PRIMARY" => array("uid"),
1312 "nickname" => array("nickname"),
1315 $database["userd"] = array(
1317 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1318 "username" => array("type" => "varchar(255)", "not null" => "1"),
1321 "PRIMARY" => array("id"),
1322 "username" => array("username"),
1331 * run from command line
1333 function dbstructure_run(&$argv, &$argc) {
1341 @include(".htconfig.php");
1342 require_once("include/dba.php");
1343 $db = new dba($db_host, $db_user, $db_pass, $db_data);
1344 unset($db_host, $db_user, $db_pass, $db_data);
1347 update_structure(true, true);
1350 if (array_search(__file__,get_included_files())===0){
1351 dbstructure_run($_SERVER["argv"],$_SERVER["argc"]);