function nm_search_with_placeholder($placeholder = '')
{
    global $i18n;
    if (!$placeholder) {
        $placeholder = isset($i18n['news_manager/SEARCH_PLACEHOLDER']) ? $i18n['news_manager/SEARCH_PLACEHOLDER'] : $i18n['news_manager/SEARCH'] . ' ...';
    }
    $placeholder = htmlspecialchars($placeholder);
    $url = nm_get_url();
    ?>
  <form id="search" action="<?php 
    echo $url;
    ?>
" method="post">
    <input type="text" class="text" name="keywords" value="<?php 
    echo $placeholder;
    ?>
" onfocus="if (this.value=='<?php 
    echo $placeholder;
    ?>
') {this.value=''}" onblur="if (this.value=='') {this.value='<?php 
    echo $placeholder;
    ?>
'}" /><!--[if IE]><input type="text" style="display: none;" disabled="disabled" size="20"
    value="Ignore field. IE bug fix" /><![endif]--><input type="submit" class="submit" name="search" value="<?php 
    i18n('news_manager/SEARCH');
    ?>
" />
  </form>
  <?php 
}
Beispiel #2
0
/**
* Create a default home calendar for the user.
* @param string $username The username of the user we are creating relationships for.
*/
function CreateHomeCalendar($username)
{
    global $session, $c;
    if (!isset($c->home_calendar_name) || strlen($c->home_calendar_name) == 0) {
        return true;
    }
    $usr = getUserByName($username);
    $parent_path = "/" . $username . "/";
    $calendar_path = $parent_path . $c->home_calendar_name . "/";
    $dav_etag = md5($usr->user_no . $calendar_path);
    $qry = new AwlQuery('SELECT 1 FROM collection WHERE dav_name = :dav_name', array(':dav_name' => $calendar_path));
    if ($qry->Exec()) {
        if ($qry->rows() > 0) {
            $c->messages[] = i18n("Home calendar already exists.");
            return true;
        }
    } else {
        $c->messages[] = i18n("There was an error writing to the database.");
        return false;
    }
    $sql = 'INSERT INTO collection (user_no, parent_container, dav_name, dav_etag, dav_displayname, is_calendar, created, modified, resourcetypes) ';
    $sql .= 'VALUES( :user_no, :parent_container, :calendar_path, :dav_etag, :displayname, true, current_timestamp, current_timestamp, :resourcetypes );';
    $params = array(':user_no' => $usr->user_no, ':parent_container' => $parent_path, ':calendar_path' => $calendar_path, ':dav_etag' => $dav_etag, ':displayname' => $usr->fullname, ':resourcetypes' => '<DAV::collection/><urn:ietf:params:xml:ns:caldav:calendar/>');
    $qry = new AwlQuery($sql, $params);
    if ($qry->Exec()) {
        $c->messages[] = i18n("Home calendar added.");
        dbg_error_log("User", ":Write: Created user's home calendar at '%s'", $calendar_path);
    } else {
        $c->messages[] = i18n("There was an error writing to the database.");
        return false;
    }
    return true;
}
Beispiel #3
0
 /**
  * Convert tree to options multi
  *
  * @param array $data
  * @param int $level
  * @param array $options
  * @param array $result
  */
 public static function convert_tree_to_options_multi($data, $level = 0, $options = [], &$result)
 {
     // convert to array
     if (!empty($options['skip_keys']) && !is_array($options['skip_keys'])) {
         $options['skip_keys'] = [$options['skip_keys']];
     }
     foreach ($data as $k => $v) {
         // if we are skipping certain keys
         if (!empty($options['skip_keys']) && in_array($k, $options['skip_keys'])) {
             continue;
         }
         // assemble variable
         $value = $v;
         $value['name'] = !empty($options['i18n']) ? i18n(null, $v[$options['name_field']]) : $v[$options['name_field']];
         $value['level'] = $level;
         if (!empty($options['icon_field'])) {
             $value['icon_class'] = html::icon(['type' => $v[$options['icon_field']], 'class_only' => true]);
         }
         if (!empty($options['disabled_field'])) {
             $value['disabled'] = !empty($v[$options['disabled_field']]);
         }
         $result[$k] = $value;
         // if we have options
         if (!empty($v['options'])) {
             self::convert_tree_to_options_multi($v['options'], $level + 1, $options, $result);
         }
     }
 }
Beispiel #4
0
function fatlady_phyinf($prefix, $inf)
{
    /* Check the interface setting */
    if (query($prefix . "/inf/uid") != $inf) {
        /* internet error, no i18n(). */
        set_result("FAILED", $prefix . "/inf/uid", "INF UID mismatch");
        return;
    }
    /* Check PHYINF */
    $phy = query($prefix . "/inf/phyinf");
    $phyp = XNODE_getpathbytarget($prefix, "phyinf", "uid", $phy, 0);
    if ($phy == "" || $phyp == "") {
        /* internet error, no i18n(). */
        set_result("FAILED", $prefix . "/inf/phyinf", "Invalid phyinf");
        return;
    }
    /* Check MACADDR */
    $macaddr = query($phyp . "/macaddr");
    if ($macaddr != "" && PHYINF_validmacaddr($macaddr) != "1") {
        set_result("FAILED", $phyp . "/macaddr", i18n("Invalid MAC address"));
        return;
    }
    $type = query($phyp . "/type");
    if ($type == "eth") {
        $media = query($phyp . "/media/linktype");
        if ($media != "" && $media != "AUTO" && $media != "1000F" && $media != "1000H" && $media != "100F" && $media != "100H" && $media != "10F" && $media != "10H") {
            set_result("FAILED", $phyp . "/media/linktype", i18n("Invalid media type"));
            return;
        }
    }
    /* We only validate the 'macaddr' & 'media' here,
     * so be sure to save 'macaddr' & 'media' only at 'setcfg' */
    set($prefix . "/valid", 1);
    set_result("OK", "", "");
}
Beispiel #5
0
function check_dmz_setting($path, $addrtype, $lan_ip, $mask)
{
    if (query($path . "/enable") == "1") {
        anchor($path);
        $hostid = query("hostid");
        if ($hostid == "") {
            set_result("FAILED", $path . "/hostid", i18n("DMZ IP Address cannot be empty."));
            return "FAILED";
        }
        if ($hostid <= 0) {
            set_result("FAILED", $path . "/hostid", i18n("DMZ IP Address is not a valid IP Address."));
            return "FAILED";
        }
        if ($addrtype == "ipv4") {
            $dmzip = ipv4ip($lan_ip, $mask, $hostid);
            if (INET_validv4host($dmzip, $mask) == 0) {
                set_result("FAILED", $path . "/hostid", i18n("DMZ IP Address is not a valid IP Address."));
                return "FAILED";
            }
        }
    } else {
        set($path . "/enable", "0");
    }
    return "OK";
}
Beispiel #6
0
	function exec($args, $stdin, &$stdout, &$stderr, &$system)
	{
		if (!empty($args))
		{
			switch ($this->stage)
			{
				case 1:
					if (!login($this->username, $args))
					{
						$stderr = ucf(i18n("login failed")).". ".ucf(i18n("please try again"));
					}
					else
					{
						$system->triggerEventIntern("login", array());
						//$response->addScript("window.location.reload()");
						
						$user = new mUser();
						$user->setByUsername($this->username);
						
						$stdout = $user->name." ".i18n("logged in successfully");
					}
					
					$this->stage = 0;
					return true;
			}
			
			$this->username = $args;
			$stdout = ucf(i18n("password:"******"document.getElementById('cmdline').type='password';");
			return false;
		}
		return true;
	}
    static function renderUpdateForm(SiteUser $user = null, $exclude_fields = array())
    {
        $settings = Vars::getSettings();
        $profile = $user ? $user->getProfile() : null;
        // get vars from form submission
        $nickname = isset($_POST['nickname']) ? strip_tags($_POST['nickname']) : (isset($profile) ? $profile->getNickname() : '');
        $mandatory_label = ' <span style="color: rgb(185,2,0); font-weight: bold;">*</span>';
        $avatar_field = '
  <div class="form-group" id="form-field-avatar" >
    <label for="avatar">' . i18n(array('en' => 'Avatar', 'zh' => '头像')) . ' <small style="font-weight: normal;"><i>(' . i18n(array('en' => 'optional', 'zh' => '可选')) . ')</i></small></label>
    ' . ($profile ? "<div><img src='" . $profile->getThumbnailUrl() . "' alt='" . $user->getUsername() . "' style='cursor: pointer;' /></div>" : '') . '
    <input type="file" id="avatar" name="avatar"' . ($profile ? ' style="display: none;"' : '') . ' />
    <small>' . i18n(array('en' => 'Max image file size: ' . round($settings['profile']['avatar_max_size'] / 1000000, 1) . 'MB', 'zh' => '最大图片上传尺寸: ' . round($settings['profile']['avatar_max_size'] / 1000000, 1) . 'MB')) . '</small>
  </div>
';
        $rtn = '
  <div class="form-group" id="form-field-nickname">
    <label for="nickname">' . i18n(array('en' => 'Nick name', 'zh' => '昵称')) . $mandatory_label . ' <small style="font-weight: normal;"><i>(' . i18n(array('en' => 'what others see you as', 'zh' => '其他用户看到的您的称呼')) . ')</i></small></label>
    <input type="text" class="form-control" id="nickname" name="nickname" value="' . $nickname . '" required placeholder="" />
  </div>' . (in_array('avatar', $exclude_fields) ? '' : $avatar_field) . '
  <script type="text/javascript">
    $("#form-field-avatar img").click(function(){
      $("#avatar").trigger("click");
    });
    $("#avatar").change(function(){
      //$("#form-field-avatar img").fadeOut();
      $(this).fadeIn();
    });
  </script>
';
        return $rtn;
    }
 function add($author)
 {
     # Get current time
     $now = time();
     # Remove dangerous stuff
     $_POST[article][content] = sanitize_variables($_POST[article][content]);
     $_POST[article][title] = sanitize_variables($_POST[article][title]);
     $_POST[article][category] = sanitize_variables($_POST[article][category]);
     # Implode the category array
     $savecats = implode(", ", $_POST[article][category]);
     # Enter it all into an array for use later
     $data = array("timestamp" => $now, "content" => stripslashes($_POST[article][content]), "title" => stripslashes($_POST[article][title]), "author" => stripslashes($author), "category" => stripslashes($savecats), "views" => "0");
     # hook to add custom fields here.
     #	$data = run_filters('admin-new-savedata', $data);
     if (defined("KNIFESQL")) {
         $dataclass = KArticles::connect();
         $write_sql = "INSERT INTO articles VALUES ('{$data['timestamp']}', '{$data['category']}', '{$data['author']}', '{$data['title']}', '{$data['content']}', '{$data['views']}')";
         $result = mysql_query($write_sql) or die('Query failed: ' . mysql_error());
         $statusmessage = i18n("generic_article") . " &quot;{$data['title']}&quot; " . i18n("write_published");
         return $statusmessage;
     } else {
         $dataclass = KArticles::connect();
         $dataclass->settings['articles'][$now] = $data;
         $dataclass->save();
         # Give the user a status message
         $statusmessage = i18n("generic_article") . " &quot;{$data['title']}&quot; " . i18n("write_published");
         return $statusmessage;
     }
 }
Beispiel #9
0
function check_qos_setting($path)
{
    $enable = query($path . "/device/qos/enable");
    $auto = query($path . "/device/qos/autobandwidth");
    if ($enable == "1") {
        if ($auto == "0") {
            if (isdigit(query($path . "/inf/bandwidth/upstream")) == "0" || query($path . "/inf/bandwidth/upstream") > 102400 || query($path . "/inf/bandwidth/upstream") < 1) {
                set_result("FAILED", $path . "/inf/bandwidth/upstream", i18n("The input uplink speed is invalid."));
                return "FAILED";
            } else {
                // Remove the leading zeros.
                $upstream_dec = strtoul(query($path . "/inf/bandwidth/upstream"), 10);
                set($path . "/inf/bandwidth/upstream", $upstream_dec);
            }
        } else {
            set($path . "/device/qos/autobandwidth", "1");
        }
        $type = query($path . "/inf/bandwidth/type");
        if ($type == "AUTO" || $type == "ADSL" || $type == "CABLE") {
        } else {
            set_result("FAILED", $path . "/inf/bandwidth/type", i18n("Unsupported Connection type be assigned."));
            return "FAILED";
        }
    } else {
        set($path . "/device/qos/enable", "0");
    }
    return "OK";
}
	function exec($args, $stdin, &$stdout, &$stderr, &$system)
	{
		if (!isAdmin())
		{
			$stderr = ucf(i18n("not enough rights to set initial metadata"));
			return true;
		}
		
		if (empty($args))
		{
			$stdout = "Usage: maddinit [class name] [metadata name] [value]\n";
			$stdout .= "Example: maddinit file_folder view thumbnail";
		}
		else
		{
			list($class_name, $name, $value) = splitArgs($args);
			
			$return = setInitialMetadata($class_name, $name, $value);
			
			if ($return === true)
				$stdout = "Updated metadata successfully";
			else
				$stderr = $return;
		}
		
		
		return true;
	}
Beispiel #11
0
function api_user_login()
{
    global $loginErrorMessage;
    $user = null;
    $pwd = null;
    if (isset($_POST['login'])) {
        $user = $_POST['login'];
    }
    if (isset($_POST['password'])) {
        $pwd = $_POST['password'];
    }
    // Check in database...
    // Get the main database
    $dbh_ident = get_local_auth_database();
    $stmt = $dbh_ident->prepare("SELECT * FROM pasteque_users WHERE can_login AND user_id = :user_id");
    $stmt->bindParam(':user_id', $user, \PDO::PARAM_STR);
    $stmt->execute();
    $result = $stmt->fetchAll();
    if (count($result) != 1) {
        // Bouh, invalid user
        $loginErrorMessage = \i18n("Unavailable user");
        return false;
    }
    $userDbData = $result[0];
    require_once 'PasswordHash.php';
    $hasher = new \PasswordHash(8, TRUE);
    if ($hasher->CheckPassword($pwd, $userDbData['password'])) {
        session_start();
        $_SESSION["user"] = $userDbData['user_id'];
        return true;
    } else {
        $loginErrorMessage = \i18n("Invalid user or password");
        return false;
    }
}
function i18n_gallery_supersized_edit($gallery)
{
    ?>
  <p>
    <label for="supersized-width"><?php 
    i18n('i18n_gallery/MAX_DIMENSIONS');
    ?>
</label>
    <input type="text" class="text" id="supersized-width" name="supersized-width" value="<?php 
    echo @$gallery['width'];
    ?>
" style="width:5em"/>
    x
    <input type="text" class="text" id="supersized-height" name="supersized-height" value="<?php 
    echo @$gallery['height'];
    ?>
" style="width:5em"/>
  </p>
  <p>
    <label for="supersized-interval"><?php 
    i18n('i18n_gallery/INTERVAL');
    ?>
</label>
    <input type="text" class="text" id="supersized-interval" name="supersized-interval" value="<?php 
    echo @$gallery['interval'];
    ?>
" style="width:5em"/>
  </p>
<?php 
}
Beispiel #13
0
function check_remote($entry)
{
    $port = query($entry . "/inf/web");
    if ($port != "") {
        if (isdigit($port) != "1") {
            set_result("FAILED", $entry . "/inf/web", i18n("Invalid port number"));
            return 0;
        }
        if ($port < 1 || $port > 65535) {
            set_result("FAILED", $entry . "/inf/web", i18n("Invalid port range"));
            return 0;
        }
    }
    $port = query($entry . "/inf/https_rport");
    if ($port != "") {
        if (isdigit($port) != "1") {
            set_result("FAILED", $entry . "/inf/https_rport", i18n("Invalid port number"));
            return 0;
        }
        if ($port < 1 || $port > 65535) {
            set_result("FAILED", $entry . "/inf/https_rport", i18n("Invalid port range"));
            return 0;
        }
    }
    $host = query($entry . "/inf/weballow/hostv4ip");
    if ($host != "") {
        if (INET_validv4addr($host) != "1") {
            set_result("FAILED", $entry . "/inf/weballow/hostv4ip", i18n("Invalid host IP address"));
            return 0;
        }
    }
    set_result("OK", "", "");
    return 1;
}
Beispiel #14
0
    static function renderContactForm()
    {
        $mandatory_label = ' <span style="color: rgb(185,2,0); font-weight: bold;">*</span>';
        $rtn = Message::renderMessages() . '
<form role="form" action="" method="post" id="contact">
  <fieldset>
    <div class="form-group form-field-name">
      <label for="name">' . i18n(array('en' => 'Your name', 'zh' => '您的姓名')) . $mandatory_label . '</label>
      <input class="form-control" name="contact[name]" id="name" autofocus required="">
    </div>
    <div class="form-group form-field-email">
      <label for="email">' . i18n(array('en' => 'E-mail', 'zh' => '电子邮箱')) . $mandatory_label . '</label>
      <input class="form-control" type="email" name="contact[email]" id="email" required="">
    </div>
    <div class="form-group form-field-message">
      <label for="message">' . i18n(array('en' => 'Message', 'zh' => '留言')) . $mandatory_label . '</label>
      <textarea id="message" name="contact[message]" rows="5" class="form-control" required=""></textarea>
    </div>
    <div class="form-group" id="form-field-notice"><small><i>
      ' . $mandatory_label . i18n(array('en' => ' indicates mandatory fields', 'zh' => ' 标记为必填项')) . '
    </i></small></div>
    <input type="submit" name="submit" class="btn btn-success btn-block disabled" value="' . i18n(array('en' => 'Submit', 'zh' => '提交')) . '" />
    ' . Form::loadSpamToken('#contact', 'global contact form') . '
  </fieldset>
</form>
';
        return $rtn;
    }
Beispiel #15
0
 public function templateOption()
 {
     if ($this->page->canChangeTemplate()) {
         return $this->item('file-code-o', l('pages.show.template') . ': ' . i18n($this->page->blueprint()->title()), array('href' => $this->modalUrl('template'), 'data-modal' => true, 'data-shortcut' => 't'));
     } else {
         return false;
     }
 }
Beispiel #16
0
	function exec($args, $stdin, &$stdout, &$stderr, &$system)
	{
		logout();

		$system->triggerEventIntern("logout", array());
		$stdout = ucf(i18n("logout successfull"));
		return true;
	}
Beispiel #17
0
function check_datetime($prefix)
{
    $date = query($prefix . "/date");
    $time = query($prefix . "/time");
    $month = cut($date, 0, "/");
    $day = cut($date, 1, "/");
    $year = cut($date, 2, "/");
    $hour = cut($time, 0, ":");
    $min = cut($time, 1, ":");
    $sec = cut($time, 2, ":");
    TRACE_debug("FATLADY: RUNTIME.TIME: " . $year . "/" . $month . "/" . $day);
    TRACE_debug("FATLADY: RUNTIME.TIME: " . $hour . ":" . $min . ":" . $sec);
    /* The latest time linux can support is: Tue Jan 19 11:14:07 CST 2038. */
    if (isdigit($year) == 0 || $year < 1999 || $year > 2037) {
        set_result("FAILED", $prefix . "/date", i18n("Invalid year") . " - " . $year);
        return;
    }
    if (isdigit($month) == 0 || $month <= 0 || $month > 12) {
        set_result("FAILED", $prefix . "/date", i18n("Invalid month"));
        return;
    }
    if (isdigit($day) == 0 || $day <= 0 || $day > 31) {
        set_result("FAILED", $prefix . "/date", i18n("Invalid day"));
        return;
    }
    if ($month == 2 || $month == 4 || $month == 6 || $month == 9 || $month == 11) {
        if ($day > 30) {
            set_result("FAILED", $prefix . "/date", i18n("Invalid day"));
            return;
        }
        if ($month == 2) {
            if (is29year($year) == 1) {
                if ($day > 29) {
                    set_result("FAILED", $prefix . "/date", i18n("Invalid day"));
                    return;
                }
            } else {
                if ($day > 28) {
                    set_result("FAILED", $prefix . "/date", i18n("Invalid day"));
                    return;
                }
            }
        }
    }
    if (isdigit($hour) == 0 || $hour < 0 || $hour > 23) {
        set_result("FAILED", $prefix . "/time", i18n("Invalid hour"));
        return;
    }
    if (isdigit($min) == 0 || $min < 0 || $min > 59) {
        set_result("FAILED", $prefix . "/time", i18n("Invalid minute"));
        return;
    }
    if (isdigit($sec) == 0 || $sec < 0 || $sec > 59) {
        set_result("FAILED", $prefix . "/time", i18n("Invalid second"));
        return;
    }
    set_result("OK", "", "");
}
 /**
  * The constructor
  *
  * @param string $imap_url formated for imap_open()
  */
 function __construct($imap_url)
 {
     global $c;
     if (empty($imap_url)) {
         $c->messages[] = sprintf(i18n('drivers_imap_pam : imap_url parameter not configured in /etc/davical/*-conf.php'));
         $this->valid = false;
         return;
     }
 }
function pica_RenderArticleAction($idcat, $idart, $idartlang, $actionkey)
{
    global $sess;
    if ($actionkey == "con_contentallocation") {
        return '<a title="' . i18n("Content Allocation", 'content_allocation') . '" alt="' . i18n("Content Allocation", 'content_allocation') . '" href="' . $sess->url('main.php?area=con_contentallocation&action=con_edit&idart=' . $idart . '&idartlang=' . $idartlang . '&idcat=' . $idcat . '&frame=4') . '"><img src="plugins/content_allocation/images/call_contentallocation.gif"></a>';
    } else {
        return "";
    }
}
 /**
  * The constructor
  *
  * @param string $config path where /usr/lib/squid/pam_auth is
  */
 function __construct($config)
 {
     global $c;
     if (!file_exists($config)) {
         $c->messages[] = sprintf(i18n('drivers_squid_pam : Unable to find %s file'), $config);
         $this->valid = false;
         return;
     }
 }
 /**
  * Test internationalization integration.
  */
 public function test_i18n()
 {
     // Setup
     \WP_Mock::wpFunction('load_theme_textdomain', array('times' => 1, 'args' => array('wpd', WPD_PATH . '/languages')));
     // Act
     i18n();
     // Verify
     $this->assertConditionsMet();
 }
Beispiel #22
0
 /**
  * Generate name
  *
  * @param string $name
  * @param string $icon
  * @param boolean $no_i18n
  */
 public static function name($name, $icon = null, $no_i18n = false)
 {
     if (!$no_i18n) {
         $name = i18n(null, $name);
     }
     if (!empty($icon)) {
         $name = html::icon(['type' => $icon]) . ' ' . $name;
     }
     return $name;
 }
Beispiel #23
0
	function exec($args, $stdin, &$stdout, &$stderr, &$system)
	{
		if (!empty($args))
		{
			$path = $args;
			
			if ($path{0} != "/")
				$path = $_SESSION['murrix']['path']."/$path";
				
			$node_id = getNode($path);
			
			if ($node_id > 0)
			{
				$stderr = ucf(i18n("object already exists"));
				return true;
			}
			
			$parent = new mObject(getNode($_SESSION['murrix']['path']));
			
			if (!(isAdmin() || $parent->hasRight("create")))
			{
				$stderr = ucf(i18n("not enough rights to create folder"));
				return true;
			}
			
			$object = new mObject();
			$object->setClassName("folder");
			$object->loadVars();

			$object->name = basename($path);
			$object->language = $_SESSION['murrix']['language'];
			$object->rights = $parent->getMeta("initial_rights", "rwcrwc---");
			$object->group_id = $parent->getMeta("initial_group", $parent->getGroupId());

			if (!$object->save())
			{
				$stderr = "Operation unsuccessfull.\n";
				$stderr .= "Error output:\n";
				$stderr .= $object->getLastError();
				return true;
			}
			
			clearNodeFileCache($parent->getNodeId());
			$object->linkWithNode($parent->getNodeId());
			$stdout = ucf(i18n("created folder successfully"));
		}
		else
		{
			$stdout = "Usage: oadd [name]\n";
			$stdout .= "Example: oadd newfolder";
		}
			
		return true;
	}
Beispiel #24
0
 /**
  * Test internationalization integration.
  */
 public function test_i18n()
 {
     // Setup
     \WP_Mock::wpFunction('get_locale', array('times' => 1, 'args' => array(), 'return' => 'en_US'));
     \WP_Mock::onFilter('plugin_locale')->with('en_US', 'wpd_tools')->reply('en_US');
     \WP_Mock::wpFunction('load_textdomain', array('times' => 1, 'args' => array('wpd_tools', 'lang_dir/wpd_tools/wpd_tools-en_US.mo')));
     \WP_Mock::wpFunction('plugin_basename', array('times' => 1, 'args' => array('path'), 'return' => 'path'));
     \WP_Mock::wpFunction('load_plugin_textdomain', array('times' => 1, 'args' => array('wpd_tools', false, 'path/languages/')));
     // Act
     i18n();
     // Verify
     $this->assertConditionsMet();
 }
Beispiel #25
0
function check_remote($entry)
{
    $port = query($entry . "/inf/web");
    if ($port != "") {
        if (isdigit($port) != "1") {
            set_result("FAILED", $entry . "/inf/web", i18n("Invalid port number"));
            return 0;
        }
        if ($port < 1 || $port > 65535) {
            set_result("FAILED", $entry . "/inf/web", i18n("Invalid port range"));
            return 0;
        }
        // Check with VSVR and PFWD. Currently only with NAT-1;
        $nat = XNODE_getpathbytarget("/nat", "entry", "uid", "NAT-1");
        if ($nat != "") {
            $i = 1;
            while ($i <= 2) {
                if ($i == 1) {
                    $target = "portforward";
                    $svr_str = i18n("PORT FORWARDING");
                } else {
                    $target = "virtualserver";
                    $svr_str = i18n("VIRTUAL SERVER");
                }
                $count = query($nat . "/" . $target . "/entry#");
                TRACE_debug("FATLADY: check HTTP.WAN with " . $nat . "/" . $target . " count:" . $count);
                $j = 1;
                while ($j <= $count) {
                    $CurBase = $nat . "/" . $target . "/entry:" . $j;
                    if (query($CurBase . "/protocol") == "TCP+UDP" || query($CurBase . "/protocol") == "TCP") {
                        if ($port >= query($CurBase . "/external/start") && $port <= query($CurBase . "/external/end")) {
                            set_result("FAILED", $entry . "/inf/web", i18n("The port number is used by") . " " . i18n($svr_str) . ".");
                            return 0;
                        }
                    }
                    $j++;
                }
                $i++;
            }
        }
    }
    $host = query($entry . "/inf/weballow/hostv4ip");
    if ($host != "") {
        if (INET_validv4addr($host) != "1") {
            set_result("FAILED", $entry . "/inf/weballow/hostv4ip", i18n("Invalid host IP address"));
            return 0;
        }
    }
    set_result("OK", "", "");
    return 1;
}
Beispiel #26
0
function html_street_lookup($label, $name, $intersection = FALSE)
{
    return '
		' . html_utf8(i18n('Bookmarks')) . ': <select name="' . $name . '_bookmarks" id="' . $name . '_bookmarks"></select><br />
		<label for="' . $name . '">' . html_utf8(i18n(ucfirst($label . ':'))) . '</label> <input type="text" name="' . $name . '" id="' . $name . '" value="' . (isset($_REQUEST[$name]) ? htmlentities($_REQUEST[$name], ENT_QUOTES) : '') . '" />
		<input type="hidden" name="' . $name . '_id" id="' . $name . '_id" value="' . (isset($_REQUEST[$name . '_id']) ? htmlentities($_REQUEST[$name . '_id'], ENT_QUOTES) : '') . '" />
                <div id="' . $name . '_options"></div>
                <script type="text/javascript">
                        new Ajax.Autocompleter("' . $name . '", "' . $name . '_options", "street_lookup.php", {"callback": function(element, params) { return params + "&zone=" + encodeURI($F("zones")) + "&subzone=" + encodeURI($F("subzones")); }, "paramName": "street", "afterUpdateElement": function(element, selected) { $("' . $name . '_id").value = selected.id.substr(7); } });
                </script>' . ($intersection === FALSE ? '' : '<br /><label for="' . $name . '_intersection">' . html_utf8(i18n(ucfirst($label . ' intersection:'))) . '</label> <input type="text" name="' . $name . '_intersection" id="' . $name . '_intersection" value="' . (isset($_REQUEST[$name . '_intersection']) ? htmlentities($_REQUEST[$name . '_intersection'], ENT_QUOTES) : '') . '" />
		<input type="hidden" name="' . $name . '_intersection_id" id="' . $name . '_intersection_id" value="' . (isset($_REQUEST[$name . '_intersection_id']) ? htmlentities($_REQUEST[$name . '_intersection_id'], ENT_QUOTES) : '') . '" />
                <div id="' . $name . '_intersection_options"></div>
		<input type="button" value="' . html_utf8(i18n('Bookmark!')) . '" id="bookmark_' . $name . '" />
                <script type="text/javascript">
                        new Ajax.Autocompleter("' . $name . '_intersection", "' . $name . '_intersection_options", "street_intersection_lookup.php", { "callback": function(element, params) { return params + "&street_id=" + encodeURI($F("' . $name . '_id")) + "&zone=" + encodeURI($F("zones")) + "&subzone=" + encodeURI($F("subzones")); }, "paramName": "street_intersection", "afterUpdateElement": function(element, selected) { $("' . $name . '_intersection_id").value = selected.id.substr(7); if ($("' . $name . '_intersection_id").value.length == 0) $("' . $name . '_intersection").value = ""; } });
			Event.observe($("bookmark_' . $name . '"), "click", function() {
				if ($F("' . $name . '").length * $F("' . $name . '_id").length * $F("' . $name . '_intersection").length * $F("' . $name . '_intersection_id").length == 0) {
					alert("' . i18n('Please fill in a street and an intersection') . '");
				} else {
					var name = prompt("Name the bookmark");
					window.bookmarks.push({ "name": name, "street_id" : $F("' . $name . '_id"), "street_name": $F("' . $name . '"), "street_intersection_id" : $F("' . $name . '_intersection_id"), "street_intersection_name": $F("' . $name . '_intersection") });
					createCookie("bookmarks", window.bookmarks.toJSON());
					reloadBookmarks();
					alert("Bookmark created");
				}
			});
			Event.observe($("' . $name . '_bookmarks"), "change", function() {
				var key = $F("' . $name . '_bookmarks");
				if (key < 0) return;
				var info = window.bookmarks[$F("' . $name . '_bookmarks")];
				$("' . $name . '").value = info.street_name;
				$("' . $name . '_id").value = info.street_id;
				$("' . $name . '_intersection").value = info.street_intersection_name;
				$("' . $name . '_intersection_id").value = info.street_intersection_id;
			});

			if (!window.bookmarks_selects) window.bookmarks_selects = [];
			function reloadBookmarks() {
				for (var i = 0; i <  window.bookmarks_selects.length; i++) {
					var select = window.bookmarks_selects[i];
					$(select).update("");
					$(select).insert(new Element("option", { "value": "-1" }));
					for (var j = 0; j < window.bookmarks.length; j++)
						$(select).insert(new Element("option", { value: j } ).update(window.bookmarks[j].name));
				}
			}
			window.bookmarks_selects.push($("' . $name . '_bookmarks"));
			reloadBookmarks();
                </script>
		');
}
Beispiel #27
0
	function exec($args, $stdin, &$stdout, &$stderr, &$system)
	{
		$object = new mObject(getNode($_SESSION['murrix']['path']));
		$links = $object->getLinks();
		
		if ($args == "-l")
		{
			$stdout .= "total ".count($links)."\n";
			if (count($links) > 0)
			{
				$stdout .= "<table cellspacing=\"0\">";
				$stdout .= "<tr class=\"table_title\">";
				$stdout .= "<td>Id</td>";
				$stdout .= "<td>Type</td>";
				$stdout .= "<td>Remote node</td>";
				$stdout .= "<td>Remote node is on...</td>";
				$stdout .= "</tr>";
				foreach ($links as $link)
				{
					if ($link['remote_id'] <= 0)
						$remote = ucf(i18n("unknown"));
					else
					{
						$remote_obj = new mObject($link['remote_id']);
						$remote = cmd(img(geticon($remote_obj->getIcon()))."&nbsp;".$remote_obj->getName(), "exec=show&node_id=".$remote_obj->getNodeId());
					}
	
					$stdout .= "<tr>";
					$stdout .= "<td>".$link['id']."</td>";
					$stdout .= "<td>".$link['type']."</td>";
					$stdout .= "<td>".$remote."</td>";
					$stdout .= "<td>".ucf(i18n($link['direction']))."</td>";
					$stdout .= "</tr>";
				}
				$stdout .= "</table>";
			}
		}
		else
		{
			foreach ($links as $link)
			{
				if ($link['remote_id'] > 0)
				{
					$remote_obj = new mObject($link['remote_id']);
					$stdout .= cmd($remote_obj->getName(), "exec=show&node_id=".$remote_obj->getNodeId())." ";
				}
			}
		}
		
		return true;
	}
	function exec($args, $stdin, &$stdout, &$stderr, &$system)
	{
		if (!isAdmin())
		{
			$stderr = ucf(i18n("not enough rights to add user to group"));
			return true;
		}
		
		if (empty($args))
		{
			$stdout = "Usage: gadduser [group] [username]\n";
			$stdout .= "Example: gadduser admins admin";
		}
		else
		{
			list($groupname, $username) = explode(" ", $args);
			$user = new mUser();
			$user->setByUsername($username);
			
			if ($user->id <= 0)
			{
				$stderr = ucf(i18n("no user named"))." $username ".i18n("found");
				return true;
			}
			
			$group = new mGroup();
			$group->setByName($groupname);
			
			if ($group->id <= 0)
			{
				$stderr = ucf(i18n("no group named"))." $groupname ".i18n("found");
				return true;
			}
			
			$user_groups = $user->getGroups();
			
			if (in_array($groupname, $user_groups))
			{
				$stderr = $username." ".i18n("is already a member of")." $groupname";
				return true;
			}
			
			$user->groups .= " $groupname";
			$user->save();
			
			$stdout = ucf(i18n("added"))." $username ".i18n("to")." $groupname";
		}
		
		return true;
	}
Beispiel #29
0
function check_tz_dst($prefix)
{
    $maxtz = query("/runtime/services/timezone/zone#");
    $tz = query($prefix . "/timezone");
    if ($tz > $maxtz || $tz <= 0) {
        set_result("FAILED", $prefix . "/timezone", i18n("Invalid timezone setting."));
        return;
    }
    if (query("device/time/dst") != "1") {
        set("device/time/dst", "0");
    }
    TRACE_debug("FATLADY: DEVICE.TIME: timezone=" . $tz . ", dst=" . query("device/time/dst"));
    set_result("OK", "", "");
}
function import_csv($csv)
{
    $error_mess = array();
    $update = 0;
    $create = 0;
    $error = 0;
    while ($tab = $csv->readLine()) {
        $parentOk = false;
        if ($tab['Parent'] !== NULL) {
            $parent = \Pasteque\CategoriesService::getByName($tab['Parent']);
            $image = NULL;
            if ($parent) {
                $parentOk = true;
                $tab['Parent'] = $parent->id;
            }
        } else {
            // Category isn't subCategory
            $parentOk = true;
        }
        if ($parentOk) {
            $cat = new \Pasteque\Category($tab['Parent'], $tab['Designation'], $image, $tab['Ordre']);
            $category_exist = \Pasteque\CategoriesService::getByName($cat->label);
            //UPDATE category
            if ($category_exist) {
                $cat->id = $category_exist->id;
                if (\Pasteque\CategoriesService::updateCat($cat)) {
                    $update++;
                } else {
                    $error++;
                    $error_mess[] = \i18n("On line %d: Cannot update category: '%s'", PLUGIN_NAME, $csv->getCurrentLineNumber(), $tab['Designation']);
                }
                //CREATE category
            } else {
                $id = \Pasteque\CategoriesService::createCat($cat);
                if ($id) {
                    $create++;
                } else {
                    $error++;
                    $error_mess[] = \i18n("On line %d: Cannot create category: '%s'", PLUGIN_NAME, $csv->getCurrentLineNumber(), $tab['Designation']);
                }
            }
        } else {
            $error++;
            $error_mess[] = \i18n("On line %d: Category parent doesn't exist", PLUGIN_NAME, $csv->getCurrentLineNumber());
        }
    }
    $message = \i18n("%d line(s) inserted, %d line(s) modified, %d error(s)", PLUGIN_NAME, $create, $update, $error);
    $csv->close();
    \Pasteque\tpl_msg_box($message, $error_mess);
}