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