Roxen.git / server / config_interface / dbs / schedules.pike

version» Context lines:

Roxen.git/server/config_interface/dbs/schedules.pike:14:    string schedule) {    string var;    if ((var = id->variables["period-" + schedule])) {    array(string) segments = var/":";    int period;    int offset;    if (sizeof(segments) == 2) {    period = (int)segments[0];    offset = (int)segments[1] +    (int)id->variables["time-" + schedule]; +  }    int generations = (int)id->variables["generations-" + schedule];    string method = id->variables["method-" + schedule]; -  string dir = id->variables["directories-" + schedule]; +  string dir = id->variables["directory-" + schedule];    db->query("UPDATE db_schedules "    " SET period = %d, "    " offset = %d, "    " generations = %d, "    " method = %s, "    " dir = %s "    " WHERE id = %s",    period, offset, generations, method, dir, schedule); -  } else { +  DBManager.start_backup_timer((int)schedule, period, offset); +  } +  if (id->variables["schedule-" + schedule]) {    db->query("UPDATE db_schedules " -  " SET period = 0 " +  " SET schedule = %s "    " WHERE id = %s", -  schedule); +  id->variables["schedule-" + schedule], schedule);    } -  DBManager.start_backup_timer((int)schedule, period, offset); +     } -  } +     };    if (err) master()->handle_error(err);    }    -  +  if (id->variables["new.x"]) { +  db->query("INSERT INTO db_schedules (id, period) VALUES (NULL, 0)"); +  int new_id = db->master_sql->insert_id(); +  db->query("UPDATE db_schedules SET schedule = %s where id = %d", +  sprintf((string)_(1117, "Schedule #%d"), new_id-1), new_id); +  } +     string res =    "<h3>" + _(1026, "Backup schedules") + ":</h3>\n"    "<table width='100%'>\n"    "<tr><th align='left'>" + _(1027, "Schedule") +    "</th><th align='left'>" + _(1028, "Period") +    "</th><th align='left'>" + _(1029, "Time") +    "</th><th align='left'>" + _(1030, "Generations") +    "</th><th align='left'>" + _(1031, "Method") + -  "</th></tr>\n"; +  "</th><th></th></tr>\n";       foreach(db->query("SELECT id, schedule, period, offset, dir, "    " generations, method "    " FROM db_schedules "    " ORDER BY id ASC"), mapping(string:string) schedule) { -  +  +  if (schedule->id != "1") { +  if (id->variables["delete-" + schedule->id + ".x"]) { +  db->query("UPDATE dbs SET schedule_id = NULL WHERE schedule_id = %s", +  schedule->id); +  db->query("DELETE FROM db_schedules WHERE id = %s", schedule->id); +  continue; +  } +  res += "<tr><td colspan='6'><hr></td></tr>" +  "<tr><td><input size='10em' name='schedule-" + schedule->id + "' " +  "value='" + Roxen.html_encode_string(schedule->schedule) + "' />" +  "</td>"; +  } else { +  res += "<tr><td colspan='6'><hr></td></tr>" +  "<tr><td>" +  "<b>" + Roxen.html_encode_string(schedule->schedule) +"</b>" +  "</td>\n"; +  } +     int period = (int)schedule->period;    int offset = (int)schedule->offset;    if (period) offset %= period;    int day = offset/86400;    int hour = (offset/3600)%24; -  res += "<tr><td><b>" + Roxen.html_encode_string(schedule->schedule) + -  "</b></td>\n" +  res +=    "<td><default name='period-" + schedule->id + "' value='" +    (schedule->period?(schedule->period + ":" + (day*86400)):"") +    "'><select name='period-" + schedule->id + "'>\n"    "<option value=''>" + _(482, "Never") + "</option>\n";    foreach(_(1032, "Sundays,Mondays,Tuesdays,Wednesdays,Thursdays,"    "Fridays,Saturdays")/","; int dayno; string day) {    res += sprintf("<option value='%d:%d'>%s</option>\n",    86400*7, (((dayno + 3)%7)*86400),    Roxen.html_encode_string(day));    }
Roxen.git/server/config_interface/dbs/schedules.pike:103:    "<option value='5'>5</option>\n"    "<option value='10'>10</option>\n"    "</select></default></td>\n"    "<td><default name='method-" + schedule->id +    "' value='" + schedule->method + "'>"    "<select name='method-" + schedule->id + "'>\n"    "<option value='mysqldump'>" + _(1037, "MySQLDump (recommended)") + "</option>\n"    "<option value='backup'>" + _(1038, "Backup (internal databases only)") + "</option>\n"    "</select></default></td>\n"    "</tr>\n" -  "<tr><td>&nbsp;</td><td colspan='3'>" + +  "<tr><td>&nbsp;</td><td colspan='4'>" +    _(1039, "Backup directory") + -  ": <input size='60%' name='directory-" + schedule->id + +  ": <input size='75%' name='directory-" + schedule->id +    "' type='string' value='" + Roxen.html_encode_string(schedule->dir||"") +    "' />" -  + ("<br/>Default directory: "+roxen_path("$VARDIR/backup/")) + -  "</td><td>&nbsp;</td></tr>\n"; +  "</td><td align='right'>"; +  if (schedule->id != "1") { +  res += "<submit-gbutton2 name='delete-" + schedule->id + "'>" + +  _(227, "Delete") + "</submit-gbutton2>"; +  } else { +  res += "<submit-gbutton2 name='new'>" + _(1118, "New") + "</submit-gbutton2>"; +  } +  res += "</td></tr>\n";    if (schedule->id == "1") { -  res += "<tr><td>&nbsp;</td><td colspan='3'>" + +  res += "<tr><td>&nbsp;</td><td colspan='4'>" +    _(1040, "Note: This schedule is also used to schedule backups for "    "Roxen's internal databases.") +    "</td><td>&nbsp;</td></tr>\n";    }    }    -  res += "<tr><td>" -  "<submit-gbutton2 name='ok'>"+_(201,"OK")+"</submit-gbutton2></td>\n" -  "<td align='right' colspan='4'><cf-cancel href=''/></td></tr>\n"; +  res += "<tr><td colspan='6'><hr></td></tr>" +  "<tr><td align='left'><cf-cancel href='/dbs/'/></td><td colspan='4'>" + +  sprintf((string)_(1119, "Default directory: %s"), +  Roxen.html_encode_string(roxen_path("$VARDIR/backup/"))) + +  "</td><td align='right'>" +  "<submit-gbutton2 name='ok'> "+_("bA","Save")+" </submit-gbutton2></td>\n" +  "</tr>\n"    "</table>\n";       return Roxen.http_string_answer(res);   }