Example #1
1
 public function sessions($sessions)
 {
     $this->title($this('sessions'));
     $active_sessions = $this->load->library('table')->add_columns(array(array('content' => function ($data) {
         return $data['remember_me'] ? '<i class="fa fa-toggle-on text-green" data-toggle="tooltip" title="' . i18n('persistent_connection') . '"></i>' : '<i class="fa fa-toggle-off text-grey" data-toggle="tooltip" title="' . i18n('nonpersistent_connection') . '"></i>';
     }, 'size' => TRUE, 'align' => 'center'), array('content' => function ($data) {
         return user_agent($data['user_agent']);
     }, 'size' => TRUE, 'align' => 'center'), array('title' => $this('ip_address'), 'content' => function ($data) {
         return geolocalisation($data['ip_address']) . '<span data-toggle="tooltip" data-original-title="' . $data['host_name'] . '">' . $data['ip_address'] . '</span>';
     }), array('title' => $this('reference'), 'content' => function ($data, $loader) {
         return $data['referer'] ? urltolink($data['referer']) : $loader->lang('unknown');
     }), array('title' => $this('initial_session_date'), 'content' => function ($data) {
         return '<span data-toggle="tooltip" title="' . timetostr(NeoFrag::loader()->lang('date_time_long'), $data['date']) . '">' . time_span($data['date']) . '</span>';
     }), array('title' => $this('last_activity'), 'content' => function ($data) {
         return '<span data-toggle="tooltip" title="' . timetostr(NeoFrag::loader()->lang('date_time_long'), $data['last_activity']) . '">' . time_span($data['last_activity']) . '</span>';
     }), array('content' => array(function ($data) {
         if ($data['session_id'] != NeoFrag::loader()->session('session_id')) {
             return button_delete('user/sessions/delete/' . $data['session_id'] . '.html');
         }
     }))))->pagination(FALSE)->data($this->user->get_sessions())->save();
     $sessions_history = $this->table->add_columns(array(array('content' => function ($data) {
         return user_agent($data['user_agent']);
     }, 'size' => TRUE, 'align' => 'center'), array('title' => $this('ip_address'), 'content' => function ($data) {
         return geolocalisation($data['ip_address']) . '<span data-toggle="tooltip" data-original-title="' . $data['host_name'] . '">' . $data['ip_address'] . '</span>';
     }), array('title' => $this('reference'), 'content' => function ($data, $loader) {
         return $data['referer'] ? urltolink($data['referer']) : $loader->lang('unknown');
     }), array('title' => $this('initial_session_date'), 'content' => function ($data) {
         return '<span data-toggle="tooltip" title="' . timetostr(NeoFrag::loader()->lang('date_time_long'), $data['date']) . '">' . time_span($data['date']) . '</span>';
     })))->data($sessions)->no_data($this('no_historic_available'));
     return array(new Panel(array('title' => $this('my_active_sessions'), 'icon' => 'fa-shield', 'content' => $active_sessions->display())), new Panel(array('title' => $this('sessions_historic'), 'icon' => 'fa-power-off', 'content' => $sessions_history->display())), new Button_back('user.html'));
 }
Example #2
0
/**
 *
 * @copyright  2010-2015 izend.org
 * @version    2
 * @link       http://www.izend.org
 */
function is_mobile($agent = false)
{
    if (!$agent) {
        require_once 'useragent.php';
        $agent = user_agent();
    }
    return $agent and preg_match('/android|webos|iphone|ipad|ipod|iemobile|blackberry|opera mini/i', $agent);
}
Example #3
0
/**
 *
 * @copyright  2010-2014 izend.org
 * @version    3
 * @link       http://www.izend.org
 */
function is_agent($s, $agent = false)
{
    if (!$agent) {
        require_once 'useragent.php';
        $agent = user_agent();
    }
    return $agent and preg_match('/' . $s . '/i', $agent);
}
Example #4
0
 public function __construct()
 {
     $this->UserIPAdd = ip_address();
     $this->UserBrowser = user_agent();
     $this->DB =& load_class('Database');
     $this->ENC =& load_class('Encryption');
     $this->SESS =& load_class('Session');
 }
Example #5
0
function track($request_uri = false, $track_agent = false)
{
    global $track_log, $track_db;
    global $track_agent_blacklist;
    if (!($track_log or $track_db)) {
        return true;
    }
    if (!$request_uri) {
        $request_uri = request_uri();
    }
    if (!$request_uri) {
        return false;
    }
    $user_agent = false;
    if ($track_agent or $track_agent_blacklist) {
        $user_agent = user_agent();
        if (!validate_user_agent($user_agent)) {
            $user_agent = false;
        }
        if ($user_agent and $track_agent_blacklist) {
            $reg = '/' . implode('|', $track_agent_blacklist) . '/i';
            if (preg_match($reg, $user_agent)) {
                return true;
            }
        }
    }
    $r = true;
    if ($track_log) {
        require_once 'log.php';
        $logmsg = $request_uri;
        if ($user_agent) {
            $logmsg .= "\t" . $user_agent;
        }
        $r = write_log($track_log === true ? 'track.log' : $track_log, $logmsg);
        if (!$r) {
            return false;
        }
    }
    if ($track_db) {
        $ip_address = client_ip_address();
        if (!validate_ip_address($ip_address)) {
            return false;
        }
        $sqlipaddress = db_sql_arg($ip_address, false);
        $sqlrequesturi = db_sql_arg($request_uri, true);
        $sqluseragent = db_sql_arg($user_agent, true, true);
        $tabtrack = db_prefix_table($track_db === true ? 'track' : $track_db);
        $sql = "INSERT INTO {$tabtrack} (ip_address, request_uri, user_agent) VALUES (INET_ATON({$sqlipaddress}), {$sqlrequesturi}, {$sqluseragent})";
        $r = db_insert($sql);
        if (!$r) {
            return false;
        }
    }
    return true;
}
Example #6
0
 public function _write($session_id, $user_data)
 {
     if (!count($this->session_exists($session_id))) {
         $args = array(':session_id' => $session_id, ':ip_address' => ip_address(), ':user_agent' => user_agent(), ':last_activity' => time(), ':user_data' => serialize($user_data));
         $query = "REPLACE INTO sessions (session_id, ip_address, user_agent, last_activity, user_data) VALUES (:session_id, :ip_address, :user_agent, :last_activity, :user_data)";
     } else {
         $args = array(':session_id' => $session_id, ':user_data' => serialize($user_data));
         $query = "UPDATE sessions SET user_data = :user_data WHERE session_id = :session_id";
     }
     return $this->db->query($query, $args);
 }
 public function send($array)
 {
     $log =& singleton::get(__NAMESPACE__ . '\\log');
     $array['token'] = $this->app_key;
     /*
     	Limit to 512 chars as per pushover limit.
     */
     $remove = 0;
     if (isset($array['title'])) {
         $remove = (int) strlen($array['title']);
     }
     if (isset($array['message'])) {
         $array['message'] = substr($array['message'], 0, 512 - $remove);
     }
     $options = array('http' => array('user_agent' => user_agent(), 'timeout' => 5, 'method' => 'POST', 'header' => 'Content-type: application/x-www-form-urlencoded', 'content' => http_build_query($array)));
     $context = stream_context_create($options);
     $result = @file_get_contents($this->api_url, false, $context);
     if ($result) {
         $return_data = json_decode($result, true);
         if ($return_data['status'] == 1) {
             return true;
         } else {
             $larray['event_severity'] = 'error';
             $larray['event_number'] = E_USER_ERROR;
             $larray['event_description'] = 'Unable to send pushover message.';
             $larray['event_file'] = __FILE__;
             $larray['event_file_line'] = __LINE__;
             $larray['event_type'] = 'send';
             $larray['event_source'] = 'pushover';
             $larray['event_version'] = '1';
             $larray['log_backtrace'] = true;
             $log->add($larray);
         }
     } else {
         $larray['event_severity'] = 'error';
         $larray['event_number'] = E_USER_ERROR;
         $larray['event_description'] = 'Unable to send pushover message.';
         $larray['event_file'] = __FILE__;
         $larray['event_file_line'] = __LINE__;
         $larray['event_type'] = 'send';
         $larray['event_source'] = 'pushover';
         $larray['event_version'] = '1';
         $larray['log_backtrace'] = true;
         $log->add($larray);
     }
     return false;
 }
Example #8
0
 private function checkLogin($sEmail, $sPasswd, $bIsHash = true)
 {
     // make variable safe
     $sEmail = $this->DB->escape($sEmail);
     $sPasswd = $this->DB->escape($sPasswd);
     $aUser = $this->DB->query("SELECT * FROM `users` WHERE email = '{$sEmail}'");
     $aUser = $this->DB->fetch_array($aUser);
     $iUserId = $aUser['id'];
     $sUserPass = $aUser['password'];
     $sUserSalt = $aUser['salt'];
     if ($sEmail && $sPasswd && $iUserId) {
         if (!$bIsHash) {
             $sPasswd = $this->ENC->sha512($sPasswd);
             $sPasswd = $this->ENC->sha512($sPasswd . $sUserSalt);
         }
         // we check if the account is locked from too many login attempts
         if ($this->checkBrute($iUserId) === FALSE) {
             // Check if the password in the database matches the password the user submitted.
             if ($sUserPass == $sPasswd) {
                 // Password is correct!
                 return TRUE;
                 $sUserBrowser = user_agent();
                 // Get the user-agent sting of the user.
                 $iUserId = preg_replace("/[^0-9]+/", "", $iUserId);
                 // XSS protection as we might print this value.
                 $sEmail = preg_replace("/[^a-zA-Z0-9_\\-]+/", "", $sEmail);
                 // XSS protection as we might print this value.
                 $aSessionData = array('presentation_user_id' => $iUserId, 'presentation_user_email' => $sEmail, 'presentation_user_pass' => $this->ENC->encode($sPasswd . $sUserBrowser, '3jrc5PmChv3xYrsqvFrqcaFn6CtzT4Le'), 'presentation_user_email' => $user_role);
             } else {
                 // Password is not correct
                 return FALSE;
             }
         } else {
             // Account is locked
             return 'locked';
         }
     } else {
         // No user exists.
         return FALSE;
     }
 }
Example #9
0
function upload_map($address, $logic, $layout, $play)
{
    global $clouds;
    $sys = sys_get_temp_dir();
    ignore_user_abort();
    $json = tempnam($sys, 'mj');
    $png = tempnam($sys, 'mp');
    file_put_contents($json, $_POST['logic']);
    file_put_contents($png, base64_decode($_POST['layout']));
    if (($curl = user_agent($address)) && curl_setopt($curl, CURLOPT_POST, true) && curl_setopt($curl, CURLOPT_POSTFIELDS, array($logic => new CURLFile($json, 'application/json', 'map.json'), $layout => new CURLFile($png, 'image/png', 'map.png')))) {
        if ($play) {
            if (curl_exec($curl) !== false && ($result = curl_getinfo($curl, CURLINFO_REDIRECT_URL)) !== false) {
                echo $result;
            }
        } else {
            if (($result = curl_exec($curl)) !== false && ($result = json_decode($result)) && $result->success) {
                echo 'http://', $clouds[$_POST['cloud']], isset($result->saveurl) ? $result->saveurl : $result->url;
            }
        }
    }
    unlink($json);
    unlink($png);
}
Example #10
0
 /**
  * Create a new session
  *
  * @access	public
  * @return	void
  */
 function sess_create()
 {
     $sessid = '';
     while (strlen($sessid) < 32) {
         $sessid .= mt_rand(0, mt_getrandmax());
     }
     // To make the session ID even more secure we'll combine it with the user's IP
     $sessid .= ip_address();
     $this->userdata = array('session_id' => md5(uniqid($sessid, TRUE)), 'ip_address' => ip_address(), 'user_agent' => substr(user_agent(), 0, 120), 'last_activity' => $this->now, 'user_data' => '');
     // Save the data to the DB if needed
     if ($this->sess_use_database === TRUE) {
         $this->ING->db->query($this->ING->db->insert_string($this->sess_table_name, $this->userdata));
     }
     // Write the cookie
     $this->_set_cookie();
 }
Example #11
0
 function _write($session_id, $user_data)
 {
     $args = array(':session_id' => $session_id, ':ip_address' => ip_address(), ':user_agent' => user_agent(), ':last_activity' => time(), ':user_data' => serialize($user_data));
     $query = "REPLACE INTO sessions VALUES (:session_id, :ip_address, :user_agent, :last_activity, :user_data)";
     return $this->db->query($query, $args);
 }
Example #12
0
 public function _sessions($sessions)
 {
     $this->title($this('sessions'))->subtitle($this('list_active_sessions'))->icon('fa-globe')->load->library('table')->preprocessing(function ($row) {
         $user_data = unserialize($row['user_data']);
         $row['date'] = $user_data['session']['date'];
         $row['history'] = array_reverse($user_data['session']['history']);
         $row['user_agent'] = $user_data['session']['user_agent'];
         $row['referer'] = $user_data['session']['referer'];
         unset($row['user_data']);
         return $row;
     })->add_columns(array(array('content' => function ($data) {
         return $data['remember_me'] ? '<i class="fa fa-toggle-on text-green" data-toggle="tooltip" title="Connexion persistante"></i>' : '<i class="fa fa-toggle-off text-grey" data-toggle="tooltip" title="Connexion non persistante"></i>';
     }, 'size' => TRUE, 'align' => 'center'), array('title' => $this('user'), 'content' => function ($data, $loader) {
         return $data['user_id'] ? NeoFrag::loader()->user->link($data['user_id'], $data['username']) : '<i>' . $loader->lang('guest') . '</i>';
     }, 'search' => function ($data, $loader) {
         return $data['user_id'] ? $data['username'] : $loader->lang('guest');
     }, 'sort' => function ($data, $loader) {
         return $data['user_id'] ? $data['username'] : $loader->lang('guest');
     }), array('content' => function ($data) {
         return user_agent($data['user_agent']);
     }, 'size' => TRUE, 'align' => 'center', 'search' => function ($data) {
         return $data['user_agent'];
     }, 'sort' => function ($data) {
         return $data['user_agent'];
     }), array('title' => $this('ip_address'), 'content' => function ($data) {
         return geolocalisation($data['ip_address']) . '<span data-toggle="tooltip" data-original-title="' . $data['host_name'] . '">' . $data['ip_address'] . '</span>';
     }, 'search' => function ($data) {
         return $data['ip_address'];
     }, 'sort' => function ($data) {
         return $data['ip_address'];
     }), array('title' => $this('referer'), 'content' => function ($data, $loader) {
         return $data['referer'] ? urltolink($data['referer']) : $loader->lang('none');
     }, 'search' => function ($data) {
         return $data['user_agent'];
     }, 'sort' => function ($data) {
         return $data['user_agent'];
     }), array('title' => $this('arrival_date'), 'content' => function ($data) {
         return '<span data-toggle="tooltip" title="' . timetostr(NeoFrag::loader()->lang('date_time_long'), $data['date']) . '">' . time_span($data['date']) . '</span>';
     }, 'sort' => function ($data) {
         return $data['date'];
     }), array('title' => $this('last_activity'), 'content' => function ($data) {
         return '<span data-toggle="tooltip" title="' . timetostr(NeoFrag::loader()->lang('date_time_long'), $data['last_activity']) . '">' . time_span($data['last_activity']) . '</span>';
     }, 'sort' => function ($data) {
         return $data['last_activity'];
     }), array('title' => $this('history'), 'content' => function ($data, $loader) {
         $links = implode('<br />', array_map(function ($a) {
             return '<a href="' . url($a) . '">' . $a . '</a>';
         }, $data['history']));
         return '<span data-toggle="popover" title="' . $loader->lang('last_pages_visited') . '" data-content="' . utf8_htmlentities($links) . '" data-placement="auto" data-html="1">' . icon('fa-history') . ' ' . reset($data['history']) . '</span>';
     }), array('content' => array(function ($data) {
         if ($data['user_id'] && $data['session_id'] != NeoFrag::loader()->session('session_id')) {
             return button_delete('admin/members/sessions/delete/' . $data['session_id'] . '.html');
         }
     }))))->data($sessions);
     return new Panel(array('title' => $this('sessions'), 'icon' => 'fa-globe', 'content' => $this->table->display()));
 }
Example #13
0
 /**
  * Create a new session
  *
  * @access	public
  * @return	void
  */
 function sess_create()
 {
     $sessid = '';
     while (strlen($sessid) < 32) {
         $sessid .= mt_rand(0, mt_getrandmax());
     }
     // To make the session ID even more secure we'll combine it with the user's IP
     $sessid .= ip_address();
     $this->userdata = array('session_id' => md5(uniqid($sessid, TRUE)), 'ip_address' => ip_address(), 'user_agent' => substr(user_agent(), 0, 120), 'last_activity' => $this->now, 'user_data' => '');
     // Write the cookie
     $this->_set_cookie();
 }
Example #14
0
function download_file($filename, $download_display = null)
{
    apache_setenv('no-gzip', 1);
    header('Content-Type: application/octet-stream');
    //如果是IE,要轉成 BIG5
    $bigf = $filename;
    if (is_string_like(user_agent(), '%MSIE%') || is_string_like(user_agent(), '%rv_11%')) {
        $bigf = utf8tobig5($bigf);
    }
    if ($download_display == null) {
        $download_display = basename($bigf);
    } else {
        if (is_string_like(user_agent(), '%MSIE%') || is_string_like(user_agent(), '%11%')) {
            $download_display = utf8tobig5($download_display);
        }
    }
    header("Content-Disposition: attachment; filename=\"{$download_display}\"");
    header('Content-Transfer-Encoding: binary');
    header('Expires: 0');
    header('Cache-Control: must-revalidate');
    header('Pragma: public');
    header('Content-Length: ' . filesize($filename));
    if (in_array('mod_xsendfile', apache_get_modules())) {
        header("X-Sendfile: {$filename}");
        header("X-LIGHTTPD-send-file: {$filename}");
        header("X-Accel-Redirect : {$filename}");
    } else {
        readfile($filename);
    }
}
Example #15
0
function deel_comment_list($comment, $args, $depth)
{
    echo '<li ';
    comment_class();
    echo ' id="comment-' . get_comment_ID() . '">';
    //头像
    echo '<div class="c-avatar">';
    echo str_replace(' src=', ' data-original=', get_avatar($comment->comment_author_email, $size = '54', deel_avatar_default()));
    //内容
    echo '<div class="c-main" id="div-comment-' . get_comment_ID() . '">';
    echo str_replace(' src=', ' data-original=', convert_smilies(get_comment_text()));
    if ($comment->comment_approved == '0') {
        echo '<span class="c-approved">您的评论正在排队审核中,请稍后!</span><br />';
    }
    //信息
    echo '<div class="c-meta">';
    if (git_get_option('git_autherqr_b') && !G_is_mobile()) {
        echo '<span class="c-author"><a href="' . get_comment_author_url() . '" class="weixin" style="cursor:pointer;">' . get_comment_author() . '<span class="qr weixin-popover"><img style="position:absolute;z-index:99999;" src="http://s.jiathis.com/qrcode.php?url=' . get_comment_author_url() . '"></span></a></span>';
    } else {
        echo '<span class="c-author">' . get_comment_author_link() . '</span>';
    }
    if ($comment->user_id == '1') {
        echo '<img src="' . get_bloginfo('template_directory') . '/img/webmaster.png" id="comment_is_admin" title="博主大人">&nbsp;&nbsp;';
    }
    echo get_comment_time('Y-m-d H:i ');
    echo time_ago();
    if ($comment->comment_approved !== '0') {
        echo comment_reply_link(array_merge($args, array('add_below' => 'div-comment', 'depth' => $depth, 'max_depth' => $args['max_depth'])));
        echo edit_comment_link(__('(编辑)'), ' - ', '');
        if (git_get_option('git_ua_b')) {
            echo '<span style="color: #ff6600;"> ' . user_agent($comment->comment_agent) . '</span>';
        }
    }
    echo '</div>';
    echo '</div></div>';
}
Example #16
0
 public function login($user = '', $pass = '')
 {
     $this->load->helper('input');
     $pass = $this->encrypt->sha512($pass);
     $this->db->select('user_id, user_pass, user_salt, user_role');
     $this->db->from('ing_user');
     $this->db->where('user_name', $user);
     $query = $this->db->get();
     //$query = $this->db->query('SELECT user_id, user_pass, user_salt FROM ing_admin WHERE user_name = '.$this->db->escape($user));
     if ($query->num_rows == 1) {
         // if the user exists
         $row = $query->row();
         $user_id = $row->user_id;
         $user_pass = $row->user_pass;
         $user_salt = $row->user_salt;
         $user_role = $row->user_role;
         $pass = $this->encrypt->sha512($pass . $user_salt);
         // we check if the account is locked from too many login attempts
         if ($this->checkbrute($user_id) === FALSE) {
             if ($pass == $user_pass) {
                 // Check if the password in the database matches the password the user submitted.
                 // Password is correct!
                 $user_browser = user_agent();
                 // Get the user-agent sting of the user.
                 $user_id = preg_replace("/[^0-9]+/", "", $user_id);
                 // XSS protection as we might print this value.
                 $user = preg_replace("/[^a-zA-Z0-9_\\-]+/", "", $user);
                 // XSS protection as we might print this value.
                 $session_data = array('ing_control_user_id' => $user_id, 'ing_control_user_name' => $user, 'ing_control_pass_string' => $this->encrypt->encode($user_pass . $user_browser, '3jrc5PmChv3xYrsqvFrqcaFn6CtzT4Le'), 'ing_control_user_role' => $user_role);
                 $this->session->set_userdata($session_data);
                 // set the user status to 'online'
                 $update_data = array('status_value' => 'online', 'time' => db_time());
                 $where_data = array('user_id' => $user_id, 'status_key' => 'online_status');
                 $this->db->where($where_data);
                 $this->db->update('ing_user_status', $update_data);
                 // Login successful
                 return TRUE;
             } else {
                 // Password is not correct
                 // We record this attempt in the database
                 $insert_data = array('user_id' => $user_id, 'time' => curTime());
                 $this->db->insert('ing_user_login_attempts', $insert_data);
                 //$query = $this->db->query("INSERT INTO ing_admin_login_attempts (user_id, time) VALUES ('$user_id', '$now')");
                 return FALSE;
             }
         } else {
             // Account is locked
             return 'locked';
         }
     } else {
         // No user exists.
         return FALSE;
     }
 }
Example #17
0
 /**
  * Gather user agent data.
  *
  * @author Morten Rugaard <*****@*****.**>
  *
  * @return array
  */
 protected function gatherUserAgentData()
 {
     // User agent container
     $userAgents = ['original' => null, 'nodes' => null];
     // Retrieve original user agent
     $originalUserAgent = user_agent();
     if (!empty($originalUserAgent)) {
         $userAgents['original'] = ['browser' => $originalUserAgent->getBrowserWithVersion(), 'platform' => $originalUserAgent->getPlatform(), 'device' => $originalUserAgent->getDevice(), 'isMobile' => $originalUserAgent->isMobile(), 'isTablet' => $originalUserAgent->isTablet()];
     }
     // Retrieve nodes user agent
     $nodesUserAgent = nodes_user_agent();
     if (!empty($nodesUserAgent)) {
         $userAgents['nodes'] = ['version' => $nodesUserAgent->getVersion(), 'platform' => $nodesUserAgent->getPlatform(), 'device' => $nodesUserAgent->getDevice(), 'debug' => $nodesUserAgent->getDebug()];
     }
     return $userAgents;
 }
Example #18
0
function lomake($profile, $field, $form)
{
    /* lomake */
    if ($field->varname == 'Ravitsemus_ja_liikuntasuositukset') {
        echo '<div class="form-inline">' . $form->labelEx($profile, $field->varname, array('class' => 'form-group')) . ' 
		<i class="fa fa-question-circle form-group text-success" data-toggle="tooltip" title="Voit halutessasi muokata ravitsemus ja liikunta tavoitteita. On kuitenkin tärkeää, että tiedät turvalliset ja terveelliset arvot. Summittain annetut arvot voivat olla haitaksi terveydelle."></i>
		</div>';
    } elseif ($field->varname == 'ruokavalio') {
        echo '<div class="form-inline">' . $form->labelEx($profile, $field->varname, array('class' => 'form-group')) . ' 
		<i class="fa fa-question-circle form-group text-success" data-toggle="tooltip" title="Voit määritellä itse, mistä ravintoaineista haluat ruokavalion koostuvan. "></i>
		</div>';
    } elseif ($field->varname == 'liikunta') {
        echo '<div class="form-inline">' . $form->labelEx($profile, $field->varname, array('class' => 'form-group')) . ' 
		<i class="fa fa-question-circle form-group text-success" data-toggle="tooltip" title="Voit määritellä, kuinka monta minuuttia ja kuinka monta kertaa viikossa on tavoitteenasi harrastaa liikuntaa."></i>
		</div>';
    } elseif ($field->varname == 'energia') {
        echo '<div class="form-inline">' . $form->labelEx($profile, $field->varname, array('class' => 'form-group')) . ' 
		<i class="fa fa-question-circle form-group text-success" data-toggle="tooltip" title="Voit määritellä tässä tavoite laihtumisnopeutesi. Voit vaihtoehtoisesti asettaa myös energiavaje/energialisän kilokaloreina tai asettaa kiinteän energiatavoitteen. Jos et tiedä mitä arvoja laitat, niin kysy apua esimerkiksi ravintoterapeutilta."></i>
		</div>';
    } elseif ($field->varname == 'aineenvaihdunta') {
        echo '<div class="form-inline">' . $form->labelEx($profile, $field->varname, array('class' => 'form-group')) . ' 
		<i class="fa fa-question-circle form-group text-success" data-toggle="tooltip" title="Mikäli tiedät oman aineenvaihduntasi niin voit asettaa sen täällä."></i>
		</div>';
    } elseif ($field->varname == 'aktiivisuuskerroin') {
        echo '<div class="form-inline">' . $form->labelEx($profile, $field->varname, array('class' => 'form-group')) . ' 
		<i class="fa fa-question-circle form-group text-success" data-toggle="tooltip" title="Valitse Sinua parhaiten kuvaava aktiivisuuskerroin, jotta ohjelma osaa laskea Sinulle tarkemman päivittäisen energiankulutuksesi"></i>
		</div>';
    } elseif ($field->varname == 'muokkaa_ruokavalio_suositusta') {
        echo '<div class="form-inline">' . $form->labelEx($profile, $field->varname, array('class' => 'form-group')) . ' 
		<i class="fa fa-question-circle form-group text-success" data-toggle="tooltip" title="Voit määritellä kuinka suuri osa tavoiteruokavaliostasi koostuu proteiinista, rasvasta ja hiilihydraatista."></i>
		</div>';
    } elseif ($field->varname == 'varoitukset') {
        echo '<div class="form-inline">' . $form->labelEx($profile, $field->varname, array('class' => 'form-group')) . ' 

		<i class="fa fa-question-circle form-group text-success" data-toggle="tooltip" title="Valitsemalla KYLLÄ, ohjelma ilmoittaa sinulle mikäli alkoholinkulutuksesi ylittää turvallisen rajan."></i>
		</div>';
    } else {
        echo $form->labelEx($profile, $field->varname);
    }
    if ($widgetEdit = $field->widgetEdit($profile)) {
        echo $widgetEdit;
    } elseif ($field->range) {
        $ex = explode(";", $field->range);
        foreach ($ex as $k => $v) {
            $ex2 = array();
            $ex2 = explode("==", $v);
            if ($profile[$field->varname] == $ex2[0]) {
                $checked = 'checked';
            } else {
                $checked = '';
            }
            echo '
			<div class="row">
			<div class="form-inline">
			   <input type="radio" class="radio1" name="Profile[' . $field->varname . ']" ' . $checked . ' value="' . $ex2[0] . '">
			   <span class="radioLabel">' . $ex2[1] . '</span>
			</div>
			</div>
			';
        }
    } elseif ($field->field_type == "TEXT") {
        echo $form->textArea($profile, $field->varname, array('rows' => 6, 'cols' => 50, 'class' => 'form-control'));
    } elseif ($field->field_type == "FLOAT") {
        echo $form->numberField($profile, $field->varname, array('class' => 'form-control', 'step' => '0.01'));
    } elseif ($field->varname == "ppkkvvvv") {
        if (user_agent() == 'ios' or user_agent() == 'android') {
            echo $form->dateField($profile, $field->varname, array('size' => 60, 'maxlength' => $field->field_size ? $field->field_size : 255, 'class' => 'form-control'));
        } else {
            echo $form->textField($profile, $field->varname, array('class' => 'form-control syntyKalenteri', 'readonly' => 'yes'));
        }
    } else {
        echo $form->textField($profile, $field->varname, array('size' => 60, 'maxlength' => $field->field_size ? $field->field_size : 255, 'class' => 'form-control'));
    }
    echo $form->error($profile, $field->varname);
    /* lomake */
}
Example #19
0
    if ($errors) {
        $_SESSION['message'] = 'Please answer all questions with an * / SVP répondre à toutes les questions avec une *';
        $_SESSION['post'] = $_POST;
        header('location: index.php');
        exit;
    } else {
        unset($_SESSION['post']);
        $args = array(':ios_comments' => $_POST['ios_comments'], ':android_comments' => $_POST['android_comments']);
        for ($i = 1; $i <= 3; $i++) {
            for ($j = 1; $j <= 4; $j++) {
                $args[':ios_' . $i . '_' . $j] = $_POST['ios_' . $i . '_' . $j];
                $args[':android_' . $i . '_' . $j] = $_POST['android_' . $i . '_' . $j];
            }
        }
        $ip_address = ip_address();
        $user_agent = user_agent();
        $session_id = session_id();
        $now = date('Y-m-d H:i:s');
        $query = "INSERT INTO survey_activities VALUES ('{$user[0]['id']}', '{$ip_address}', '{$user_agent}', '{$session_id}', '{$now}')";
        $db->query($query, array());
        $query = "INSERT INTO survey_answers (\n\t\t  ios_1_1,\n\t\t  ios_1_2,\n\t\t  ios_1_3,\n\t\t  ios_1_4,\n\t\t  ios_2_1,\n\t\t  ios_2_2,\n\t\t  ios_2_3,\n\t\t  ios_2_4,\n\t\t  ios_3_1,\n\t\t  ios_3_2,\n\t\t  ios_3_3,\n\t\t  ios_3_4,\n\t\t  android_1_1,\n\t\t  android_1_2,\n\t\t  android_1_3,\n\t\t  android_1_4,\n\t\t  android_2_1,\n\t\t  android_2_2,\n\t\t  android_2_3,\n\t\t  android_2_4,\n\t\t  android_3_1,\n\t\t  android_3_2,\n\t\t  android_3_3,\n\t\t  android_3_4,\n\t\t  ios_comments,\n\t\t  android_comments\n\t\t) values (\n\t\t  :ios_1_1,\n\t\t  :ios_1_2,\n\t\t  :ios_1_3,\n\t\t  :ios_1_4,\n\t\t  :ios_2_1,\n\t\t  :ios_2_2,\n\t\t  :ios_2_3,\n\t\t  :ios_2_4,\n\t\t  :ios_3_1,\n\t\t  :ios_3_2,\n\t\t  :ios_3_3,\n\t\t  :ios_3_4,\n\t\t  :android_1_1,\n\t\t  :android_1_2,\n\t\t  :android_1_3,\n\t\t  :android_1_4,\n\t\t  :android_2_1,\n\t\t  :android_2_2,\n\t\t  :android_2_3,\n\t\t  :android_2_4,\n\t\t  :android_3_1,\n\t\t  :android_3_2,\n\t\t  :android_3_3,\n\t\t  :android_3_4,\n\t\t  :ios_comments,\n\t\t  :android_comments\n\t\t  )";
        $db->query($query, $args);
        $_SESSION['message'] = 'Thank You for your paticipation. / Merci d\'avoir participé.';
        header('location: index.php');
        exit;
    }
}
function user_agent()
{
    $user_agent = !isset($_SERVER['HTTP_USER_AGENT']) ? FALSE : $_SERVER['HTTP_USER_AGENT'];
    return $user_agent;
 /**
  * Detects iOS-native browsers.
  * This function is covenient for making adaptive html boilerplate.
  * @return  array
  */
 function user_agent_ios()
 {
     static $result = null;
     if (!is_array($result)) {
         $result = array('is_ios' => false);
         $data = user_agent();
         $result['is_ios'] = $data['platform'] == 'iOS';
     }
     return $result;
 }