Exemplo n.º 1
0
function print_table($matrix)
{
    global $g_xml;
    global $g_list;
    global $g_total_machines;
    global $g_list_length;
    global $g_time_now;
    // print all attributes in a table
    echo '<table border="0" cellpadding="4" cellspacing="2">';
    //echo '<caption>Details</caption>';
    echo '<tr class="d2">';
    for ($col = 0; $col < $g_list_length; $col++) {
        echo '<th>', $g_list[$col], '</th>';
        // add a column that computes the job running time by subtracting current time with JobStart
        if ($g_list[$col] == 'JobStart') {
            echo '<th>JobRunTime</th>';
        }
    }
    echo '</tr>';
    for ($row = 0; $row < $g_total_machines; $row++) {
        echo '<tr class="d', $row & 1, '">';
        for ($col = 0; $col < $g_list_length; $col++) {
            echo '<td>', format_data($g_list[$col], $matrix[$row][$col]), '</td>';
        }
        echo '</tr>';
    }
    echo '</table>';
}
Exemplo n.º 2
0
function ConverteData($data, $formato, $locale = 'pt_BR')
{
    if (!$data) {
        return null;
    }
    $data = trim($data);
    setlocale(LC_ALL, $locale);
    $timestamp = parse_data($data, $locale);
    return format_data($timestamp, $formato);
}
Exemplo n.º 3
0
 /**
  * 新增或更新一个文章
  * @author jry <*****@*****.**>
  */
 public function update()
 {
     // 处理数据
     $_POST = format_data();
     //调用create方法构造数据
     $cid = I('post.cid');
     $category_info = D($this->moduleName . '/Category')->find($cid);
     $doc_type_info = D($this->moduleName . '/Type')->where(array('id' => $category_info['doc_type']))->find();
     $_POST['doc_type'] = $doc_type_info['id'];
     $base_data = $this->create();
     if ($base_data) {
         //获取当前分类
         $extend_table_object = D($this->moduleName . '/' . $this->moduleName . ucfirst($doc_type_info['name']));
         $extend_data = $extend_table_object->create();
         //子模型数据验证
         if (!$extend_data) {
             $this->error = $extend_table_object->getError();
         }
         if ($extend_data) {
             if (empty($base_data['id'])) {
                 //新增基础内容
                 $base_id = $this->add();
                 if ($base_id) {
                     $extend_data['id'] = $base_id;
                     $extend_id = $extend_table_object->add($extend_data);
                     if (!$extend_id) {
                         $this->delete($base_id);
                         $this->error = '新增扩展内容出错!';
                         return false;
                     }
                     return $base_id;
                 } else {
                     $this->error = '新增基础内容出错!';
                     return false;
                 }
             } else {
                 $status = $this->save();
                 //更新基础内容
                 if ($status) {
                     $status = $extend_table_object->save();
                     //更新基础内容
                     if (false === $status) {
                         $this->error = '更新扩展内容出错!';
                         return false;
                     }
                     return $extend_data;
                 } else {
                     $this->error = '更新基础内容出错!';
                     return false;
                 }
             }
         }
     }
     return false;
 }
Exemplo n.º 4
0
 /**
  * 编辑文章
  * @author jry <*****@*****.**>
  */
 public function edit($id)
 {
     if (IS_POST) {
         $post_object = D('Admin/Post');
         $data = $post_object->create(format_data());
         if ($data) {
             $id = $post_object->save();
             if ($id !== false) {
                 $this->success('更新成功', U('index'));
             } else {
                 $this->error('更新失败');
             }
         } else {
             $this->error($post_object->getError());
         }
     } else {
         // 使用FormBuilder快速建立表单页面。
         $builder = new \Common\Builder\FormBuilder();
         $builder->setMetaTitle('编辑文章')->setPostUrl(U('edit'))->addFormItem('id', 'hidden', 'ID', 'ID')->addFormItem('title', 'text', '标题', '标题')->addFormItem('abstract', 'textarea', '摘要', '摘要')->addFormItem('content', 'kindeditor', '内容', '内容')->addFormItem('cover', 'picture', '封面', '封面')->addFormItem('create_time', 'datetime', '发布时间', '发布时间')->addFormItem('sort', 'num', '排序', '用于显示的顺序')->setFormData(D('Admin/Post')->find($id))->display();
     }
 }
Exemplo n.º 5
0
<?php

require "../private_php/print_private_area.php";
require_file();
$conn = connection_db();
session_control();
if (isset($_POST["Inserisci"])) {
    //Verifiche integrità dati
    if (!empty($_POST['nome']) && !empty($_POST['cognome']) && !empty($_POST['gg']) && !empty($_POST['mm']) && !empty($_POST['yy']) && !empty($_POST['luogoN'])) {
        if (preg_match("/^[^@ ]{2,}@[^@ \\.]+\\.[^@ \\.]{2,}\$/", $_POST['email']) or empty($_POST['email'])) {
            if (checkdate($_POST['mm'], $_POST['gg'], $_POST['yy'])) {
                $dataN = format_data($_POST['yy'], $_POST['mm'], $_POST['gg']);
                $test = true;
                $query = "INSERT INTO persona (`id`, `nome`, `cognome`, `sesso`, `dataNascita`, `luogoNascita`, `telefono`, `email`, `parrocchia`, `assicurato`) VALUES ('', '" . addslashes($_POST['nome']) . "', '" . addslashes($_POST['cognome']) . "', '" . $_POST['sesso'] . "', '{$dataN}', '" . addslashes($_POST['luogoN']) . "', '" . $_POST['telefono'] . "', '" . $_POST['email'] . "', '" . addslashes($_POST['parrocchia']) . "', 'no')";
                mysql_query($query, $conn) or $test = false;
                connection_db_close($conn);
                if ($test) {
                    $mess = urlencode("siInserimento avvenuto con successo");
                    header('location: ' . $_SERVER['PHP_SELF'] . '?msg=' . $mess);
                } else {
                    echo $query . "OPS! query fallita";
                }
            } else {
                $mess = urlencode("noIl campo data non è valido");
                header('location: ' . $_SERVER['PHP_SELF'] . '?msg=' . $mess);
            }
        } else {
            $mess = urlencode("noInserire una email valida");
            header('location: ' . $_SERVER['PHP_SELF'] . '?msg=' . $mess);
        }
    } else {
Exemplo n.º 6
0
function db_query($data, $action, $table, $field, $row = "temp_row_id", $return = false)
{
    global $current_user_id;
    // update - select existing values for comparison
    if ($action == "UPDATE") {
        $_fields = '';
        foreach ($data as $_key => $_val) {
            $_fields .= "`" . $_key . "`,";
            $_newvalues[] = format_data($_val);
        }
        $_fields = remove_lastchar(trim($_fields), ",");
        if ($_fields) {
            $_sql_select = "SELECT " . $_fields . " FROM " . $table . " WHERE " . $field . " = " . $row . " LIMIT 1";
            $_result = mysql_query($_sql_select);
            if (!$_result) {
                die("MySQL Error:  " . mysql_error() . "<pre>db_query: " . $_sql_select . "</pre>");
            }
            while ($_row_select = mysql_fetch_array($_result)) {
                foreach ($data as $_key => $_val) {
                    // format old values to make sure sql works, this makes line breaks count as changed
                    $_oldvalues[$_key] = addslashes($_row_select[$_key]);
                }
            }
            mysql_free_result($_result);
        }
    } elseif ($action == "INSERT") {
        foreach ($data as $_key => $_val) {
            $_newvalues[] = format_data($_val);
            $_oldvalues[$_key] = "NULL";
        }
    }
    // we should now have 2 arrarys of fieldnames as keys and new and old values
    if (count($data) !== count($_oldvalues)) {
        echo 'db_query: array count not matched<p>';
        exit;
    }
    // construct sql for $_table AND changelog table, single query with multiple inserts
    $_sql_log = "INSERT INTO changelog\n\t(`cha_user`,`cha_session`,`cha_action`,`cha_table`,`cha_row`,`cha_field`,`cha_old`,`cha_new`)\n\tVALUES\n\t";
    // loop _data, check if current(old) value is different to new, and create sql statements accordingly
    $_sql_update = '';
    $_sql_insert1 = '';
    $_sql_insert2 = '';
    $_msg = '';
    $_changecount = 0;
    foreach ($data as $_key => $_val) {
        if ($_oldvalues[$_key] != $_val) {
            if ($_val == "NULL") {
                $_sql_update .= $_key . "=NULL,";
            } elseif ($_val == "") {
                $_sql_update .= $_key . "='',";
            } else {
                $_sql_update .= $_key . "='" . format_data($_val) . "',";
            }
            $_sql_insert1 .= $_key . ",";
            if ($table == 'property') {
                $_sql_insert2 .= "'" . addslashes($_val) . "',";
                $_sql_log .= "('" . $current_user_id . "','" . session_id() . "','" . $action . "','" . $table . "','" . $row . "','" . $_key . "','" . $_oldvalues[$_key] . "','" . addslashes($_val) . "'),\n";
            } else {
                $_sql_insert2 .= "'" . format_data($_val) . "',";
                $_sql_log .= "('" . $current_user_id . "','" . session_id() . "','" . $action . "','" . $table . "','" . $row . "','" . $_key . "','" . $_oldvalues[$_key] . "','" . format_data($_val) . "'),\n";
            }
            $_msg .= $_key . " was changed from " . $_oldvalues[$_key] . " to " . $_val . "\n";
            $_changecount++;
            $returnArray[$_key] = array('old' => $_oldvalues[$_key], 'new' => $_val);
        }
    }
    $_sql_log = remove_lastchar(trim($_sql_log), ",");
    $_sql_update = remove_lastchar(trim($_sql_update), ",");
    $_sql_insert1 = remove_lastchar(trim($_sql_insert1), ",");
    $_sql_insert2 = remove_lastchar(trim($_sql_insert2), ",");
    if ($action == "UPDATE") {
        $_sql_return = "UPDATE " . $table . " SET " . $_sql_update . " WHERE " . $field . " = " . $row;
    } elseif ($action == "INSERT") {
        $_sql_return = "INSERT INTO " . $table . " (" . $_sql_insert1 . ") VALUES (" . $_sql_insert2 . ")";
    }
    /* elseif ($_action == "DELETE") {
    		$_sql_return = "DELETE FROM ".$_table." WHERE ".$_field." = ".$_row;
    		}*/
    if ($_changecount) {
        // only execute the sql queries if a change has been made
        $_result_return = mysql_query($_sql_return);
        if (!$_result_return) {
            die("MySQL Error:  " . mysql_error() . "<pre>db_query RETURN: " . $_sql_return . "</pre>");
        }
        if ($action == "UPDATE") {
            $_insert_id = $row;
        } elseif ($action == "INSERT") {
            $_insert_id = mysql_insert_id();
            $_sql_log = str_replace("temp_row_id", $_insert_id, $_sql_log);
            // replace temp_row_id with insert_id
        }
        //mysql_free_result($_result_return);
        $_result_log = mysql_query($_sql_log);
        if (!$_result_log) {
            die("MySQL Error:  " . mysql_error() . "<pre>db_query LOG: " . $_sql_log . "</pre>");
        }
        //mysql_free_result($_result_log);
    }
    // dubug info
    if ($return == true) {
        return array('row' => $_insert_id, 'array' => $returnArray);
    } else {
        return $_insert_id;
        // return the effected row in $_table, not changelog
    }
    unset($data, $action, $table, $field, $row);
}
Exemplo n.º 7
0
    $days = floor($time / 86400);
    $time %= 86400;
    if ($days) {
        echo $days . ' Tage(n), ';
    }
    echo gmdate('H:i:s', $time);
    ?>
 Stunden nicht geladen werden!</p>
	<?php 
}
?>
	<?php 
if ($can_edit && !$feed['update_timestamp']) {
    ?>
	<p class="info nomargin"><em>Hinweis:</em> Es kann ein wenig dauern, bis diese Liste die letzten Änderungen berücksichtigt.</p>
	<?php 
}
$feeds = $database->query('SELECT data, id FROM data WHERE feed_id = ' . $feed_id . ' AND timestamp IS NOT NULL ORDER BY id ASC');
$feed = $feeds->fetch();
if ($feed) {
    echo '<ol><li>' . format_data($feed['data'], $feed['id']) . '</li>';
    foreach ($feeds as $feed) {
        echo '<li>' . format_data($feed['data'], $feed['id']) . '</li>';
    }
    echo '</ol>';
} else {
    echo '<p>- Bisher keine -</p>';
}
?>
</div>
Exemplo n.º 8
0
     $db_data = $results['Results'];
     // build return link
     $return = $_SERVER['SCRIPT_NAME'] . '?';
     if ($_POST["app_id"]) {
         $results['Results']['app_id'] = $_POST["app_id"];
     }
     if (is_array($results['Results'])) {
         $return .= http_build_query($results['Results']);
     }
     if ($results['Errors']) {
         echo error_message($results['Errors'], urlencode($return));
         exit;
     }
     // extract notes from db_data and store in notes table
     if ($db_data["notes"]) {
         $notes = format_data($db_data["notes"]);
         unset($db_data["notes"]);
         if ($notes) {
             $db_data2 = array('not_blurb' => $notes, 'not_row' => $app_id, 'not_type' => 'appointment', 'not_user' => $_SESSION["auth"]["use_id"], 'not_date' => $date_mysql);
             db_query($db_data2, "INSERT", "note", "not_id");
         }
     }
     unset($db_data["notes"]);
     //echo "<hr>$app_starthr>";
     // now add the date, time and duration to db_data array
     $db_data["app_start"] = date(MYSQL_DATE_FORMAT, $app_start);
     $db_data["app_end"] = date(MYSQL_DATE_FORMAT, $app_end);
     //print_r($db_data);
     //exit;
     db_query($db_data, "UPDATE", "appointment", "app_id", $app_id);
 }
</span>
					<?php 
}
?>
				</div>
				<div class="form-group">
	       			<label>Saída</label>
	       			<span id="helpBlock" class="help-block"><?php 
echo format_data($deslocamento->des_saida);
?>
</span>
				</div>				
				<div class="form-group">
	       			<label>Chegada</label>
	       			<span id="helpBlock" class="help-block"><?php 
echo format_data($deslocamento->des_chegada);
?>
</span>
				</div>
				<div class="form-group">
					<label>Endereço de origem</label>
					<span id="helpBlock" class="help-block"><?php 
echo nl2br($deslocamento->des_origem);
?>
</span>
				</div>
				<div class="form-group">
					<label>Endereço de destino</label>
					<span id="helpBlock" class="help-block"><?php 
echo nl2br($deslocamento->des_destino);
?>
Exemplo n.º 10
0
								<td><a href="<?php 
        echo base_url();
        ?>
planejamento/showHospedagem/<?php 
        echo $acomodacao->hos_id;
        ?>
"><?php 
        echo $acomodacao->hos_nome;
        ?>
</a></td>
								<td><?php 
        echo format_data($acomodacao->aco_chegada);
        ?>
</td>
								<td><?php 
        echo format_data($acomodacao->aco_saida);
        ?>
</td>
								<td><?php 
        echo $acomodacao->aco_almoco;
        ?>
</td>
								<td><?php 
        echo $acomodacao->aco_janta;
        ?>
</td>
								<td><?php 
        echo $acomodacao->aco_catering;
        ?>
</td>
							</tr>
Exemplo n.º 11
0
         } catch (Exception $e) {
             $error .= $e->getMessage();
         }
         $contents = html_entity_decode($contents, ENT_COMPAT, "utf-8");
         preg_match_all($_POST['search'], $contents, $matches, PREG_SET_ORDER);
         restore_error_handler();
         if (preg_last_error() != PREG_NO_ERROR) {
             $error = "Regulärer Ausdruck ungültig.";
         } else {
             $output = '';
             foreach ($matches as $match) {
                 $sheet = preg_replace_callback('/\\$([0-9]+)/', function ($vmatch) use($match) {
                     return $match[$vmatch[1]];
                 }, $_POST['exercise']);
                 list($sheet_url, $sheet_text) = split_data($sheet);
                 $sheet_out = format_data($sheet);
                 if ($sheet_url) {
                     // Prüfen, ob die URL existiert
                     try {
                         check_if_url_changed($sheet_url, false);
                     } catch (Exception $ignore) {
                         $sheet_out .= ' (Die Datei wurde nicht gefunden)';
                     }
                 }
                 $output .= '<li>' . $sheet_out . '</li>';
             }
         }
     } else {
         $error .= 'Ungültiger Regulärer Ausdruck.';
     }
 }
Exemplo n.º 12
0
function revert()
{
    global $userdata, $basedata;
    for ($i = 0; $i < count($userdata); $i++) {
        $pk = $userdata[$i]['type'] . $userdata[$i]['id'];
        if ($userdata[$i]['id'] > 0 && isset($basedata[$pk]) && $basedata[$pk]['complete'] && is_modified($userdata[$i])) {
            $deleted = isset($userdata[$i]['action']) && $userdata[$i]['action'] == 'delete';
            $userdata[$i] = strip_version($basedata[$pk]);
            if ($deleted) {
                $userdata[$i]['action'] = 'delete';
            }
        }
    }
    return format_data();
}
Exemplo n.º 13
0
<?php

require "../private_php/print_private_area.php";
require_file();
$conn = connection_db();
session_control();
$info = '';
$successo = 'no';
if (isset($_POST["Inserisci"])) {
    //Verifiche integrità dati
    if (!empty($_POST['ggi']) && !empty($_POST['mmi']) && !empty($_POST['ggf']) && !empty($_POST['mmf']) && !empty($_POST['yyf'])) {
        if (checkdate($_POST['mmi'], $_POST['ggi'], $_POST['yyi']) && checkdate($_POST['mmf'], $_POST['ggf'], $_POST['yyf'])) {
            $dataInizio = format_data($_POST['yyi'], $_POST['mmi'], $_POST['ggi']);
            $dataFine = format_data($_POST['yyf'], $_POST['mmf'], $_POST['ggf']);
            if (strtotime($dataInizio) > strtotime(date('Y-m-d'))) {
                if ($dataInizio <= $dataFine) {
                    //Gestisco il tema a Null
                    if ($_POST['tema'] == 'Nessuno') {
                        $tema = 'NULL';
                    } else {
                        $tema = "'" . $_POST['tema'] . "'";
                    }
                    $test = true;
                    $query = "INSERT INTO istanzaevento (`evento`, `dataInizio`, `dataFine`, `luogo`, `nPartecipanti`, `programma`, `tema`) VALUES ('" . addslashes($_POST['evento']) . "', '{$dataInizio}', '{$dataFine}', '" . addslashes($_POST['luogo']) . "', '0', '" . addslashes($_POST['programma']) . "', " . addslashes($tema) . ")";
                    //echo $query;
                    mysql_query($query, $conn) or $test = false;
                    if ($test) {
                        $info = "Inserimento avvenuto con successo";
                        $successo = 'si';
                    } else {
                        $info = "L'evento è già stato inserito";
Exemplo n.º 14
0
     if ($_POST['app_id']) {
         $results['Results']['app_id'] = $_POST['app_id'];
     }
     if (is_array($results['Results'])) {
         $return .= http_build_query($results['Results']);
     }
     if ($results['Errors']) {
         echo error_message($results['Errors'], urlencode($return));
         exit;
     }
     if ($app_start != strtotime($appointmentData['app_start']) || $appAllday != $appointmentData['app_allday']) {
         $resetStatus($attachedDeals);
     }
     // extract notes from db_data and store in notes table
     if ($db_data['notes']) {
         $notes = format_data($db_data['notes']);
         unset($db_data['notes']);
         if ($notes) {
             $db_data2 = array('not_blurb' => $notes, 'not_row' => $app_id, 'not_type' => 'appointment', 'not_user' => $_SESSION['auth']['use_id'], 'not_date' => $date_mysql);
             db_query($db_data2, "INSERT", "note", "not_id");
         }
     }
     unset($db_data['notes']);
     $db_data['app_start'] = date("Y-m-d H:i:s", $app_start);
     $db_data['app_end'] = date("Y-m-d H:i:s", $app_end);
     $db_response = db_query($db_data, "UPDATE", "appointment", "app_id", $app_id, true);
     notify($db_response, 'edit');
 }
 if ($_POST['searchLink']) {
     header("Location:" . urldecode($_POST['searchLink']) . "&app_id={$app_id}");
 } else {
Exemplo n.º 15
0
    $output = substr($pieces[$ii], $pos);
    $g_xml = simplexml_load_string($output);
    //echo $schedd,' has ',count( $g_xml->c ),' jobs.<br />';
    if ($g_xml !== false) {
        read_data($g_schedds[$ii - 1]);
    } else {
        echo '<h2>Error getting xml data from schedd: ', $schedd, '</h2>';
        echo '<h3>', $cmd, '</h3>';
        echo '<pre>', htmlentities($output), '</pre>';
    }
}
data_accounting();
print_accounting();
echo '<hr />';
sort_data();
format_data();
print_data();
?>

		<hr>
		<p>Last update: <?php 
echo date(DATE_RFC822);
?>
</p>


		<?php 
do_refresh_button();
?>
	
	
Exemplo n.º 16
0
    $titles[] = Title::newFromID($row->page_id);
}
$dbr->freeResult($res);
$dbw =& wfGetDB(DB_SLAVE);
foreach ($titles as $title) {
    if ($title == null) {
        echo "error title is null " . print_r($title, true);
        continue;
    }
    $url = "http://www.wikihow.com/" . $title->getPartialURL();
    // get age
    $findAge = true;
    $age = 0;
    if ($findAge) {
        $min = $dbr->selectField('revision', 'min(rev_timestamp)', array('rev_page=' . $title->getArticleID()));
        $d = format_data($min);
        $diff = time() - $d;
        $age = ceil($diff / 60 / 60 / 24);
        //echo "$url " . $title->getArticleID() . "  is $age days old..\n";
        $age = " age {$age} days";
    }
    $position = checkGoogle(wfMsg('howto', $title->getFullText()), "http://www.wikihow.com/" . $title->getPrefixedURL());
    $sql = "INSERT INTO google_indexed (gi_page, gi_is_indexed, gi_position) VALUES \n\t\t\t\t({$title->getArticleID()}, " . ($position > 0 ? "1" : "0") . ", {$position} );";
    $dbw->query($sql);
    if ($position > 0) {
        print "indexed: {$url} {$age} position {$position} \n";
    } else {
        print "not indexed: {$url} {$age}\n";
    }
    //throttle();
}
Exemplo n.º 17
0
	function format_data(&$data) {
		global $rtype;
		
		if(is_object($data)) return;
		
		if(is_array($data)) {
			foreach($data as $key => $val) {
				format_data($data[$key]);
			}
		/* plists get a special date format as their output,
		 * due to spec restrictions.
		 */
		} else if(strtotime($data) > 0 && !is_numeric($data) && $rtype == "plist") {
			$data = gmdate('c', strtotime($data));
		} else if(is_numeric($data)) {
			if(is_intger($data)) {
				$data = (int)$data;
			} else {
				$data = (double)$data;
			}
		} else if($data === "true") {
			$data = true;
		} else if($data === "false") {
			$data = false;
		}
		if(is_string($data) && $rtype == "xml") {
			$data = str_replace(array("&", "<", ">"), array("&amp;", "&lt;", "&gt;"), $data);
		}
	}
Exemplo n.º 18
0
            //校验用户或者编号是否存在
            $check_user_info = array();
            $check_user_info = DB::fetch_first("SELECT user_id,user_password FROM " . DB::table('users') . " WHERE user_name ='" . $user_name . "' AND isdelete = 0 LIMIT 1");
            if (empty($check_user_info)) {
                $check_user_info = DB::fetch_first("SELECT user_id,user_password FROM " . DB::table('users') . " WHERE user_id ='" . $user_name . "' AND isdelete = 0 LIMIT 1");
            }
            //校验密码
            if ($check_user_info['user_id']) {
                $user_encode_password = encode_password($user_password);
                if ($user_encode_password == $check_user_info['user_password']) {
                    if ($api_client) {
                        allow_crossdomain();
                        $userinfo = DB::fetch_first("SELECT * FROM " . DB::table('users') . " WHERE user_id ='" . $check_user_info['user_id'] . "' LIMIT 1");
                        //并返回用户信息
                        $return = array('errcode' => 'e_1000', 'errmsg' => lang('error', 'e_1000'), 'data' => $userinfo);
                    } elseif ($location_url) {
                        $user['user_id'] = $check_user_info['user_id'];
                        ext::synlogin($user, $user);
                        header('location:' . $location_url . '');
                        die;
                    } else {
                        $user['user_id'] = $check_user_info['user_id'];
                        ext::synlogin($user, $user);
                        $return = array('errcode' => 'e_1000', 'errmsg' => lang('error', 'e_1000'), 'data' => '');
                    }
                }
            }
        }
        echo format_data($return, $data_format_type);
        break;
}
Exemplo n.º 19
0
				</tbody>
			</table>
			
			<legend>Atividades recentes</legend>
			
			<table class="table table-condensed table-hover tblApresentacao tblSemLinhas">
				<tbody>
					<?php 
if (!empty($atividades)) {
    ?>
						<?php 
    foreach ($atividades as $atividade) {
        ?>
							<tr><td>
								<?php 
        echo format_data($atividade->ati_criado_em);
        ?>
 :: <?php 
        echo str_replace('base_url', base_url(), $atividade->ati_descricao);
        ?>
<br>
							</td></tr>
						<?php 
    }
    ?>
					<?php 
} else {
    ?>
						<tr><td>Nenhuma atividade recente</td></tr>
					<?php 
}
 /**
  * 用户修改信息
  * @author jry <*****@*****.**>
  */
 public function profile()
 {
     if (IS_POST) {
         // 强制设置用户ID
         $uid = $this->is_login();
         $_POST['uid'] = $uid;
         $_POST = format_data();
         // 获取用户信息
         $user_object = D('User/User');
         $user_info = $user_object->find($uid);
         // 保存昵称
         if (I('post.nickname')) {
             $result = $user_object->where(array('id' => $uid))->setField('nickname', I('post.nickname'));
             if ($result === false) {
                 $this->error('昵称修改失败' . $user_object->getError());
             }
         } else {
             $this->error('请填写昵称');
         }
         // 保存扩展信息
         $type = $user_info['user_type'];
         $map['user_type'] = array('eq', $type);
         $count = D('User/Attribute')->where($map)->count();
         if ($count) {
             $user_type_name = D('User/Type')->where(array('id' => $user_info['user_type']))->getField('name');
             $user_extend_object = D('User' . ucfirst($user_type_name));
             $extend_data = $user_extend_object->create();
             if (!$extend_data) {
                 $this->error($user_extend_object->getError());
             }
             $extend_info = $user_extend_object->find($uid);
             if ($extend_info) {
                 $result = $user_extend_object->save($extend_data);
             } else {
                 $result = $user_extend_object->add($extend_data);
             }
             if ($result === false) {
                 $this->error('扩展信息修改失败' . $user_extend_object->getError());
             } else {
                 $this->success('信息修改成功');
             }
         }
     } else {
         // 获取当前用户
         $user_object = D('User/User');
         $user_info = $user_object->detail($this->is_login());
         $type = $user_info['user_type'];
         $user_type_info = D('User/Type')->find($type);
         // 获取扩展字段
         $map['user_type'] = array('eq', $type);
         $attribute_list[$type] = D('User/Attribute')->where($map)->order('id asc')->select();
         // 解析字段options
         $new_attribute_list_sort['user']['type'] = 'group';
         if ($attribute_list[$type]) {
             // 增加昵称表单
             $nick['name'] = 'nickname';
             $nick['title'] = '昵称';
             $nick['type'] = 'text';
             $nick['value'] = $user_info['nickname'];
             $new_attribute_list[1][0] = $nick;
             foreach ($attribute_list[$type] as $attr) {
                 $attr['options'] = parse_attr($attr['options']);
                 $new_attribute_list[$type][$attr['id']] = $attr;
                 $new_attribute_list[$type][$attr['id']]['value'] = $user_info[$attr['name']];
             }
             $new_attribute_list_sort['user']['options']['group_extend']['title'] = '完善' . $user_type_info['title'] . '信息';
             $new_attribute_list_sort['user']['options']['group_extend']['options'] = $new_attribute_list[$type];
         }
         // 使用FormBuilder快速建立表单页面。
         $builder = new \Common\Builder\FormBuilder();
         $builder->setMetaTitle('修改信息')->setPostUrl(U(''))->setExtraItems($new_attribute_list_sort)->setTemplate(C('USER_CENTER_FORM'))->display();
     }
 }
Exemplo n.º 21
0
				</form>
			</div>
			
			<legend>Notícias</legend>
			
			<table class="table table-condensed table-hover tblApresentacao tblSemLinhas">
				<tbody>
					<?php 
if (!empty($noticias)) {
    ?>
						<?php 
    foreach ($noticias as $noticia) {
        ?>
							<tr><td>
								<?php 
        echo format_data($noticia->not_criado_em);
        ?>
 :: <a href="<?php 
        echo base_url();
        ?>
evento/showNoticia/<?php 
        echo $noticia->not_id;
        ?>
"><strong><?php 
        echo stripslashes($noticia->not_titulo);
        ?>
</strong></a> por <a href="<?php 
        echo base_url();
        ?>
evento/perfil/<?php 
        echo $noticia->usu_id;
Exemplo n.º 22
0
function db_query($_data, $_action, $_table, $_field, $_row = "temp_row_id")
{
    global $current_user_id;
    // update - select existing values for comparison
    if ($_action == "UPDATE") {
        foreach ($_data as $_key => $_val) {
            $_fields .= $_key . ",";
            $_newvalues[] = format_data("{$_val}");
        }
        $_fields = remove_lastchar(trim($_fields), ",");
        if ($_fields) {
            $_sql_select = "SELECT " . $_fields . " FROM " . $_table . " WHERE " . $_field . " = " . $_row . " LIMIT 1";
            $_result = mysql_query($_sql_select);
            if (!$_result) {
                die("MySQL Error:  " . mysql_error() . "<pre>db_query: " . $_sql_select . "</pre>");
            }
            while ($_row_select = mysql_fetch_array($_result)) {
                foreach ($_data as $_key => $_val) {
                    // format old values to make sure sql works
                    $_oldvalues[$_key] = format_data($_row_select[$_key]);
                }
            }
            mysql_free_result($_result);
        }
    } elseif ($_action == "INSERT") {
        foreach ($_data as $_key => $_val) {
            $_newvalues[] = format_data($_val);
            $_oldvalues[$_key] = "NULL";
        }
    }
    /* // delete
    	elseif ($_action == "DELETE") {
    		foreach($_data as $_key=>$_val) {			
    			$_newvalues[] = "NULL";
    			$_oldvalues[$_key] = trim("$_val");
    			}
    		}*/
    // we should now have 2 arrarys of fieldnames as keys and new and old values
    if (count($_data) !== count($_oldvalues)) {
        echo 'db_query: array count not matched<p>';
        exit;
    }
    // construct sql for $_table AND changelog table, single query with multiple inserts
    $_sql_log = "INSERT INTO changelog \n\t(cha_user,cha_session,cha_action,cha_table,cha_row,cha_field,cha_old,cha_new)\n\tVALUES \n\t";
    // loop _data, check if current(old) value is different to new, and create sql statements accordingly
    foreach ($_data as $_key => $_val) {
        if ($_oldvalues[$_key] !== $_val) {
            // enter NULL value without quotes (09/05/06)
            if ($_val == "NULL") {
                $_sql_update .= $_key . "=NULL,";
            } elseif ($_val == "") {
                $_sql_update .= $_key . "='',";
            } else {
                $_sql_update .= $_key . "='" . format_data($_val) . "',";
            }
            $_sql_insert1 .= $_key . ",";
            $_sql_insert2 .= "'" . format_data($_val) . "',";
            $_sql_log .= "('" . $current_user_id . "','" . session_id() . "','" . $_action . "','" . $_table . "','" . $_row . "','" . format_data($_key) . "','" . format_data($_oldvalues[$_key]) . "','" . format_data($_val) . "'),\n";
            $_msg .= $_key . " was changed from " . $_oldvalues[$_key] . " to " . $_val . "\n";
            $_changecount++;
        }
    }
    $_sql_log = remove_lastchar(trim($_sql_log), ",");
    $_sql_update = remove_lastchar(trim($_sql_update), ",");
    $_sql_insert1 = remove_lastchar(trim($_sql_insert1), ",");
    $_sql_insert2 = remove_lastchar(trim($_sql_insert2), ",");
    if ($_action == "UPDATE") {
        $_sql_return = "UPDATE " . $_table . " SET " . $_sql_update . " WHERE " . $_field . " = " . $_row;
    } elseif ($_action == "INSERT") {
        $_sql_return = "INSERT INTO " . $_table . " (" . $_sql_insert1 . ") VALUES (" . $_sql_insert2 . ")";
    }
    /* elseif ($_action == "DELETE") {
    		$_sql_return = "DELETE FROM ".$_table." WHERE ".$_field." = ".$_row;
    		}*/
    if ($_changecount) {
        // only execute the sql queries if a change has been made
        $_result_return = mysql_query($_sql_return);
        if (!$_result_return) {
            die("MySQL Error:  " . mysql_error() . "<pre>db_query RETURN: " . $_sql_return . "</pre>");
        }
        if ($_action == "UPDATE") {
            $_insert_id = $_row;
        } elseif ($_action == "INSERT") {
            $_insert_id = mysql_insert_id();
            $_sql_log = str_replace("temp_row_id", $_insert_id, $_sql_log);
            // replace temp_row_id with insert_id
        }
        //mysql_free_result($_result_return);
        $_result_log = mysql_query($_sql_log);
        if (!$_result_log) {
            die("MySQL Error:  " . mysql_error() . "<pre>db_query LOG: " . $_sql_log . "</pre>");
        }
        //mysql_free_result($_result_log);
    }
    /* // dubug info
    	echo "<pre><b>Current values</b>\n";
    	print_r($_oldvalues);
    	echo "<pre><b>New values</b>\n";
    	print_r($_data);
    	echo "<hr>sql_log: ".$_sql_log;
    	echo "<hr>msg: ".$_msg;	*/
    return $_insert_id;
    // return the effected row in $_table, not changelog
    unset($_data, $_action, $_table, $_field, $_row);
}
Exemplo n.º 23
0
    $exercises = $database->query('
				SELECT
					id, data, feed_id,
					(SELECT comment FROM user_data WHERE user_id = ' . user()->id . ' AND data_id = id) AS comment,
					(SELECT invisible FROM user_data WHERE user_id = ' . user()->id . ' AND data_id = id) AS invisible,
					(SELECT known FROM user_data WHERE user_id = ' . user()->id . ' AND data_id = id) AS known
				FROM
					data
				WHERE feed_id IN (SELECT feed_id FROM user_feeds WHERE user_id = ' . user()->id . ')' . ' AND timestamp IS NOT NULL ' . ($only_feed !== false ? ' AND feed_id = ' . $only_feed : '') . ' ORDER BY id ASC');
    $outputted = false;
    foreach ($exercises as $exercise) {
        if ($exercise['invisible'] && $hide_invisible) {
            continue;
        }
        $outputted = true;
        $formatted_data = format_data($exercise['data'], $exercise['id']);
        $classes = $formatted_data != $data && !$exercise['known'] ? ' neu' : '';
        echo '<tr class="' . $classes . '" id="data-' . $exercise['id'] . '"><td><a class="course-disp-only" href="index.php?inv=' . ($hide_invisible ? 0 : 1) . '&amp;f=' . $exercise['feed_id'] . '">' . htmlspecialchars($descs[$exercise['feed_id']]) . '</a></td><td>' . $formatted_data . '</td><td class="editable-note" id="edit-' . $exercise['id'] . '">' . htmlspecialchars($exercise['comment']) . '</td><td>';
        echo '<a class="erledigt" href="index.php?inv=' . ($hide_invisible ? 0 : 1) . '&amp;f=' . ($only_feed !== false ? $only_feed : '') . '&amp;d=' . $exercise['id'] . '">' . ($exercise['invisible'] == 1 ? 'Unerledigt' : 'Erledigt') . '</a></td></tr>';
    }
    if (!$outputted) {
        echo '<tr><td colspan="4">Derzeit sind keine Aufgaben zu bearbeiten.</td></tr>';
    }
    ?>
	</table>
	<p class="right small">
		<a href="index.php?inv=<?php 
    echo $hide_invisible ? 1 : 0;
    ?>
&amp;f=<?php 
    echo $only_feed ? $only_feed : '';
Exemplo n.º 24
0
function format_field($prompt, $field, $prompt_mask = NULL, $field_mask = NULL)
{
    return "\n<tr>" . format_prompt($prompt, $prompt_mask) . format_data($field, $field_mask) . "</tr>";
}
Exemplo n.º 25
0
 public function testFormatData()
 {
     $this->assertEquals(date('d/m/Y'), format_data(date('Y-m-d')));
 }
Exemplo n.º 26
0
    echo $user->id;
    ?>
uebung-<?php 
    echo $exercise['id'];
    ?>
</id>
		<title><?php 
    echo htmlspecialchars($descs[$exercise['feed_id']]);
    ?>
 - <?php 
    echo strip_tags(format_data($exercise['data'], $exercise['id']));
    ?>
</title>
		<summary type="html">
		<?php 
    echo htmlspecialchars(format_data($exercise['data'], $exercise['id']));
    ?>
		</summary>
		<?php 
    list($url, $text) = split_data($exercise['data']);
    if ($url) {
        ?>
			<link title="<?php 
        echo htmlspecialchars(trim($text));
        ?>
" href="<?php 
        echo htmlspecialchars($url);
        ?>
" rel="alternate" />
		<?php 
    } else {
</span>
				<?php 
}
?>
			</div>
			<div class="form-group">
	       		<label>Chegada na hospedaria</label>
	       		<span id="helpBlock" class="help-block"><?php 
echo !empty($acomodacao->aco_chegada) ? format_data($acomodacao->aco_chegada) : '<br>';
?>
</span>
			</div>				
			<div class="form-group">
	       		<label>Saída da hospedaria</label>
	       		<span id="helpBlock" class="help-block"><?php 
echo !empty($acomodacao->aco_saida) ? format_data($acomodacao->aco_saida) : '<br>';
?>
</span>
			</div>				
			<div class="form-group">
	       		<label>Quantidade de almoços</label>
	       		<span id="helpBlock" class="help-block"><?php 
echo !empty($acomodacao->aco_almoco) ? $acomodacao->aco_almoco : '<br>';
?>
</span>
			</div>				
			<div class="form-group">
	       		<label>Quantidade de jantas</label>
	       		<span id="helpBlock" class="help-block"><?php 
echo !empty($acomodacao->aco_janta) ? $acomodacao->aco_janta : '<br>';
?>