Beispiel #1
0
 public function Init()
 {
     /**
      * show all errors
      */
     show_errors();
     /**
      * check if page is secured
      */
     if (protocol() == 'https') {
         forceHTTPS();
     }
     /**
      * initializing session
      */
     sessions::init();
     /**
      * getting requested url
      */
     $this->Get_Url();
     /**
      * replace - to _
      */
     array_walk($this->_Url, array($this, 'Url_replace'));
     /**
      * check if controller name not exists
      */
     if (empty($this->_Url[0])) {
         $this->_Url[0] = default_controller();
     }
     $this->Set_Controller();
     $this->Set_Method();
 }
Beispiel #2
0
function MDB2Error($MDB2Object, $msg = "")
{
    if (PEAR::isError($MDB2Object)) {
        addError($msg . "<br>" . $MDB2Object->getMessage());
        if (EC_DEBUG) {
            addError($MDB2Object->getUserinfo());
        }
        show_errors();
        die;
    }
}
Beispiel #3
0
  <link rel="stylesheet" type="text/css" href="{!! asset('vendors/timepicker/bootstrap-timepicker.min.css') !!}">
@endsection

@section('footer')
  <script type="text/javascript" src="{!! asset('vendors/timepicker/bootstrap-timepicker.min.js') !!}"></script>
  
@endsection
@section('content')
    <section class="content-header">
      <h1>
        Sửa Teachers #{{ $data['teacher']->id }}
      </h1>

      <?php 
show_messages();
show_errors();
show_errors_validate();
?>

    </section>

    <section class="content">
  
    <div class="box box-primary">
      <form method="post" action="" role="form">
        {!! Form::token() !!}
        <div class="box-body">
          <input type="hidden" name="id" value="<?php 
$data['teacher']->id;
?>
">
Beispiel #4
0
		{
		$signup_count = 1;
		$action['result'] = 'success';
		array_push($text,'登録情報の変更が完了しました。');
		}
		else{
			$action['result'] = 'error';
			array_push($text,'User could not be updated to the database. Reason: ' . mysql_error());
		}
	}
	$action['text'] = $text;
}

?>

<?= show_errors($action); ?>

<?php
if($action['result'] == null){
 // SQL文
$sql = "SELECT username,email,name1,name2,kana1,kana2,postal,pref,address1,tel FROM users ";
$sql.= "WHERE username = '******'";
$result = mysql_query($sql);
$row = mysql_fetch_array($result, MYSQL_NUM);

$_POST['username'] = $row[0];
$_POST['email'] = $row[1];
$_POST['name1'] = $row[2];
$_POST['name2'] = $row[3];
$_POST['kana1'] = $row[4];
$_POST['kana2'] = $row[5];
Beispiel #5
0
    public function graph($opts = false)
    {
        $debug = false;
        if (is_array($opts)) {
            extract($opts);
        }
        if (!$view) {
            $view = "weekly";
        }
        if (!$this->tbl) {
            $this->tbl = $this->_loadTableInfo();
            // $this->tbl = self::$_tableInfo[$this->_table];
        }
        if (!$title) {
            $title = $this->_table;
        }
        if ($debug) {
            da($this->tbl);
        }
        if (!$this->_dateField) {
            // @todo, infer datefield from field info. JB  8/8/08 2:59 PM
            $errors[] = "We don't know the date field for {$this->_table}.";
        }
        if ($errors) {
            show_errors($errors);
        }
        $g = group_time($view, $this->_dateField, array("table" => $this->_table));
        $sql = $this->getTrendSql($opts);
        $trend = acqueryz($sql, $this->_db);
        $trend = $trend->fetchAll();
        $hidefields = array();
        $graphf = array($this->_dateField, 'count');
        $data = array();
        $i = 0;
        if (count($trend)) {
            ?>
            <div id="tableWrapper" style="display:none">
            <div>Showing <b><?php 
            echo $num;
            ?>
</b> records</div>
            <table class="list"><?php 
            foreach ($trend as $row) {
                $i++;
                $i % 2 ? $row_class = "odd" : ($row_class = "even");
                extract($row);
                if ($i == 1) {
                    // do header row
                    ?>
                      <tr class="reverse">
                        <td>Action</td>
                        <?php 
                    foreach ($row as $f => $v) {
                        if (!in_array($f, $hidefields)) {
                            ?>
                            <td><?php 
                            echo camelcap($f);
                            ?>
</td>
                       <?php 
                        }
                    }
                    ?>
                      </tr>
                <?php 
                }
                ?>
                <tr class="<?php 
                echo $row_class;
                ?>
">
                  <td> <a href="<?php 
                echo $this->_controller;
                ?>
?action=edit_<?php 
                echo $this->_table;
                ?>
&<?php 
                echo $this->_idField;
                ?>
=<?php 
                echo ${$this}->_idField;
                ?>
">Edit</a>
                  </td>
                  <?php 
                foreach ($row as $f => $v) {
                    if (!in_array($f, $hidefields)) {
                        if ($f == $graphf[0]) {
                            $v = date($g[dformat], strtotime($v));
                            $data[$i - 1][label] = $v;
                        }
                        if ($f == $graphf[1]) {
                            $data[$i - 1][point] = $v;
                        }
                        ?>
                            <td> <?php 
                        echo $v;
                        ?>
 </td>
                       <?php 
                    }
                    ?>
                  <?php 
                }
                ?>
                </tr>
                <?php 
            }
            ?>
</table>
            </div>
            <?php 
            if (count($data)) {
                $g = new ACGraph($data, $title . " " . $view);
                $g->render();
            }
        } else {
            ?>
<p>No <?php 
            echo $title;
            ?>
 records found</p><?php 
        }
    }
    $email = mysqli_real_escape_string($conn, $_GET['email']);
    $key = mysqli_real_escape_string($conn, $_GET['key']);
    echo " E:{$email} + K:{$key} ";
    //check if the key is in the database
    $check_key = $conn->query("SELECT * FROM `confirm` WHERE `email` = '{$email}' AND `key` = '{$key}' LIMIT 1") or die(mysql_error());
    echo "check_key";
    if (mysqli_num_rows($check_key) != 0) {
        echo "num_row >0";
        //get the confirm info
        $confirm_info = mysqli_fetch_assoc($check_key);
        //confirm the email and update the users database
        $update_users = $conn->query("UPDATE `users` SET `active` = 1 WHERE `id` = '{$confirm_info['userid']}' LIMIT 1") or die(mysql_error());
        //delete the confirm row
        $delete = $conn->query("DELETE FROM `confirm` WHERE `id` = '{$confirm_info['id']}' LIMIT 1") or die(mysql_error());
        if ($update_users) {
            $action['result'] = 'success';
            $action['text'] = 'User has been confirmed. Thank-You!';
        } else {
            $action['result'] = 'error';
            $action['text'] = 'The user could not be updated Reason: ' . mysql_error();
        }
    } else {
        echo "num_row=0";
        $action['result'] = 'error';
        $action['text'] = 'The key and email is not in our database.';
    }
}
echo show_errors($action);
?>

            <div id="content">

            <?php 
include 'personValidate.inc';
if ($_POST['_form_submit'] != 1) {
    //in this case, the form has not been submitted, so show it
    include 'personForm.inc';
} else {
    //in this case, the form has been submitted, so validate it
    $errors = validate_form();
    //step one is validation.
    // errors array lists problems on the form submitted
    if ($errors) {
        // display the errors and the form to fix
        show_errors($errors);
        if ($_POST['availability'] == null) {
            $ima = null;
        } else {
            $ima = implode(',', $_POST['availability']);
        }
        //editied by James Loeffler
        $person = new Person($_POST['first_name'], $_POST['last_name'], $birthday, $_POST['gender'], $_POST['address'], $_POST['city'], $_POST['state'], $_POST['zip'], $_POST['phone1'], $_POST['phone2'], $_POST['email'], $_POST['type'], $_POST['status'], $_POST['schedule'], $_POST['notes'], $_POST['skills'], $_POST['reason_interested'], $_POST['dateadded'], $_POST['old_pass'], $ima, $_POST['contact_preference']);
        include 'personForm.inc';
    } else {
        process_form($id);
    }
    echo "</div>";
    include 'footer.inc';
    echo '</div></body></html>';
    die;
Beispiel #8
0
function show_guestbook_add_form($formTitle = NULL, $buttonName = NULL)
{
    global $MAX_NAME_LENGTH;
    global $MAX_EMAIL_LENGTH;
    global $MAX_URL_LENGTH;
    global $NAME_FIELD_NAME;
    global $EMAIL_FIELD_NAME;
    global $URL_FIELD_NAME;
    global $COMMENTS_FIELD_NAME;
    global $ADD_FORM_LEGEND;
    global $ADD_FORM_BUTTON_TEXT;
    global $CHALLENGE_STRING_LENGTH;
    global $CHALLENGE_FIELD_NAME;
    global $CHALLENGE_FIELD_PARAM_NAME;
    global $ENABLE_EMAIL_FIELD;
    global $ENABLE_URL_FIELD;
    global $ENABLE_COMMENT_FIELD;
    global $GUESTBOOK_URL_PATH;
    global $NEW_REPLY_TEXT;
    if (!isset($formTitle)) {
        $formTitle = $ADD_FORM_LEGEND;
    }
    if (!isset($buttonName)) {
        $buttonName = $ADD_FORM_BUTTON_TEXT;
    }
    $ipaddress = $_SERVER['REMOTE_ADDR'];
    if (is_banned($ipaddress)) {
        return FALSE;
    }
    $nameValue = "";
    if (isset($_POST['name'])) {
        $nameValue = "value=\"" . htmlspecialchars_default($_POST['name']) . "\" ";
    }
    $emailValue = "";
    if (isset($_POST['email'])) {
        $emailValue = "value=\"" . htmlspecialchars_default($_POST['email']) . "\" ";
    }
    $urlValue = "";
    if (isset($_POST['url'])) {
        $urlValue = "value=\"" . htmlspecialchars_default($_POST['url']) . "\" ";
    }
    $commentsValue = "";
    if (isset($_POST['comments'])) {
        $commentsValue = htmlspecialchars_default($_POST['comments']);
    }
    ?>
<br>
<div style="width: 200px; margin: auto;">
	<a id="post_new_link" href="#"><b>
		<?php 
    echo htmlspecialchars_default($NEW_REPLY_TEXT);
    ?>
	</b></a>
</div>
<div id="error"><?php 
    show_errors();
    ?>
</div>
<form id="post_new" method="post" action="<?php 
    echo urlencode($GUESTBOOK_URL_PATH);
    ?>
">
<fieldset>
<?php 
    //<legend><?_php echo htmlspecialchars_default($formTitle); ?_></legend>
    ?>
<p>



<label for="name"><?php 
    echo htmlspecialchars_default($NAME_FIELD_NAME);
    ?>
:</label>
<input type="text" name="name" id="name" maxlength="<?php 
    echo htmlspecialchars_default($MAX_NAME_LENGTH);
    ?>
" class="inputText" <?php 
    echo $nameValue;
    ?>
/>
<br />

<?php 
    if ($ENABLE_EMAIL_FIELD === TRUE) {
        ?>
<label for="email"><?php 
        echo htmlspecialchars_default($EMAIL_FIELD_NAME);
        ?>
:</label>
<input type="text" name="email" id="email" maxlength="<?php 
        echo htmlspecialchars_default($MAX_EMAIL_LENGTH);
        ?>
" class="inputText" <?php 
        echo $emailValue;
        ?>
/>
<br />
<?php 
    }
    ?>
	
<?php 
    if ($ENABLE_URL_FIELD === TRUE) {
        ?>
<label for="url"><?php 
        echo htmlspecialchars_default($URL_FIELD_NAME);
        ?>
:</label>
<input type="text" name="url" id="url" maxlength="<?php 
        echo htmlspecialchars_default($MAX_URL_LENGTH);
        ?>
" class="inputText" <?php 
        echo $urlValue;
        ?>
/>
<br />
<?php 
    }
    ?>

<?php 
    if ($ENABLE_COMMENT_FIELD === TRUE) {
        ?>
<label for="comments"><?php 
        echo htmlspecialchars_default($COMMENTS_FIELD_NAME);
        ?>
:</label>
<textarea name="comments" id="comments" cols="40" rows="4" class="inputTextArea">
<?php 
        echo $commentsValue;
        ?>
</textarea>
<br />
<?php 
    }
    ?>

<?php 
    global $CHALLENGE_ENABLED;
    if ($CHALLENGE_ENABLED === TRUE) {
        // Create the challenge string and store in the session
        createChallengeString();
        ?>
<label for="<?php 
        echo htmlspecialchars_default($CHALLENGE_FIELD_PARAM_NAME);
        ?>
"><?php 
        echo htmlspecialchars_default($CHALLENGE_FIELD_NAME);
        ?>
:</label>
<input type="text" name="<?php 
        echo htmlspecialchars_default($CHALLENGE_FIELD_PARAM_NAME);
        ?>
" id="<?php 
        echo htmlspecialchars_default($CHALLENGE_FIELD_PARAM_NAME);
        ?>
" maxlength="<?php 
        echo htmlspecialchars_default($CHALLENGE_STRING_LENGTH);
        ?>
" size="<?php 
        echo htmlspecialchars_default($CHALLENGE_STRING_LENGTH);
        ?>
" class="inputText" />
<img src="<?php 
        echo urlencode($GUESTBOOK_URL_PATH);
        ?>
?action=challengeimage" alt="Challenge Image" class="challengeImage" />
<br />
<?php 
    }
    ?>

</p>
<input type="hidden" name="action" value="add" />
<input type="submit" value="<?php 
    echo htmlspecialchars_default($buttonName);
    ?>
" class="submit" />
</fieldset>  
</form>
<?php 
}
function bulutfon_output($vars)
{
    require_once "init.php";
    $repository = new Repository();
    $request = Request::createFromGlobals();
    $provider = new Bulutfon($repository->getKeys());
    $tokens = $repository->getTokens();
    $smarty = bulutfon_smarty();
    if ($tokens) {
        $token = new AccessToken(Helper::decamelize($tokens));
    } else {
        Helper::outputIfAjax("<a href='{$provider->getAuthorizationUrl()}' class='button'>Yetkilendir.</a>");
        Helper::redirect($provider->getAuthorizationUrl());
    }
    switch ($request->get('tab', 'default')) {
        case 'delete':
            $phone = (int) $request->get('number', false);
            if ($repository->deleteNumber($phone)) {
                Helper::json('deleted');
            }
            Helper::json('failed');
            break;
        case 'addtouser':
            $smarty->assign('number', $request->get('number'));
            if ($request->get('clientid')) {
                $validator = new Valitron\Validator($_POST);
                $rules = array('required' => array(array('telefon-numarasi'), array('clientid'), array('value')), 'integer' => array(array('telefon-numarasi'), array('clientid')), 'lengthMin' => array(array('telefon-numarasi', 10)), 'lengthMax' => array(array('telefon-numarasi', 20)));
                $validator->rules($rules);
                function show_errors($array, $value, $smarty)
                {
                    $errors = "<div style='color: #a94442;background-color: #f2dede;border:1px solid #ebccd1;padding:5px'><ul style='padding:0'>";
                    if (isset($array)) {
                        foreach ($array as $e) {
                            $errors .= "<li>{$e}</li>";
                        }
                        $smarty->assign($value, "{$errors}</ul></div>");
                    }
                }
                if ($validator->validate()) {
                    $add = $repository->addNumber($request->get('clientid'), $request->get('telefon-numarasi'));
                    if ($add) {
                        $smarty->assign('success', 'Kayıt başarıyla eklenmiştir.');
                    } else {
                        $errors = array();
                        $errors['telefon-numarasi'] = array('Bu telefon numarası zaten kayıtlı.');
                        show_errors($errors['telefon-numarasi'], 'telefon', $smarty);
                        $smarty->assign('number', $request->get('telefon-numarasi'));
                    }
                } else {
                    // really hate smarty and i am a bit lazy.
                    $errors = $validator->errors();
                    // it must be handled by smarty but i cant figure out
                    show_errors($errors['telefon-numarasi'], 'telefon', $smarty);
                    show_errors($errors['clientid'], 'user', $smarty);
                    show_errors($errors['value'], 'user', $smarty);
                }
            }
            $smarty->display('adduser.tpl');
            break;
        default:
            $page = $request->get('page', 1);
            $userid = $request->get('userid');
            // 100 results a bit overkill setted to 10.
            $filters = array('limit' => (int) $request->get('limit', 10));
            $fields = true;
            if ($userid) {
                $smarty->assign('userid', $userid);
                $numbers = $repository->getUserNumbers($userid);
                if (!$numbers) {
                    Helper::json("<p>Kayıtlı telefon numarası bulunamadı.</p>");
                }
                $smarty->assign('userNumbers', $numbers);
                foreach ($numbers as $number) {
                    if (strlen($number) > 9 && strlen($number) < 12) {
                        array_push($numbers, '90' . ltrim($number, '0'));
                    }
                }
                $numbers = Helper::imp($numbers);
                $filters['caller_or_callee'] = $numbers;
            }
            $smarty->assign('cdrs', $provider->getCdrs($token, $filters, $page)->cdrs);
            $smarty->assign('fields', $fields);
            $smarty->assign('page', $page);
            $smarty->assign('limit', (int) $request->get('limit', 10));
            Helper::outputIfAjax($smarty->fetch('cdr.tpl'));
            $smarty->display('cdr.tpl');
            break;
    }
}
Beispiel #10
0
function db_populate($install_filename, $display_sql)
{
    global $show_all_errors, $str_parsed_sql;
    if ($install_filename == '') {
        return;
    }
    $current_pointer = false;
    $full_sql = '';
    $magic = @get_magic_quotes_runtime();
    @set_magic_quotes_runtime(0);
    $fd = @fopen('sql/' . $install_filename, 'r', true);
    // Discard everything up to the required point in the upgrade file.
    while (!feof($fd) && empty($current_pointer)) {
        $data = trim(fgets($fd, 4096), "\r\n ");
        if (strpos(strtoupper($data), strtoupper($_SESSION['install_file'])) || substr($_SESSION['install_file'], 0, 6) == 'tables') {
            $current_pointer = true;
        }
    }
    // We already have a $data item from above.
    if (substr($data, 0, 2) == "/*" && substr($_SESSION['install_file'], 0, 6) != 'tables') {
        // Do nothing...We skip over comments in upgrade files.
    } else {
        $full_sql .= $data;
    }
    // We need to strip out the comments from upgrade files.
    while (!feof($fd)) {
        $data = trim(fgets($fd, 4096), "\r\n ");
        if (substr($data, 0, 2) == '/*' && substr($_SESSION['install_file'], 0, 6) != 'tables') {
            // Do nothing...We skip over comments in upgrade files.
        } else {
            $full_sql .= $data;
        }
    }
    @set_magic_quotes_runtime($magic);
    fclose($fd);
    $parsed_sql = parse_sql($full_sql);
    // String version of parsed_sql that is used if displaying SQL only.
    $str_parsed_sql = '';
    for ($i = 0, $sqlCntStr = count($parsed_sql); $i < $sqlCntStr; $i++) {
        if (empty($display_sql)) {
            if ($show_all_errors == true) {
                echo $parsed_sql[$i] . '<br />';
            }
            dbi_execute($parsed_sql[$i], array(), false, $show_all_errors);
        } else {
            $str_parsed_sql .= $parsed_sql[$i] . "\n\n";
        }
    }
    // Enable warnings.
    show_errors(true);
}
Beispiel #11
0
 $db_password = getPostValue('form_db_password');
 $db_cachedir = getPostValue('form_db_cachedir');
 //Allow  field length to change if needed
 $onload = 'db_type_handler();';
 //disable warnings
 show_errors();
 $real_db = $db_database;
 if ($db_type == 'sqlite') {
     $real_db = get_full_include_path($db_database);
 }
 if ($db_password == 'none') {
     $db_password = '';
 }
 $c = dbi_connect($db_host, $db_login, $db_password, $real_db, false);
 //enable warnings
 show_errors(true);
 if ($c) {
     $_SESSION['db_success'] = true;
     // Do some queries to try to determine the previous version
     get_installed_version();
     $response_msg = '<b>' . translate('Connection Successful') . '</b> ' . translate('Please go to next page to continue installation') . '.';
 } else {
     $response_msg = $failure . dbi_error() . "</blockquote>\n";
     // See if user is valid, but database doesn't exist
     // The normal call to dbi_connect simply return false for both conditions
     if ($db_type == 'mysql') {
         $c = mysql_connect($db_host, $db_login, $db_password);
     } else {
         if ($db_type == 'mssql') {
             $c = mssql_connect($db_host, $db_login, $db_password);
         } else {
Beispiel #12
0
<h3><?php 
echo l('new_tab');
?>
</h3>
<form action="<?php 
echo Request::requestUri();
?>
" method="post" class="overlay_thin">
	<?php 
echo show_errors($tab->errors);
?>
	<div class="tabular box">
		<?php 
echo View::render('custom_tabs/_form');
?>
	</div>
	<div class="actions">
		<input type="submit" value="<?php 
echo l('create');
?>
" />
		<input type="button" value="<?php 
echo l('cancel');
?>
" onclick="close_overlay();" />
	</div>
</form>
function show_page()
{
    global $gearmanxi_cfg;
    global $errors;
    $make_worker_html = true;
    // make the apache_safe_dir if we need to
    if (!file_exists($gearmanxi_cfg["apache_safe_dir"])) {
        if (!mkdir($gearmanxi_cfg["apache_safe_dir"], 0777, true)) {
            $errors[] .= "Unable to create apache safe directory: " . $gearmanxi_cfg["apache_safe_dir"];
        }
    }
    // rudimentary check to see if user has set up the config array
    if (!empty($gearmanxi_cfg["worker"]["example1"]) && !empty($gearmanxi_cfg["worker"]["example2.fqdn.com"])) {
        $errors[] = "It looks like you haven't set up the configuration array in " . dirname(__FILE__) . "/modgearmanxi.config.inc.php";
        $make_worker_html = false;
    }
    do_page_start(array("page_title" => "ModGearman XI Manager"), true);
    echo "<h1>ModGearman XI Manager</h1>";
    show_errors($errors);
    // build the correlating list of tabs and div content for that div - all while building a portion of the overview status table
    $worker_tabs = "";
    $worker_divs = "";
    $overview_status_table = "<table class='infotable table table-condensed table-bordered' style='width: 60%;'>";
    if ($make_worker_html) {
        foreach ($gearmanxi_cfg["worker"] as $worker_name => $worker) {
            $worker_id = base64_encode($worker_name);
            // build the tabs section
            $worker_tabs .= "<li><a href='#{$worker_name}' title='{$worker_name}'><span>{$worker_name}</span></a></li>\n";
            // get the info we need to build the rest of the html
            $worker_can_connect = test_ssh_connectivity($worker["user"], $worker["ip"]);
            $worker_gearman_cfg_readable = test_cfg_writable($worker["user"], $worker["ip"], $worker["cfg"]);
            $worker_gearman_cfg_writable = test_cfg_writable($worker["user"], $worker["ip"], $worker["cfg"]);
            $worker_gearman_dir_writable = test_dir_writable($worker["user"], $worker["ip"], dirname($worker["cfg"]));
            // copy the remote file so we can edit it if we need to
            $worker_local_conf = local_copy_cfg($worker["user"], $worker["ip"], $worker["cfg"]);
            $worker_copy_conf_successful = scp_remote_file($worker["user"], $worker["ip"], $worker["cfg"], $worker_local_conf);
            // service control stuff
            $worker_gearman_running = service_status($worker["user"], $worker["ip"], $worker["initd"], $worker_gearman_running_text);
            $action_value = "Restart Worker";
            $stop_button = "<input type='submit' name='cmd' value='Stop Worker' style='margin-left: 5px;' />";
            if ($worker_gearman_running == false) {
                $stop_button = "";
                if (strpos($worker_gearman_running_text, "is not running") !== false) {
                    $action_value = "Start Worker";
                } else {
                    $action_value = "Attempt to Start Worker";
                }
            }
            // build this workers div
            $worker_divs .= "<div id='{$worker_name}' style='width: 60%;'>" . "<form method='post'>" . "<input type='hidden' name='worker_id' value='{$worker_id}' />" . "<table class='infotable table table-condensed table-striped table-bordered'>" . "<tr><td>Username:</td><td>" . $worker["user"] . "</td></tr>" . "<tr><td>IP Address:</td><td>" . $worker["ip"] . "</td></tr>" . "<tr><td>Configuration File:</td><td>" . $worker["cfg"] . "</td></tr>" . "<tr><td>Service Control:</td><td>" . $worker["initd"] . "</td></tr>" . "</table>" . worker_status_table("infotable table table-condensed table-striped table-bordered", $worker_can_connect, $worker_gearman_cfg_readable, $worker_gearman_cfg_writable, $worker_gearman_dir_writable, $worker_gearman_running, $worker_gearman_running_text) . "<input type='submit' name='cmd' value='{$action_value}' />" . $stop_button . "<input type='submit' name='cmd' value='Update Configuration' style='float: right;' />" . "<textarea name='conf' rows='24' style='width: 100%; margin-top: 5px;'>" . file_get_contents($worker_local_conf) . "</textarea>" . "</form>" . "</div>";
            // build the status table for overview
            $overview_status_table .= "<tr>" . "<td><strong>{$worker_name}</strong>&nbsp;" . $worker["user"] . "@" . $worker["ip"] . ":" . $worker["cfg"] . " (" . $worker["initd"] . ")</td>" . "</tr><tr>" . "<td align='right'>" . worker_status_table("infotable table table-condensed table-striped table-bordered", $worker_can_connect, $worker_gearman_cfg_readable, $worker_gearman_cfg_writable, $worker_gearman_dir_writable, $worker_gearman_running, $worker_gearman_running_text) . "<form method='post'>" . "<input type='hidden' name='worker_id' value='{$worker_id}' />" . "<div style='float: right; display: inline-block; margin-top: 5px;'>" . "<input type='submit' name='cmd' value='{$action_value}' />" . $stop_button . "</div>" . "</form>" . "</td>" . "</tr>";
        }
    }
    $overview_status_table .= "</table>";
    ?>
  <script>
  $(function () {
    $("#tabs").tabs().show();
  });
  window.setInterval(function() {
    $.ajax("modgearmanxi.php?cmd=top&ver=<?php 
    echo $gearmanxi_cfg["mod_gearman_version"];
    ?>
").done(function(html) {
      $("#gearman_top").empty().append(html);
    });
  }, 1000);
  </script>
  <p>Manage all of your remote ModGearman Workers from a central location!</p>
  <p>In order to make full use of this component, you'll need to make sure that 
     this servers apache user can connect remotely - without password authentication -
     to each of the worker servers you want to manage. The user that you connect as to 
     each of those servers needs to have read/write access to the configuration 
     files listed in modgearmanxi.config.inc.php.</p>
  <p>There is a script that you can run (it isn't necessary as long as you've met the 
     previous listed requirements) to make all that easier. Its located at 
  <strong style="font-family: courier;"><?php 
    echo dirname(__FILE__) . "/setup.sh";
    ?>
</strong>.</p>
  <div id="tabs" class="hide">
  <ul class="tabnavigation">
  <li><a href="#overview" title="Overview"><span>Overview</span></a></li>
  <?php 
    echo $worker_tabs;
    ?>
  </ul>
  <div id="overview" class="ui-tabs-hide">
  <h5 class="ul">gearman_top Output</h5>
  <div id="gearman_top" style="display: inline-block;"></div>
  <h5 class="ul">ModGearman Workers</h5>
  <?php 
    echo $overview_status_table;
    ?>
  </div>
  <?php 
    echo $worker_divs;
    ?>
  </div>
  <?php 
}
/**
* update_booking retrieves and sanitizes $_POST data, and uses it to update
* the booking with $b_id, then updates the databse
* @param   string    $b_id the id of the booking to update
* @return the updated booking or false if unsuccessful
*/
function update_booking($b_id)
{
    include 'bookingValidate.inc';
    $e = validate_form();
    if (sizeof($e) == 0) {
        $b = retrieve_dbBookings($b_id);
        $referred_by = trim(str_replace("'", "\\'", htmlentities($_POST['referred_by'])));
        $b->set_referred_by($referred_by);
        $hospital = trim(str_replace("'", "\\'", htmlentities($_POST['hospital'])));
        $b->set_hospital($hospital);
        $department = trim(str_replace("'", "\\'", htmlentities($_POST['dept'])));
        $b->set_department($department);
        $b->set_health_questions($_POST['health_questions']);
        //sets date_in to Will Call if date in is not yet known
        if ($_POST['visitOrWC'] == "Will Call") {
            $b->set_date_in("Will Call");
        } else {
            $date_in = $_POST['date_in_year'] . '-' . $_POST['date_in_month'] . '-' . $_POST['date_in_day'];
            $b->set_date_in($date_in);
        }
        //updates day and overnight use
        if ($_POST['overnight'] == "yes") {
            $b->set_overnight_use("yes");
        } else {
            $b->set_overnight_use("no");
        }
        if ($_POST['day'] == "yes") {
            $b->set_day_use("yes");
        } else {
            $b->set_day_use("no");
        }
        //sets payment arrangement
        $payment = trim(str_replace("'", "\\'", htmlentities($_POST['payment'])));
        $b->set_payment_arrangement($payment);
        //updates notes
        $notes = trim(str_replace("'", "\\'", htmlentities($_POST['notes'])));
        $b->set_mgr_notes($notes);
        $new_status = $_POST['status'];
        $b->set_status($new_status);
        if (update_dbBookings($b)) {
            return $b;
        } else {
            return false;
        }
    } else {
        echo 'The booking could not be updated for the following reasons: <br/>';
        show_errors($e);
        echo 'Click <a href = viewBookings.php?id=update&bookingid=' . $b_id . '>Edit This Booking </a> to try editing again';
        return 'incomplete';
    }
}
Beispiel #15
0
 /**
  * This works with scriptaculous in-place editor for text data types only.
  * @author Jonah  10/25/08 12:30 PM
  * @todo - Return the field name of the related table record in the case of relationships.
  *
  * @version 1.0
  * @returns the value given to the function that was just updated in the db.
  */
 public function saveAjax($opts = false)
 {
     $R =& $_REQUEST;
     if ($opts && is_array($opts)) {
         extract($opts);
     }
     //  validate some variables
     if (!isset($R[value])) {
         $errors[] = "Value field not provided to DBOS:ajax_db, information was not saved.  Use standard edit link.";
     } else {
         $value = $R[value];
     }
     if (!($field = $R[field])) {
         $errors[] = "Field var not provided to DBOS:ajax_db, information was not saved.  Use standard edit link.";
     }
     if (!is_numeric($this->id)) {
         $errors[] = "DBOS:ajax_db must have numeric id to update. {$this->id}";
     }
     if ($errors) {
         show_errors($errors);
         return;
     }
     // Some data types will be translated
     if ($R[type] == "binary") {
         if (strtolower($value) == "yes" || $value == 1) {
             $value = 1;
             $out_value = "Yes";
         } else {
             $value = 0;
             $out_value = "No";
         }
     } else {
         // $out_value = $R[value];
     }
     // ok, we have sane data, give it a try:
     // $sql = " UPDATE  $this->table SET $field = '".mes($value)."' WHERE $this->indexField = '$this->id' LIMIT 1 ";
     // $this->set($field,$value);
     $this->{$field} = $value;
     $this->save();
     // $this->db_query($sql);
     if (!$out_value) {
         $out_value = $this->{$field};
     }
     echo $out_value;
 }
 public function save()
 {
     $debug = false;
     $changed_fields = array();
     $table_fields = $this->getTableFields();
     if ($this->debug) {
         da($table_fields);
     }
     foreach ($table_fields as $k) {
         if ($k == $this->_idField) {
             continue;
         }
         if ($k == $this->_timeStampField) {
             continue;
         }
         $v = $this->getField($k);
         // Be smart about dates.  JB  10/8/08 4:48 PM
         if ($debug) {
             da("hello {$k}");
         }
         if (!self::$_tableInfo[$this->_table][$k]) {
             self::$_tableInfo[$this->_table][$k] = $this->loadTable();
             // da(self::$_tableInfo[$this->_table]);
         }
         $field_type = self::$_tableInfo[$this->_db . "." . $this->_table][$k]['type'];
         if (($field_type == "datetime" || $field_type == "date") && $this->_dbValues[$k] != $v) {
             $tmp_date = $v;
             if (trim($v)) {
                 // Fix for some time situations that confuse strtotime
                 $tparts = explode(" ", $v);
                 if (is_array($tparts)) {
                     if (strtolower($tparts[2]) == "pm") {
                         if (substr($tparts[1], 0, 2) > 12) {
                             $v = str_replace("pm", "", $v);
                         }
                     }
                 }
                 $timestamp = strtotime($v);
                 $v = date("Y-m-d H:i:s", $timestamp);
                 $this->{$k} = $v;
             }
             if ($debug) {
                 da("This is a date: {$tmp_date} : {$v} ");
             }
         }
         if ($this->_dbValues[$k] != $v) {
             $changed_fields[$k] = $v;
         }
     }
     $is_update = 0;
     // deal with index fields
     if (is_string($this->_idField)) {
         $idf = $this->_idField;
         if ($id = $this->{$idf}) {
             if ($this->isId($id)) {
                 if ($this->exists($id)) {
                     $is_update = 1;
                 } else {
                     // add id to fields to insert
                     $had_id = 1;
                     $changed_fields[$idf] = $id;
                 }
             }
             // if there's no id, we just hope for having an id from auto_increment
             $sql_where = " `{$idf}` = '{$id}' ";
         }
     } elseif (is_array($this->_idField)) {
         unset($sql_set);
         foreach ($this->_idField as $field) {
             $sql_set[] = " {$field} = '{$this->{$field}}' ";
         }
         $sql_where = implode(" AND ", $sql_set);
     }
     // Don't do the query if we don't seem to have anything new to save.
     if (empty($changed_fields) && !is_update) {
         // When creating a new record it is legitimate to not set any fields.
         if ($this->debug) {
             show_errors("There were no fields to change.");
         }
         return false;
     } else {
         if ($this->debug) {
             da($changed_fields);
         }
     }
     $ss = $this->_setstr($changed_fields);
     $set_sql = "{$ss}";
     if (!$set_sql) {
         // apparently, nothing has changed.
         return false;
     }
     if ($is_update) {
         $sql = "UPDATE {$this->_table} SET {$set_sql} WHERE {$sql_where} LIMIT 1";
     } else {
         $sql = "INSERT INTO {$this->_table} SET {$set_sql} ";
         // the following isn't implemented yet.  JB  5/28/08 8:21 AM
         $sql .= " ON DUPLICATE KEY UPDATE {$set_sql}";
     }
     $this->last_sql = $sql;
     if ($this->debug) {
         echo "SQL: {$sql}\n";
     }
     $ok = mysql_db_query($this->_db, $sql);
     if ($this->debug) {
         da($sql);
     }
     if (!$ok) {
         mysql_die($sql);
         return false;
     } else {
         if (!$is_update and !$had_id) {
             $id = mysql_insert_id();
         }
         $this->loadFields($id);
         return $id;
     }
 }