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" => ""),
619 "updated" => array("type" => "datetime", "default" => "0000-00-00 00:00:00"),
622 "PRIMARY" => array("id"),
623 "nurl" => array("nurl"),
626 $database["glink"] = array(
628 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
629 "cid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
630 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
631 "gcid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
632 "zcid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
633 "updated" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
636 "PRIMARY" => array("id"),
637 "cid_uid_gcid_zcid" => array("cid","uid","gcid","zcid"),
638 "gcid" => array("gcid"),
639 "zcid" => array("zcid"),
642 $database["group"] = array(
644 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
645 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
646 "visible" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
647 "deleted" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
648 "name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
651 "PRIMARY" => array("id"),
652 "uid" => array("uid"),
655 $database["group_member"] = array(
657 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
658 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
659 "gid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
660 "contact-id" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
663 "PRIMARY" => array("id"),
664 "uid_gid_contactid" => array("uid","gid","contact-id"),
667 $database["guid"] = array(
669 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
670 "guid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
673 "PRIMARY" => array("id"),
674 "guid" => array("guid"),
677 $database["hook"] = array(
679 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
680 "hook" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
681 "file" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
682 "function" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
683 "priority" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"),
686 "PRIMARY" => array("id"),
687 "hook_file_function" => array("hook(30)","file(60)","function(30)"),
690 $database["intro"] = array(
692 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
693 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
694 "fid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
695 "contact-id" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
696 "knowyou" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
697 "duplex" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
698 "note" => array("type" => "text", "not null" => "1"),
699 "hash" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
700 "datetime" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
701 "blocked" => array("type" => "tinyint(1)", "not null" => "1", "default" => "1"),
702 "ignore" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
705 "PRIMARY" => array("id"),
708 $database["item"] = array(
710 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
711 "guid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
712 "uri" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
713 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
714 "contact-id" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
715 "type" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
716 "wall" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
717 "gravity" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
718 "parent" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
719 "parent-uri" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
720 "extid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
721 "thr-parent" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
722 "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
723 "edited" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
724 "commented" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
725 "received" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
726 "changed" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
727 "owner-name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
728 "owner-link" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
729 "owner-avatar" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
730 "author-name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
731 "author-link" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
732 "author-avatar" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
733 "title" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
734 "body" => array("type" => "mediumtext", "not null" => "1"),
735 "app" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
736 "verb" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
737 "object-type" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
738 "object" => array("type" => "text", "not null" => "1"),
739 "target-type" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
740 "target" => array("type" => "text", "not null" => "1"),
741 "postopts" => array("type" => "text", "not null" => "1"),
742 "plink" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
743 "resource-id" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
744 "event-id" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
745 "tag" => array("type" => "mediumtext", "not null" => "1"),
746 "attach" => array("type" => "mediumtext", "not null" => "1"),
747 "inform" => array("type" => "mediumtext", "not null" => "1"),
748 "file" => array("type" => "mediumtext", "not null" => "1"),
749 "location" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
750 "coord" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
751 "allow_cid" => array("type" => "mediumtext", "not null" => "1"),
752 "allow_gid" => array("type" => "mediumtext", "not null" => "1"),
753 "deny_cid" => array("type" => "mediumtext", "not null" => "1"),
754 "deny_gid" => array("type" => "mediumtext", "not null" => "1"),
755 "private" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
756 "pubmail" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
757 "moderated" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
758 "visible" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
759 "spam" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
760 "starred" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
761 "bookmark" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
762 "unseen" => array("type" => "tinyint(1)", "not null" => "1", "default" => "1"),
763 "deleted" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
764 "origin" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
765 "forum_mode" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
766 "last-child" => array("type" => "tinyint(1) unsigned", "not null" => "1", "default" => "1"),
767 "mention" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
768 "network" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
771 "PRIMARY" => array("id"),
772 "guid" => array("guid"),
773 "uri" => array("uri"),
774 "parent" => array("parent"),
775 "parent-uri" => array("parent-uri"),
776 "extid" => array("extid"),
777 "uid_id" => array("uid","id"),
778 "uid_created" => array("uid","created"),
779 "uid_unseen" => array("uid","unseen"),
780 "uid_network_received" => array("uid","network","received"),
781 "uid_received" => array("uid","received"),
782 "uid_network_commented" => array("uid","network","commented"),
783 "uid_commented" => array("uid","commented"),
784 "uid_title" => array("uid","title"),
785 "uid_thrparent" => array("uid","thr-parent"),
786 "uid_parenturi" => array("uid","parent-uri"),
787 "uid_contactid_created" => array("uid","contact-id","created"),
788 "wall_body" => array("wall","body(6)"),
789 "uid_visible_moderated_created" => array("uid","visible","moderated","created"),
790 "uid_uri" => array("uid","uri"),
791 "uid_wall_created" => array("uid","wall","created"),
792 "resource-id" => array("resource-id"),
793 "uid_type" => array("uid","type"),
794 "uid_starred" => array("uid","starred"),
795 "contactid_allowcid_allowpid_denycid_denygid" => array("contact-id","allow_cid(10)","allow_gid(10)","deny_cid(10)","deny_gid(10)"),
796 "uid_wall_parent_created" => array("uid","wall","parent","created"),
797 "uid_type_changed" => array("uid","type","changed"),
798 "contactid_verb" => array("contact-id","verb"),
799 "deleted_changed" => array("deleted","changed"),
800 "uid_wall_changed" => array("uid","wall","changed"),
801 "uid_eventid" => array("uid","event-id"),
802 "uid_authorlink" => array("uid","author-link"),
803 "uid_ownerlink" => array("uid","owner-link"),
806 $database["item_id"] = array(
808 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
809 "iid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
810 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
811 "sid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
812 "service" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
815 "PRIMARY" => array("id"),
816 "uid" => array("uid"),
817 "sid" => array("sid"),
818 "service" => array("service"),
819 "iid" => array("iid"),
822 $database["locks"] = array(
824 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
825 "name" => array("type" => "varchar(128)", "not null" => "1", "default" => ""),
826 "locked" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
827 "created" => array("type" => "datetime", "default" => "0000-00-00 00:00:00"),
830 "PRIMARY" => array("id"),
833 $database["mail"] = array(
835 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
836 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
837 "guid" => array("type" => "varchar(64)", "not null" => "1", "default" => ""),
838 "from-name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
839 "from-photo" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
840 "from-url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
841 "contact-id" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
842 "convid" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"),
843 "title" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
844 "body" => array("type" => "mediumtext", "not null" => "1"),
845 "seen" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
846 "reply" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
847 "replied" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
848 "unknown" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
849 "uri" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
850 "parent-uri" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
851 "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
854 "PRIMARY" => array("id"),
855 "uid" => array("uid"),
856 "guid" => array("guid"),
857 "convid" => array("convid"),
858 "reply" => array("reply"),
859 "uri" => array("uri"),
860 "parent-uri" => array("parent-uri"),
863 $database["mailacct"] = array(
865 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
866 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
867 "server" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
868 "port" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
869 "ssltype" => array("type" => "varchar(16)", "not null" => "1", "default" => ""),
870 "mailbox" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
871 "user" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
872 "pass" => array("type" => "text", "not null" => "1"),
873 "reply_to" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
874 "action" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
875 "movetofolder" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
876 "pubmail" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
877 "last_check" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
880 "PRIMARY" => array("id"),
883 $database["manage"] = array(
885 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
886 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
887 "mid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
890 "PRIMARY" => array("id"),
891 "uid_mid" => array("uid","mid"),
894 $database["notify"] = array(
896 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
897 "hash" => array("type" => "varchar(64)", "not null" => "1", "default" => ""),
898 "type" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
899 "name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
900 "url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
901 "photo" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
902 "date" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
903 "msg" => array("type" => "mediumtext", "not null" => "1"),
904 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
905 "link" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
906 "parent" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
907 "seen" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
908 "verb" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
909 "otype" => array("type" => "varchar(16)", "not null" => "1", "default" => ""),
912 "PRIMARY" => array("id"),
913 "uid" => array("uid"),
916 $database["notify-threads"] = array(
918 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
919 "notify-id" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
920 "master-parent-item" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
921 "parent-item" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
922 "receiver-uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
925 "PRIMARY" => array("id"),
926 "master-parent-item" => array("master-parent-item"),
927 "receiver-uid" => array("receiver-uid"),
930 $database["pconfig"] = array(
932 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
933 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
934 "cat" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
935 "k" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
936 "v" => array("type" => "mediumtext", "not null" => "1"),
939 "PRIMARY" => array("id"),
940 "uid_cat_k" => array("uid","cat(30)","k(30)"),
943 $database["photo"] = array(
945 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
946 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
947 "contact-id" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
948 "guid" => array("type" => "varchar(64)", "not null" => "1", "default" => ""),
949 "resource-id" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
950 "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
951 "edited" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
952 "title" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
953 "desc" => array("type" => "text", "not null" => "1"),
954 "album" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
955 "filename" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
956 "type" => array("type" => "varchar(128)", "not null" => "1", "default" => "image/jpeg"),
957 "height" => array("type" => "smallint(6)", "not null" => "1", "default" => "0"),
958 "width" => array("type" => "smallint(6)", "not null" => "1", "default" => "0"),
959 "datasize" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
960 "data" => array("type" => "mediumblob", "not null" => "1"),
961 "scale" => array("type" => "tinyint(3)", "not null" => "1", "default" => "0"),
962 "profile" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
963 "allow_cid" => array("type" => "mediumtext", "not null" => "1"),
964 "allow_gid" => array("type" => "mediumtext", "not null" => "1"),
965 "deny_cid" => array("type" => "mediumtext", "not null" => "1"),
966 "deny_gid" => array("type" => "mediumtext", "not null" => "1"),
969 "PRIMARY" => array("id"),
970 "uid" => array("uid"),
971 "resource-id" => array("resource-id"),
972 "guid" => array("guid"),
975 $database["poll"] = array(
977 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
978 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
979 "q0" => array("type" => "mediumtext", "not null" => "1"),
980 "q1" => array("type" => "mediumtext", "not null" => "1"),
981 "q2" => array("type" => "mediumtext", "not null" => "1"),
982 "q3" => array("type" => "mediumtext", "not null" => "1"),
983 "q4" => array("type" => "mediumtext", "not null" => "1"),
984 "q5" => array("type" => "mediumtext", "not null" => "1"),
985 "q6" => array("type" => "mediumtext", "not null" => "1"),
986 "q7" => array("type" => "mediumtext", "not null" => "1"),
987 "q8" => array("type" => "mediumtext", "not null" => "1"),
988 "q9" => array("type" => "mediumtext", "not null" => "1"),
991 "PRIMARY" => array("id"),
992 "uid" => array("uid"),
995 $database["poll_result"] = array(
997 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
998 "poll_id" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
999 "choice" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1002 "PRIMARY" => array("id"),
1003 "poll_id" => array("poll_id"),
1004 "choice" => array("choice"),
1007 $database["profile"] = array(
1009 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1010 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1011 "profile-name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1012 "is-default" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1013 "hide-friends" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1014 "name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1015 "pdesc" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1016 "dob" => array("type" => "varchar(32)", "not null" => "1", "default" => "0000-00-00"),
1017 "address" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1018 "locality" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1019 "region" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1020 "postal-code" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
1021 "country-name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1022 "hometown" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1023 "gender" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
1024 "marital" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1025 "with" => array("type" => "text", "not null" => "1"),
1026 "howlong" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1027 "sexual" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1028 "politic" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1029 "religion" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1030 "pub_keywords" => array("type" => "text", "not null" => "1"),
1031 "prv_keywords" => array("type" => "text", "not null" => "1"),
1032 "likes" => array("type" => "text", "not null" => "1"),
1033 "dislikes" => array("type" => "text", "not null" => "1"),
1034 "about" => array("type" => "text", "not null" => "1"),
1035 "summary" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1036 "music" => array("type" => "text", "not null" => "1"),
1037 "book" => array("type" => "text", "not null" => "1"),
1038 "tv" => array("type" => "text", "not null" => "1"),
1039 "film" => array("type" => "text", "not null" => "1"),
1040 "interest" => array("type" => "text", "not null" => "1"),
1041 "romance" => array("type" => "text", "not null" => "1"),
1042 "work" => array("type" => "text", "not null" => "1"),
1043 "education" => array("type" => "text", "not null" => "1"),
1044 "contact" => array("type" => "text", "not null" => "1"),
1045 "homepage" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1046 "photo" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1047 "thumb" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1048 "publish" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1049 "net-publish" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1052 "PRIMARY" => array("id"),
1053 "hometown" => array("hometown"),
1056 $database["profile_check"] = array(
1058 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1059 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1060 "cid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1061 "dfrn_id" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1062 "sec" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1063 "expire" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1066 "PRIMARY" => array("id"),
1069 $database["push_subscriber"] = array(
1071 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1072 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1073 "callback_url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1074 "topic" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1075 "nickname" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1076 "push" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1077 "last_update" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1078 "secret" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1081 "PRIMARY" => array("id"),
1084 $database["queue"] = array(
1086 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1087 "cid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1088 "network" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
1089 "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1090 "last" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1091 "content" => array("type" => "mediumtext", "not null" => "1"),
1092 "batch" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1095 "PRIMARY" => array("id"),
1096 "cid" => array("cid"),
1097 "created" => array("created"),
1098 "last" => array("last"),
1099 "network" => array("network"),
1100 "batch" => array("batch"),
1103 $database["register"] = array(
1105 "id" => array("type" => "int(11) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1106 "hash" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1107 "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1108 "uid" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"),
1109 "password" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1110 "language" => array("type" => "varchar(16)", "not null" => "1", "default" => ""),
1113 "PRIMARY" => array("id"),
1116 $database["search"] = array(
1118 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1119 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1120 "term" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1123 "PRIMARY" => array("id"),
1124 "uid" => array("uid"),
1125 "term" => array("term"),
1128 $database["session"] = array(
1130 "id" => array("type" => "bigint(20) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1131 "sid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1132 "data" => array("type" => "text", "not null" => "1"),
1133 "expire" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1136 "PRIMARY" => array("id"),
1137 "sid" => array("sid"),
1138 "expire" => array("expire"),
1141 $database["sign"] = array(
1143 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1144 "iid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1145 "retract_iid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1146 "signed_text" => array("type" => "mediumtext", "not null" => "1"),
1147 "signature" => array("type" => "text", "not null" => "1"),
1148 "signer" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1151 "PRIMARY" => array("id"),
1152 "iid" => array("iid"),
1153 "retract_iid" => array("retract_iid"),
1156 $database["spam"] = array(
1158 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1159 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1160 "spam" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1161 "ham" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1162 "term" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1163 "date" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1166 "PRIMARY" => array("id"),
1167 "uid" => array("uid"),
1168 "spam" => array("spam"),
1169 "ham" => array("ham"),
1170 "term" => array("term"),
1173 $database["term"] = array(
1175 "tid" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1176 "oid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1177 "otype" => array("type" => "tinyint(3) unsigned", "not null" => "1", "default" => "0"),
1178 "type" => array("type" => "tinyint(3) unsigned", "not null" => "1", "default" => "0"),
1179 "term" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1180 "url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1181 "aid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1182 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1185 "PRIMARY" => array("tid"),
1186 "oid_otype_type_term" => array("oid","otype","type","term"),
1187 "uid_term_tid" => array("uid","term","tid"),
1188 "type_term" => array("type","term"),
1189 "uid_otype_type_term_tid" => array("uid","otype","type","term","tid"),
1190 "otype_type_term_tid" => array("otype","type","term","tid"),
1193 $database["thread"] = array(
1195 "iid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0", "primary" => "1"),
1196 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1197 "contact-id" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"),
1198 "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1199 "edited" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1200 "commented" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1201 "received" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1202 "changed" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1203 "wall" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1204 "private" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1205 "pubmail" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1206 "moderated" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1207 "visible" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1208 "spam" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1209 "starred" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1210 "ignored" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1211 "bookmark" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1212 "unseen" => array("type" => "tinyint(1)", "not null" => "1", "default" => "1"),
1213 "deleted" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1214 "origin" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1215 "forum_mode" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1216 "mention" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1217 "network" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
1220 "PRIMARY" => array("iid"),
1221 "created" => array("created"),
1222 "commented" => array("commented"),
1223 "uid_network_commented" => array("uid","network","commented"),
1224 "uid_network_created" => array("uid","network","created"),
1225 "uid_contactid_commented" => array("uid","contact-id","commented"),
1226 "uid_contactid_created" => array("uid","contact-id","created"),
1227 "wall_private_received" => array("wall","private","received"),
1228 "uid_created" => array("uid","created"),
1229 "uid_commented" => array("uid","commented"),
1232 $database["tokens"] = array(
1234 "id" => array("type" => "varchar(40)", "not null" => "1", "primary" => "1"),
1235 "secret" => array("type" => "text", "not null" => "1"),
1236 "client_id" => array("type" => "varchar(20)", "not null" => "1", "default" => ""),
1237 "expires" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1238 "scope" => array("type" => "varchar(200)", "not null" => "1", "default" => ""),
1239 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1242 "PRIMARY" => array("id"),
1245 $database["unique_contacts"] = array(
1247 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1248 "url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1249 "nick" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1250 "name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1251 "avatar" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1254 "PRIMARY" => array("id"),
1255 "url" => array("url"),
1258 $database["user"] = array(
1260 "uid" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1261 "guid" => array("type" => "varchar(64)", "not null" => "1", "default" => ""),
1262 "username" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1263 "password" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1264 "nickname" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1265 "email" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1266 "openid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1267 "timezone" => array("type" => "varchar(128)", "not null" => "1", "default" => ""),
1268 "language" => array("type" => "varchar(32)", "not null" => "1", "default" => "en"),
1269 "register_date" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1270 "login_date" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1271 "default-location" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1272 "allow_location" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1273 "theme" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1274 "pubkey" => array("type" => "text", "not null" => "1"),
1275 "prvkey" => array("type" => "text", "not null" => "1"),
1276 "spubkey" => array("type" => "text", "not null" => "1"),
1277 "sprvkey" => array("type" => "text", "not null" => "1"),
1278 "verified" => array("type" => "tinyint(1) unsigned", "not null" => "1", "default" => "0"),
1279 "blocked" => array("type" => "tinyint(1) unsigned", "not null" => "1", "default" => "0"),
1280 "blockwall" => array("type" => "tinyint(1) unsigned", "not null" => "1", "default" => "0"),
1281 "hidewall" => array("type" => "tinyint(1) unsigned", "not null" => "1", "default" => "0"),
1282 "blocktags" => array("type" => "tinyint(1) unsigned", "not null" => "1", "default" => "0"),
1283 "unkmail" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1284 "cntunkmail" => array("type" => "int(11)", "not null" => "1", "default" => "10"),
1285 "notify-flags" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "65535"),
1286 "page-flags" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"),
1287 "prvnets" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1288 "pwdreset" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1289 "maxreq" => array("type" => "int(11)", "not null" => "1", "default" => "10"),
1290 "expire" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"),
1291 "account_removed" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1292 "account_expired" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1293 "account_expires_on" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1294 "expire_notification_sent" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1295 "service_class" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
1296 "def_gid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1297 "allow_cid" => array("type" => "mediumtext", "not null" => "1"),
1298 "allow_gid" => array("type" => "mediumtext", "not null" => "1"),
1299 "deny_cid" => array("type" => "mediumtext", "not null" => "1"),
1300 "deny_gid" => array("type" => "mediumtext", "not null" => "1"),
1301 "openidserver" => array("type" => "text", "not null" => "1"),
1304 "PRIMARY" => array("uid"),
1305 "nickname" => array("nickname"),
1308 $database["userd"] = array(
1310 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1311 "username" => array("type" => "varchar(255)", "not null" => "1"),
1314 "PRIMARY" => array("id"),
1315 "username" => array("username"),
1324 * run from command line
1326 function dbstructure_run(&$argv, &$argc) {
1334 @include(".htconfig.php");
1335 require_once("include/dba.php");
1336 $db = new dba($db_host, $db_user, $db_pass, $db_data);
1337 unset($db_host, $db_user, $db_pass, $db_data);
1340 update_structure(true, true);
1343 if (array_search(__file__,get_included_files())===0){
1344 dbstructure_run($argv,$argc);