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"),
624 "PRIMARY" => array("id"),
625 "nurl" => array("nurl"),
628 $database["glink"] = array(
630 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
631 "cid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
632 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
633 "gcid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
634 "zcid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
635 "updated" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
638 "PRIMARY" => array("id"),
639 "cid_uid_gcid_zcid" => array("cid","uid","gcid","zcid"),
640 "gcid" => array("gcid"),
641 "zcid" => array("zcid"),
644 $database["group"] = array(
646 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
647 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
648 "visible" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
649 "deleted" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
650 "name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
653 "PRIMARY" => array("id"),
654 "uid" => array("uid"),
657 $database["group_member"] = array(
659 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
660 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
661 "gid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
662 "contact-id" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
665 "PRIMARY" => array("id"),
666 "uid_gid_contactid" => array("uid","gid","contact-id"),
669 $database["guid"] = array(
671 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
672 "guid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
675 "PRIMARY" => array("id"),
676 "guid" => array("guid"),
679 $database["hook"] = array(
681 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
682 "hook" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
683 "file" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
684 "function" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
685 "priority" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"),
688 "PRIMARY" => array("id"),
689 "hook_file_function" => array("hook(30)","file(60)","function(30)"),
692 $database["intro"] = array(
694 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
695 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
696 "fid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
697 "contact-id" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
698 "knowyou" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
699 "duplex" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
700 "note" => array("type" => "text", "not null" => "1"),
701 "hash" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
702 "datetime" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
703 "blocked" => array("type" => "tinyint(1)", "not null" => "1", "default" => "1"),
704 "ignore" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
707 "PRIMARY" => array("id"),
710 $database["item"] = array(
712 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
713 "guid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
714 "uri" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
715 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
716 "contact-id" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
717 "type" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
718 "wall" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
719 "gravity" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
720 "parent" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
721 "parent-uri" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
722 "extid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
723 "thr-parent" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
724 "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
725 "edited" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
726 "commented" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
727 "received" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
728 "changed" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
729 "owner-name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
730 "owner-link" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
731 "owner-avatar" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
732 "author-name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
733 "author-link" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
734 "author-avatar" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
735 "title" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
736 "body" => array("type" => "mediumtext", "not null" => "1"),
737 "app" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
738 "verb" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
739 "object-type" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
740 "object" => array("type" => "text", "not null" => "1"),
741 "target-type" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
742 "target" => array("type" => "text", "not null" => "1"),
743 "postopts" => array("type" => "text", "not null" => "1"),
744 "plink" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
745 "resource-id" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
746 "event-id" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
747 "tag" => array("type" => "mediumtext", "not null" => "1"),
748 "attach" => array("type" => "mediumtext", "not null" => "1"),
749 "inform" => array("type" => "mediumtext", "not null" => "1"),
750 "file" => array("type" => "mediumtext", "not null" => "1"),
751 "location" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
752 "coord" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
753 "allow_cid" => array("type" => "mediumtext", "not null" => "1"),
754 "allow_gid" => array("type" => "mediumtext", "not null" => "1"),
755 "deny_cid" => array("type" => "mediumtext", "not null" => "1"),
756 "deny_gid" => array("type" => "mediumtext", "not null" => "1"),
757 "private" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
758 "pubmail" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
759 "moderated" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
760 "visible" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
761 "spam" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
762 "starred" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
763 "bookmark" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
764 "unseen" => array("type" => "tinyint(1)", "not null" => "1", "default" => "1"),
765 "deleted" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
766 "origin" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
767 "forum_mode" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
768 "last-child" => array("type" => "tinyint(1) unsigned", "not null" => "1", "default" => "1"),
769 "mention" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
770 "network" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
773 "PRIMARY" => array("id"),
774 "guid" => array("guid"),
775 "uri" => array("uri"),
776 "parent" => array("parent"),
777 "parent-uri" => array("parent-uri"),
778 "extid" => array("extid"),
779 "uid_id" => array("uid","id"),
780 "uid_created" => array("uid","created"),
781 "uid_unseen" => array("uid","unseen"),
782 "uid_network_received" => array("uid","network","received"),
783 "uid_received" => array("uid","received"),
784 "uid_network_commented" => array("uid","network","commented"),
785 "uid_commented" => array("uid","commented"),
786 "uid_title" => array("uid","title"),
787 "uid_thrparent" => array("uid","thr-parent"),
788 "uid_parenturi" => array("uid","parent-uri"),
789 "uid_contactid_created" => array("uid","contact-id","created"),
790 "wall_body" => array("wall","body(6)"),
791 "uid_visible_moderated_created" => array("uid","visible","moderated","created"),
792 "uid_uri" => array("uid","uri"),
793 "uid_wall_created" => array("uid","wall","created"),
794 "resource-id" => array("resource-id"),
795 "uid_type" => array("uid","type"),
796 "uid_starred" => array("uid","starred"),
797 "contactid_allowcid_allowpid_denycid_denygid" => array("contact-id","allow_cid(10)","allow_gid(10)","deny_cid(10)","deny_gid(10)"),
798 "uid_wall_parent_created" => array("uid","wall","parent","created"),
799 "uid_type_changed" => array("uid","type","changed"),
800 "contactid_verb" => array("contact-id","verb"),
801 "deleted_changed" => array("deleted","changed"),
802 "uid_wall_changed" => array("uid","wall","changed"),
803 "uid_eventid" => array("uid","event-id"),
804 "uid_authorlink" => array("uid","author-link"),
805 "uid_ownerlink" => array("uid","owner-link"),
808 $database["item_id"] = array(
810 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
811 "iid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
812 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
813 "sid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
814 "service" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
817 "PRIMARY" => array("id"),
818 "uid" => array("uid"),
819 "sid" => array("sid"),
820 "service" => array("service"),
821 "iid" => array("iid"),
824 $database["locks"] = array(
826 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
827 "name" => array("type" => "varchar(128)", "not null" => "1", "default" => ""),
828 "locked" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
829 "created" => array("type" => "datetime", "default" => "0000-00-00 00:00:00"),
832 "PRIMARY" => array("id"),
835 $database["mail"] = array(
837 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
838 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
839 "guid" => array("type" => "varchar(64)", "not null" => "1", "default" => ""),
840 "from-name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
841 "from-photo" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
842 "from-url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
843 "contact-id" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
844 "convid" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"),
845 "title" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
846 "body" => array("type" => "mediumtext", "not null" => "1"),
847 "seen" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
848 "reply" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
849 "replied" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
850 "unknown" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
851 "uri" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
852 "parent-uri" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
853 "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
856 "PRIMARY" => array("id"),
857 "uid" => array("uid"),
858 "guid" => array("guid"),
859 "convid" => array("convid"),
860 "reply" => array("reply"),
861 "uri" => array("uri"),
862 "parent-uri" => array("parent-uri"),
865 $database["mailacct"] = array(
867 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
868 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
869 "server" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
870 "port" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
871 "ssltype" => array("type" => "varchar(16)", "not null" => "1", "default" => ""),
872 "mailbox" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
873 "user" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
874 "pass" => array("type" => "text", "not null" => "1"),
875 "reply_to" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
876 "action" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
877 "movetofolder" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
878 "pubmail" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
879 "last_check" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
882 "PRIMARY" => array("id"),
885 $database["manage"] = array(
887 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
888 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
889 "mid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
892 "PRIMARY" => array("id"),
893 "uid_mid" => array("uid","mid"),
896 $database["notify"] = array(
898 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
899 "hash" => array("type" => "varchar(64)", "not null" => "1", "default" => ""),
900 "type" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
901 "name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
902 "url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
903 "photo" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
904 "date" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
905 "msg" => array("type" => "mediumtext", "not null" => "1"),
906 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
907 "link" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
908 "parent" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
909 "seen" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
910 "verb" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
911 "otype" => array("type" => "varchar(16)", "not null" => "1", "default" => ""),
914 "PRIMARY" => array("id"),
915 "uid" => array("uid"),
918 $database["notify-threads"] = array(
920 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
921 "notify-id" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
922 "master-parent-item" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
923 "parent-item" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
924 "receiver-uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
927 "PRIMARY" => array("id"),
928 "master-parent-item" => array("master-parent-item"),
929 "receiver-uid" => array("receiver-uid"),
932 $database["pconfig"] = array(
934 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
935 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
936 "cat" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
937 "k" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
938 "v" => array("type" => "mediumtext", "not null" => "1"),
941 "PRIMARY" => array("id"),
942 "uid_cat_k" => array("uid","cat(30)","k(30)"),
945 $database["photo"] = array(
947 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
948 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
949 "contact-id" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
950 "guid" => array("type" => "varchar(64)", "not null" => "1", "default" => ""),
951 "resource-id" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
952 "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
953 "edited" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
954 "title" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
955 "desc" => array("type" => "text", "not null" => "1"),
956 "album" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
957 "filename" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
958 "type" => array("type" => "varchar(128)", "not null" => "1", "default" => "image/jpeg"),
959 "height" => array("type" => "smallint(6)", "not null" => "1", "default" => "0"),
960 "width" => array("type" => "smallint(6)", "not null" => "1", "default" => "0"),
961 "datasize" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
962 "data" => array("type" => "mediumblob", "not null" => "1"),
963 "scale" => array("type" => "tinyint(3)", "not null" => "1", "default" => "0"),
964 "profile" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
965 "allow_cid" => array("type" => "mediumtext", "not null" => "1"),
966 "allow_gid" => array("type" => "mediumtext", "not null" => "1"),
967 "deny_cid" => array("type" => "mediumtext", "not null" => "1"),
968 "deny_gid" => array("type" => "mediumtext", "not null" => "1"),
971 "PRIMARY" => array("id"),
972 "uid" => array("uid"),
973 "resource-id" => array("resource-id"),
974 "guid" => array("guid"),
977 $database["poll"] = array(
979 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
980 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
981 "q0" => array("type" => "mediumtext", "not null" => "1"),
982 "q1" => array("type" => "mediumtext", "not null" => "1"),
983 "q2" => array("type" => "mediumtext", "not null" => "1"),
984 "q3" => array("type" => "mediumtext", "not null" => "1"),
985 "q4" => array("type" => "mediumtext", "not null" => "1"),
986 "q5" => array("type" => "mediumtext", "not null" => "1"),
987 "q6" => array("type" => "mediumtext", "not null" => "1"),
988 "q7" => array("type" => "mediumtext", "not null" => "1"),
989 "q8" => array("type" => "mediumtext", "not null" => "1"),
990 "q9" => array("type" => "mediumtext", "not null" => "1"),
993 "PRIMARY" => array("id"),
994 "uid" => array("uid"),
997 $database["poll_result"] = array(
999 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1000 "poll_id" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1001 "choice" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1004 "PRIMARY" => array("id"),
1005 "poll_id" => array("poll_id"),
1006 "choice" => array("choice"),
1009 $database["profile"] = array(
1011 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1012 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1013 "profile-name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1014 "is-default" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1015 "hide-friends" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1016 "name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1017 "pdesc" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1018 "dob" => array("type" => "varchar(32)", "not null" => "1", "default" => "0000-00-00"),
1019 "address" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1020 "locality" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1021 "region" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1022 "postal-code" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
1023 "country-name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1024 "hometown" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1025 "gender" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
1026 "marital" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1027 "with" => array("type" => "text", "not null" => "1"),
1028 "howlong" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1029 "sexual" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1030 "politic" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1031 "religion" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1032 "pub_keywords" => array("type" => "text", "not null" => "1"),
1033 "prv_keywords" => array("type" => "text", "not null" => "1"),
1034 "likes" => array("type" => "text", "not null" => "1"),
1035 "dislikes" => array("type" => "text", "not null" => "1"),
1036 "about" => array("type" => "text", "not null" => "1"),
1037 "summary" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1038 "music" => array("type" => "text", "not null" => "1"),
1039 "book" => array("type" => "text", "not null" => "1"),
1040 "tv" => array("type" => "text", "not null" => "1"),
1041 "film" => array("type" => "text", "not null" => "1"),
1042 "interest" => array("type" => "text", "not null" => "1"),
1043 "romance" => array("type" => "text", "not null" => "1"),
1044 "work" => array("type" => "text", "not null" => "1"),
1045 "education" => array("type" => "text", "not null" => "1"),
1046 "contact" => array("type" => "text", "not null" => "1"),
1047 "homepage" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1048 "photo" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1049 "thumb" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1050 "publish" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1051 "net-publish" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1054 "PRIMARY" => array("id"),
1055 "hometown" => array("hometown"),
1058 $database["profile_check"] = array(
1060 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1061 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1062 "cid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1063 "dfrn_id" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1064 "sec" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1065 "expire" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1068 "PRIMARY" => array("id"),
1071 $database["push_subscriber"] = array(
1073 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1074 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1075 "callback_url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1076 "topic" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1077 "nickname" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1078 "push" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1079 "last_update" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1080 "secret" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1083 "PRIMARY" => array("id"),
1086 $database["queue"] = array(
1088 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1089 "cid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1090 "network" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
1091 "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1092 "last" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1093 "content" => array("type" => "mediumtext", "not null" => "1"),
1094 "batch" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1097 "PRIMARY" => array("id"),
1098 "cid" => array("cid"),
1099 "created" => array("created"),
1100 "last" => array("last"),
1101 "network" => array("network"),
1102 "batch" => array("batch"),
1105 $database["register"] = array(
1107 "id" => array("type" => "int(11) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1108 "hash" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1109 "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1110 "uid" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"),
1111 "password" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1112 "language" => array("type" => "varchar(16)", "not null" => "1", "default" => ""),
1115 "PRIMARY" => array("id"),
1118 $database["search"] = array(
1120 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1121 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1122 "term" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1125 "PRIMARY" => array("id"),
1126 "uid" => array("uid"),
1127 "term" => array("term"),
1130 $database["session"] = array(
1132 "id" => array("type" => "bigint(20) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1133 "sid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1134 "data" => array("type" => "text", "not null" => "1"),
1135 "expire" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1138 "PRIMARY" => array("id"),
1139 "sid" => array("sid"),
1140 "expire" => array("expire"),
1143 $database["sign"] = array(
1145 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1146 "iid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1147 "retract_iid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1148 "signed_text" => array("type" => "mediumtext", "not null" => "1"),
1149 "signature" => array("type" => "text", "not null" => "1"),
1150 "signer" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1153 "PRIMARY" => array("id"),
1154 "iid" => array("iid"),
1155 "retract_iid" => array("retract_iid"),
1158 $database["spam"] = array(
1160 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1161 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1162 "spam" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1163 "ham" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1164 "term" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1165 "date" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1168 "PRIMARY" => array("id"),
1169 "uid" => array("uid"),
1170 "spam" => array("spam"),
1171 "ham" => array("ham"),
1172 "term" => array("term"),
1175 $database["term"] = array(
1177 "tid" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1178 "oid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1179 "otype" => array("type" => "tinyint(3) unsigned", "not null" => "1", "default" => "0"),
1180 "type" => array("type" => "tinyint(3) unsigned", "not null" => "1", "default" => "0"),
1181 "term" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1182 "url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1183 "aid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1184 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1187 "PRIMARY" => array("tid"),
1188 "oid_otype_type_term" => array("oid","otype","type","term"),
1189 "uid_term_tid" => array("uid","term","tid"),
1190 "type_term" => array("type","term"),
1191 "uid_otype_type_term_tid" => array("uid","otype","type","term","tid"),
1192 "otype_type_term_tid" => array("otype","type","term","tid"),
1195 $database["thread"] = array(
1197 "iid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0", "primary" => "1"),
1198 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1199 "contact-id" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"),
1200 "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1201 "edited" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1202 "commented" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1203 "received" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1204 "changed" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1205 "wall" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1206 "private" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1207 "pubmail" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1208 "moderated" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1209 "visible" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1210 "spam" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1211 "starred" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1212 "ignored" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1213 "bookmark" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1214 "unseen" => array("type" => "tinyint(1)", "not null" => "1", "default" => "1"),
1215 "deleted" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1216 "origin" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1217 "forum_mode" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1218 "mention" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1219 "network" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
1222 "PRIMARY" => array("iid"),
1223 "created" => array("created"),
1224 "commented" => array("commented"),
1225 "uid_network_commented" => array("uid","network","commented"),
1226 "uid_network_created" => array("uid","network","created"),
1227 "uid_contactid_commented" => array("uid","contact-id","commented"),
1228 "uid_contactid_created" => array("uid","contact-id","created"),
1229 "wall_private_received" => array("wall","private","received"),
1230 "uid_created" => array("uid","created"),
1231 "uid_commented" => array("uid","commented"),
1234 $database["tokens"] = array(
1236 "id" => array("type" => "varchar(40)", "not null" => "1", "primary" => "1"),
1237 "secret" => array("type" => "text", "not null" => "1"),
1238 "client_id" => array("type" => "varchar(20)", "not null" => "1", "default" => ""),
1239 "expires" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1240 "scope" => array("type" => "varchar(200)", "not null" => "1", "default" => ""),
1241 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1244 "PRIMARY" => array("id"),
1247 $database["unique_contacts"] = array(
1249 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1250 "url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1251 "nick" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1252 "name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1253 "avatar" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1254 "location" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1255 "about" => array("type" => "text", "not null" => "1"),
1258 "PRIMARY" => array("id"),
1259 "url" => array("url"),
1262 $database["user"] = array(
1264 "uid" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1265 "guid" => array("type" => "varchar(64)", "not null" => "1", "default" => ""),
1266 "username" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1267 "password" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1268 "nickname" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1269 "email" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1270 "openid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1271 "timezone" => array("type" => "varchar(128)", "not null" => "1", "default" => ""),
1272 "language" => array("type" => "varchar(32)", "not null" => "1", "default" => "en"),
1273 "register_date" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1274 "login_date" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1275 "default-location" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1276 "allow_location" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1277 "theme" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1278 "pubkey" => array("type" => "text", "not null" => "1"),
1279 "prvkey" => array("type" => "text", "not null" => "1"),
1280 "spubkey" => array("type" => "text", "not null" => "1"),
1281 "sprvkey" => array("type" => "text", "not null" => "1"),
1282 "verified" => array("type" => "tinyint(1) unsigned", "not null" => "1", "default" => "0"),
1283 "blocked" => array("type" => "tinyint(1) unsigned", "not null" => "1", "default" => "0"),
1284 "blockwall" => array("type" => "tinyint(1) unsigned", "not null" => "1", "default" => "0"),
1285 "hidewall" => array("type" => "tinyint(1) unsigned", "not null" => "1", "default" => "0"),
1286 "blocktags" => array("type" => "tinyint(1) unsigned", "not null" => "1", "default" => "0"),
1287 "unkmail" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1288 "cntunkmail" => array("type" => "int(11)", "not null" => "1", "default" => "10"),
1289 "notify-flags" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "65535"),
1290 "page-flags" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"),
1291 "prvnets" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1292 "pwdreset" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1293 "maxreq" => array("type" => "int(11)", "not null" => "1", "default" => "10"),
1294 "expire" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"),
1295 "account_removed" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1296 "account_expired" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1297 "account_expires_on" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1298 "expire_notification_sent" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1299 "service_class" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
1300 "def_gid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1301 "allow_cid" => array("type" => "mediumtext", "not null" => "1"),
1302 "allow_gid" => array("type" => "mediumtext", "not null" => "1"),
1303 "deny_cid" => array("type" => "mediumtext", "not null" => "1"),
1304 "deny_gid" => array("type" => "mediumtext", "not null" => "1"),
1305 "openidserver" => array("type" => "text", "not null" => "1"),
1308 "PRIMARY" => array("uid"),
1309 "nickname" => array("nickname"),
1312 $database["userd"] = array(
1314 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1315 "username" => array("type" => "varchar(255)", "not null" => "1"),
1318 "PRIMARY" => array("id"),
1319 "username" => array("username"),
1328 * run from command line
1330 function dbstructure_run(&$argv, &$argc) {
1338 @include(".htconfig.php");
1339 require_once("include/dba.php");
1340 $db = new dba($db_host, $db_user, $db_pass, $db_data);
1341 unset($db_host, $db_user, $db_pass, $db_data);
1344 update_structure(true, true);
1347 if (array_search(__file__,get_included_files())===0){
1348 dbstructure_run($argv,$argc);