function paraToSql($rel, $path, $para) { global $sql, $para_nr, $category_id; if (isset($para['edit'])) { $para_id = $para_nr++; $para_path = ''; if (strstr($para['path'], '-') === false) { // Change a paragraph $sql .= "insert into referendum_type_law (referendum, id, add, path, title, text)\n\t select\n\t\tcurrval('referendum_id_seq'),\n\t\t'{$para_id}',\n\t\t'{$para['edit']['add']}',\n\t\t'{$para['path']}',\n\t\t'{$para['edit']['title']}',\n\t\t'{$para['edit']['text']}';\n\t "; } else { if ($rel === false) { $sql .= "insert into referendum_type_law (referendum, id, add, path, title, text)\n\t select\n\t\tcurrval('referendum_id_seq'),\n\t\t'{$para_id}',\n\t\t'{$para['edit']['add']}',\n\t\tlaw_next_paragraph({$category_id}, '{$path}'),\n\t\t'{$para['edit']['title']}',\n\t\t'{$para['edit']['text']}';\n\t "; } else { $sql .= "insert into referendum_type_law (referendum, id, add, path, title, text)\n\t select\n\t\tcurrval('referendum_id_seq'),\n\t\t'{$para_id}',\n\t\t'{$para['edit']['add']}',\n\t\tlaw_next_paragraph({$category_id},\n\t\t\t\t law_paragraph_combine(path, 0, '{$path}')),\n\t\t'{$para['edit']['title']}',\n\t\t'{$para['edit']['text']}'\n\t from\n\t\treferendum_type_law\n\t where referendum = currval('referendum_id_seq')\n\t\t and id = '{$rel}';\n\t "; } } } else { if (strstr($para['path'], '-') !== false) { if ($rel === false) { $sql .= "insert into referendum_type_law (referendum, id, add, path, title, text)\n\t select\n\t\tcurrval('referendum_id_seq'),\n\t\t'{$para_id}',\n\t\t'false',\n\t\tlaw_next_paragraph({$category_id}, '{$path}'),\n\t\t'',\n\t\t'';\n\t "; } else { $sql .= "insert into referendum_type_law (referendum, id, add, path, title, text)\n\t select\n\t\tcurrval('referendum_id_seq'),\n\t\t'{$para_id}',\n\t\t'false',\n\t\tlaw_next_paragraph({$category_id},\n\t\t\t\t law_paragraph_combine(path, 0, '{$path}')),\n\t\t'',\n\t\t''\n\t from\n\t\treferendum_type_law\n\t where referendum = currval('referendum_id_seq')\n\t\t and id = '{$rel}';\n\t "; } } else { $para_id = false; $para_path = $para['path']; } } $lastrel = $para_id; $lastpath = pathCombine($para_path, 0, "0"); foreach ($para['sub'] as $key => $sub) { if ($key != '0') { list($lastrel, $lastpath) = paraToSql($lastrel, $lastpath, $sub); } } return array($para_id, $para_path); }
function writable_folder_test($dir) { if (!file_exists($dir) && $dir != "" && $dir != "./.") { @mkdir($dir, 0777, true); } $fp = @fopen(pathCombine(array($dir, "imAdmin_test_file")), "w"); if (!$fp) { return false; } if (@fwrite($fp, "test") === false) { return false; } @fclose($fp); if (!@file_exists(pathCombine(array($dir, "imAdmin_test_file")))) { return false; } @unlink(pathCombine(array($dir, "imAdmin_test_file"))); return true; }
function insertNode($path, $node) { $children = $node->childNodes; $virtual = true; $title = ''; $text = ''; $pos = 0; while ($pos < $children->length && domNodeIsEmpty($children->item($pos))) { $pos++; } if ($pos < $children->length) { $item = $children->item($pos); if ($item->nodeType == XML_ELEMENT_NODE && $item->tagName == 'h') { $title = trim($item->firstChild->data); $virtual = false; $pos++; } } while ($pos < $children->length && domNodeIsEmpty($children->item($pos))) { $pos++; } if ($pos < $children->length) { $item = $children->item($pos); if ($item->nodeType == XML_TEXT_NODE) { $text = trim($item->data); $virtual = false; $pos++; } } if ($path != '') { if ($node->hasAttribute('delete')) { if (!$node->hasAttribute('id') || !$virtual) { die('Malformed XML: delete tag has no id or is virtual'); } $newPath = deleteParagraph(pathCombine($path, 1, $node->getAttribute('id'))); } else { if ($node->hasAttribute('id')) { if (!$virtual) { $newPath = editParagraph(pathCombine($path, 1, $node->getAttribute('id')), $title, $text); } else { $newPath = pathCombine($path, 1, $node->getAttribute('id')); } } else { if (!$virtual) { $newPath = addParagraph($path, 't', $title, $text); } else { $newPath = addParagraph($path, 'f'); } } } } $lastPath = pathCombine($newPath, 0, '0'); while ($pos < $children->length && domNodeIsEmpty($children->item($pos))) { $pos++; } while ($pos < $children->length) { $lastPath = insertNode($lastPath, $children->item($pos++)); while ($pos < $children->length && domNodeIsEmpty($children->item($pos))) { $pos++; } } return $newPath; }
function insertNode($rel, $path, $node) { global $para_root, $para_ids, $para_nr; $children = $node->childNodes; $para = false; $title = ''; $text = ''; $pos = 0; while ($pos < $children->length && domNodeIsEmpty($children->item($pos))) { $pos++; } if ($pos < $children->length) { $item = $children->item($pos); if ($item->nodeType == XML_ELEMENT_NODE && $item->tagName == 'h') { $title = trim($item->firstChild->data); $pos++; } } while ($pos < $children->length && domNodeIsEmpty($children->item($pos))) { $pos++; } if ($pos < $children->length) { $item = $children->item($pos); if ($item->nodeType == XML_TEXT_NODE) { $text = trim($item->data); $pos++; } } if ($text != '' || $title != '') { $para = $para_nr++; $para_ids[$para] = array('relative' => $rel, 'id' => $para, 'type' => 'add', 'title' => $title, 'text' => $text, 'sub' => array(), 'next' => array()); if ($path != '') { $para_ids[$para]['path'] = $path; if ($rel !== false) { $para_ids[$rel]['sub'][] =& $para_ids[$para]; } } else { $para_ids[$para]['path'] = ''; if ($rel !== false) { $para_ids[$rel]['next'][] =& $para_ids[$para]; } } if ($rel === false) { $para_root[$para] =& $para_ids[$para]; } $subRel = $para; $subPath = '0'; } else { $subRel = $rel; $subPath = pathCombine($path, 0, '0'); } $prevChild = insertNodes($children, $pos, $subRel, $subPath); return $para; }
</table> <div class="text-center" style="margin-top: 10px;"> <input type="submit" class="button green" value="<?php echo l10n('form_submit'); ?> " name="send"> <input type="reset" class="button" value="<?php echo l10n('form_reset'); ?> "> </div> </form> </div> <script>$(document).ready(function () { $("#from").focus(); });</script> <?php $path = pathCombine(array("../", $imSettings['general']['public_folder'], "email_log.txt")); if (file_exists($path) && function_exists("file_get_contents")) { ?> <div class="page-navbar">Email Log</div> <div class="email-test-container"> <textarea readonly="true" style="width: 99%; height: 200px;"><?php echo file_get_contents($path); ?> </textarea> </div> <?php } ?> </div> <?php require_once "footer.php";
function changePermissions(array $d) { global $config; if ($config["chmod"] != 1) { echo json_encode(array("status" => "ERROR", "message" => "No rights to change permissions")); } elseif (!isset($d["chmod"]) || $d['chmod'] == "") { echo json_encode(array("status" => "ERROR", "message" => "Could not identify new permissions")); } elseif (!isPathValid(pathCombine($d['dir'], $d['filename']))) { echo json_encode(array("status" => "ERROR", "message" => "Not allowed to change the permissions")); } else { chDirIfNecessary($d['dir']); $chmod = $d["chmod"]; $cmi = true; if (!is_numeric($chmod)) { $cmi = false; $chmod = str_replace(" ", "", $chmod); if (strlen($chmod) == 9) { $cmi = true; $arr = array(substr($chmod, 0, 3), substr($chmod, 3, 3), substr($chmod, 6, 3)); $chtmp = "0"; foreach ($arr as $right) { $rtmp = 0; if (substr($right, 0, 1) == "r") { $rtmp = $rtmp + 4; } elseif (substr($right, 0, 1) != "-") { $cmi = false; } if (substr($right, 1, 1) == "w") { $rtmp = $rtmp + 2; } elseif (substr($right, 1, 1) != "-") { $cmi = false; } if (substr($right, 2, 1) == "x") { $rtmp = $rtmp + 1; } elseif (substr($right, 2, 1) != "-") { $cmi = false; } $chtmp = $chtmp . $rtmp; } $chmod = intval($chtmp); } } else { $chmod = "0" . $chmod; } if ($cmi) { try { chmod($d["filename"], (int) octdec($chmod)); echo json_encode(array("status" => "OK", "message" => "Permissions changed successfully")); } catch (Exception $e) { echo json_encode(array("status" => "ERROR", "message" => "Error while changing permissions")); } } else { echo json_encode(array("status" => "ERROR", "message" => "Could not determine permission format")); } } }
function drawLaw($level, $node) { if (isset($node['path'])) { printf("<div class='law law_%s' id='law-%s'>\n", $level, $node['path']); if ($level > 0) { if (strstr($node['path'], '-') === false) { $id = $node['path']; } else { $id = "New"; } if (isset($node['edit'])) { if ($node['edit']['add'] == 't') { printf("<div class='law_head law_edit_head law_head_%s law_head_added'>\n\t %s:\n\t <input\n\t\tclass='head_input'\n\t\tname='law_edit_title_%s'\n\t\ttype='text'\n\t\tvalue='%s'\n\t />\n\t <input\n\t\tclass='clickable_head law_edit_cancel'\n\t\tname='law_edit_cancel_%s'\n\t\ttype='submit'\n\t\tvalue='<-'\n\t />\n\t <input\n\t\tclass='clickable_head law_edit_delete'\n\t\tname='law_edit_delete_%s'\n\t\ttype='submit'\n\t\tvalue='X'\n\t />\n\t </div>\n\t <div class='law_text'>\n\t <textarea name='law_edit_text_%s'>%s</textarea>\n\t </div>\n\t ", $level, $id, $node['path'], $node['edit']['title'], $node['path'], $node['path'], $node['path'], $node['edit']['text']); } else { $title = sprintf(T_("Paragraph deleted: %s"), $id); printf("<div class='law_head law_edit_head law_head_%s law_head_deleted'>\n\t <input\n\t\tclass='clickable_head law_edit_edit'\n\t\tname='law_edit_edit_%s'\n\t\ttype='submit'\n\t\tvalue='%s'\n\t />\n\t <input\n\t\tclass='clickable_head law_edit_cancel'\n\t\tname='law_edit_cancel_%s'\n\t\ttype='submit'\n\t\tvalue='<-'\n\t />\n\t </div>\n\t ", $level, $node['path'], $title, $node['path']); } } else { if (!isset($node['add'])) { $title = sprintf(T_("Paragraph not created: %s"), $id); $cls = "law_head_virtual"; } else { if ($node['add'] == 't') { $title = sprintf(T_("%s: %s"), $id, $node['title']); $cls = "law_head_added"; } else { $title = sprintf(T_("Paragraph deleted: %s"), $id); $cls = "law_head_deleted"; } } printf("<div class='law_head law_edit_head law_head_%s %s'>\n\t <input\n\t class='clickable_head law_edit_edit'\n\t name='law_edit_edit_%s'\n\t type='submit'\n\t value='%s'\n\t />\n\t <input\n\t\tclass='clickable_head law_edit_delete'\n\t name='law_edit_delete_%s'\n\t type='submit'\n\t value='X'\n\t />\n\t </div>\n\t ", $level, $cls, $node['path'], $title, $node['path']); if ($node['add'] == 't') { printf("<div class='law_text'>%s</div>", $node['text']); } } } printf("<div class='law law_%s'>\n\t <input\n\t class='law_edit_insert'\n\t name='law_edit_insert_%s'\n\t type='submit'\n\t value='Insert new paragraph after %s' />\n\t </div>\n\t ", $level + 1, pathCombine($node['path'], 0, '0'), pathCombine($node['path'], 0, '0')); } foreach ($node['sub'] as $key => $subNode) { if ($key != '0') { drawLaw($level + 1, $subNode); } } if (isset($node['path'])) { printf("<input\n\t class='law_edit_insert'\n\t name='law_edit_insert_%s'\n\t type='submit'\n\t value='Insert new paragraph after %s' />\n\t ", $node['path'], $node['path']); echo "</div>\n"; } }