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 "attag" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
417 "photo" => array("type" => "text", "not null" => "1"),
418 "thumb" => array("type" => "text", "not null" => "1"),
419 "micro" => array("type" => "text", "not null" => "1"),
420 "site-pubkey" => array("type" => "text", "not null" => "1"),
421 "issued-id" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
422 "dfrn-id" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
423 "url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
424 "nurl" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
425 "addr" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
426 "alias" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
427 "pubkey" => array("type" => "text", "not null" => "1"),
428 "prvkey" => array("type" => "text", "not null" => "1"),
429 "batch" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
430 "request" => array("type" => "text", "not null" => "1"),
431 "notify" => array("type" => "text", "not null" => "1"),
432 "poll" => array("type" => "text", "not null" => "1"),
433 "confirm" => array("type" => "text", "not null" => "1"),
434 "poco" => array("type" => "text", "not null" => "1"),
435 "aes_allow" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
436 "ret-aes" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
437 "usehub" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
438 "subhub" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
439 "hub-verify" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
440 "last-update" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
441 "success_update" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
442 "name-date" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
443 "uri-date" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
444 "avatar-date" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
445 "term-date" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
446 "priority" => array("type" => "tinyint(3)", "not null" => "1", "default" => "0"),
447 "blocked" => array("type" => "tinyint(1)", "not null" => "1", "default" => "1"),
448 "readonly" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
449 "writable" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
450 "forum" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
451 "prv" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
452 "hidden" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
453 "archive" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
454 "pending" => array("type" => "tinyint(1)", "not null" => "1", "default" => "1"),
455 "rating" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
456 "reason" => array("type" => "text", "not null" => "1"),
457 "closeness" => array("type" => "tinyint(2)", "not null" => "1", "default" => "99"),
458 "info" => array("type" => "mediumtext", "not null" => "1"),
459 "profile-id" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
460 "bdyear" => array("type" => "varchar(4)", "not null" => "1", "default" => ""),
461 "bd" => array("type" => "date", "not null" => "1", "default" => "0000-00-00"),
462 "notify_new_posts" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
463 "fetch_further_information" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
464 "ffi_keyword_blacklist" => array("type" => "mediumtext", "not null" => "1"),
467 "PRIMARY" => array("id"),
468 "uid" => array("uid"),
471 $database["conv"] = array(
473 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
474 "guid" => array("type" => "varchar(64)", "not null" => "1", "default" => ""),
475 "recips" => array("type" => "mediumtext", "not null" => "1"),
476 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
477 "creator" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
478 "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
479 "updated" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
480 "subject" => array("type" => "mediumtext", "not null" => "1"),
483 "PRIMARY" => array("id"),
484 "uid" => array("uid"),
487 $database["deliverq"] = array(
489 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
490 "cmd" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
491 "item" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
492 "contact" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
495 "PRIMARY" => array("id"),
498 $database["dsprphotoq"] = array(
500 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
501 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
502 "msg" => array("type" => "mediumtext", "not null" => "1"),
503 "attempt" => array("type" => "tinyint(4)", "not null" => "1", "default" => "0"),
506 "PRIMARY" => array("id"),
509 $database["event"] = array(
511 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
512 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
513 "cid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
514 "uri" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
515 "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
516 "edited" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
517 "start" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
518 "finish" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
519 "summary" => array("type" => "text", "not null" => "1"),
520 "desc" => array("type" => "text", "not null" => "1"),
521 "location" => array("type" => "text", "not null" => "1"),
522 "type" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
523 "nofinish" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
524 "adjust" => array("type" => "tinyint(1)", "not null" => "1", "default" => "1"),
525 "ignore" => array("type" => "tinyint(1) unsigned", "not null" => "1", "default" => "0"),
526 "allow_cid" => array("type" => "mediumtext", "not null" => "1"),
527 "allow_gid" => array("type" => "mediumtext", "not null" => "1"),
528 "deny_cid" => array("type" => "mediumtext", "not null" => "1"),
529 "deny_gid" => array("type" => "mediumtext", "not null" => "1"),
532 "PRIMARY" => array("id"),
533 "uid" => array("uid"),
536 $database["fcontact"] = array(
538 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
539 "url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
540 "name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
541 "photo" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
542 "request" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
543 "nick" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
544 "addr" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
545 "batch" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
546 "notify" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
547 "poll" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
548 "confirm" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
549 "priority" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
550 "network" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
551 "alias" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
552 "pubkey" => array("type" => "text", "not null" => "1"),
553 "updated" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
556 "PRIMARY" => array("id"),
557 "addr" => array("addr"),
560 $database["ffinder"] = array(
562 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
563 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
564 "cid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
565 "fid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
568 "PRIMARY" => array("id"),
571 $database["fserver"] = array(
573 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
574 "server" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
575 "posturl" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
576 "key" => array("type" => "text", "not null" => "1"),
579 "PRIMARY" => array("id"),
580 "server" => array("server"),
583 $database["fsuggest"] = array(
585 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
586 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
587 "cid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
588 "name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
589 "url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
590 "request" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
591 "photo" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
592 "note" => array("type" => "text", "not null" => "1"),
593 "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
596 "PRIMARY" => array("id"),
599 $database["gcign"] = array(
601 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
602 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
603 "gcid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
606 "PRIMARY" => array("id"),
607 "uid" => array("uid"),
608 "gcid" => array("gcid"),
611 $database["gcontact"] = array(
613 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
614 "name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
615 "url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
616 "nurl" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
617 "photo" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
618 "connect" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
621 "PRIMARY" => array("id"),
622 "nurl" => array("nurl"),
625 $database["glink"] = array(
627 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
628 "cid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
629 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
630 "gcid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
631 "zcid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
632 "updated" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
635 "PRIMARY" => array("id"),
636 "cid_uid_gcid_zcid" => array("cid","uid","gcid","zcid"),
637 "gcid" => array("gcid"),
638 "zcid" => array("zcid"),
641 $database["group"] = array(
643 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
644 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
645 "visible" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
646 "deleted" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
647 "name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
650 "PRIMARY" => array("id"),
651 "uid" => array("uid"),
654 $database["group_member"] = array(
656 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
657 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
658 "gid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
659 "contact-id" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
662 "PRIMARY" => array("id"),
663 "uid_gid_contactid" => array("uid","gid","contact-id"),
666 $database["guid"] = array(
668 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
669 "guid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
672 "PRIMARY" => array("id"),
673 "guid" => array("guid"),
676 $database["hook"] = array(
678 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
679 "hook" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
680 "file" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
681 "function" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
682 "priority" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"),
685 "PRIMARY" => array("id"),
686 "hook_file_function" => array("hook(30)","file(60)","function(30)"),
689 $database["intro"] = array(
691 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
692 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
693 "fid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
694 "contact-id" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
695 "knowyou" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
696 "duplex" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
697 "note" => array("type" => "text", "not null" => "1"),
698 "hash" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
699 "datetime" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
700 "blocked" => array("type" => "tinyint(1)", "not null" => "1", "default" => "1"),
701 "ignore" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
704 "PRIMARY" => array("id"),
707 $database["item"] = array(
709 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
710 "guid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
711 "uri" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
712 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
713 "contact-id" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
714 "type" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
715 "wall" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
716 "gravity" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
717 "parent" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
718 "parent-uri" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
719 "extid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
720 "thr-parent" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
721 "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
722 "edited" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
723 "commented" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
724 "received" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
725 "changed" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
726 "owner-name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
727 "owner-link" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
728 "owner-avatar" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
729 "author-name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
730 "author-link" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
731 "author-avatar" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
732 "title" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
733 "body" => array("type" => "mediumtext", "not null" => "1"),
734 "app" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
735 "verb" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
736 "object-type" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
737 "object" => array("type" => "text", "not null" => "1"),
738 "target-type" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
739 "target" => array("type" => "text", "not null" => "1"),
740 "postopts" => array("type" => "text", "not null" => "1"),
741 "plink" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
742 "resource-id" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
743 "event-id" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
744 "tag" => array("type" => "mediumtext", "not null" => "1"),
745 "attach" => array("type" => "mediumtext", "not null" => "1"),
746 "inform" => array("type" => "mediumtext", "not null" => "1"),
747 "file" => array("type" => "mediumtext", "not null" => "1"),
748 "location" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
749 "coord" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
750 "allow_cid" => array("type" => "mediumtext", "not null" => "1"),
751 "allow_gid" => array("type" => "mediumtext", "not null" => "1"),
752 "deny_cid" => array("type" => "mediumtext", "not null" => "1"),
753 "deny_gid" => array("type" => "mediumtext", "not null" => "1"),
754 "private" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
755 "pubmail" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
756 "moderated" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
757 "visible" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
758 "spam" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
759 "starred" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
760 "bookmark" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
761 "unseen" => array("type" => "tinyint(1)", "not null" => "1", "default" => "1"),
762 "deleted" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
763 "origin" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
764 "forum_mode" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
765 "last-child" => array("type" => "tinyint(1) unsigned", "not null" => "1", "default" => "1"),
766 "mention" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
767 "network" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
770 "PRIMARY" => array("id"),
771 "guid" => array("guid"),
772 "uri" => array("uri"),
773 "parent" => array("parent"),
774 "parent-uri" => array("parent-uri"),
775 "extid" => array("extid"),
776 "uid_id" => array("uid","id"),
777 "uid_created" => array("uid","created"),
778 "uid_unseen" => array("uid","unseen"),
779 "uid_network_received" => array("uid","network","received"),
780 "uid_received" => array("uid","received"),
781 "uid_network_commented" => array("uid","network","commented"),
782 "uid_commented" => array("uid","commented"),
783 "uid_title" => array("uid","title"),
784 "uid_thrparent" => array("uid","thr-parent"),
785 "uid_parenturi" => array("uid","parent-uri"),
786 "uid_contactid_created" => array("uid","contact-id","created"),
787 "wall_body" => array("wall","body(6)"),
788 "uid_visible_moderated_created" => array("uid","visible","moderated","created"),
789 "uid_uri" => array("uid","uri"),
790 "uid_wall_created" => array("uid","wall","created"),
791 "resource-id" => array("resource-id"),
792 "uid_type" => array("uid","type"),
793 "uid_starred" => array("uid","starred"),
794 "contactid_allowcid_allowpid_denycid_denygid" => array("contact-id","allow_cid(10)","allow_gid(10)","deny_cid(10)","deny_gid(10)"),
795 "uid_wall_parent_created" => array("uid","wall","parent","created"),
796 "uid_type_changed" => array("uid","type","changed"),
797 "contactid_verb" => array("contact-id","verb"),
798 "deleted_changed" => array("deleted","changed"),
799 "uid_wall_changed" => array("uid","wall","changed"),
800 "uid_eventid" => array("uid","event-id"),
801 "uid_authorlink" => array("uid","author-link"),
802 "uid_ownerlink" => array("uid","owner-link"),
805 $database["item_id"] = array(
807 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
808 "iid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
809 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
810 "sid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
811 "service" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
814 "PRIMARY" => array("id"),
815 "uid" => array("uid"),
816 "sid" => array("sid"),
817 "service" => array("service"),
818 "iid" => array("iid"),
821 $database["locks"] = array(
823 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
824 "name" => array("type" => "varchar(128)", "not null" => "1", "default" => ""),
825 "locked" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
828 "PRIMARY" => array("id"),
831 $database["mail"] = array(
833 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
834 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
835 "guid" => array("type" => "varchar(64)", "not null" => "1", "default" => ""),
836 "from-name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
837 "from-photo" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
838 "from-url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
839 "contact-id" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
840 "convid" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"),
841 "title" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
842 "body" => array("type" => "mediumtext", "not null" => "1"),
843 "seen" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
844 "reply" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
845 "replied" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
846 "unknown" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
847 "uri" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
848 "parent-uri" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
849 "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
852 "PRIMARY" => array("id"),
853 "uid" => array("uid"),
854 "guid" => array("guid"),
855 "convid" => array("convid"),
856 "reply" => array("reply"),
857 "uri" => array("uri"),
858 "parent-uri" => array("parent-uri"),
861 $database["mailacct"] = array(
863 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
864 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
865 "server" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
866 "port" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
867 "ssltype" => array("type" => "varchar(16)", "not null" => "1", "default" => ""),
868 "mailbox" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
869 "user" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
870 "pass" => array("type" => "text", "not null" => "1"),
871 "reply_to" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
872 "action" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
873 "movetofolder" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
874 "pubmail" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
875 "last_check" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
878 "PRIMARY" => array("id"),
881 $database["manage"] = array(
883 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
884 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
885 "mid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
888 "PRIMARY" => array("id"),
889 "uid_mid" => array("uid","mid"),
892 $database["notify"] = array(
894 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
895 "hash" => array("type" => "varchar(64)", "not null" => "1", "default" => ""),
896 "type" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
897 "name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
898 "url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
899 "photo" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
900 "date" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
901 "msg" => array("type" => "mediumtext", "not null" => "1"),
902 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
903 "link" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
904 "parent" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
905 "seen" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
906 "verb" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
907 "otype" => array("type" => "varchar(16)", "not null" => "1", "default" => ""),
910 "PRIMARY" => array("id"),
911 "uid" => array("uid"),
914 $database["notify-threads"] = array(
916 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
917 "notify-id" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
918 "master-parent-item" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
919 "parent-item" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
920 "receiver-uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
923 "PRIMARY" => array("id"),
924 "master-parent-item" => array("master-parent-item"),
925 "receiver-uid" => array("receiver-uid"),
928 $database["pconfig"] = array(
930 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
931 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
932 "cat" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
933 "k" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
934 "v" => array("type" => "mediumtext", "not null" => "1"),
937 "PRIMARY" => array("id"),
938 "uid_cat_k" => array("uid","cat(30)","k(30)"),
941 $database["photo"] = array(
943 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
944 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
945 "contact-id" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
946 "guid" => array("type" => "varchar(64)", "not null" => "1", "default" => ""),
947 "resource-id" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
948 "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
949 "edited" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
950 "title" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
951 "desc" => array("type" => "text", "not null" => "1"),
952 "album" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
953 "filename" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
954 "type" => array("type" => "varchar(128)", "not null" => "1", "default" => "image/jpeg"),
955 "height" => array("type" => "smallint(6)", "not null" => "1", "default" => "0"),
956 "width" => array("type" => "smallint(6)", "not null" => "1", "default" => "0"),
957 "datasize" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
958 "data" => array("type" => "mediumblob", "not null" => "1"),
959 "scale" => array("type" => "tinyint(3)", "not null" => "1", "default" => "0"),
960 "profile" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
961 "allow_cid" => array("type" => "mediumtext", "not null" => "1"),
962 "allow_gid" => array("type" => "mediumtext", "not null" => "1"),
963 "deny_cid" => array("type" => "mediumtext", "not null" => "1"),
964 "deny_gid" => array("type" => "mediumtext", "not null" => "1"),
967 "PRIMARY" => array("id"),
968 "uid" => array("uid"),
969 "resource-id" => array("resource-id"),
970 "guid" => array("guid"),
973 $database["poll"] = array(
975 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
976 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
977 "q0" => array("type" => "mediumtext", "not null" => "1"),
978 "q1" => array("type" => "mediumtext", "not null" => "1"),
979 "q2" => array("type" => "mediumtext", "not null" => "1"),
980 "q3" => array("type" => "mediumtext", "not null" => "1"),
981 "q4" => array("type" => "mediumtext", "not null" => "1"),
982 "q5" => array("type" => "mediumtext", "not null" => "1"),
983 "q6" => array("type" => "mediumtext", "not null" => "1"),
984 "q7" => array("type" => "mediumtext", "not null" => "1"),
985 "q8" => array("type" => "mediumtext", "not null" => "1"),
986 "q9" => array("type" => "mediumtext", "not null" => "1"),
989 "PRIMARY" => array("id"),
990 "uid" => array("uid"),
993 $database["poll_result"] = array(
995 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
996 "poll_id" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
997 "choice" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1000 "PRIMARY" => array("id"),
1001 "poll_id" => array("poll_id"),
1002 "choice" => array("choice"),
1005 $database["profile"] = array(
1007 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1008 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1009 "profile-name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1010 "is-default" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1011 "hide-friends" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1012 "name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1013 "pdesc" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1014 "dob" => array("type" => "varchar(32)", "not null" => "1", "default" => "0000-00-00"),
1015 "address" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1016 "locality" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1017 "region" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1018 "postal-code" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
1019 "country-name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1020 "hometown" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1021 "gender" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
1022 "marital" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1023 "with" => array("type" => "text", "not null" => "1"),
1024 "howlong" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1025 "sexual" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1026 "politic" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1027 "religion" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1028 "pub_keywords" => array("type" => "text", "not null" => "1"),
1029 "prv_keywords" => array("type" => "text", "not null" => "1"),
1030 "likes" => array("type" => "text", "not null" => "1"),
1031 "dislikes" => array("type" => "text", "not null" => "1"),
1032 "about" => array("type" => "text", "not null" => "1"),
1033 "summary" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1034 "music" => array("type" => "text", "not null" => "1"),
1035 "book" => array("type" => "text", "not null" => "1"),
1036 "tv" => array("type" => "text", "not null" => "1"),
1037 "film" => array("type" => "text", "not null" => "1"),
1038 "interest" => array("type" => "text", "not null" => "1"),
1039 "romance" => array("type" => "text", "not null" => "1"),
1040 "work" => array("type" => "text", "not null" => "1"),
1041 "education" => array("type" => "text", "not null" => "1"),
1042 "contact" => array("type" => "text", "not null" => "1"),
1043 "homepage" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1044 "photo" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1045 "thumb" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1046 "publish" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1047 "net-publish" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1050 "PRIMARY" => array("id"),
1051 "hometown" => array("hometown"),
1054 $database["profile_check"] = array(
1056 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1057 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1058 "cid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1059 "dfrn_id" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1060 "sec" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1061 "expire" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1064 "PRIMARY" => array("id"),
1067 $database["push_subscriber"] = array(
1069 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1070 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1071 "callback_url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1072 "topic" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1073 "nickname" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1074 "push" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1075 "last_update" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1076 "secret" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1079 "PRIMARY" => array("id"),
1082 $database["queue"] = array(
1084 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1085 "cid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1086 "network" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
1087 "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1088 "last" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1089 "content" => array("type" => "mediumtext", "not null" => "1"),
1090 "batch" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1093 "PRIMARY" => array("id"),
1094 "cid" => array("cid"),
1095 "created" => array("created"),
1096 "last" => array("last"),
1097 "network" => array("network"),
1098 "batch" => array("batch"),
1101 $database["register"] = array(
1103 "id" => array("type" => "int(11) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1104 "hash" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1105 "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1106 "uid" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"),
1107 "password" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1108 "language" => array("type" => "varchar(16)", "not null" => "1", "default" => ""),
1111 "PRIMARY" => array("id"),
1114 $database["search"] = array(
1116 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1117 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1118 "term" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1121 "PRIMARY" => array("id"),
1122 "uid" => array("uid"),
1123 "term" => array("term"),
1126 $database["session"] = array(
1128 "id" => array("type" => "bigint(20) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1129 "sid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1130 "data" => array("type" => "text", "not null" => "1"),
1131 "expire" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1134 "PRIMARY" => array("id"),
1135 "sid" => array("sid"),
1136 "expire" => array("expire"),
1139 $database["sign"] = array(
1141 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1142 "iid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1143 "retract_iid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1144 "signed_text" => array("type" => "mediumtext", "not null" => "1"),
1145 "signature" => array("type" => "text", "not null" => "1"),
1146 "signer" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1149 "PRIMARY" => array("id"),
1150 "iid" => array("iid"),
1151 "retract_iid" => array("retract_iid"),
1154 $database["spam"] = array(
1156 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1157 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1158 "spam" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1159 "ham" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1160 "term" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1161 "date" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1164 "PRIMARY" => array("id"),
1165 "uid" => array("uid"),
1166 "spam" => array("spam"),
1167 "ham" => array("ham"),
1168 "term" => array("term"),
1171 $database["term"] = array(
1173 "tid" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1174 "oid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1175 "otype" => array("type" => "tinyint(3) unsigned", "not null" => "1", "default" => "0"),
1176 "type" => array("type" => "tinyint(3) unsigned", "not null" => "1", "default" => "0"),
1177 "term" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1178 "url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1179 "aid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1180 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1183 "PRIMARY" => array("tid"),
1184 "oid_otype_type_term" => array("oid","otype","type","term"),
1185 "uid_term_tid" => array("uid","term","tid"),
1186 "type_term" => array("type","term"),
1187 "uid_otype_type_term_tid" => array("uid","otype","type","term","tid"),
1188 "otype_type_term_tid" => array("otype","type","term","tid"),
1191 $database["thread"] = array(
1193 "iid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0", "primary" => "1"),
1194 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1195 "contact-id" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"),
1196 "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1197 "edited" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1198 "commented" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1199 "received" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1200 "changed" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1201 "wall" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1202 "private" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1203 "pubmail" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1204 "moderated" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1205 "visible" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1206 "spam" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1207 "starred" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1208 "ignored" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1209 "bookmark" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1210 "unseen" => array("type" => "tinyint(1)", "not null" => "1", "default" => "1"),
1211 "deleted" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1212 "origin" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1213 "forum_mode" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1214 "mention" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1215 "network" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
1218 "PRIMARY" => array("iid"),
1219 "created" => array("created"),
1220 "commented" => array("commented"),
1221 "uid_network_commented" => array("uid","network","commented"),
1222 "uid_network_created" => array("uid","network","created"),
1223 "uid_contactid_commented" => array("uid","contact-id","commented"),
1224 "uid_contactid_created" => array("uid","contact-id","created"),
1225 "wall_private_received" => array("wall","private","received"),
1226 "uid_created" => array("uid","created"),
1227 "uid_commented" => array("uid","commented"),
1230 $database["tokens"] = array(
1232 "id" => array("type" => "varchar(40)", "not null" => "1", "primary" => "1"),
1233 "secret" => array("type" => "text", "not null" => "1"),
1234 "client_id" => array("type" => "varchar(20)", "not null" => "1", "default" => ""),
1235 "expires" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1236 "scope" => array("type" => "varchar(200)", "not null" => "1", "default" => ""),
1237 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1240 "PRIMARY" => array("id"),
1243 $database["unique_contacts"] = array(
1245 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1246 "url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1247 "nick" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1248 "name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1249 "avatar" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1252 "PRIMARY" => array("id"),
1253 "url" => array("url"),
1256 $database["user"] = array(
1258 "uid" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1259 "guid" => array("type" => "varchar(64)", "not null" => "1", "default" => ""),
1260 "username" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1261 "password" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1262 "nickname" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1263 "email" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1264 "openid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1265 "timezone" => array("type" => "varchar(128)", "not null" => "1", "default" => ""),
1266 "language" => array("type" => "varchar(32)", "not null" => "1", "default" => "en"),
1267 "register_date" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1268 "login_date" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1269 "default-location" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1270 "allow_location" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1271 "theme" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1272 "pubkey" => array("type" => "text", "not null" => "1"),
1273 "prvkey" => array("type" => "text", "not null" => "1"),
1274 "spubkey" => array("type" => "text", "not null" => "1"),
1275 "sprvkey" => array("type" => "text", "not null" => "1"),
1276 "verified" => array("type" => "tinyint(1) unsigned", "not null" => "1", "default" => "0"),
1277 "blocked" => array("type" => "tinyint(1) unsigned", "not null" => "1", "default" => "0"),
1278 "blockwall" => array("type" => "tinyint(1) unsigned", "not null" => "1", "default" => "0"),
1279 "hidewall" => array("type" => "tinyint(1) unsigned", "not null" => "1", "default" => "0"),
1280 "blocktags" => array("type" => "tinyint(1) unsigned", "not null" => "1", "default" => "0"),
1281 "unkmail" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1282 "cntunkmail" => array("type" => "int(11)", "not null" => "1", "default" => "10"),
1283 "notify-flags" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "65535"),
1284 "page-flags" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"),
1285 "prvnets" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1286 "pwdreset" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1287 "maxreq" => array("type" => "int(11)", "not null" => "1", "default" => "10"),
1288 "expire" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"),
1289 "account_removed" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1290 "account_expired" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1291 "account_expires_on" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1292 "expire_notification_sent" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1293 "service_class" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
1294 "def_gid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1295 "allow_cid" => array("type" => "mediumtext", "not null" => "1"),
1296 "allow_gid" => array("type" => "mediumtext", "not null" => "1"),
1297 "deny_cid" => array("type" => "mediumtext", "not null" => "1"),
1298 "deny_gid" => array("type" => "mediumtext", "not null" => "1"),
1299 "openidserver" => array("type" => "text", "not null" => "1"),
1302 "PRIMARY" => array("uid"),
1303 "nickname" => array("nickname"),
1306 $database["userd"] = array(
1308 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1309 "username" => array("type" => "varchar(255)", "not null" => "1"),
1312 "PRIMARY" => array("id"),
1313 "username" => array("username"),
1322 * run from command line
1324 function dbstructure_run(&$argv, &$argc) {
1332 @include(".htconfig.php");
1333 require_once("include/dba.php");
1334 $db = new dba($db_host, $db_user, $db_pass, $db_data);
1335 unset($db_host, $db_user, $db_pass, $db_data);
1338 update_structure(true, true);
1341 if (array_search(__file__,get_included_files())===0){
1342 dbstructure_run($argv,$argc);