Example #1
0
 function display($template)
 {
     $template_path = $this->template_dir . $template;
     if (!file_exists($template_path)) {
         add_error(_("Template error: No such template file:") . $template_path);
         return false;
     }
     $cache_id = md5(realpath($template_path));
     $cache_path = $this->cache_dir . basename($template) . '.' . $cache_id . '.inc';
     if (!file_exists($cache_path) || filemtime($cache_path) <= filemtime($template_path)) {
         require 'tags.inc';
         $compiled = preg_replace($find, $replace, file_get_contents($template_path));
         $compiled = preg_replace($empty_blocks, "\n", $compiled);
         if (empty($compiled) || !$compiled) {
             add_error(_("Template error: Error caching template file:") . $template);
             return false;
         } else {
             if (!($h = @fopen($cache_path, 'w'))) {
                 add_error(_("Template error: could not write to template cache directory."));
                 return false;
             }
             fwrite($h, $compiled);
             fclose($h);
         }
     }
     extract($this->vars);
     include $cache_path;
     return true;
 }
 function modules($id = '')
 {
     if (empty($id)) {
         redirect($this->uri->rsegments[1] . '/listing');
     }
     if ($_POST) {
         $sql = "\n                SELECT da.*, a.name, a.action\n                FROM disposition_action da\n                JOIN action a ON da.action_id = a.id\n                WHERE da.status < 3 AND parent = (\n                    SELECT id FROM disposition_action WHERE action_id = ? AND ref = ?\n                )\n            ";
         $param = array($this->_action['id'], $id);
         $modules = $this->db->query($sql, $param)->result_array();
         if (!empty($modules)) {
             add_error(l('Modules have not been finished yet'));
         } else {
             if (empty($this->workflow['pages'])) {
                 redirect($this->_name . '/summary/' . $id);
             } else {
                 // redirect($this->_name . '/' . $this->workflow['pages'][0] . '/' . $id);
                 redirect($this->action_uri . '/' . $id);
             }
         }
     }
     $user = $this->auth->get_user();
     $sql = "\n            SELECT da.*, a.name, a.action\n            FROM disposition_action da\n            JOIN action a ON da.action_id = a.id\n            JOIN disposition d ON da.disposition_id = d.id\n            WHERE parent = (\n                SELECT id FROM disposition_action WHERE action_id = ? AND ref = ?\n            )\n        ";
     $param = array($this->_action['id'], $id);
     $this->_data['modules'] = $this->db->query($sql, $param)->result_array();
     $config = array('fields' => array('name', 'status'), 'names' => array('Action'), 'formats' => array('callback__act', 'param_short(disposition_status)'), 'show_checkbox' => false, 'actions' => array());
     $this->load->library('xgrid', $config, 'module_list');
 }
Example #3
0
 public function save()
 {
     $post = $this->input->post();
     if (!$post || !$this->input->post('translate')) {
         add_error(translate('Une erreur est survenue'));
         redirect('traductions/index');
     }
     $issetLang = isset($post['lang']);
     $lang = $issetLang ? $post['lang'] : 'fr';
     if ($issetLang) {
         unset($post['lang']);
     }
     unset($post['translate']);
     $fullTrads = $this->traductor->getFull();
     foreach ($fullTrads as $file => $trads) {
         foreach ($trads as $id => $trad) {
             if (isset($post['exclude-' . $id]) && $post['exclude-' . $id]) {
                 $fullTrads[$file][$id]['excluded'][$lang] = '1';
             } else {
                 $fullTrads[$file][$id]['excluded'][$lang] = '0';
             }
             if (isset($post['ignore-' . $id]) && $post['ignore-' . $id]) {
                 $fullTrads[$file][$id]['ignored'][$lang] = '1';
             } else {
                 $fullTrads[$file][$id]['ignored'][$lang] = '0';
             }
         }
     }
     $this->traductor->setFull($fullTrads);
     $this->traductor->complete($post, $lang);
     $this->traductor->translation($lang);
     add_success(translate('La traduction a bien été effectuée'));
     redirect('traductions/index');
 }
Example #4
0
 public function save($id = null)
 {
     $this->load->helper('memberspace/authorization');
     $this->load->helper('flashmessages/flashmessages');
     $this->load->model('memberspace/user');
     $this->load->helper('form');
     $datas = array();
     if (isset($_POST) && isset($_POST['save-user'])) {
         $datas = $_POST;
         unset($_POST['save-user']);
         if (isset($_POST['id']) && $_POST['id']) {
             if (!user_can('update', 'user', $_POST['id'])) {
                 add_error(translate('Vous ne pouvez pas modifier cet utilisateur'));
             }
         } else {
             if (!user_can('add', 'user', $_POST['id'])) {
                 add_error(translate('Vous ne pouvez pas ajouter d\'utilisateur'));
             }
         }
         if ($this->user->fromPost() !== false) {
             add_success(translate('L\'utilisateur a bien été ajouté'));
             redirect('bo/users/all');
         } else {
             add_error($this->form_validation->error_string());
         }
     } else {
         if ($id) {
             $datas = $this->user->getId($id, 'array');
         }
     }
     return $datas;
 }
 function _save($id = null)
 {
     $this->_view = $this->_name . '/show';
     $model = $this->_model();
     if ($_POST) {
         if ($this->_validate()) {
             $_POST['id'] = $id;
             try {
                 $tags = $_POST['tags'];
                 unset($_POST['tags']);
                 $id = $model->save($_POST, $id);
                 $model->update_tag($tags, $id);
                 if (!$this->input->is_ajax_request()) {
                     redirect($this->_get_uri('listing'));
                 }
                 add_info($id ? l('Record updated') : l('Record added'));
             } catch (Exception $e) {
                 add_error(l($e->getMessage()));
             }
         }
     } else {
         if ($id !== null) {
             $this->_data['id'] = $id;
             $_POST = $model->get($id);
             $_POST['tags'] = $model->get_tag($id);
         }
     }
 }
 function form_fields($values = array())
 {
     $fields = parent::form_fields();
     $CI =& get_instance();
     $CI->load->module_model(BLOG_FOLDER, 'blog_users_model');
     $CI->load->module_model(BLOG_FOLDER, 'blog_posts_model');
     $post_title = '';
     $post_options = $CI->blog_posts_model->options_list('id', 'title', array(), 'date_added desc');
     if (empty($post_options)) {
         return lang('blog_error_no_posts_to_comment');
     }
     $fields['post_id'] = array('type' => 'select', 'options' => $post_options, 'label' => 'Post');
     if (!empty($values['id'])) {
         $post = $CI->blog_posts_model->find_by_key($values['post_id']);
         $post_title = $post->title;
         if (!$post->is_published()) {
             add_error(lang('blog_post_is_not_published'));
         }
         $fields['post_id'] = array('type' => 'hidden', 'value' => $post_title, 'displayonly' => TRUE);
         $fields['post_title'] = array('label' => 'Post', 'value' => $post_title, 'order' => 1);
         $fields['post_title']['displayonly'] = TRUE;
         $fields['post_published']['displayonly'] = TRUE;
         $fields['author_email']['displayonly'] = TRUE;
         $fields['author_name']['displayonly'] = TRUE;
         $fields['post_title']['displayonly'] = TRUE;
         $fields['author_website']['displayonly'] = TRUE;
         $fields['ip_host']['displayonly'] = TRUE;
         $fields['date_submitted'] = array('displayonly' => TRUE, 'value' => english_date($values['date_added'], TRUE));
         $ip_host = !empty($values['author_ip']) ? gethostbyaddr($values['author_ip']) . ' (' . $values['author_ip'] . ')' : '';
         $fields['ip_host'] = array('label' => 'IP/Host', 'value' => $ip_host, 'order' => 5, 'displayonly' => TRUE);
         $fields['Reply to this Comment'] = array('type' => 'section');
         $replies = $this->find_all_array(array('parent_id' => $values['id']));
         $reply_arr = array();
         foreach ($replies as $r) {
             $reply_arr[] = $r['content'];
         }
         $fields['replies'] = array('label' => 'Replies', 'displayonly' => TRUE, 'value' => implode('<br /><br />', $reply_arr));
         if ($values['author_id'] == $CI->fuel_auth->user_data('id') or $CI->fuel_auth->is_super_admin()) {
             $fields['reply'] = array('label' => 'Reply', 'type' => 'textarea');
             $notify_options = array('Commentor' => lang('blog_comment_notify_option2'), 'All' => lang('blog_comment_notify_option1'), 'None' => lang('blog_comment_notify_option3'));
             $fields['reply_notify'] = array('label' => 'Notfiy', 'type' => 'enum', 'options' => $notify_options);
         }
         // hidden
         $fields['author_ip'] = array('type' => 'hidden');
     } else {
         $fields['author_ip'] = array('type' => 'hidden', 'value' => $_SERVER['REMOTE_ADDR'], 'label' => 'Author IP Address');
         $fields['is_spam'] = array('type' => 'hidden');
         $fields['date_added']['type'] = 'hidden';
         // so it will auto add
         $fields['last_modified']['type'] = 'hidden';
         // so it will auto add
     }
     // set author to current fuel user
     if (empty($fields['author_id']) and $CI->fuel_auth->user_data('id')) {
         $fields['author_id'] = array('value' => $CI->fuel_auth->user_data('id'));
     }
     $fields['author_id'] = array('type' => 'hidden');
     return $fields;
 }
Example #7
0
function spam_receive()
{
    //`spam_id``user``IP``type`
    if (isset($_POST['this_is_spam'])) {
        //KOlla om det är admin som säger
        if (isset($_SESSION[PREFIX . 'user_id']) && user_get_admin($_SESSION[PREFIX . 'user_id']) > 1) {
            foreach ($_POST['id'] as $s_id) {
                $sql = "UPDATE " . PREFIX . sql_safe($_POST['type']) . " SET is_spam=2 WHERE id=" . sql_safe($s_id) . ";";
                echo "<br />DEBUG1827: {$sql}";
                if (mysql_query($sql)) {
                    add_message($_POST['type'] . " " . $s_id . " marked as spam.");
                } else {
                    add_error("There was some kind of error... (errorcode 1726)");
                }
            }
        } else {
            $sql = "INSERT INTO " . PREFIX . "spam SET type='" . sql_safe($_POST['type']) . "', spam_id=" . sql_safe($_POST['id']) . ", ";
            //Om man är inloggad
            if (isset($_SESSION[PREFIX . 'user_id'])) {
                $sql .= "user="******";";
            } else {
                $sql .= "IP='" . sql_safe($_SERVER['REMOTE_ADDR']) . "';";
            }
            // echo "<br />DEBUG1012: $sql";
            if (mysql_query($sql)) {
                add_message("Thank you for helping us keep the site spam-free!");
            } else {
                add_error("There was some kind of error... (errorcode 1727)");
            }
        }
    }
    if (isset($_POST['this_is_not_spam'])) {
        //KOlla om det är admin som säger
        if (isset($_SESSION[PREFIX . 'user_id']) && user_get_admin($_SESSION[PREFIX . 'user_id']) > 1) {
            foreach ($_POST['id'] as $s_id) {
                $sql = "UPDATE " . PREFIX . sql_safe($_POST['type']) . " SET is_spam=-2 WHERE id=" . sql_safe($s_id) . ";";
                echo "<br />DEBUG1827: {$sql}";
                if (mysql_query($sql)) {
                    add_message($_POST['type'] . " " . $s_id . " marked as not spam.");
                } else {
                    add_error("There was some kind of error... (errorcode 1728)");
                }
            }
        } else {
            $sql = "DELETE FROM " . PREFIX . "spam WHERE type='" . sql_safe($_POST['type']) . "' AND spam_id=" . sql_safe($_POST['id']) . " AND ";
            //Om man är inloggad
            if (isset($_SESSION[PREFIX . 'user_id'])) {
                $sql .= "user="******";";
            } else {
                $sql .= "IP='" . sql_safe($_SERVER['REMOTE_ADDR']) . "';";
            }
            if (mysql_query($sql)) {
                add_message("Thank you for helping us keep the site spam-free!");
            } else {
                add_error("There was some kind of error... (errorcode 1729)");
            }
        }
    }
}
 public function upload()
 {
     $this->load->library('form_builder');
     $this->load->module_model(FUEL_FOLDER, 'fuel_navigation_groups_model');
     $this->load->module_model(FUEL_FOLDER, 'fuel_navigation_model');
     $this->js_controller_params['method'] = 'upload';
     if (!empty($_POST)) {
         $params = $this->input->post();
         if (!empty($_FILES['file']['name'])) {
             $error = FALSE;
             $file_info = $_FILES['file'];
             $params['file_path'] = $file_info['tmp_name'];
             $params['var'] = $this->input->post('variable') ? $this->input->post('variable', TRUE) : 'nav';
             $params['language'] = $this->input->post('language', TRUE);
             if (!$this->fuel->navigation->upload($params)) {
                 $error = TRUE;
             }
             if ($error) {
                 add_error(lang('error_upload'));
             } else {
                 // change list view page state to show the selected group id
                 $this->fuel->admin->set_notification(lang('navigation_success_upload'), Fuel_admin::NOTIFICATION_SUCCESS);
                 redirect(fuel_url('navigation?group_id=' . $params['group_id']));
             }
         } else {
             add_error(lang('error_upload'));
         }
     }
     $fields = array();
     $nav_groups = $this->fuel_navigation_groups_model->options_list('id', 'name', array('published' => 'yes'), 'id asc');
     if (empty($nav_groups)) {
         $nav_groups = array('1' => 'main');
     }
     // load custom fields
     $this->form_builder->load_custom_fields(APPPATH . 'config/custom_fields.php');
     $fields['group_id'] = array('type' => 'select', 'options' => $nav_groups, 'module' => 'navigation_group');
     $fields['file'] = array('type' => 'file', 'accept' => '');
     $fields['variable'] = array('label' => 'Variable', 'value' => $this->input->post('variable') ? $this->input->post('variable', TRUE) : 'nav', 'size' => 10);
     $fields['language'] = array('type' => 'select', 'options' => $this->fuel->language->options(), 'first_option' => lang('label_select_one'));
     $fields['clear_first'] = array('type' => 'enum', 'options' => array('yes' => 'yes', 'no' => 'no'));
     $fields['__fuel_module__'] = array('type' => 'hidden');
     $fields['__fuel_module__']['value'] = $this->module;
     $fields['__fuel_module__']['class'] = '__fuel_module__';
     $fields['__fuel_module_uri__'] = array('type' => 'hidden');
     $fields['__fuel_module_uri__']['value'] = $this->module_uri;
     $fields['__fuel_module_uri__']['class'] = '__fuel_module_uri__';
     $this->form_builder->set_fields($fields);
     $this->form_builder->submit_value = '';
     $this->form_builder->use_form_tag = FALSE;
     $this->form_builder->set_field_values($_POST);
     $vars['instructions'] = lang('navigation_import_instructions');
     $vars['form'] = $this->form_builder->render();
     $vars['back_action'] = ($this->fuel->admin->last_page() and $this->fuel->admin->is_inline()) ? $this->fuel->admin->last_page() : fuel_uri($this->module_uri);
     $crumbs = array($this->module_uri => $this->module_name, lang('action_upload'));
     $this->fuel->admin->set_titlebar($crumbs);
     $this->fuel->admin->render('upload', $vars, Fuel_admin::DISPLAY_NO_ACTION);
 }
Example #9
0
 function add_organization($id)
 {
     if (!empty($_POST['org_id'])) {
         $this->_model()->add_organization($id, $_POST['org_id']);
         add_info(l('Group data added.'));
     } else {
         add_error(l('No data to add.'));
     }
     redirect($_SERVER['HTTP_REFERER']);
 }
 function __construct()
 {
     parent::__construct();
     $this->config->load('seo');
     $this->js_controller_params['module'] = 'seo';
     $this->load->module_language(SEO_FOLDER, 'seo', $this->config->item('language'));
     if ($this->config->item('dev_password', 'fuel')) {
         add_error(lang('error_seo_dev_password'));
     }
 }
 public function delete()
 {
     global $db;
     $query = "DELETE FROM `student_leaves_of_absence` where `id`=" . $db->qstr($this->id);
     if (!$db->Execute($query)) {
         add_error("Failed to remove leave of absence from database.");
         application_log("error", "Unable to delete a student_leaves_of_absence record. Database said: " . $db->ErrorMsg());
     } else {
         add_success("Successfully removed Leave of Absence.");
     }
 }
Example #12
0
function ensure_authenticated()
{
    if ($_SESSION['authenticated'] != true) {
        add_error("You must be authenticated to view this page");
        header("Location: index.php");
        exit(0);
        /* return would just return from this function... not good enough */
    } else {
        debug("passed authentication check ok!\n");
    }
}
 public function delete()
 {
     global $db;
     $query = "DELETE FROM `student_formal_remediations` where `id`=" . $db->qstr($this->id);
     if (!$db->Execute($query)) {
         add_error("Failed to remove formal remediation from database.");
         application_log("error", "Unable to delete a student_formal_remediations record. Database said: " . $db->ErrorMsg());
     } else {
         add_success("Successfully removed Formal Remediation.");
     }
 }
 function add_privilege($id)
 {
     if (!empty($_POST['uri'])) {
         $this->_model()->add_privilege($id, $_POST['uri']);
         $this->cache->context_delete($this->_model()->CACHE_KEY_PRIVILEGE);
         add_info(l('Privilege added.'));
     } else {
         add_error(l('No privilege to add.'));
     }
     redirect($_SERVER['HTTP_REFERER']);
 }
 /**
  * User is included to prevent tampering with another user's sequence.
  * @param User $user
  * @param array $ids
  */
 public function setSequence($user_id, array $ids)
 {
     global $db;
     $stmt = $db->Prepare('update `student_research` set `priority`=? where `user_id`=? and `id`=?');
     foreach ($ids as $priority => $id) {
         if (!$db->Execute($stmt, array($priority, $user_id, $id))) {
             add_error("Failed to re-sequence Research Citations.");
             application_log("error", "Unable to modify a student_research record. Database said: " . $db->ErrorMsg());
             break;
         }
     }
 }
Example #16
0
function notice_receive()
{
    if (isset($_POST['notice_close'])) {
        //Check that logged in user owns the notice
        if (login_check_logged_in_mini() > 0) {
            $sql = "UPDATE " . PREFIX . "notice \r\n\t\t\tSET closed=NOW()\r\n\t\t\tWHERE user="******" AND id=" . sql_safe($_POST['notice_id']) . ";";
            if (!mysql_query($sql)) {
                add_error(sprintf(_("Notice could not be closed.<br />SQL: %s<br />Error: %s"), $sql, mysql_error()));
            }
        }
    }
}
 public function update(array $input_arr)
 {
     extract($input_arr);
     global $db;
     $query = "Update `student_clineval_comments` set `comment`=?, `source`=? where `id`=?";
     if (!$db->Execute($query, array($text, $source, $this->id))) {
         add_error("Failed to update a clinical performance evaluation comment.");
         application_log("error", "Unable to update a student_clineval_comment record. Database said: " . $db->ErrorMsg());
     } else {
         add_success("Successfully updated clinical performance evaluation.");
     }
 }
Example #18
0
function privmess_send($sender, $reciever, $subject, $message, $display_sucess_message = TRUE)
{
    $sql = "INSERT INTO " . PREFIX . "privmess SET \r\n\tsender='" . sql_safe($sender) . "',\r\n\treciever='" . sql_safe($reciever) . "', \t \r\n\tsubject='" . sql_safe($subject) . "',\r\n\tmessage='" . sql_safe($message) . "';";
    if (mysql_query($sql)) {
        if ($display_sucess_message) {
            add_message(_("Message sent"));
        }
        return mysql_insert_id();
    } else {
        add_error(sprintf(_("Message could not be sent. Error: %s"), mysql_error()));
    }
    return NULL;
}
Example #19
0
 function delete()
 {
     if (!$this->is_id($this->id)) {
         add_error("could_not_find_entry");
         return false;
     }
     if (!$this->db_delete("DELETE FROM configurations WHERE id=%d", array($this->id))) {
         add_error("could_not_delete");
         return false;
     } else {
         $this->generate_config_file();
         return true;
     }
 }
Example #20
0
 private function sendMailConfirmation($userId, $mailRedirect)
 {
     $this->load->model('user');
     $this->load->library('mailManager');
     $this->load->model('configuration');
     $subject = $this->configuration->getValue('mail_confirmation_subject', 'Confirmation de votre inscription');
     $user = $this->user->getId($userId);
     if (!$user) {
         add_error('Le mail de confirmation n\'a pas pu être envoyé car l\'utilisateur n\'a pas été trouvé en base');
         return;
     }
     $keyConfirm = md5($user->login . '_' . $user->password);
     $message = $this->load->view('memberspace/confirmation/mail/custom', array('login' => $user->login, 'urlRedirection' => base_url($mailRedirect . '/' . $user->id . '/' . $keyConfirm), 'nomFrom' => $this->configuration->getValue('mail_confirmation_nom_from', 'Tout l\'&eacutequipe de Have A Site'), 'title' => 'Confirmation de votre inscription'), true);
     $this->mailmanager->sendMail($subject, $message, $user->email);
 }
function display_class()
{
    initialise_class();
    $class = $_SESSION['class'];
    $classname = "No Name Yet";
    if (!empty($class)) {
        if (!empty($class['name'])) {
            //if success class exist.
            $classname = $class['name'][0];
        }
    } else {
        add_error("Class is Empty");
    }
    echo '<div class="box box-info">
	<div class="box-header">
	<h3 class="box-title">';
    echo $classname;
    echo '</h3></div><!-- /.box-header -->
	    <div class="box-body no-padding">
	      <table class="table table-striped">
	        <tbody>
	          <tr>
	            <th style="width: 10px">#</th>
	            <th>Name</th>
	            <th style="width:40px;">Remove</th>
	          </tr>';
    if (!empty($class['fname'])) {
        //if alert messages exist.
        $i = 0;
        foreach ($class['fname'] as $fname) {
            echo '<tr><td>';
            echo $i + 1;
            echo '.</td><td>';
            echo $class['fname'][$i] . " " . $class['lname'][$i];
            echo '</td><td>
			<form action="process_classcreate.php" method="post">
			<button name="classremove" class="btn btn-block btn-danger btn-sm"><i class="fa fa-fw fa-close"></i></button>
			<input type="hidden" name="removeid" value="' . $i . '">
			</form>
			</td></tr>';
            $i++;
        }
    }
    echo '</tbody>
	    </table>
	    </div>
	  </div>';
}
 /**
 Change user password.
 */
 function change_password()
 {
     global $__in, $__out;
     if ($__in['__is_form_submitted']) {
         if ($__in['new_password'] != $__in['renew_password']) {
             add_error("please_retype_password_correctly", array(), "renew_password");
             return false;
         }
         $user = new user($_SESSION['user_id']);
         if (!$user->change_password($__in['user']['old_password'], $__in['user']['new_password'], $__in['user']['renew_password'])) {
             return false;
         } else {
             return dispatcher::redirect(array("action" => "home"), "password_changed");
         }
     }
 }
 public static function fromArray(array $arr, $mode = false)
 {
     $klass = get_called_class();
     $o = new $klass();
     //if the class implements the Validation interface, fetch the required fields and field rules and enforce and required fields
     if ($mode != "fetch" && in_array('Validation', class_implements($o))) {
         $req_fields = $o->fetchRequiredFields($mode);
         $field_rules = $o->fetchFieldRules($mode);
         foreach ($req_fields as $field) {
             if (!isset($arr[$field]) || !trim($arr[$field])) {
                 if (!isset($o->{$field}) || !trim($o->{$field})) {
                     $field_split = explode("_", $field);
                     foreach ($field_split as $key => $field_segment) {
                         $field_split[$key] = ucwords($field_segment);
                     }
                     $field_text = implode(" ", $field_split);
                     add_error("<strong>" . $field_text . "</strong> is a required field. Please ensure you've provided a value.");
                     $o->VALID = false;
                 }
             }
         }
     } else {
         //if Validation not implemented, no fields are considered required and basic string cleaning will be done
         $field_rules = false;
     }
     //Cleans and sets each field
     //foreach value in the array (likely $_POST), clean using the rules for that field, or if no rules defined do string cleaning
     foreach ($arr as $field => $value) {
         if ($field_rules && isset($field_rules[$field])) {
             /**
              * @todo Determine the best way to clean AND validate
              * ex: if the field is int, and 'abc' it the value, have it return an error message
              * will likely need to use filter_vars in place of clean_input
              */
             $cleaned = clean_input($arr[$field], $field_rules[$field]);
             $o->{$field} = $cleaned;
         } else {
             //if no cleaning rule specified, default to basic string cleaning
             $cleaned = clean_input($arr[$field], array("trim", "notags"));
             $o->{$field} = $cleaned;
         }
     }
     return $o;
 }
function get_all_students()
{
    $teacherid = $_SESSION['id'];
    $connection = db_connect();
    //connect to database
    $query = "SELECT * FROM student INNER JOIN class ON student.class_id = class.id WHERE class.teacher_id = '{$teacherid}'  ORDER BY student.class_id";
    $result = mysqli_query($connection, $query);
    //perform query
    if ($result) {
        //check if query ran
        while ($row = $result->fetch_array()) {
            $rows[] = $row;
        }
        return $rows;
    } else {
        add_error("SQL ERROR");
    }
    db_close($connection);
}
Example #25
0
 function goo_gl($url)
 {
     $this->url = $url;
     if (function_exists('curl_init')) {
         $curl = curl_init();
         curl_setopt($curl, CURLOPT_URL, 'http://goo.gl/api/url');
         curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
         curl_setopt($curl, CURLOPT_POST, 1);
         curl_setopt($curl, CURLOPT_POSTFIELDS, 'user=toolbar@google.com&url=' . urlencode($this->url) . '&auth_token=' . $this->googlToken($url));
         $saida = curl_exec($curl);
         curl_close($curl);
         if ($saida) {
             $json = json_decode($saida);
             $this->resul = isset($json->short_url) ? $json->short_url : null;
         }
     } else {
         add_error(_t('Warning: The cURL extension is not found. Please check your PHP configuration.'));
     }
 }
Example #26
0
function version_increase($amount)
{
    // echo "<br />DEBUG1337: Ny version $amount!";
    /************************************/
    /*	Ta reda på nytt versionsnummer	*/
    /************************************/
    //Ta reda på nyvarande versionsnummer
    $sql = "SELECT version, time FROM " . PREFIX . "version ORDER BY id DESC LIMIT 0,1";
    if ($vv = mysql_query($sql)) {
        if ($v = mysql_fetch_array($vv)) {
            //Räkna ut nytt värde
            if (!strcmp($amount, "next")) {
                $new_version = (int) ($v['version'] + 1);
            } else {
                $new_version = $v['version'] + $amount;
            }
        } else {
            $new_version = $amount;
        }
        //current version is 0
        $new_version = number_format($new_version, 3, ".", "");
        //Sätt in en ny version med det nya versionsnumret
        $sql = "INSERT INTO " . PREFIX . "version SET version='" . $new_version . "';";
        if (mysql_query($sql)) {
            $id = mysql_insert_id();
            //Lägg in alla feedbacks som är färdiga och inte redan finns i version_done
            version_add_unlinked_feedbacks_to_latest($v['time']);
            //Sätt in id för den nya versionen till alla som har version=NULL i version_done
            $sql = "UPDATE " . PREFIX . "version_done SET version={$id} WHERE version IS NULL;";
            if (mysql_query($sql)) {
                return TRUE;
            } else {
                add_error("There was a problem with version_done!");
            }
        } else {
            add_error(sprintf(_("There was a problem with the version!\n\t\t\t\t\t\t<br />SQL: %s\n\t\t\t\t\t\t<br />ERROR: %s"), $sql, mysql_error()));
        }
    } else {
        add_error("There was a problem with the database!");
    }
    return FALSE;
}
Example #27
0
 function save($arg_language_key, $arg_arr_languages)
 {
     global $arr_AVAILABLE_LANGUAGES;
     if (!$arg_language_key) {
         add_error('please_write_the_variable_name', array(), 'key');
         return false;
     }
     $arr_available_languages = array_keys($arr_AVAILABLE_LANGUAGES);
     if (is_array($arr_available_languages)) {
         while (list(, $lang) = each($arr_available_languages)) {
             $arr_lang = array();
             require PHP_ROOT . 'config/translation/' . $lang . '.php';
             $arr_lang[$arg_language_key] = $arg_arr_languages[$lang];
             $str_lang = "<?\n" . $this->array_to_string($arr_lang, '$arr_lang') . "\n";
             echo $str_lang;
             $this->string_to_file($str_lang, PHP_ROOT . 'config/translation/' . $lang . '.php');
         }
     }
     return true;
 }
Example #28
0
function category_receive()
{
    if (isset($_POST['save_category'])) {
        $sql = "";
        if (isset($_POST['category_id'])) {
            //Check that user has ownership here
            if (!category_get_user_privilege($_SESSION['user_id'], $_POST['category_id'])) {
                add_error(sprintf(_("Access denied (%s)"), 341053));
            } else {
                $sql = "UPDATE task_category SET \n\t\t\t\t`name`='" . sql_safe($_POST['name']) . "',\n\t\t\t\t`description`='" . sql_safe($_POST['description']) . "'\n\t\t\t\tWHERE id=" . sql_safe($_POST['category_id']) . ";";
            }
        } else {
            $sql = "INSERT INTO task_category SET \n\t\t\tcreator='" . sql_safe($_SESSION['user_id']) . "',\n\t\t\t`name`='" . sql_safe($_POST['name']) . "',\n\t\t\t`description`='" . sql_safe($_POST['description']) . "';";
        }
        if ($sql != "") {
            message_try_mysql($sql, 531220, _("Category saved"));
            // preprint($sql);
        }
    }
}
Example #29
0
function flattr_set_flattr_choice($user_id, $flattr_choice)
{
    // echo "flattr_set_flattr_choice($user_id, $flattr_choice)";
    $current_choices = flattr_get_flattr_choices($user_id);
    $new_choices = serialize($flattr_choice);
    // echo "<pre>current_choices:".print_r($current_choices,1)."</pre>";
    if (strcmp($current_choices, $new_choices)) {
        if (!$current_choices) {
            $sql = "INSERT INTO " . PREFIX . "flattr SET showFlattr=\"" . sql_safe($new_choices) . "\", user_id=" . sql_safe($user_id) . ";";
        } else {
            $sql = "UPDATE " . PREFIX . "flattr SET showFlattr=\"" . sql_safe($new_choices) . "\" WHERE user_id=" . sql_safe($user_id) . ";";
        }
        // echo "<pre>".print_r($sql,1)."</pre>";
        if (mysql_query($sql)) {
            add_message(_("New flattr choices set"));
        } else {
            add_error(sprintf(_("New flattr choices could not be set. Error: %s"), mysql_error()));
        }
    }
}
Example #30
0
 function _process($data)
 {
     $this->load->library('validator');
     /*
     Set rules up here so we can pass them to the form_builder to display errors.
     validator_helper contains the valid_email function... validator helper automatically gets' looded with Validation Class'
     */
     $this->validator->add_rule('first_name', 'required', 'Please enter in an first name', $this->input->post('first_name'));
     $this->validator->add_rule('last_name', 'required', 'Please enter in an last name', $this->input->post('last_name'));
     $this->validator->add_rule('email', 'valid_email', 'Please enter in a valid email', $this->input->post('email'));
     $this->validator->add_rule('question', 'required', 'Please enter in an question', $this->input->post('question'));
     if ($this->validator->validate()) {
         $this->load->library('email');
         $this->load->helper('inflector');
         // send email
         $this->email->from($data['email'], $data['first_name'] . ' ' . $data['last_name']);
         /*********************************************************************
         			YOU MUST FILL OUT THE CORRECT dev_email config in application/config/MY_config.php
         			AND/OR THE CORRECT TO email address
         			*********************************************************************/
         // check config if we are in dev mode
         if ($this->config->item('dev_mode')) {
             $this->email->to($this->config->item('dev_email'));
         } else {
             // need to fill this out to work
             $this->email->to('');
         }
         $this->email->subject('Website Contact Form');
         $msg = "The following information was submitted:\n";
         foreach ($data as $key => $val) {
             $msg .= humanize($key, 3) . ": " . $val . "\n";
         }
         $this->email->message($msg);
         // let her rip
         if (!$this->email->send()) {
             add_error('There was an error notifying');
             return FALSE;
         }
         return TRUE;
     }
 }