Example #1
0
 function execute($task)
 {
     if (method_exists($this, $task)) {
         return $this->{$task}();
     } else {
         echo "Invalid Task - {$task}<br>";
         print_p($this);
         exit;
     }
 }
Example #2
0
 function Display($value, $params, $context, $id)
 {
     if (is_array($value)) {
         print_p(dumpStack());
         print_p($value);
         exit;
     }
     $data = @json_decode($value, true);
     if (!$data) {
         return "";
     }
     return implode(", ", $data);
 }
Example #3
0
 static function get_css($path)
 {
     $file = isset($path) && $path ? file($path) : print_p('no file');
     $init = 0;
     $css_token = array();
     foreach ($file as $arr => $value) {
         $value = stripinput($value);
         if (preg_match('@Marker@si', $value)) {
             $init = 1;
         }
         if ($init > 0) {
             if ($init > 1) {
                 $css_token = strtok($value, "{}");
                 $css[] = str_replace(':before', '', $css_token);
             }
             $init++;
         }
     }
     return $css;
 }
Example #4
0
 /**
  * Theme Styler Page
  * Edit done, save done. Now load.
  */
 public function theme_editor()
 {
     global $aidlink, $locale;
     if (isset($_GET['e_action']) && $_GET['e_action'] == "edit" && isset($_GET['preset']) && isnum($_GET['preset'])) {
         $result = dbquery("SELECT * FROM " . DB_THEME . " WHERE theme_name='" . $this->theme_name . "' AND theme_id='" . intval($_GET['preset']) . "'");
         if (dbrows($result) > 0) {
             $this->data = dbarray($result);
             if ($this->data['theme_config']) {
                 $this->data += unserialize(stripslashes($this->data['theme_config']));
             }
         }
     }
     self::save_theme();
     $this->font_decoration_options = array($locale['theme_5000'], $locale['theme_5001'], $locale['theme_5002'], $locale['theme_5003'], $locale['theme_5004'], $locale['theme_5005'], $locale['theme_5006'], $locale['theme_5007']);
     $this->fills = array($locale['theme_5008'], $locale['theme_5009'], $locale['theme_5010'], $locale['theme_5011'], $locale['theme_5012']);
     $tab_title['title'][] = $locale['theme_2001'];
     $tab_title['id'][] = 'font';
     $tab_title['icon'][] = 'fa fa-text-width m-r-10';
     $tab_title['title'][] = $locale['theme_2002'];
     $tab_title['id'][] = 'grid';
     $tab_title['icon'][] = 'fa fa-magic m-r-10';
     $tab_title['title'][] = $locale['theme_2003'];
     $tab_title['id'][] = 'nav';
     $tab_title['icon'][] = 'fa fa-navicon m-r-10';
     $tab_active = tab_active($tab_title, 0);
     if ($this->debug) {
         print_p($_POST);
     }
     // Use a modal to block user to avoid double clicking the save button.
     echo openmodal('dbi', sprintf($locale['theme_2005'], ucwords($this->theme_name)), array('class' => 'zindex-boost modal-center', 'button_id' => 'save_theme', 'static' => 1));
     echo "<div class='pull-left m-r-20'><i class='icon_notify n-magic'></i></div>\n";
     echo "<div class='overflow-hide text-smaller'>" . $locale['theme_2006'] . "</div>\n";
     echo closemodal();
     // how come my multiple preset missing now?
     echo openform('theme_edit', 'post', FUSION_REQUEST, array("class" => "m-t-20"));
     echo "<div class='list-group-item m-b-20 clearfix'>\n";
     echo "<div class='pull-right m-l-10'>\n";
     echo form_button('save_theme', $locale['theme_5013'], 'save_theme', array('class' => 'btn-primary m-r-10'));
     echo form_button('close_theme', $locale['close'], 'close_theme', array('class' => 'btn-default'));
     echo "</div>\n";
     echo "<div class='overflow-hide'>\n";
     echo form_hidden('theme_id', '', $this->data['theme_id']);
     echo form_hidden("theme_datestamp", '', time());
     echo form_text('theme_title', $locale['theme_2007'], $this->data['theme_title'], array('inline' => 1, 'required' => TRUE));
     echo form_hidden('theme_name', $locale['theme_2008'], $this->theme_name, array('inline' => 1, 'deactivate' => 1));
     echo "</div>\n";
     echo "</div>\n";
     echo opentab($tab_title, $tab_active, 'atom');
     echo opentabbody($tab_title['title'][0], $tab_title['id'][0], $tab_active);
     echo "<div class='m-t-20'>\n";
     $this->font_admin();
     echo "</div>\n";
     echo closetabbody();
     echo opentabbody($tab_title['title'][1], $tab_title['id'][1], $tab_active);
     echo "<div class='m-t-20'>\n";
     $this->layout_admin();
     echo "</div>\n";
     echo closetabbody();
     echo opentabbody($tab_title['title'][2], $tab_title['id'][2], $tab_active);
     echo "<div class='m-t-20'>\n";
     $this->nav_admin();
     echo "</div>\n";
     echo closetabbody();
     echo closetab();
     echo closeform();
 }
Example #5
0
 public function verify_tokens($form, $post_time = 10, $preserve_token = FALSE)
 {
     global $locale, $settings, $userdata;
     // we are using this as many times of the form included in this file?
     $error = array();
     $user_id = isset($userdata['user_id']) ? $userdata['user_id'] : 0;
     $algo = $settings['password_algorithm'];
     $salt = md5(isset($userdata['user_salt']) ? $userdata['user_salt'] . SECRET_KEY_SALT : SECRET_KEY_SALT);
     if ($this->debug) {
         print_p($_POST);
     }
     // check if a session is started
     if (!isset($_SESSION['csrf_tokens'])) {
         $error[1] = $locale['token_error_1'];
         $this->stop($locale['token_error_1']);
         // check if a token is posted
     } elseif (!isset($_POST['fusion_token'])) {
         $error[2] = $locale['token_error_2'];
         $this->stop($locale['token_error_2']);
         // check if the posted token exists
     } elseif (!in_array($_POST['fusion_token'], isset($_SESSION['csrf_tokens'][$form]) ? $_SESSION['csrf_tokens'][$form] : array())) {
         $error[3] = $locale['token_error_3'];
         $this->stop($locale['token_error_3']);
         // invalid token - will not accept double posting.
     } else {
         $token_data = explode(".", stripinput($_POST['fusion_token']));
         // check if the token has the correct format
         if (count($token_data) == 3) {
             list($tuser_id, $token_time, $hash) = $token_data;
             if ($tuser_id != $user_id) {
                 // check if the logged user has the same ID as the one in token
                 //$error[4] = $locale['token_error_4'];
                 $error = 1;
                 $this->stop($locale['token_error_4']);
             } elseif (!isnum($token_time)) {
                 // make sure the token datestamp is a number before performing calculations
                 //$error[5] = $locale['token_error_5'];
                 $error = 1;
                 $this->stop($locale['token_error_5']);
                 // token is not a number.
             } elseif (time() - $token_time < $post_time) {
                 // post made too fast. Set $post_time to 0 for instant. Go for System Settings later.
                 //$error[6] = $locale['token_error_6'];
                 $error = 1;
                 $this->stop($locale['token_error_6']);
                 // check if the hash in token is valid
             } elseif ($hash != hash_hmac($algo, $user_id . $token_time . $form . SECRET_KEY, $salt)) {
                 //$error[7] = $locale['token_error_7'];
                 $error = 1;
                 $this->stop($locale['token_error_7']);
             }
         } else {
             // token incorrect format.
             //$error[8] = $locale['token_error_8'];
             $error = 1;
             $this->stop($locale['token_error_8']);
         }
     }
     // remove the token from the array as it has been used
     if ($post_time > 0) {
         // token with $post_time 0 are reusable
         foreach ($_SESSION['csrf_tokens'][$form] as $key => $val) {
             if ($val == $_POST['fusion_token']) {
                 unset($_SESSION['csrf_tokens'][$form][$key]);
             }
         }
     }
     if ($error) {
         return FALSE;
     }
     if ($this->debug) {
         notify("Token Verification Success!", "The token on token ring has been passed and validated successfully.", array('icon' => 'notify_icon n-magic'));
     }
     return TRUE;
 }
Example #6
0
 function LoadQuestion($q_id)
 {
     global $REPLACEMEuserIDold, $show_debug;
     $userObj = UserObject::get_instance();
     // storage for question data
     $q_row = array();
     $o_rows = array();
     // retrieve question row from database
     $db = new Database();
     $db->SetTable('questions');
     $db->AddField('*');
     $db->AddWhere('q_id', $q_id, 'i');
     $q_row = $db->GetSingleRow();
     // retrieve array of options from database
     $db = new Database();
     $db->SetTable('options');
     $db->AddField('*');
     $db->AddWhere('o_id', $q_id, 'i');
     $db->AddOrder('id_num');
     $o_rows = $db->GetMultiRow();
     // determine q type and create a storage class for correct type
     $q_type = $q_row['q_type'];
     $q_storage = 'ST_Question_' . $q_type;
     $store = new $q_storage();
     $store->type = $q_type;
     // populate base storage fields
     $this->LoadQuestionBase($store, $q_row, $o_rows);
     // populate class specific storage fields
     $funcname = 'LoadQuestion' . $q_type;
     call_user_func(array($this, $funcname), $store, $q_row, $o_rows);
     // display some debug data
     print_p($q_row);
     print_p($o_rows, true, 100);
     // insert track changes record
     if ($show_debug != true) {
         $track = array();
         $track['type'] = "QTI Export";
         $track['typeID'] = $q_row['q_id'];
         $track['editor'] = $userObj->get_user_ID();
         $track['new'] = "Exported to QTI file";
         $track['part'] = "all";
         $track['changed'] = date("Y-m-d H:i:s");
         $db->InsertRow("track_changes", "id", $track);
     }
     // return question
     return $store;
 }
Example #7
0
        echo '[';
        foreach ($row as $cell) {
            echo '{' . $cell[0] . ',' . $cell[1] . '},';
        }
        echo "]\n";
    }
}
function strongest_path($p)
{
    $l = count($p);
    for ($i = 0; $i < $l; $i++) {
        for ($j = 0; $j < $l; $j++) {
            if ($i == $j) {
                continue;
            }
            for ($k = 0; $k < $l; $k++) {
                if ($i == $k || $j == $k) {
                    continue;
                }
                $min = min_d($p[$j][$i], $p[$i][$k]);
                if (gt($min, $p[$j][$k])) {
                    $p[$j][$k] = $min;
                }
            }
        }
    }
    return $p;
}
$n = [[null, 8, 14, 10], [13, null, 6, 2], [7, 15, null, 12], [11, 19, 9, null]];
print_p(strongest_path(init($n)));
Example #8
0
 function LoadExtmatch(&$source)
 {
     // easy to do, no feedback in Rogo so goes the way of the dinosar
     $dest = new ST_Question_Extmatch();
     $dest->load_id = $source->load_id;
     $dest->status = $source->qmd_status;
     $dest->type = "extmatch";
     $shuf = 0;
     foreach ($source->responses as $respeach) {
         if ($respeach->shuffle == 1) {
             $shuf = 1;
         }
     }
     if ($shuf == 1) {
         //  if ($source->responses[1]->shuffle == 1) {
         $dest->q_option_order = 'random';
     }
     $this->GenerateQuestionInfo($dest, $source->material, $source->title);
     // load option list
     $optionlist = $this->GetResponseLabelList($source, false, $lablk, $lablkd);
     $optid = 1;
     foreach ($optionlist as $id => $option) {
         $opt = new STQ_Extm_Option();
         $opt->option = $option;
         $opt->id = $id;
         $dest->optionlist[$optid] = $opt;
         $optid++;
     }
     $optid = 1;
     // load all stems
     $stemid = 1;
     $respcond = $this->GetRespConditions($source, 1);
     print_p($respcond);
     $usedfb = array();
     $dest->marks = 0;
     foreach ($source->responses as $rid => $response) {
         $stem = new STQ_Extm_Scenario();
         $stem->stem = MakeValidHTML(RemoveLoneP($response->material->GetHTML()));
         $stem->base_response_id = $rid;
         if (!empty($response->material->media)) {
             $stem->media = $response->material->media;
             $stem->media_width = $response->material->media_width;
             $stem->media_height = $response->material->media_height;
         }
         $dest->scenarios[$stemid++] = $stem;
         $correct = array();
         foreach ($respcond as $cond) {
             foreach ($cond->conditions as $condvar) {
                 // 1 mark per correct answer so skip ones that have a diff respident and mark correct rest
                 if ($condvar->respident != $rid) {
                     continue;
                 }
                 if ($condvar->not) {
                     continue;
                 }
                 $correct[] = $condvar->value;
             }
         }
         list($marks_incorrect, $marks_partial, $marks_correct) = $this->getMarksFromRespConditions($source);
         $dest->marks_correct = $marks_correct;
         $dest->marks_incorrect = $marks_incorrect;
         $dest->marks_partial = $marks_partial;
         // work out correct answers for this stem
         $correct_mapped = array();
         foreach ($correct as $answer) {
             foreach ($dest->optionlist as $oid => $option) {
                 if ($option->id == $answer) {
                     $stem->correctans[] = $oid;
                 }
             }
             foreach ($lablkd as $lablkk => $lablkv) {
                 if ($lablkk != "") {
                     if ($lablk[$rid][$answer] == $lablkk) {
                         $stem->correctans[] = $lablkv;
                     }
                 }
             }
         }
         // get feedback for this stem
         $fb = $this->GetFeedbacks($source, $rid);
         $stem->feedback = $this->GetFeedbackFromArray($source, $fb);
     }
     return $dest;
 }
Example #9
0
//echo form_checkbox('Checkbox 4, child of Checkbox 3', 'checkbox_input4', 'checkbox_input4', $settings_test['checkbox_input4'], array('child_of' => 'checkbox_input3', 'inline' => 1));
//echo form_name('Name', 'name_input', 'name_input', $settings_test['name_input'], array('required' => 1, 'inline' => 1));
//echo form_address('Address', 'address_input', 'address_input', explode('|', $settings_test['address_input']), array('inline' => 1));
echo form_textarea('textarea', 'Text area', $settings_test['textarea'], array('autosize' => 1, 'inline' => 1));
//var_dump($_SESSION['form_fields'][$_SERVER['PHP_SELF']]);
$file_options = array('upload_path' => DOWNLOADS . "images/", 'max_width' => 600, 'max_height' => 600, 'max_byte' => 1500000000, 'type' => 'image', 'required' => 0, 'delete_original' => 0, 'thumbnail_folder' => '', 'thumbnail' => 1, 'thumbnail_suffix' => '_thumb', 'thumbnail_w' => 400, 'thumbnail_h' => 400, 'error_text' => 'Please select an image', 'inline' => 1, 'thumbnail2' => 0);
echo form_fileinput('file_input', 'File upload', '', $file_options);
// all file types.
echo form_button('submit', 'Submit', 'value', array('class' => 'btn-success'));
echo closeform();
echo "<br>These are the default and posted settings merged, which would endup being inserted in the DB:";
if (isset($settings_test)) {
    print_p($settings_test);
}
echo "<br>These are the tokens available for this form:";
if (isset($_SESSION['csrf_tokens']['form'])) {
    print_p($_SESSION['csrf_tokens']['form']);
}
echo "<hr/>\n";
echo "<h3>Serialize method</h3>\n";
$testArray = array("a" => 1, "b" => 2, "c" => 3, "d" => addslashes(4), "e" => timer(time()), "f" => "string", "g" => array("1" => "a", "2" => "b", "3" => "c"));
// This is used in UserFieldsInput.php L490 during registration to DB_NEW_USERS
echo "<div class='well m-10'>This will be stored into SQL column. Using base64_encode, You won't be able to see value entirely</div>\n";
$info = base64_encode(serialize($testArray));
print_p($info);
// This is called back in register.php L50
echo "<div class='well m-10'>But when callback with base64_decode and unserialize</div>\n";
$info = unserialize(base64_decode($info));
print_p($info);
closetable();
require_once THEMES . "templates/footer.php";
Example #10
0
function print_p($elem, $expandfirst = true, $trim = 100, $max_level = 10, $print_nice_stack = array())
{
    $configObject = Config::get_instance();
    $base_dir = $configObject->get('cfg_root_path');
    OutputHeader_pp();
    global $nice_id;
    if (is_array($elem) || is_object($elem)) {
        if (in_array($elem, $print_nice_stack, true)) {
            echo "<font color=red>RECURSION</font>";
            return;
        }
        $print_nice_stack[] =& $elem;
        if ($max_level < 1) {
            echo "<font color=red>nivel maximo alcanzado</font>";
            return;
        }
        $max_level--;
        //echo "<table border=0 cellspacing=0 cellpadding=3 width=100%>";
        $title = '';
        $isarray = false;
        if (is_array($elem)) {
            $title = "<img src='{$base_dir}/qti/artwork/array.png' width='16' height='16'> Array (" . count($elem) . ")";
            $isarray = true;
            //echo '<tr><td colspan=2 style="background-color:#333333;"><strong><font color=white>ARRAY</font></strong></td></tr>';
        } else {
            //echo '<tr><td colspan=2 style="background-color:#333333;"><strong>';
            //echo '<font color=white>+ * - OBJECT Type: '.get_class($elem).'</font></strong></td></tr>';
            $title = "<img src='{$base_dir}/qti/artwork/class.png' width='16' height='16'> Object Type: " . get_class($elem);
            //			if (is_callable(array(get_class($elem),"__toString")))
            if (is_callable(array($elem, "__toString"))) {
                //if (get_class($elem) == "ST_QTI12_Material")
                //{
                $title .= " (" . trim(substr($elem->__toString(), 0, 125)) . ")";
                //}
            }
        }
        echo "<div class='print_cont'>";
        echo "<div class='print_head'>";
        echo "<img src='{$base_dir}/qti/artwork/plus.png' width='16' height='16' onclick='print_nice_expand(" . $nice_id . ")'>";
        echo "<img src='{$base_dir}/qti/artwork/star.png' width='16' height='16' onclick='print_nice_expand_all(" . $nice_id . ")'>";
        echo "<img src='{$base_dir}/qti/artwork/minus.png' width='16' height='16' onclick='print_nice_contract(" . $nice_id . ")'>";
        echo "<img src='{$base_dir}/qti/artwork/raw.png' width='16' height='16' onclick='print_nice_toggle_raw(" . $nice_id . ")'>";
        echo "&nbsp;&nbsp;";
        echo $title . "</div>";
        echo "<div class='print_raw' id='print_nice_raw_" . $nice_id . "' style=\"display:none\"><pre>";
        print_r($elem);
        echo "</pre></div>";
        $style = '';
        if ($expandfirst && ($max_level == 9 || $isarray)) {
            $style = "display:inline;";
        }
        echo "<div class='print_body' id='print_nice_" . $nice_id . "' style='" . $style . "'>";
        $nice_id++;
        if (count($elem) > 0) {
            echo "<table border=\"0\" cellspacing=\"0\" cellpadding=\"2\" style=\"width:100%\">";
            $color = 0;
            foreach ($elem as $k => $v) {
                if ($max_level % 2) {
                    $rgb = $color++ % 2 ? "#DDDDDD" : "#EEEEEE";
                } else {
                    $rgb = $color++ % 2 ? "#DDDDFF" : "#EEEEFF";
                }
                //$rgb = '#FFFFFF';
                echo '<tr bgcolor="' . $rgb . '"><td valign="top" class="print_label" nowrap width="0%">';
                echo $k;
                echo '</td><td class="print_variable" width="100%">';
                print_p($v, $expandfirst, $trim, $max_level, $print_nice_stack);
                echo "</td></tr>";
            }
            echo "</table>";
        } else {
            echo "<font color=green>Empty Array</font>";
        }
        echo "</div>";
        echo "</div>";
        return;
    }
    if ($elem === null) {
        echo "<font color=green>NULL</font>";
    } elseif ($elem === 0) {
        echo "0";
    } elseif ($elem === true) {
        echo "<font color=green>TRUE</font>";
    } elseif ($elem === false) {
        echo "<font color=green>FALSE</font>";
    } elseif ($elem === "") {
        echo "<font color=green>EMPTY STRING</font>";
    } else {
        $out = "";
        $elem = htmlentities($elem);
        if (strlen($elem) > $trim) {
            while ($elem != "") {
                $out .= substr($elem, 0, $trim) . "<strong><font color=blue>*</font></strong><br />";
                $elem = substr($elem, $trim);
            }
            $elem = $out;
        }
        echo str_replace("\n", "<strong><font color=red>*</font></strong><br>\n", $elem);
    }
}
Example #11
0
 static function Debug($type, $vars)
 {
     if (!FST_EMail::$debug) {
         return;
     }
     echo "<h2>{$type}</h2>";
     foreach ($vars as $name => $data) {
         echo "<h4>{$name}</h4>";
         print_p($data);
     }
     if (FST_EMail::$exit_on_debug) {
         exit;
     }
 }
Example #12
0
<?php

include __DIR__ . '/bootstrap.php';
// Define home route
$app->get('/', function ($request, $response) {
    return $this->view->render($response, 'about.twig', ['messages' => $this->flash->getMessages()]);
})->setName('home');
$app->get('/error', function ($request, $response) {
    $response = $response->withHeader('X-Status-Reason', $this->flash->getMessage('error'));
    print_p($this->flash->getMessages());
    die;
    return $this->view->render($response->withStatus(400), 'error.twig', ['messages' => $this->flash->getMessages(), 'error_detail' => $this->flash->getMessages()]);
})->setName('error');
include __DIR__ . '/routes_signouts.php';
include __DIR__ . '/routes_territories.php';
include __DIR__ . '/routes_buildings.php';
include __DIR__ . '/routes_people.php';
// $app->get('/contact', function ($request, $response) {
// return $this->view->render($response, 'contact.twig', [
// 		'messages' => $this->flash->getMessages()
// 	]);
// })->setName('contact');
// $app->post('/contact', function ($request, $response, $args) {
// 	$post = $request->getParsedBody();
// 	$name = $post['name'];
// 	$email = $post['email'];
// 	$msg = $post['msg'];
// 	if( !empty($name) && !empty($email) && !empty($msg) ){
// 	   $cleanName   =  filter_var( $name, FILTER_SANITIZE_STRING );
// 	   $cleanEmail  =  filter_var($email, FILTER_SANITIZE_EMAIL );
// 	   $cleanName   =  filter_var(  $msg, FILTER_SANITIZE_STRING );
Example #13
0
 function Save($params, &$data)
 {
     global $mysqli, $string;
     echo "<h4>{$string['params']}</h4>";
     print_p($params);
     echo "<h4>{$string['othherdebug']}</h4>";
     $this->db = new Database();
     if (count($data->questions) == 0) {
         $this->AddError($string['noquestions']);
         return;
     }
     $paperid = $params->paper;
     $userObj = UserObject::get_instance();
     $userID = $userObj->get_user_ID();
     $db = new Database();
     $db->SetTable('properties');
     $db->AddField('*');
     $db->AddWhere('property_id', $paperid, 'i');
     $paper_row = $db->GetSingleRow();
     $ownerid = $userID;
     $data->ownerID = $userID;
     $nextscreen = 1;
     $nextid = 1;
     if ($paperid) {
         echo "{$string['addingtopaper']} {$paperid}<br>";
         $this->db->SetTable('papers');
         $this->db->AddField("max(screen) as screen");
         $this->db->AddField("max(display_pos) as display_pos");
         $this->db->AddWhere('paper', $paperid, 'i');
         $curpos = $this->db->GetSingleRow();
         $nextscreen = $curpos['screen'] + 1;
         $nextid = $curpos['display_pos'] + 1;
     }
     /*    // Get the actual ID of the module
             $this->db->SetTable('modules');
             $this->db->AddField('id');
             // Temp fix - if more than one team just get the first. Avoids error but doesn't fix the problem completely
             if (strpos($q_group, ',') !== false) {
               $q_group = strstr($q_group, ',', true);
             }
             $this->db->AddWhere('moduleid', $q_group, 's');
             $module_row = $this->db->GetSingleRow();
         */
     $module_id = -1;
     $paperutils = Paper_utils::get_instance();
     $module_id1 = $paperutils->get_modules($paper_row['property_id'], $mysqli);
     if ($module_id1 !== false) {
         $module_id = $module_id1;
     }
     $modutils = module_utils::get_instance();
     $q_group = $modutils->get_moduleid_from_id($module_id, $mysqli);
     if ($module_id !== false) {
         // Get a list of the team and user's keywords
         $user_keywords = array();
         if (is_array($module_id)) {
             foreach (array_keys($module_id) as $mod_id) {
                 $user_keywordsl = $this->GetExistingKeywords($mod_id);
                 $user_keywords = array_merge($user_keywords, $user_keywordsl);
             }
         } else {
             $user_keywords = $this->GetExistingKeywords($module_id);
         }
     }
     foreach ($data->questions as &$question) {
         $this->q_row = $this->db->GetBlankTableRow("questions");
         $this->o_row = $this->db->GetBlankTableRow("options");
         $this->o_rows = array();
         // stuff from parameters
         $this->q_row['ownerID'] = $ownerid;
         // general stuff that needs to be done for every qtype
         $this->q_row['creation_date'] = date("Y-m-d H:i:s");
         $this->q_row['last_edited'] = date("Y-m-d H:i:s");
         $this->q_row['q_type'] = $question->type;
         $this->q_row['status'] = isset($this->statuses[$question->status]) ? $this->statuses[$question->status] : $this->default_status;
         $this->q_row['theme'] = $question->theme;
         $this->q_row['notes'] = $question->notes;
         $this->q_row['leadin'] = $question->leadin;
         $this->q_row['bloom'] = $question->bloom;
         $this->q_row['q_media'] = $question->media;
         $this->q_row['q_media_width'] = $question->media_width;
         $this->q_row['q_media_height'] = $question->media_height;
         $this->q_row['deleted'] = null;
         $this->q_row['locked'] = null;
         $this->q_row['std'] = null;
         $this->q_row['q_option_order'] = $question->q_option_order;
         if (isset($question->settings)) {
             $this->q_row['settings'] = $question->settings;
         }
         $oiii = print_r($question, true);
         $t = 8;
         if ($question->type == "blank") {
             $this->SaveBlank($question);
         } elseif ($question->type == "calculation") {
             $this->SaveCalculation($question);
             $this->q_row['q_type'] = 'enhancedcalc';
         } elseif ($question->type == "dichotomous") {
             $this->SaveDichotomous($question);
         } elseif ($question->type == "extmatch") {
             $this->SaveExtMatch($question);
         } elseif ($question->type == "flash") {
             $this->SaveFlash($question);
         } elseif ($question->type == "hotspot") {
             $this->SaveHotspot($question);
         } elseif ($question->type == "info") {
             $this->SaveInfo($question);
         } elseif ($question->type == "labelling") {
             $this->SaveLabelling($question);
         } elseif ($question->type == "likert") {
             $this->SaveLikert($question);
         } elseif ($question->type == "matrix") {
             $this->SaveMatrix($question);
         } elseif ($question->type == "mcq") {
             $this->SaveMcq($question);
         } elseif ($question->type == "true_false") {
             $this->SaveTrueFalse($question);
         } elseif ($question->type == "mrq") {
             $this->SaveMrq($question);
         } elseif ($question->type == "rank") {
             $this->SaveRank($question);
         } elseif ($question->type == "textbox") {
             $this->SaveTextbox($question);
         } else {
             $this->AddError("Question type " . $question->type . " not yet supported", $question->load_id);
             continue;
         }
         if (!in_array($this->q_row['q_option_order'], array('display order', 'alphabetic', 'random'))) {
             $this->q_row['q_option_order'] = 'display order';
             print "correcting q_option_order";
         }
         if (!empty($this->q_row['scenario']) && strcasecmp("<p>&nbsp;</p>", $this->q_row['scenario']) == 0) {
             $this->q_row['scenario'] = '';
         }
         // create plain version of scenario and leadin
         $this->q_row['scenario_plain'] = empty($this->q_row['scenario']) ? '' : trim(strip_tags($this->q_row['scenario']));
         $this->q_row['leadin_plain'] = empty($this->q_row['leadin']) ? '' : trim(strip_tags($this->q_row['leadin']));
         if (!empty($this->q_row['correct_fback']) && !empty($this->q_row['incorrect_fback']) && $this->q_row['correct_fback'] == $this->q_row['incorrect_fback']) {
             $this->q_row['incorrect_fback'] = '';
         }
         // if no o_row, create a blank one
         if (count($this->o_rows) == 0 and $question->type != "calculation") {
             $this->o_row['marks_correct'] = 1;
             $this->o_row['marks_incorrect'] = 0;
             $this->o_row['marks_partial'] = 0;
             $this->o_rows[] = $this->o_row;
         }
         // store question row
         $this->db->InsertRow("questions", "q_id", $this->q_row);
         $question->save_id = $this->q_row['q_id'];
         $this->qm_row = $this->db->GetBlankTableRow("questions_modules");
         $this->qm_row['q_id'] = $this->q_row['q_id'];
         if (is_array($module_id)) {
             foreach (array_keys($module_id) as $mod_id) {
                 $this->qm_row['idMod'] = $mod_id;
                 $this->db->InsertRow("questions_modules", "temp", $this->qm_row);
             }
         } else {
             $this->qm_row['idMod'] = $module_id;
             $this->db->InsertRow("questions_modules", "temp", $this->qm_row);
         }
         $new_keywords = array();
         if ($module_id != -1) {
             if (is_array($module_id)) {
                 $user_keywords2 = array();
                 foreach (array_keys($module_id) as $mod_id) {
                     $new_keywords1 = $this->SaveKeywords($this->q_row['q_id'], $question->keywords, $mod_id, $user_keywords, $user_keywords2);
                     $new_keywords = array_merge($new_keywords, $new_keywords1);
                 }
                 $user_keywords = array_merge($user_keywords, $user_keywords2);
             } else {
                 $new_keywords = $this->SaveKeywords($this->q_row['q_id'], $question->keywords, $module_id, $user_keywords);
             }
         }
         // store option rows
         foreach ($this->o_rows as &$o_row) {
             $o_row['o_id'] = $this->q_row['q_id'];
             if (!empty($o_row['feedback_right']) && $o_row['feedback_right'] == $o_row['feedback_wrong']) {
                 $o_row['feedback_wrong'] = "";
             }
             $this->db->InsertRow("options", "id_num", $o_row);
         }
         // store additional metadata
         if ($question->load_id != '') {
             $meta_row = array('id' => null, 'questionID' => $question->save_id, 'type' => 'QTI Ident', 'value' => $question->load_id);
         }
         $this->db->InsertRow("questions_metadata", "id", $meta_row);
         echo "<h4>{$string['questiontables']}</h4>";
         echo "<div>{$string['questionsrow']}</div>";
         print_p($this->q_row, false);
         echo "<div>{$string['optionsrows']}</div>";
         print_p($this->o_rows, false, 100);
         echo "<div>{$string['newkeywords']}</div>";
         print_p($new_keywords, false);
         $track = array();
         $track['type'] = $string['qtiimport'];
         $track['typeID'] = $this->q_row['q_id'];
         $track['editor'] = $userID;
         $track['new'] = "{$string['imported1_2']} " . $params->original_filename;
         $track['part'] = "all";
         $track['changed'] = date("Y-m-d H:i:s");
         $db->InsertRow("track_changes", "id", $track);
         // we have a paper, add this question onto the list of questions for the paper
         if ($paperid && empty($data->papers)) {
             $p_row = $this->db->GetBlankTableRow('papers');
             $p_row['paper'] = $paperid;
             $p_row['question'] = $question->save_id;
             $p_row['screen'] = $nextscreen;
             $p_row['display_pos'] = $nextid++;
             $this->db->InsertRow('papers', 'p_id', $p_row);
         }
     }
     $logger = new Logger($mysqli);
     if (!empty($data->papers)) {
         foreach ($data->papers as &$paper) {
             foreach ($paper->screens as &$screen) {
                 foreach ($screen->question_ids as $q_id) {
                     $p_row = $this->db->GetBlankTableRow('papers');
                     echo sprintf($string['addingquestiondetails'], $q_id, $nextid, $nextscreen) . '<br>';
                     $p_row['paper'] = $paperid;
                     $q = FindQuestion($data->questions, $q_id);
                     $p_row['question'] = $q->save_id;
                     $p_row['screen'] = $nextscreen;
                     $p_row['display_pos'] = $nextid++;
                     $this->db->InsertRow('papers', 'p_id', $p_row);
                     $logger->track_change('Paper', $paperid, $userID, '', $q_id, 'Add Question (from QTI)');
                 }
                 $nextscreen++;
             }
         }
     }
 }
Example #14
0
 function doSave($field, &$data)
 {
     print_p($_POST);
     exit;
 }
Example #15
0
/**
 * MYSQL Row modifiers. Insert/Update/Delete
 *
 * @param string $table
 * @param array $inputdata
 * @param string $mode save|update|delete
 * @param array $options
 * 	<ul>
 * 		<li><strong>debug (boolean)</strong>:
 * 			If TRUE, do nothing, just show the SQL. FALSE by default</li>
 * 		<li><strong>primary_key (string|string[])</strong>:
 * 			Names of primary key columns. If it is empty,
 * 			columns will detected automatically.</li>
 * 		<li><strong>no_unique (boolean)</strong>:
 * 			If TRUE, primary key columns will be not removed
 * 			from $inputdata. FALSE by default.</li>
 * 		<li><strong>keep_session (boolean)</strong>:
 * 			If TRUE, defender will not unset field sessions.</li>
 * 	</ul>
 * @return int|FALSE
 * 	If an error happens, it returns FALSE.
 * 	Otherwise, if $mode is save and the primary key column is
 * 	incremented automatically, this function returns the last inserted id.
 * 	In other cases it always returns 0.
 */
function dbquery_insert($table, $inputdata, $mode, array $options = array())
{
    $options += array('debug' => FALSE, 'primary_key' => '', 'no_unique' => FALSE, 'keep_session' => FALSE);
    if (defined("FUSION_NULL")) {
        if ($options['debug']) {
            print_p('Fusion Null Declared. Developer, check form tokens.');
        }
        return FALSE;
    }
    global $defender;
    $cresult = dbquery("SHOW COLUMNS FROM {$table}");
    $columns = array();
    $pkcolumns = array();
    while ($cdata = dbarray($cresult)) {
        $columns[] = $cdata['Field'];
        if ($cdata['Key'] === 'PRI') {
            $pkcolumns[$cdata['Field']] = $cdata['Field'];
        }
    }
    if ($options['primary_key']) {
        $options['primary_key'] = (array) $options['primary_key'];
        $pkcolumns = array_combine($options['primary_key'], $options['primary_key']);
    }
    $sanitized_input = array();
    $data = array_intersect_key($inputdata, array_flip($columns));
    $pkvalues = array_intersect_key($data, $pkcolumns);
    if (!$options['no_unique'] and $mode !== 'save') {
        foreach ($pkcolumns as $c) {
            unset($data[$c]);
        }
    }
    if (!$data) {
        if ($options['debug']) {
            print_p('$inputdata does not contain any valid column.');
        }
        return FALSE;
    }
    $sqlPatterns = array('save' => 'INSERT INTO `{table}` SET {values}', 'update' => 'UPDATE `{table}` SET {values} WHERE {where}', 'delete' => 'DELETE FROM `{table}` WHERE {where}');
    foreach ($data as $name => $value) {
        $sanitized_input[] = "`{$name}` = '{$value}'";
    }
    if (!isset($sqlPatterns[$mode])) {
        // TODO Replace die with something better. I kept the old way (Rimelek)
        die;
    }
    $where = '';
    if ($mode === 'update' or $mode === 'delete') {
        $pkwhere = array();
        foreach ($pkvalues as $name => $pkvalue) {
            $pkwhere[] = "`{$name}`='{$pkvalue}'";
        }
        $where = implode(' AND ', $pkwhere);
    }
    $sql = strtr($sqlPatterns[$mode], array('{table}' => $table, '{values}' => implode(', ', $sanitized_input), '{where}' => $where));
    $result = NULL;
    if ($options['debug']) {
        print_p($where);
        print_p($sanitized_input);
        print_p($sql);
    } else {
        $result = dbquery($sql);
        if (!$options['keep_session']) {
            //print_p('field session unset during '.$sql);
            $defender->unset_field_session();
        }
    }
    if ($result === FALSE) {
        // Because dblastid() can return the id of the last record of the error log.
        return FALSE;
    }
    return $mode === 'save' ? dblastid() : 0;
}
Example #16
0
 function Save($params, &$data)
 {
     global $string;
     echo "<h4>{$string['params']}</h4>";
     print_p($params);
     echo "<h4>{$string['generaldebuginfo']}</h4>";
     global $REPLACEMEuserIDold;
     $userObj = UserObject::get_instance();
     $userID = $userObj->get_user_ID();
     $data->ownerID = $userID;
     $this->data =& $data;
     $this->params =& $params;
     $this->ll = array();
     for ($i = 1; $i < 27; $i++) {
         $varletter = chr(ord('A') + $i - 1);
         $this->ll[$i] = $varletter;
     }
     // paper mode
     if (count($data->papers) > 0) {
         foreach ($data->papers as &$paper) {
             //print_p($paper);
             $this->output = $this->DoHeader();
             $this->output .= "\t<assessment title='" . $paper->paper_title . "' ident='" . $paper->load_id . "'>\n";
             if ($paper->rubric) {
                 $this->output .= "\t\t<rubric><![CDATA[" . $paper->rubric . "]]></rubric>\n";
             }
             foreach ($paper->screens as $id => &$screen) {
                 $this->output .= "\t\t<section title='Screen {$id}' ident='{$id}'>\n";
                 foreach ($screen->question_ids as $q_id) {
                     $question = FindQuestion($data->questions, $q_id);
                     if ($question) {
                         $this->OutputQuestion($question);
                     } else {
                         $this->AddError("Screen {$id} references questions {$q_id} which doesnt exist");
                     }
                 }
                 $this->output .= "\t\t</section>\n";
             }
             $this->output .= "\t</assessment>\n";
             $this->output .= sprintf("</questestinterop>\n");
             $filename = $params->base_dir . $params->dir . "/paper-" . $paper->load_id . ".xml";
             file_put_contents($filename, $this->output);
             //$data->files[$paper->paper_title] = $filename;
             $data->files[] = new ST_File("paper-" . $paper->load_id . ".xml", $paper->paper_title, $params->dir);
         }
     } else {
         // question mode
         $this->output = $this->DoHeader();
         // this needs a lot more work on this function
         foreach ($data->questions as $question) {
             $this->OutputQuestion($question);
         }
         $this->output .= sprintf("</questestinterop>\n");
         $filename = $params->base_dir . $params->dir . "/questions.xml";
         file_put_contents($filename, $this->output);
         $data->files[] = new ST_File("questions.xml", "Questions", $params->dir);
     }
     echo "<h4>QTI Output</h4>";
     echo "<pre>";
     echo htmlentities($this->output);
     echo "</pre>";
 }
Example #17
0
 private function _delete_fields()
 {
     global $aidlink;
     if (isset($_GET['action']) && $_GET['action'] == 'field_delete' && isset($_GET['field_id']) && self::validate_field($_GET['field_id'])) {
         $result = dbquery("SELECT field.field_id, field.field_cat, field.field_order, field.field_name, u.field_cat_id, u.field_parent, root.field_cat_db\n\t\t\tFROM " . $this->field_db . " field\n\t\t\tLEFT JOIN " . $this->category_db . " u ON (field.field_cat=u.field_cat_id)\n\t\t\tLEFT JOIN " . $this->category_db . " root on (u.field_parent = root.field_cat_id)\n\t\t\tWHERE field_id='" . intval($_GET['field_id']) . "'\n\t\t\t");
         if (dbrows($result) > 0) {
             $data = dbarray($result);
             $target_database = $data['field_cat_db'] ? DB_PREFIX . $data['field_cat_db'] : DB_USERS;
             $field_list = fieldgenerator($target_database);
             if (in_array($data['field_name'], $field_list)) {
                 // drop database
                 if (!$this->debug && !empty($target_database)) {
                     $result = dbquery("ALTER TABLE " . $target_database . " DROP " . $data['field_name']);
                     // reorder the rest of the same cat minus 1
                     $result = dbquery("UPDATE " . $this->field_db . " SET field_order=field_order-1 WHERE field_order > '" . $data['field_order'] . "' AND field_cat='" . $data['field_cat'] . "'");
                     $result = dbquery("DELETE FROM " . $this->field_db . " WHERE field_id='" . $data['field_id'] . "'");
                 }
             } else {
                 // just delete the field
                 if (!$this->debug) {
                     $result = dbquery("DELETE FROM " . $this->field_db . " WHERE field_id='" . $data['field_id'] . "'");
                 } else {
                     print_p("DELETE " . $data['field_id'] . " FROM " . $this->field_db);
                 }
             }
             if (!$this->debug) {
                 addNotice('success', $this->locale['field_0201']);
                 redirect(FUSION_SELF . $aidlink);
             }
         } else {
             if (!$this->debug) {
                 addNotice('warning', $this->locale['field_0202']);
                 redirect(FUSION_SELF . $aidlink);
             } else {
                 print_p($this->locale['field_0202']);
             }
         }
     }
 }
/**
 * Function to redirect on invalid page access.
 * @param      $rights
 * @param bool $debug
 */
function pageAccess($rights, $debug = FALSE)
{
    $error = array();
    if ($debug) {
        print_p('Admin Panel mode');
    }
    if (!defined('iAUTH')) {
        $error[] = 'iAuth error';
    }
    if (!isset($_GET['aid'])) {
        $error[] = 'Aid link error';
    }
    if (iADMIN && !empty($_GET['aid'])) {
        if ($_GET['aid'] != iAUTH) {
            $error[] = 'Aidlink mismatch. ' . iAUTH . ' != ' . $_GET['aid'] . "<br/>";
            $error[] .= USER_IP;
        }
    } else {
        $error[] = "You are logged out while accessing admin panel";
    }
    if (!checkrights($rights)) {
        $error[] = 'Checkrights Error';
    }
    if (!empty($error)) {
        if ($debug) {
            print_p($error);
        } else {
            redirect(BASEDIR);
        }
    }
}
Example #19
0
    // deze wel weg, want deze legitimeren de inlogsessie
    //			          de rest hoeft niet weg, dat gebeurt wel als iemand anders inlogt
    header("Location: login");
}
if ($paget == 'home') {
    $items = fetch_all_array("SELECT * FROM `nodes` \r\nINNER JOIN `pcont` \r\nON `nodes`.`id`=`pcont`.`node` \r\nWHERE `pcont`.`page`='2'");
    $menu = array(title => 'Portfolio', items => array(array(title => 'test', link => 'pagina/test'), array(title => 'test', link => 'pagina/test'), array(title => 'test', link => 'pagina/test'), array(title => 'test', link => 'pagina/test')));
    $side_bar[] = array(title => "Featured", content => array_do('stripslashes', fetch_all_array("SELECT * FROM featured WHERE `stop`>'" . time() . "' LIMIT 0,2")));
    if ($debug) {
        echo 'style/' . $template . '/home.php';
        echo '<pre>';
        print_r($items);
        print_r($menu);
        print_r($side_items);
        echo '</pre>';
    }
    include 'style/' . $template . '/home.php';
}
if ($paget == 'survey' && strtoupper($q[1]) == "ELO") {
    $items = array("Test");
    include 'style/' . $template . '/home.php';
    exit;
}
if ($paget == 'survey') {
    $items = array(array(title => 'ELO Enqu&ecirc;te', content => file_get_contents('survey1.html')));
    $side_bar[] = array(title => "Info", content => array(array(title => "ELO", comment => "Een ELO of te wel Elektronische Leeromgeving is \"Een sociaal systeem waarbinnen word geleerd en waarbij gebruik word gemaakt van ICT hulmiddelen\". Het doel van een ELO is om het leeren en lesgeven makkelijker te maken.")));
    include 'style/' . $template . '/home.php';
}
if ($paget == 'survey_check') {
    print_p($_POST);
}
Example #20
0
 /**
  * Set CustomPage Links into Navigation Bar
  * @param $data
  */
 protected function set_customPageLinks($data)
 {
     $page_language = explode(".", $data['page_language']);
     foreach ($page_language as $language) {
         $link_order = dbresult(dbquery("SELECT MAX(link_order) FROM " . DB_SITE_LINKS . " " . (multilang_table("SL") ? "WHERE link_language='" . LANGUAGE . "' AND" : "WHERE") . " link_cat='" . $data['page_link_cat'] . "'"), 0) + 1;
         $link_data = array('link_id' => !empty($data['link_id']) ? $data['link_id'] : 0, 'link_cat' => $data['page_link_cat'], 'link_name' => $data['page_title'], 'link_url' => 'viewpage.php?page_id=' . $data['page_id'], 'link_icon' => '', 'link_language' => $language, 'link_visibility' => 0, 'link_position' => 2, 'link_window' => 0, 'link_order' => $link_order);
         print_p($link_data);
         if (\PHPFusion\SiteLinks::verify_edit($link_data['link_id'])) {
             dbquery_insert(DB_SITE_LINKS, $link_data, 'update');
         } else {
             dbquery_insert(DB_SITE_LINKS, $link_data, 'save');
         }
     }
 }
Example #21
0
 function Load($params)
 {
     global $string;
     echo "<h4>{$string['params']}</h4>";
     print_p($params);
     global $import_directory;
     $xml_files = array();
     //print_p($params);
     $this->params = $params;
     $import_directory = $params->base_dir . $params->dir . "/";
     $filename = $params->sourcefile;
     $ext = strtolower(pathinfo($filename, PATHINFO_EXTENSION));
     if ($ext == "xml") {
         $xml_files[basename($filename)] = $filename;
     } else {
         if ($ext == "zip") {
             echo "Extracting zip<br />";
             $zip = new ZipArchive();
             $res = $zip->open($filename);
             if ($res === true) {
                 $zip->extractTo($params->base_dir . $params->dir . "/");
                 for ($i = 0; $i < $zip->numFiles; $i++) {
                     $stat = $zip->statIndex($i);
                     $filename = $stat['name'];
                     $ext = strtolower(pathinfo($filename, PATHINFO_EXTENSION));
                     if ($ext == "xml") {
                         $xml_files[$filename] = $params->base_dir . $params->dir . "/" . $filename;
                     }
                 }
                 $zip->close();
             } else {
                 print "zip invalid ";
                 switch ($res) {
                     case ZipArchive::ER_EXISTS:
                         $ErrMsg = "File already exists.";
                         break;
                     case ZipArchive::ER_INCONS:
                         $ErrMsg = "Zip archive inconsistent.";
                         break;
                     case ZipArchive::ER_MEMORY:
                         $ErrMsg = "Malloc failure.";
                         break;
                     case ZipArchive::ER_NOENT:
                         $ErrMsg = "No such file.";
                         break;
                     case ZipArchive::ER_NOZIP:
                         $ErrMsg = "Not a zip archive.";
                         break;
                     case ZipArchive::ER_OPEN:
                         $ErrMsg = "Can't open file.";
                         break;
                     case ZipArchive::ER_READ:
                         $ErrMsg = "Read error.";
                         break;
                     case ZipArchive::ER_SEEK:
                         $ErrMsg = "Seek error.";
                         break;
                     default:
                         $ErrMsg = "Unknown (Code {$rOpen})";
                         break;
                 }
                 print "Zip Error Message: " . $ErrMsg . "\r\n";
                 $this->AddError($string['invalidzip']);
                 return;
             }
         }
     }
     $files['qti12'] = array();
     // qti 1.2 files, each unrelated to the rest
     $files['manifest'] = array();
     // manifest files
     $files['item'] = array();
     // qti 2 questions
     $files['paper'] = array();
     // qti 2 test files
     foreach ($xml_files as $filename => $fullpath) {
         $type = $this->DetectFileType($fullpath);
         $files[$type][$filename] = $fullpath;
     }
     if (count($files['qti12']) == 0) {
         $this->AddError($string['noqtiinzip']);
         return;
     }
     $result = new stdClass();
     $result->questions = array();
     // process qti 1.2 files
     foreach ($files['qti12'] as $filename => $fullpath) {
         $qti12 = new IE_QTI12_Load();
         $params->sourcefile = $fullpath;
         $ob = new OB();
         $ob->ClearAndSave();
         $output = $qti12->Load($params);
         $this->debug .= $ob->GetContent();
         $ob->Restore();
         foreach ($qti12->warnings as $qid => $warnings) {
             foreach ($warnings as $warn) {
                 $this->warnings[$qid][] = $warn;
             }
         }
         foreach ($qti12->errors as $qid => $errors) {
             foreach ($errors as $error) {
                 $this->errors[$qid][] = $error;
             }
         }
         echo "<h4>{$string['fileoutput']}: {$filename}</h4>";
         echo $this->debug;
         foreach ($output->questions as $id => $question) {
             $result->questions[$id] = $question;
         }
         if (!empty($output->papers)) {
             foreach ($output->papers as $id => $paper) {
                 $result->papers[$id] = $paper;
             }
         }
     }
     return $result;
 }
Example #22
0
		static function other($name) {
			$path = PATH_BASE."/".$name.".php";
			if(!file_exists($path)) die('Could not find file. '.print_p(debug_backtrace()));
			require_once($path);
		}
Example #23
0
 /**
  * Builds the Regular Expressions Patterns
  * This function will create the Regex patterns and will put the built patterns
  * in $patterns_regex array. This array will then used in preg_match function
  * to match against current request.
  * @access private
  */
 private function prepareStatements()
 {
     // Patterns
     self::getOtherTags();
     foreach ($this->patterns_regex as $field => $searchRegex) {
         // rawsearchpatterns
         foreach ($searchRegex as $key => $searchVars) {
             // searchvariables
             if (isset($this->dbid[$field])) {
                 $this->do_output_lookup($searchVars, $field, $key);
             } else {
                 $this->regex_statements['failed_pattern'][$field][] = array("status" => "This " . $field . " has been omitted entirely and short of development.");
             }
             $this->do_uri_lookup($field, $key);
         }
     }
     // Alias -- this is only activated after RC - Need new admin panel
     if (!empty($this->handlers)) {
         $fields = array();
         foreach ($this->handlers as $key => $value) {
             $fields[] = "'" . $value . "'";
         }
         $handlers = implode(",", $fields);
         $query = "SELECT * FROM " . DB_PERMALINK_ALIAS . " WHERE alias_type IN(" . $handlers . ")";
         $this->queries[] = $query;
         $aliases = dbquery($query);
         if (dbrows($aliases)) {
             while ($alias = dbarray($aliases)) {
                 //$this->replaceAliasPatterns($data);
                 $alias_php_url = $this->getAliasURL($alias['alias_url'], $alias['alias_php_url'], $alias['alias_type']);
                 $field = $alias['alias_type'];
                 if (array_key_exists(1, $alias_php_url) && strcmp(PERMALINK_CURRENT_PATH, $alias_php_url[1]) == 0) {
                     $this->redirect_301($alias_php_url[0]);
                 }
                 // Check If there are any Alias Patterns defined for this Type or not
                 if (array_key_exists($field, $this->alias_pattern)) {
                     foreach ($this->alias_pattern[$field] as $replace => $search) {
                         // Secondly, Replace %alias_target% with Alias PHP URL
                         $search = str_replace("%alias_target%", $alias['alias_php_url'], $search);
                         $search_string = $search;
                         $alias_search = str_replace($this->rewrite_code[$field], $this->rewrite_replace[$field], $search_string);
                         $alias_search = self::cleanRegex($alias_search);
                         $alias_search = "~^" . $alias_search . "\$";
                         // Now Replace Pattern Tags with suitable Regex Codes
                         $search = $this->makeSearchRegex($search, $field);
                         // If the Pattern is found in the Output
                         if (preg_match($search, $this->output)) {
                             // Search them all and put them in $matches
                             preg_match_all($search, $this->output, $matches);
                             // $matches[0] represents the Array of all the matches for this Pattern
                             foreach ($matches[0] as $count => $match) {
                                 // First of all, Replace %alias% with the actual Alias Name
                                 $replace_str = str_replace("%alias%", $alias['alias_url'], $replace);
                                 $match = self::cleanRegex($match);
                                 // Replace Tags with their suitable matches
                                 $replace_str = $this->replaceOtherTags($field, $search_string, $replace_str, $matches, $count);
                                 $replace_str = $this->cleanURL($replace_str);
                                 $this->regex_statements['alias'][$field][] = array($match => $replace_str);
                                 $this->regex_statements['alias_redirect'][$field][] = array($alias_search => $replace_str);
                             }
                         } else {
                             $this->regex_statements['failed_alias'][$field][] = array("search" => $search, "status" => "failed");
                         }
                     }
                 }
                 $this->aliases[] = $alias;
             }
         }
     }
     if ($this->debug_regex) {
         print_p($this->regex_statements);
     }
 }
Example #24
0
 static function _($url, $xhtml = false, $ssl = null, $d = false)
 {
     // skip any external urls
     if (strpos($url, "option") !== false && strpos($url, "option=com_fss") === false) {
         return JRoute::_($url, $xhtml, $ssl);
     }
     global $FSSRoute_debug;
     global $FSSRoute_menus;
     global $FSSRoute_access;
     self::$d = $d;
     // get any menu items for fss
     FSS_Helper::GetRouteMenus();
     // Get the router
     $router = JFactory::getApplication()->getRouter();
     // if the url dont start with index.php, we need to add the exisitng url to what we want
     if (substr($url, 0, 9) != "index.php") {
         //echo "Making FUll URL: $url<br>";
         $url = self::_fullURL($router, $url);
         //echo "Resut : $url<br>";
     }
     $uri = new JURI($url);
     // work out is we are in an Itemid already, if so, set it as the best match
     if ($uri->hasVar('Itemid')) {
         $bestmatch = $uri->getVar('Itemid');
     } else {
         $bestmatch = '';
     }
     $bestcount = 0;
     $uriquery = $uri->toString(array('query'));
     $urivars = FSSRoute::SplitURL($uriquery);
     $sourcevars = FSSRoute::SplitURL($url);
     // check through the menu item for the current url, and add any items to the new url that are missing
     if ($bestmatch && array_key_exists($bestmatch, $FSSRoute_menus)) {
         foreach ($FSSRoute_menus[$bestmatch] as $key => $value) {
             if (!array_key_exists($key, $urivars) && !array_key_exists($key, $sourcevars)) {
                 $urivars[$key] = $value;
             }
         }
     }
     $current_access = 0;
     if (array_key_exists(FSS_Input::getInt('Itemid'), $FSSRoute_access)) {
         $current_access = $FSSRoute_access[FSS_Input::getInt('Itemid')];
     }
     if ($d) {
         echo "Incoming Link : {$url}<br>";
         echo "Cur Item ID : " . FSS_Input::getInt('Itemid') . "<br>";
         //print_p($FSSRoute_menus);
     }
     foreach ($FSSRoute_menus as $id => $vars) {
         if ($d) {
             echo "{$id} => <Br>";
             print_p($vars);
         }
         // need to check if the access level is the same
         if ($current_access && array_key_exists($id, $FSSRoute_access) && $FSSRoute_access[$id] != $current_access) {
             if ($d) {
                 echo "No Access<br>";
             }
             continue;
         }
         $count = FSSRoute::MatchVars($urivars, $vars);
         if (FSS_Input::getInt('Itemid') == $id && $count > 0) {
             if ($d) {
                 echo "Current ItemId: increase count<br>";
             }
             $count++;
         }
         if ($d) {
             echo "Count: {$count}<br>";
         }
         if ($count > $bestcount) {
             if ($d) {
                 echo "New best match - {$id}<br>";
             }
             $bestcount = $count;
             $bestmatch = $id;
         }
     }
     if ($bestcount == 0 && array_key_exists('view', $sourcevars) && substr($sourcevars['view'], 0, 6) == "admin_") {
         foreach ($FSSRoute_menus as $id => $item) {
             // need to check if the access level is the same
             if ($current_access && array_key_exists($id, $FSSRoute_access) && $FSSRoute_access[$id] != $current_access) {
                 continue;
             }
             if ($item['view'] == "admin") {
                 $bestcount = 1;
                 $bestmatch = $id;
             }
         }
     }
     // no match found, try to fallback on the main support menu id
     if ($bestcount == 0) {
         foreach ($FSSRoute_menus as $id => $item) {
             // need to check if the access level is the same
             if ($current_access && array_key_exists($id, $FSSRoute_access) && $FSSRoute_access[$id] != $current_access) {
                 continue;
             }
             if ($item['view'] == "main") {
                 $bestcount = 1;
                 $bestmatch = $id;
             }
         }
     }
     if ($bestcount == 0) {
         // still no match found, use any fss menu
         if (count($FSSRoute_menus) > 0) {
             foreach ($FSSRoute_menus as $id => $item) {
                 // need to check if the access level is the same
                 if ($current_access && array_key_exists($id, $FSSRoute_access) && $FSSRoute_access[$id] != $current_access) {
                     continue;
                 }
                 $bestcount = 1;
                 $bestmatch = $id;
                 break;
             }
         }
     }
     if ($d) {
         echo "Best Found : {$bestcount}, {$bestmatch}<br>";
     }
     // sticky menu items
     if (FSS_Settings::get('sticky_menus_type')) {
         $cur_item_id = FSS_Input::GetInt("Itemid");
         if ($cur_item_id > 0) {
             $sticky_ids = explode(";", FSS_Settings::get('sticky_menus'));
             if (FSS_Settings::get('sticky_menus_type') == 1 && in_array($cur_item_id, $sticky_ids) || FSS_Settings::get('sticky_menus_type') == 2 && !in_array($cur_item_id, $sticky_ids)) {
                 $bestcount = 0;
                 $uri->setVar('Itemid', $cur_item_id);
             }
         }
     }
     if ($bestcount > 0) {
         $uri->setVar('Itemid', $bestmatch);
         // we need to remove parameters that are in the main url as well as the sub one
         // wait till 2.2 for this change as it may break stuff
     }
     if ($d) {
         echo "Using : " . $uri->toString(array('path', 'query', 'fragment')) . "<br>";
     }
     return JRoute::_($uri->toString(array('path', 'query', 'fragment')), $xhtml, $ssl);
 }
Example #25
0
file_put_contents($load_debug_file, $data_p);
// save load debug info
$load_debug_file = $base_dir . $dir . "/debug_load.html";
$ob->Clear();
include "tmpl/debug_head.php";
echo $result['load']['debug'];
$data_p = $ob->GetContent();
//$ob->Restore();
file_put_contents($load_debug_file, $data_p);
// save save debug info
$save_debug_file = $base_dir . $dir . "/debug_save.html";
$ob->Clear();
include "tmpl/debug_head.php";
echo $result['save']['debug'];
$data_p = $ob->GetContent();
//$ob->Restore();
file_put_contents($save_debug_file, $data_p);
// save other debug info
$result_debug_file = $base_dir . $dir . "/debug_res.html";
$ob->Clear();
unset($result['save']['debug']);
unset($result['load']['debug']);
unset($result['save']['data']);
unset($result['load']['data']);
include "tmpl/debug_head.php";
print_p($result);
$result_p = $ob->GetContent();
//$ob->Restore();
file_put_contents($result_debug_file, $result_p);
$ob->Clear();
echo $mainoutput;
Example #26
0
 function Save($params, &$data)
 {
     global $string;
     echo "<h4>{$string['params']}</h4>";
     print_p($params);
     echo "<h4>{$string['generaldebuginfo']}</h4>";
     global $REPLACEMEuserIDold;
     $data->ownerID = $userID;
     $this->data =& $data;
     $this->params =& $params;
     $this->outputfiles = array();
     $this->ll = array();
     for ($i = 1; $i < 27; $i++) {
         $varletter = chr(ord('A') + $i - 1);
         $this->ll[$i] = $varletter;
     }
     // output all questions as xml files ready for packaging
     foreach ($data->questions as $question) {
         $this->output = "";
         $this->OutputQuestion($question);
         $file = "question-" . $question->load_id . ".xml";
         $filename = $params->base_dir . $params->dir . "/" . $file;
         file_put_contents($filename, $this->output);
         $data->files[] = new ST_File($file, trim(strip_tags($question->leadin)), $params->dir, 'question', $question->load_id);
         $this->outputfiles[$file] = $this->output;
     }
     // should we export a test file?
     if (count($data->papers) == 1) {
         foreach ($data->papers as $paper) {
             // create manifest for questions with no associated paper
             $ob = new OB();
             $ob->ClearAndSave();
             include "qti20/tmpl/imsmanifest-paper.php";
             $manifest = $ob->GetContent();
             $ob->Restore();
             $file = "imsmanifest.xml";
             $filename = $params->base_dir . $params->dir . "/" . $file;
             file_put_contents($filename, $manifes);
             $data->files[] = new ST_File($file, "IMS Manifest", $params->dir, 'manifest', $question->load_id);
             $this->outputfiles[$file] = $manifest;
             // create manifest for questions with no associated paper
             $ob = new OB();
             $ob->ClearAndSave();
             include "qti20/tmpl/test-paper.php";
             $manifest = $ob->GetContent();
             $ob->Restore();
             $file = "test.xml";
             $filename = $params->base_dir . $params->dir . "/" . $file;
             file_put_contents($filename, $manifest);
             $data->files[] = new ST_File($file, "Test File", $params->dir, 'test', $question->load_id);
             $this->outputfiles[$file] = $manifest;
         }
     } else {
         // create manifest for questions with no associated paper
         $ob = new OB();
         $ob->ClearAndSave();
         include "qti20/tmpl/imsmanifest-question.php";
         $manifest = $ob->GetContent();
         $ob->Restore();
         $file = "imsmanifest.xml";
         $filename = $params->base_dir . $params->dir . "/" . $file;
         file_put_contents($filename, $manifest);
         $data->files[] = new ST_File($file, "IMS Manifest", $params->dir, 'manifest', $question->load_id);
         $this->outputfiles[$file] = $manifest;
         // create manifest for questions with no associated paper
         $ob = new OB();
         $ob->ClearAndSave();
         include "qti20/tmpl/test-question.php";
         $manifest = $ob->GetContent();
         $ob->Restore();
         $file = "test.xml";
         $filename = $params->base_dir . $params->dir . "/" . $file;
         file_put_contents($filename, $manifest);
         $data->files[] = new ST_File($file, "Test File", $params->dir, 'test', $question->load_id);
         $this->outputfiles[$file] = $manifest;
     }
     foreach ($this->outputfiles as $file => $text) {
         echo "<h4>QTI File : {$file}</h4>";
         echo "<pre>";
         echo htmlentities($text);
         echo "</pre>";
     }
 }
Example #27
0
 /** Add Modules Plugin Form */
 private function quantum_module_form()
 {
     global $aidlink, $defender, $locale;
     $form_action = FUSION_SELF . $aidlink;
     if (isset($_GET['action']) && $_GET['action'] == 'module_edit' && isset($_GET['module_id']) && isnum($_GET['module_id'])) {
         $form_action .= "&amp;action=" . $_GET['action'] . "&amp;module_id=" . $_GET['module_id'];
         $result = dbquery("SELECT * FROM " . $this->field_db . " WHERE field_id='" . $_GET['module_id'] . "'");
         if (dbrows($result) > 0) {
             $this->field_data = dbarray($result);
             if ($this->debug) {
                 print_p('Old Data');
                 print_p($this->field_data);
             }
         } else {
             if (!$this->debug) {
                 addNotice('warning', $locale['field_0205']);
                 redirect(FUSION_SELF . $aidlink);
             }
         }
     }
     $this->field_data['add_module'] = isset($_POST['add_module']) ? form_sanitizer($_POST['add_module']) : $this->field_data['field_name'];
     $user_field_name = '';
     $user_field_api_version = '';
     $user_field_desc = '';
     $user_field_dbname = '';
     $user_field_dbinfo = '';
     if (file_exists($this->plugin_locale_folder . stripinput($this->field_data['add_module']) . ".php") && file_exists($this->plugin_folder . stripinput($this->field_data['add_module']) . "_include_var.php")) {
         include $this->plugin_locale_folder . stripinput($this->field_data['add_module']) . ".php";
         include $this->plugin_folder . stripinput($this->field_data['add_module']) . "_include_var.php";
         $this->user_field_dbinfo = $user_field_dbinfo;
         if (!isset($user_field_dbinfo)) {
             addNotice('warning', $locale['fields_0602']);
         }
     } else {
         $defender->stop();
         addNotice('danger', $locale['fields_0109']);
     }
     // Script Execution
     if (isset($_POST['enable'])) {
         $this->field_data = array('add_module' => isset($_POST['add_module']) ? form_sanitizer($_POST['add_module']) : $this->field_data['field_name'], 'field_type' => 'file', 'field_id' => isset($_POST['field_id']) ? form_sanitizer($_POST['field_id'], '', 'field_id') : isset($_GET['module_id']) && isnum($_GET['module_id']) ? $_GET['module_id'] : 0, 'field_title' => form_sanitizer($_POST['field_title'], '', 'field_title'), 'field_name' => form_sanitizer($_POST['field_name'], '', 'field_name'), 'field_cat' => form_sanitizer($_POST['field_cat'], '', 'field_cat'), 'field_default' => form_sanitizer($_POST['field_default'], '', 'field_default'), 'field_error' => form_sanitizer($_POST['field_error'], '', 'field_error'), 'field_required' => isset($_POST['field_required']) ? 1 : 0, 'field_registration' => isset($_POST['field_registration']) ? 1 : 0, 'field_log' => isset($_POST['field_log']) ? 1 : 0, 'field_order' => form_sanitizer($_POST['field_order'], '0', 'field_order'));
         $this->field_data['field_name'] = str_replace(' ', '_', $this->field_data['field_name']);
         // make sure no space.
         $this->create_fields($this->field_data, 'module');
     }
     echo "<div class='m-t-20'>\n";
     echo openform('fieldform', 'post', $form_action, array('max_tokens' => 1));
     echo "<p class='strong text-dark'>" . $user_field_name . "</p>\n";
     echo "<div class='well'>\n";
     echo "<p class='strong'>" . $locale['fields_0400'] . "</p>\n";
     echo "<span class='text-dark strong'>" . $locale['fields_0401'] . "</span> " . ($user_field_api_version ? $user_field_api_version : $locale['fields_0402']) . "<br/>\n";
     echo "<span class='text-dark strong'>" . $locale['fields_0403'] . "</span>" . ($user_field_dbname ? "<br/>" . $user_field_dbname : '<br/>' . $locale['fields_0404']) . "<br/>\n";
     echo "<span class='text-dark strong'>" . $locale['fields_0405'] . "</span>" . ($user_field_dbinfo ? "<br/>" . $user_field_dbinfo : '<br/>' . $locale['fields_0406']) . "<br/>\n";
     echo "<span class='text-dark strong'>" . $locale['fields_0407'] . "</span>" . ($user_field_desc ? "<br/>" . $user_field_desc : '') . "<br/>\n";
     echo "</div>\n";
     echo "<hr/>\n";
     // start form.
     $disable_opts = array();
     foreach ($this->page_list as $index => $v) {
         $disable_opts[] = $index;
     }
     echo form_select_tree('field_cat', $locale['fields_0410'], $this->field_data['field_cat'], array('no_root' => 1, 'disable_opts' => $disable_opts), $this->category_db, 'field_cat_name', 'field_cat_id', 'field_parent');
     if ($user_field_dbinfo != "") {
         if (version_compare($user_field_api_version, "1.01.00", ">=")) {
             echo form_checkbox('field_required', $locale['fields_0411'], $this->field_data['field_required']);
         } else {
             echo "<p>\n" . $locale['428'] . "</p>\n";
         }
     }
     if ($user_field_dbinfo != "") {
         if (version_compare($user_field_api_version, "1.01.00", ">=")) {
             echo form_checkbox('field_log', $locale['fields_0412'], $this->field_data['field_log']);
         } else {
             echo "<p>\n" . $locale['429a'] . "</p>\n";
         }
     }
     if ($user_field_dbinfo != "") {
         echo form_checkbox('field_registration', $locale['fields_0413'], $this->field_data['field_registration']);
     }
     echo form_text('field_order', $locale['fields_0414'], $this->field_data['field_order']);
     echo form_hidden('add_module', '', $this->field_data['add_module']);
     echo form_hidden('field_name', '', $user_field_dbname);
     echo form_hidden('field_title', '', $user_field_name);
     // new api introduced
     echo form_hidden('field_default', '', isset($user_field_default) ? $user_field_default : '');
     echo form_hidden('field_options', '', isset($user_field_options) ? $user_field_options : '');
     echo form_hidden('field_error', '', isset($user_field_error) ? $user_field_error : '');
     echo form_hidden('field_config', '', isset($user_field_config) ? $user_field_config : '');
     echo form_hidden('field_id', '', $this->field_data['field_id']);
     echo form_button('enable', $this->field_data['field_id'] ? $locale['fields_0415'] : $locale['fields_0416'], $this->field_data['field_id'] ? $locale['fields_0415'] : $locale['fields_0416'], array('class' => 'btn-primary btn-sm'));
     echo closeform();
     echo "</div>\n";
 }