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 echo "-- ------------------------------------------\n";
110 echo "-- ".FRIENDICA_PLATFORM." ".FRIENDICA_VERSION." (".FRIENDICA_CODENAME,")\n";
111 echo "-- DB_UPDATE_VERSION ".DB_UPDATE_VERSION."\n";
112 echo "-- ------------------------------------------\n\n\n";
113 foreach ($database AS $name => $structure) {
115 echo "-- TABLE $name\n";
117 db_create_table($name, $structure['fields'], true, false, $structure["indexes"]);
123 function update_structure($verbose, $action) {
128 logger('updating structure', LOGGER_DEBUG);
130 // Get the current structure
133 $tables = q("show tables");
135 foreach ($tables AS $table) {
136 $table = current($table);
138 $database[$table] = table_structure($table);
141 // Get the definition
142 $definition = db_definition();
145 foreach ($definition AS $name => $structure) {
147 if (!isset($database[$name])) {
148 $r = db_create_table($name, $structure["fields"], $verbose, $action);
150 $errors .= t('Errors encountered creating database tables.').$name.EOL;
152 // Drop the index if it isn't present in the definition
153 foreach ($database[$name]["indexes"] AS $indexname => $fieldnames)
154 if (!isset($structure["indexes"][$indexname])) {
155 $sql2=db_drop_index($indexname);
157 $sql3 = "ALTER TABLE `".$name."` ".$sql2;
162 // Compare the field structure field by field
163 foreach ($structure["fields"] AS $fieldname => $parameters) {
164 if (!isset($database[$name]["fields"][$fieldname])) {
165 $sql2=db_add_table_field($fieldname, $parameters);
167 $sql3 = "ALTER TABLE `".$name."` ".$sql2;
171 // Compare the field definition
172 $current_field_definition = implode(",",$database[$name]["fields"][$fieldname]);
173 $new_field_definition = implode(",",$parameters);
174 if ($current_field_definition != $new_field_definition) {
175 $sql2=db_modify_table_field($fieldname, $parameters);
177 $sql3 = "ALTER TABLE `".$name."` ".$sql2;
187 foreach ($structure["indexes"] AS $indexname => $fieldnames) {
188 if (!isset($database[$name]["indexes"][$indexname])) {
189 $sql2=db_create_index($indexname, $fieldnames);
192 $sql3 = "ALTER TABLE `".$name."` ".$sql2;
208 $errors .= t('Errors encountered performing database changes.').$sql3.EOL;
216 function db_field_command($parameters, $create = true) {
217 $fieldstruct = $parameters["type"];
219 if ($parameters["not null"])
220 $fieldstruct .= " NOT NULL";
222 if (isset($parameters["default"])){
223 if (strpos(strtolower($parameters["type"]),"int")!==false) {
224 $fieldstruct .= " DEFAULT ".$parameters["default"];
226 $fieldstruct .= " DEFAULT '".$parameters["default"]."'";
229 if ($parameters["extra"] != "")
230 $fieldstruct .= " ".$parameters["extra"];
232 if (($parameters["primary"] != "") AND $create)
233 $fieldstruct .= " PRIMARY KEY";
235 return($fieldstruct);
238 function db_create_table($name, $fields, $verbose, $action, $indexes=null) {
245 foreach($fields AS $fieldname => $field) {
246 $sql_rows[] = "`".dbesc($fieldname)."` ".db_field_command($field);
249 if (!is_null($indexes)) {
251 foreach ($indexes AS $indexname => $fieldnames) {
252 $sql_index = db_create_index($indexname, $fieldnames, "");
253 if (!is_null($sql_index)) $sql_rows[] = $sql_index;
257 $sql = implode(",\n\t", $sql_rows);
259 $sql = sprintf("CREATE TABLE IF NOT EXISTS `%s` (\n\t", 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, $method="ADD") {
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 $method = strtoupper(trim($method));
302 if ($method!="" && $method!="ADD") {
303 throw new Exception("Invalid parameter 'method' in db_create_index(): '$method'");
307 $sql = sprintf("%s INDEX `%s` (%s)", $method, dbesc($indexname), $names);
311 function db_definition() {
315 $database["addon"] = array(
317 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
318 "name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
319 "version" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
320 "installed" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
321 "hidden" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
322 "timestamp" => array("type" => "bigint(20)", "not null" => "1", "default" => "0"),
323 "plugin_admin" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
326 "PRIMARY" => array("id"),
329 $database["attach"] = array(
331 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
332 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
333 "hash" => array("type" => "varchar(64)", "not null" => "1", "default" => ""),
334 "filename" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
335 "filetype" => array("type" => "varchar(64)", "not null" => "1", "default" => ""),
336 "filesize" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
337 "data" => array("type" => "longblob", "not null" => "1"),
338 "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
339 "edited" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
340 "allow_cid" => array("type" => "mediumtext", "not null" => "1"),
341 "allow_gid" => array("type" => "mediumtext", "not null" => "1"),
342 "deny_cid" => array("type" => "mediumtext", "not null" => "1"),
343 "deny_gid" => array("type" => "mediumtext", "not null" => "1"),
346 "PRIMARY" => array("id"),
349 $database["auth_codes"] = array(
351 "id" => array("type" => "varchar(40)", "not null" => "1", "primary" => "1"),
352 "client_id" => array("type" => "varchar(20)", "not null" => "1", "default" => ""),
353 "redirect_uri" => array("type" => "varchar(200)", "not null" => "1", "default" => ""),
354 "expires" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
355 "scope" => array("type" => "varchar(250)", "not null" => "1", "default" => ""),
358 "PRIMARY" => array("id"),
361 $database["cache"] = array(
363 "k" => array("type" => "varchar(255)", "not null" => "1", "primary" => "1"),
364 "v" => array("type" => "text", "not null" => "1"),
365 "updated" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
368 "PRIMARY" => array("k"),
369 "updated" => array("updated"),
372 $database["challenge"] = array(
374 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
375 "challenge" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
376 "dfrn-id" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
377 "expire" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
378 "type" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
379 "last_update" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
382 "PRIMARY" => array("id"),
385 $database["clients"] = array(
387 "client_id" => array("type" => "varchar(20)", "not null" => "1", "primary" => "1"),
388 "pw" => array("type" => "varchar(20)", "not null" => "1", "default" => ""),
389 "redirect_uri" => array("type" => "varchar(200)", "not null" => "1", "default" => ""),
390 "name" => array("type" => "text"),
391 "icon" => array("type" => "text"),
392 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
395 "PRIMARY" => array("client_id"),
398 $database["config"] = array(
400 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
401 "cat" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
402 "k" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
403 "v" => array("type" => "text", "not null" => "1"),
406 "PRIMARY" => array("id"),
407 "cat_k" => array("cat(30)","k(30)"),
410 $database["contact"] = array(
412 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
413 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
414 "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
415 "self" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
416 "remote_self" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
417 "rel" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
418 "duplex" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
419 "network" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
420 "name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
421 "nick" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
422 "location" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
423 "about" => array("type" => "text", "not null" => "1"),
424 "keywords" => array("type" => "text", "not null" => "1"),
425 "gender" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
426 "attag" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
427 "photo" => array("type" => "text", "not null" => "1"),
428 "thumb" => array("type" => "text", "not null" => "1"),
429 "micro" => array("type" => "text", "not null" => "1"),
430 "site-pubkey" => array("type" => "text", "not null" => "1"),
431 "issued-id" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
432 "dfrn-id" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
433 "url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
434 "nurl" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
435 "addr" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
436 "alias" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
437 "pubkey" => array("type" => "text", "not null" => "1"),
438 "prvkey" => array("type" => "text", "not null" => "1"),
439 "batch" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
440 "request" => array("type" => "text", "not null" => "1"),
441 "notify" => array("type" => "text", "not null" => "1"),
442 "poll" => array("type" => "text", "not null" => "1"),
443 "confirm" => array("type" => "text", "not null" => "1"),
444 "poco" => array("type" => "text", "not null" => "1"),
445 "aes_allow" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
446 "ret-aes" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
447 "usehub" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
448 "subhub" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
449 "hub-verify" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
450 "last-update" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
451 "success_update" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
452 "name-date" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
453 "uri-date" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
454 "avatar-date" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
455 "term-date" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
456 "last-item" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
457 "priority" => array("type" => "tinyint(3)", "not null" => "1", "default" => "0"),
458 "blocked" => array("type" => "tinyint(1)", "not null" => "1", "default" => "1"),
459 "readonly" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
460 "writable" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
461 "forum" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
462 "prv" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
463 "hidden" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
464 "archive" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
465 "pending" => array("type" => "tinyint(1)", "not null" => "1", "default" => "1"),
466 "rating" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
467 "reason" => array("type" => "text", "not null" => "1"),
468 "closeness" => array("type" => "tinyint(2)", "not null" => "1", "default" => "99"),
469 "info" => array("type" => "mediumtext", "not null" => "1"),
470 "profile-id" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
471 "bdyear" => array("type" => "varchar(4)", "not null" => "1", "default" => ""),
472 "bd" => array("type" => "date", "not null" => "1", "default" => "0000-00-00"),
473 "notify_new_posts" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
474 "fetch_further_information" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
475 "ffi_keyword_blacklist" => array("type" => "mediumtext", "not null" => "1"),
478 "PRIMARY" => array("id"),
479 "uid" => array("uid"),
482 $database["conv"] = array(
484 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
485 "guid" => array("type" => "varchar(64)", "not null" => "1", "default" => ""),
486 "recips" => array("type" => "mediumtext", "not null" => "1"),
487 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
488 "creator" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
489 "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
490 "updated" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
491 "subject" => array("type" => "mediumtext", "not null" => "1"),
494 "PRIMARY" => array("id"),
495 "uid" => array("uid"),
498 $database["deliverq"] = array(
500 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
501 "cmd" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
502 "item" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
503 "contact" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
506 "PRIMARY" => array("id"),
509 $database["dsprphotoq"] = array(
511 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
512 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
513 "msg" => array("type" => "mediumtext", "not null" => "1"),
514 "attempt" => array("type" => "tinyint(4)", "not null" => "1", "default" => "0"),
517 "PRIMARY" => array("id"),
520 $database["event"] = array(
522 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
523 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
524 "cid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
525 "uri" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
526 "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
527 "edited" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
528 "start" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
529 "finish" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
530 "summary" => array("type" => "text", "not null" => "1"),
531 "desc" => array("type" => "text", "not null" => "1"),
532 "location" => array("type" => "text", "not null" => "1"),
533 "type" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
534 "nofinish" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
535 "adjust" => array("type" => "tinyint(1)", "not null" => "1", "default" => "1"),
536 "ignore" => array("type" => "tinyint(1) unsigned", "not null" => "1", "default" => "0"),
537 "allow_cid" => array("type" => "mediumtext", "not null" => "1"),
538 "allow_gid" => array("type" => "mediumtext", "not null" => "1"),
539 "deny_cid" => array("type" => "mediumtext", "not null" => "1"),
540 "deny_gid" => array("type" => "mediumtext", "not null" => "1"),
543 "PRIMARY" => array("id"),
544 "uid" => array("uid"),
547 $database["fcontact"] = array(
549 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
550 "url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
551 "name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
552 "photo" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
553 "request" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
554 "nick" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
555 "addr" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
556 "batch" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
557 "notify" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
558 "poll" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
559 "confirm" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
560 "priority" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
561 "network" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
562 "alias" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
563 "pubkey" => array("type" => "text", "not null" => "1"),
564 "updated" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
567 "PRIMARY" => array("id"),
568 "addr" => array("addr"),
571 $database["ffinder"] = array(
573 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
574 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
575 "cid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
576 "fid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
579 "PRIMARY" => array("id"),
582 $database["fserver"] = array(
584 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
585 "server" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
586 "posturl" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
587 "key" => array("type" => "text", "not null" => "1"),
590 "PRIMARY" => array("id"),
591 "server" => array("server"),
594 $database["fsuggest"] = array(
596 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
597 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
598 "cid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
599 "name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
600 "url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
601 "request" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
602 "photo" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
603 "note" => array("type" => "text", "not null" => "1"),
604 "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
607 "PRIMARY" => array("id"),
610 $database["gcign"] = array(
612 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
613 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
614 "gcid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
617 "PRIMARY" => array("id"),
618 "uid" => array("uid"),
619 "gcid" => array("gcid"),
622 $database["gcontact"] = array(
624 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
625 "name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
626 "url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
627 "nurl" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
628 "photo" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
629 "connect" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
630 "updated" => array("type" => "datetime", "default" => "0000-00-00 00:00:00"),
631 "location" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
632 "about" => array("type" => "text", "not null" => "1"),
633 "keywords" => array("type" => "text", "not null" => "1"),
634 "gender" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
635 "network" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
636 "generation" => array("type" => "tinyint(3)", "not null" => "1", "default" => "0"),
639 "PRIMARY" => array("id"),
640 "nurl" => array("nurl"),
643 $database["glink"] = array(
645 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
646 "cid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
647 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
648 "gcid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
649 "zcid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
650 "updated" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
653 "PRIMARY" => array("id"),
654 "cid_uid_gcid_zcid" => array("cid","uid","gcid","zcid"),
655 "gcid" => array("gcid"),
656 "zcid" => array("zcid"),
659 $database["group"] = array(
661 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
662 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
663 "visible" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
664 "deleted" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
665 "name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
668 "PRIMARY" => array("id"),
669 "uid" => array("uid"),
672 $database["group_member"] = array(
674 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
675 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
676 "gid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
677 "contact-id" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
680 "PRIMARY" => array("id"),
681 "uid_gid_contactid" => array("uid","gid","contact-id"),
684 $database["guid"] = array(
686 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
687 "guid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
690 "PRIMARY" => array("id"),
691 "guid" => array("guid"),
694 $database["hook"] = array(
696 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
697 "hook" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
698 "file" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
699 "function" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
700 "priority" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"),
703 "PRIMARY" => array("id"),
704 "hook_file_function" => array("hook(30)","file(60)","function(30)"),
707 $database["intro"] = array(
709 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
710 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
711 "fid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
712 "contact-id" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
713 "knowyou" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
714 "duplex" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
715 "note" => array("type" => "text", "not null" => "1"),
716 "hash" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
717 "datetime" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
718 "blocked" => array("type" => "tinyint(1)", "not null" => "1", "default" => "1"),
719 "ignore" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
722 "PRIMARY" => array("id"),
725 $database["item"] = array(
727 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
728 "guid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
729 "uri" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
730 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
731 "contact-id" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
732 "type" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
733 "wall" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
734 "gravity" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
735 "parent" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
736 "parent-uri" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
737 "extid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
738 "thr-parent" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
739 "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
740 "edited" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
741 "commented" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
742 "received" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
743 "changed" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
744 "owner-name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
745 "owner-link" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
746 "owner-avatar" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
747 "author-name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
748 "author-link" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
749 "author-avatar" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
750 "title" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
751 "body" => array("type" => "mediumtext", "not null" => "1"),
752 "app" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
753 "verb" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
754 "object-type" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
755 "object" => array("type" => "text", "not null" => "1"),
756 "target-type" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
757 "target" => array("type" => "text", "not null" => "1"),
758 "postopts" => array("type" => "text", "not null" => "1"),
759 "plink" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
760 "resource-id" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
761 "event-id" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
762 "tag" => array("type" => "mediumtext", "not null" => "1"),
763 "attach" => array("type" => "mediumtext", "not null" => "1"),
764 "inform" => array("type" => "mediumtext", "not null" => "1"),
765 "file" => array("type" => "mediumtext", "not null" => "1"),
766 "location" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
767 "coord" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
768 "allow_cid" => array("type" => "mediumtext", "not null" => "1"),
769 "allow_gid" => array("type" => "mediumtext", "not null" => "1"),
770 "deny_cid" => array("type" => "mediumtext", "not null" => "1"),
771 "deny_gid" => array("type" => "mediumtext", "not null" => "1"),
772 "private" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
773 "pubmail" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
774 "moderated" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
775 "visible" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
776 "spam" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
777 "starred" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
778 "bookmark" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
779 "unseen" => array("type" => "tinyint(1)", "not null" => "1", "default" => "1"),
780 "deleted" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
781 "origin" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
782 "forum_mode" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
783 "last-child" => array("type" => "tinyint(1) unsigned", "not null" => "1", "default" => "1"),
784 "mention" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
785 "network" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
786 "rendered-hash" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
787 "rendered-html" => array("type" => "mediumtext", "not null" => "1"),
788 "global" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
791 "PRIMARY" => array("id"),
792 "guid" => array("guid"),
793 "uri" => array("uri"),
794 "parent" => array("parent"),
795 "parent-uri" => array("parent-uri"),
796 "extid" => array("extid"),
797 "uid_id" => array("uid","id"),
798 "uid_created" => array("uid","created"),
799 "uid_unseen" => array("uid","unseen"),
800 "uid_network_received" => array("uid","network","received"),
801 "uid_received" => array("uid","received"),
802 "uid_network_commented" => array("uid","network","commented"),
803 "uid_commented" => array("uid","commented"),
804 "uid_title" => array("uid","title"),
805 "uid_thrparent" => array("uid","thr-parent"),
806 "uid_parenturi" => array("uid","parent-uri"),
807 "uid_contactid_created" => array("uid","contact-id","created"),
808 "wall_body" => array("wall","body(6)"),
809 "uid_visible_moderated_created" => array("uid","visible","moderated","created"),
810 "uid_uri" => array("uid","uri"),
811 "uid_wall_created" => array("uid","wall","created"),
812 "resource-id" => array("resource-id"),
813 "uid_type" => array("uid","type"),
814 "uid_starred" => array("uid","starred"),
815 "contactid_allowcid_allowpid_denycid_denygid" => array("contact-id","allow_cid(10)","allow_gid(10)","deny_cid(10)","deny_gid(10)"),
816 "uid_wall_parent_created" => array("uid","wall","parent","created"),
817 "uid_type_changed" => array("uid","type","changed"),
818 "contactid_verb" => array("contact-id","verb"),
819 "deleted_changed" => array("deleted","changed"),
820 "uid_wall_changed" => array("uid","wall","changed"),
821 "uid_eventid" => array("uid","event-id"),
822 "uid_authorlink" => array("uid","author-link"),
823 "uid_ownerlink" => array("uid","owner-link"),
826 $database["item_id"] = array(
828 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
829 "iid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
830 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
831 "sid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
832 "service" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
835 "PRIMARY" => array("id"),
836 "uid" => array("uid"),
837 "sid" => array("sid"),
838 "service" => array("service"),
839 "iid" => array("iid"),
842 $database["locks"] = array(
844 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
845 "name" => array("type" => "varchar(128)", "not null" => "1", "default" => ""),
846 "locked" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
847 "created" => array("type" => "datetime", "default" => "0000-00-00 00:00:00"),
850 "PRIMARY" => array("id"),
853 $database["mail"] = array(
855 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
856 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
857 "guid" => array("type" => "varchar(64)", "not null" => "1", "default" => ""),
858 "from-name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
859 "from-photo" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
860 "from-url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
861 "contact-id" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
862 "convid" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"),
863 "title" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
864 "body" => array("type" => "mediumtext", "not null" => "1"),
865 "seen" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
866 "reply" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
867 "replied" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
868 "unknown" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
869 "uri" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
870 "parent-uri" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
871 "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
874 "PRIMARY" => array("id"),
875 "uid" => array("uid"),
876 "guid" => array("guid"),
877 "convid" => array("convid"),
878 "reply" => array("reply"),
879 "uri" => array("uri"),
880 "parent-uri" => array("parent-uri"),
883 $database["mailacct"] = 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 "server" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
888 "port" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
889 "ssltype" => array("type" => "varchar(16)", "not null" => "1", "default" => ""),
890 "mailbox" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
891 "user" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
892 "pass" => array("type" => "text", "not null" => "1"),
893 "reply_to" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
894 "action" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
895 "movetofolder" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
896 "pubmail" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
897 "last_check" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
900 "PRIMARY" => array("id"),
903 $database["manage"] = array(
905 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
906 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
907 "mid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
910 "PRIMARY" => array("id"),
911 "uid_mid" => array("uid","mid"),
914 $database["notify"] = array(
916 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
917 "hash" => array("type" => "varchar(64)", "not null" => "1", "default" => ""),
918 "type" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
919 "name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
920 "url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
921 "photo" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
922 "date" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
923 "msg" => array("type" => "mediumtext", "not null" => "1"),
924 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
925 "link" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
926 "parent" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
927 "seen" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
928 "verb" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
929 "otype" => array("type" => "varchar(16)", "not null" => "1", "default" => ""),
932 "PRIMARY" => array("id"),
933 "uid" => array("uid"),
936 $database["notify-threads"] = array(
938 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
939 "notify-id" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
940 "master-parent-item" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
941 "parent-item" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
942 "receiver-uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
945 "PRIMARY" => array("id"),
946 "master-parent-item" => array("master-parent-item"),
947 "receiver-uid" => array("receiver-uid"),
950 $database["pconfig"] = array(
952 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
953 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
954 "cat" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
955 "k" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
956 "v" => array("type" => "mediumtext", "not null" => "1"),
959 "PRIMARY" => array("id"),
960 "uid_cat_k" => array("uid","cat(30)","k(30)"),
963 $database["photo"] = array(
965 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
966 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
967 "contact-id" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
968 "guid" => array("type" => "varchar(64)", "not null" => "1", "default" => ""),
969 "resource-id" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
970 "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
971 "edited" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
972 "title" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
973 "desc" => array("type" => "text", "not null" => "1"),
974 "album" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
975 "filename" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
976 "type" => array("type" => "varchar(128)", "not null" => "1", "default" => "image/jpeg"),
977 "height" => array("type" => "smallint(6)", "not null" => "1", "default" => "0"),
978 "width" => array("type" => "smallint(6)", "not null" => "1", "default" => "0"),
979 "datasize" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
980 "data" => array("type" => "mediumblob", "not null" => "1"),
981 "scale" => array("type" => "tinyint(3)", "not null" => "1", "default" => "0"),
982 "profile" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
983 "allow_cid" => array("type" => "mediumtext", "not null" => "1"),
984 "allow_gid" => array("type" => "mediumtext", "not null" => "1"),
985 "deny_cid" => array("type" => "mediumtext", "not null" => "1"),
986 "deny_gid" => array("type" => "mediumtext", "not null" => "1"),
989 "PRIMARY" => array("id"),
990 "uid" => array("uid"),
991 "resource-id" => array("resource-id"),
992 "guid" => array("guid"),
995 $database["poll"] = array(
997 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
998 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
999 "q0" => array("type" => "mediumtext", "not null" => "1"),
1000 "q1" => array("type" => "mediumtext", "not null" => "1"),
1001 "q2" => array("type" => "mediumtext", "not null" => "1"),
1002 "q3" => array("type" => "mediumtext", "not null" => "1"),
1003 "q4" => array("type" => "mediumtext", "not null" => "1"),
1004 "q5" => array("type" => "mediumtext", "not null" => "1"),
1005 "q6" => array("type" => "mediumtext", "not null" => "1"),
1006 "q7" => array("type" => "mediumtext", "not null" => "1"),
1007 "q8" => array("type" => "mediumtext", "not null" => "1"),
1008 "q9" => array("type" => "mediumtext", "not null" => "1"),
1011 "PRIMARY" => array("id"),
1012 "uid" => array("uid"),
1015 $database["poll_result"] = array(
1017 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1018 "poll_id" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1019 "choice" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1022 "PRIMARY" => array("id"),
1023 "poll_id" => array("poll_id"),
1024 "choice" => array("choice"),
1027 $database["profile"] = array(
1029 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1030 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1031 "profile-name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1032 "is-default" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1033 "hide-friends" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1034 "name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1035 "pdesc" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1036 "dob" => array("type" => "varchar(32)", "not null" => "1", "default" => "0000-00-00"),
1037 "address" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1038 "locality" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1039 "region" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1040 "postal-code" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
1041 "country-name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1042 "hometown" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1043 "gender" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
1044 "marital" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1045 "with" => array("type" => "text", "not null" => "1"),
1046 "howlong" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1047 "sexual" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1048 "politic" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1049 "religion" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1050 "pub_keywords" => array("type" => "text", "not null" => "1"),
1051 "prv_keywords" => array("type" => "text", "not null" => "1"),
1052 "likes" => array("type" => "text", "not null" => "1"),
1053 "dislikes" => array("type" => "text", "not null" => "1"),
1054 "about" => array("type" => "text", "not null" => "1"),
1055 "summary" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1056 "music" => array("type" => "text", "not null" => "1"),
1057 "book" => array("type" => "text", "not null" => "1"),
1058 "tv" => array("type" => "text", "not null" => "1"),
1059 "film" => array("type" => "text", "not null" => "1"),
1060 "interest" => array("type" => "text", "not null" => "1"),
1061 "romance" => array("type" => "text", "not null" => "1"),
1062 "work" => array("type" => "text", "not null" => "1"),
1063 "education" => array("type" => "text", "not null" => "1"),
1064 "contact" => array("type" => "text", "not null" => "1"),
1065 "homepage" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1066 "photo" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1067 "thumb" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1068 "publish" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1069 "net-publish" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1072 "PRIMARY" => array("id"),
1073 "hometown" => array("hometown"),
1076 $database["profile_check"] = array(
1078 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1079 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1080 "cid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1081 "dfrn_id" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1082 "sec" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1083 "expire" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1086 "PRIMARY" => array("id"),
1089 $database["push_subscriber"] = array(
1091 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1092 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1093 "callback_url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1094 "topic" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1095 "nickname" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1096 "push" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1097 "last_update" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1098 "secret" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1101 "PRIMARY" => array("id"),
1104 $database["queue"] = array(
1106 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1107 "cid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1108 "network" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
1109 "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1110 "last" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1111 "content" => array("type" => "mediumtext", "not null" => "1"),
1112 "batch" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1115 "PRIMARY" => array("id"),
1116 "cid" => array("cid"),
1117 "created" => array("created"),
1118 "last" => array("last"),
1119 "network" => array("network"),
1120 "batch" => array("batch"),
1123 $database["register"] = array(
1125 "id" => array("type" => "int(11) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1126 "hash" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1127 "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1128 "uid" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"),
1129 "password" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1130 "language" => array("type" => "varchar(16)", "not null" => "1", "default" => ""),
1133 "PRIMARY" => array("id"),
1136 $database["search"] = array(
1138 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1139 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1140 "term" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1143 "PRIMARY" => array("id"),
1144 "uid" => array("uid"),
1145 "term" => array("term"),
1148 $database["session"] = array(
1150 "id" => array("type" => "bigint(20) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1151 "sid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1152 "data" => array("type" => "text", "not null" => "1"),
1153 "expire" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1156 "PRIMARY" => array("id"),
1157 "sid" => array("sid"),
1158 "expire" => array("expire"),
1161 $database["sign"] = array(
1163 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1164 "iid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1165 "retract_iid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1166 "signed_text" => array("type" => "mediumtext", "not null" => "1"),
1167 "signature" => array("type" => "text", "not null" => "1"),
1168 "signer" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1171 "PRIMARY" => array("id"),
1172 "iid" => array("iid"),
1173 "retract_iid" => array("retract_iid"),
1176 $database["spam"] = array(
1178 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1179 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1180 "spam" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1181 "ham" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1182 "term" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1183 "date" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1186 "PRIMARY" => array("id"),
1187 "uid" => array("uid"),
1188 "spam" => array("spam"),
1189 "ham" => array("ham"),
1190 "term" => array("term"),
1193 $database["term"] = array(
1195 "tid" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1196 "oid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1197 "otype" => array("type" => "tinyint(3) unsigned", "not null" => "1", "default" => "0"),
1198 "type" => array("type" => "tinyint(3) unsigned", "not null" => "1", "default" => "0"),
1199 "term" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1200 "url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1201 "guid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1202 "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1203 "received" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1204 "global" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1205 "aid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1206 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1209 "PRIMARY" => array("tid"),
1210 "oid_otype_type_term" => array("oid","otype","type","term"),
1211 "uid_term_tid" => array("uid","term","tid"),
1212 "type_term" => array("type","term"),
1213 "uid_otype_type_term_global_created" => array("uid","otype","type","term","global","created"),
1214 "otype_type_term_tid" => array("otype","type","term","tid"),
1215 "guid" => array("guid"),
1218 $database["thread"] = array(
1220 "iid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0", "primary" => "1"),
1221 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1222 "contact-id" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"),
1223 "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1224 "edited" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1225 "commented" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1226 "received" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1227 "changed" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1228 "wall" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1229 "private" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1230 "pubmail" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1231 "moderated" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1232 "visible" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1233 "spam" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1234 "starred" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1235 "ignored" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1236 "bookmark" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1237 "unseen" => array("type" => "tinyint(1)", "not null" => "1", "default" => "1"),
1238 "deleted" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1239 "origin" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1240 "forum_mode" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1241 "mention" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1242 "network" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
1245 "PRIMARY" => array("iid"),
1246 "created" => array("created"),
1247 "commented" => array("commented"),
1248 "uid_network_commented" => array("uid","network","commented"),
1249 "uid_network_created" => array("uid","network","created"),
1250 "uid_contactid_commented" => array("uid","contact-id","commented"),
1251 "uid_contactid_created" => array("uid","contact-id","created"),
1252 "wall_private_received" => array("wall","private","received"),
1253 "uid_created" => array("uid","created"),
1254 "uid_commented" => array("uid","commented"),
1257 $database["tokens"] = array(
1259 "id" => array("type" => "varchar(40)", "not null" => "1", "primary" => "1"),
1260 "secret" => array("type" => "text", "not null" => "1"),
1261 "client_id" => array("type" => "varchar(20)", "not null" => "1", "default" => ""),
1262 "expires" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1263 "scope" => array("type" => "varchar(200)", "not null" => "1", "default" => ""),
1264 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1267 "PRIMARY" => array("id"),
1270 $database["unique_contacts"] = array(
1272 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1273 "url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1274 "nick" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1275 "name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1276 "avatar" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1277 "location" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1278 "about" => array("type" => "text", "not null" => "1"),
1281 "PRIMARY" => array("id"),
1282 "url" => array("url"),
1285 $database["user"] = array(
1287 "uid" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1288 "guid" => array("type" => "varchar(64)", "not null" => "1", "default" => ""),
1289 "username" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1290 "password" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1291 "nickname" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1292 "email" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1293 "openid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1294 "timezone" => array("type" => "varchar(128)", "not null" => "1", "default" => ""),
1295 "language" => array("type" => "varchar(32)", "not null" => "1", "default" => "en"),
1296 "register_date" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1297 "login_date" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1298 "default-location" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1299 "allow_location" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1300 "theme" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1301 "pubkey" => array("type" => "text", "not null" => "1"),
1302 "prvkey" => array("type" => "text", "not null" => "1"),
1303 "spubkey" => array("type" => "text", "not null" => "1"),
1304 "sprvkey" => array("type" => "text", "not null" => "1"),
1305 "verified" => array("type" => "tinyint(1) unsigned", "not null" => "1", "default" => "0"),
1306 "blocked" => array("type" => "tinyint(1) unsigned", "not null" => "1", "default" => "0"),
1307 "blockwall" => array("type" => "tinyint(1) unsigned", "not null" => "1", "default" => "0"),
1308 "hidewall" => array("type" => "tinyint(1) unsigned", "not null" => "1", "default" => "0"),
1309 "blocktags" => array("type" => "tinyint(1) unsigned", "not null" => "1", "default" => "0"),
1310 "unkmail" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1311 "cntunkmail" => array("type" => "int(11)", "not null" => "1", "default" => "10"),
1312 "notify-flags" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "65535"),
1313 "page-flags" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"),
1314 "prvnets" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1315 "pwdreset" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1316 "maxreq" => array("type" => "int(11)", "not null" => "1", "default" => "10"),
1317 "expire" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"),
1318 "account_removed" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1319 "account_expired" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1320 "account_expires_on" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1321 "expire_notification_sent" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1322 "service_class" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
1323 "def_gid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1324 "allow_cid" => array("type" => "mediumtext", "not null" => "1"),
1325 "allow_gid" => array("type" => "mediumtext", "not null" => "1"),
1326 "deny_cid" => array("type" => "mediumtext", "not null" => "1"),
1327 "deny_gid" => array("type" => "mediumtext", "not null" => "1"),
1328 "openidserver" => array("type" => "text", "not null" => "1"),
1331 "PRIMARY" => array("uid"),
1332 "nickname" => array("nickname"),
1335 $database["userd"] = array(
1337 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1338 "username" => array("type" => "varchar(255)", "not null" => "1"),
1341 "PRIMARY" => array("id"),
1342 "username" => array("username"),
1351 * run from command line
1353 function dbstructure_run(&$argv, &$argc) {
1361 @include(".htconfig.php");
1362 require_once("include/dba.php");
1363 $db = new dba($db_host, $db_user, $db_pass, $db_data);
1364 unset($db_host, $db_user, $db_pass, $db_data);
1370 update_structure(true, true);
1373 print_structure(db_definition());
1380 echo $argv[0]." <command>\n";
1383 echo "update update database schema\n";
1384 echo "dumpsql dump database schema\n";
1392 if (array_search(__file__,get_included_files())===0){
1393 dbstructure_run($_SERVER["argv"],$_SERVER["argc"]);