Example #1
0
 public function show(Sql $sql)
 {
     $sql = $sql->sql;
     $data = executeQuery($sql);
     $format = getHeaders($data);
     return view('sql.index', compact('data', 'format', 'sql'));
 }
Example #2
0
function compareView()
{
    echo '<table id="compareTable">';
    getHeaders();
    getProducts();
    echo '</table>';
}
Example #3
0
function callAPI($method, $base, $path, $data = false)
{
    $curl = curl_init();
    $url = sprintf("%s%s", $base, $path);
    switch ($method) {
        case "POST":
            curl_setopt($curl, CURLOPT_POST, 1);
            if ($data) {
                curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
            }
            break;
        case "PUT":
            curl_setopt($curl, CURLOPT_PUT, 1);
            break;
        case "DELETE":
            curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "DELETE");
            break;
        default:
            if ($data) {
                $url = sprintf("%s%s?%s", $base, $path, http_build_query($data));
            }
    }
    print "calling " . $url . "\n";
    #curl_setopt($curl, CURLOPT_VERBOSE, true);
    curl_setopt($curl, CURLOPT_HTTPHEADER, getHeaders($method, $path));
    curl_setopt($curl, CURLOPT_URL, $url);
    curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
    return curl_exec($curl);
}
function getResponse($urlExtension)
{
    $curl = curl_init();
    $url = "http://api.arbetsformedlingen.se/af/v0/" . $urlExtension;
    curl_setopt($curl, CURLOPT_URL, $url);
    curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
    //get headers from Settings.php
    $headers = getHeaders();
    curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
    $result = curl_exec($curl);
    if ($errno = curl_errno($curl)) {
        throw new Exception();
    }
    curl_close($curl);
    return $result;
}
 public function mostrarDetalle($cuadrante_id)
 {
     function getClient()
     {
         $client = new Google_Client();
         $client->setApplicationName(APPLICATION_NAME);
         $client->setScopes(SCOPES);
         $client->setAuthConfigFile(CLIENT_SECRET_PATH);
         $client->setAccessType('offline');
         $client->setApprovalPrompt('force');
         //esta linea la he añadido yo
         // Load previously authorized credentials from a file.
         $credentialsPath = CREDENTIALS_PATH;
         // dd($credentialsPath);
         if (file_exists($credentialsPath)) {
             $accessToken = file_get_contents($credentialsPath);
         } else {
             // Request authorization from the user.
             dd('no hay autorización, habrá que modificar el código');
             $authUrl = $client->createAuthUrl();
             printf("Open the following link in your browser:\n%s\n", $authUrl);
             print 'Enter verification code: ';
             $authCode = trim(fgets(STDIN));
             // Exchange authorization code for an access token.
             $accessToken = $client->authenticate($authCode);
             // Store the credentials to disk.
             if (!file_exists(dirname($credentialsPath))) {
                 mkdir(dirname($credentialsPath), 0700, true);
             }
             file_put_contents($credentialsPath, $accessToken);
             // printf("Credentials saved to %s\n", $credentialsPath);
         }
         $client->setAccessToken($accessToken);
         // Refresh the token if it's expired.
         if ($client->isAccessTokenExpired()) {
             $client->refreshToken($client->getRefreshToken());
             file_put_contents($credentialsPath, $client->getAccessToken());
         }
         return $client;
     }
     function listMessages($service, $userId, $fecha, $email)
     {
         $pageToken = NULL;
         $messages = array();
         $opt_param = array();
         //mensaje de ese empleado para ese día
         $opt_param['q'] = 'subject:' . $fecha . ' from:' . $email . ' label:Inbox';
         do {
             try {
                 if ($pageToken) {
                     $opt_param['pageToken'] = $pageToken;
                 }
                 $messagesResponse = $service->users_messages->listUsersMessages($userId, $opt_param);
                 if ($messagesResponse->getMessages()) {
                     $messages = array_merge($messages, $messagesResponse->getMessages());
                     $pageToken = $messagesResponse->getNextPageToken();
                 }
             } catch (Exception $e) {
                 print 'An error occurred: ' . $e->getMessage();
             }
         } while ($pageToken);
         return $messages;
     }
     function modifyMessage($service, $userId, $messageId, $labelsToAdd, $labelsToRemove)
     {
         $mods = new Google_Service_Gmail_ModifyMessageRequest();
         $mods->setAddLabelIds($labelsToAdd);
         $mods->setRemoveLabelIds($labelsToRemove);
         try {
             $message = $service->users_messages->modify($userId, $messageId, $mods);
             // print 'Message with ID: ' . $messageId . ' successfully modified.';
             return $message;
         } catch (Exception $e) {
             print 'An error occurred: ' . $e->getMessage();
         }
     }
     function getHeader($headers, $name)
     {
         foreach ($headers as $header) {
             if ($header['name'] == $name) {
                 return $header['value'];
             }
         }
     }
     function getHeaders($headers, $campos)
     {
         foreach ($headers as $header) {
             for ($i = 0; $i < count($campos); $i++) {
                 if ($header['name'] == $campos[$i]) {
                     $results[$campos[$i]] = $header['value'];
                 }
             }
         }
         return $results;
     }
     // function getBody($partes){
     // 	foreach($partes as $parte){
     // 		if($parte['name'] == 'body')
     // 	}
     // }
     /*
      * Decode the body.
      * @param : encoded body  - or null
      * @return : the body if found, else FALSE;
      */
     function decodeBody($body)
     {
         $rawData = $body;
         $sanitizedData = strtr($rawData, '-_', '+/');
         $decodedMessage = base64_decode($sanitizedData);
         if (!$decodedMessage) {
             $decodedMessage = FALSE;
         }
         return $decodedMessage;
     }
     $cuadrante = Cuadrante::where('id', $cuadrante_id)->first();
     $lineas = LineaCuadrante::where('cuadrante_id', $cuadrante_id)->orderBy('tipo', 'asc')->orderBy('salida', 'asc')->get();
     $fecha = $cuadrante->fecha;
     $fecha = date_format($fecha, 'd-m-Y');
     $valores = $this->empleadosTrabajando($cuadrante_id);
     Javascript::put(['valores' => $valores]);
     if ($cuadrante->estado == 'Validado') {
         define('APPLICATION_NAME', 'Gmail API PHP Quickstart');
         define('CREDENTIALS_PATH', base_path() . '/storage/app/.credentials/gmail-php-quickstart.json');
         define('CLIENT_SECRET_PATH', __DIR__ . '/client_secret.json');
         // If modifying these scopes, delete your previously saved credentials
         define('SCOPES', implode(' ', array(Google_Service_Gmail::GMAIL_MODIFY)));
         /**
          * Returns an authorized API client.
          * @return Google_Client the authorized client object
          */
         // Get the API client and construct the service object.
         $client = getClient();
         $service = new Google_Service_Gmail($client);
         $userId = 'me';
         // lista de labels con ids
         // $results = $service->users_labels->listUsersLabels($userId);
         // dd($results);
         $messages = listMessages($service, $userId, $fecha, null);
         if ($messages) {
             foreach ($lineas as $linea) {
                 $email = $linea->empleado->email;
                 $mensaje = listMessages($service, $userId, $fecha, $email);
                 // $labelsToAdd = ['Label_1'];
                 $labelsToRemove = ['INBOX'];
                 if (count($mensaje) == 1) {
                     // dd('hay uno');
                     $linea->mensaje_id = $mensaje[0]->id;
                     $detalle_mensaje = $service->users_messages->get($userId, $mensaje[0]->id);
                     $headers = $detalle_mensaje->getPayload()->getHeaders();
                     $partsBody = $detalle_mensaje->getPayload()->getParts();
                     $body = decodeBody($partsBody[0]['body']['data']);
                     $campos = array('Subject', 'Date');
                     $results = getHeaders($headers, $campos);
                     $linea->asunto = $results['Subject'];
                     $fechaLocal = date("Y-m-d H:i:s", strtotime($results['Date']));
                     $linea->fechaMensaje = $fechaLocal;
                     $linea->body = $body;
                     // $subject = getHeader($headers, 'Subject');
                     // $linea->asunto = $subject;
                     $linea->estado = 'Firmado';
                     $linea->save();
                     // modifyMessage($service,$userId,$linea->mensaje_id,$labelsToAdd,$labelsToRemove);
                     modifyMessage($service, $userId, $linea->mensaje_id, ['Label_1'], $labelsToRemove);
                 } else {
                     if (count($mensaje) > 1) {
                         //archivo en duplicados(Label_2) los antiguos
                         // dd(count($mensaje));
                         for ($i = 1; $i < count($mensaje); $i++) {
                             $detalle_mensaje = $service->users_messages->get($userId, $mensaje[$i]->id);
                             $headers = $detalle_mensaje->getPayload()->getHeaders();
                             $subject = getHeader($headers, 'Subject');
                             modifyMessage($service, $userId, $mensaje[$i]->id, ['Label_2'], $labelsToRemove);
                         }
                     } else {
                         if (!count($mensaje)) {
                             // no hay ninguno y continua el foreach
                         }
                     }
                 }
             }
         }
     }
     return view('controlHorario.detalleCuadrante', compact('cuadrante', 'lineas'));
 }
Example #6
0
function getUserIdByKey($key)
{
    global $db;
    $row = $db->get("me_login", "id_user", ["AND" => ["key" => $key, "browser" => getHeaders("User-Agent")]]);
    return $row;
}
Example #7
0
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<?php 
//	echo "Hello World!<br/>";    //helloworld
echo "Tudou Header Fetcher DebugMod!!<br/><br/>";
echo "JS传递参数前请使用escape()转换<br/>";
//   echo phpinfo();    //phpinfo()php环境信息
$turl = isset($_GET['turl']) ? $_GET['turl'] : '';
if (preg_match('/tudou\\.com\\/.*\\/v\\.swf/i', $turl) != 0) {
    $url = $turl;
    echo "<br/>Url:<br/>";
    echo $url;
    echo "<br/>Header:<br/>";
    for ($i = 0; $i < 10; $i++) {
        $Headers = getHeaders($url);
        echo "第{$i}次重试<br/>";
        if (preg_match('/forbidden/i', $Headers) == 0) {
            break 1;
        }
    }
    echo $Headers;
    echo "<br/><br/>Return Location:<br/>";
    if (preg_match_all('/iid=[\\d]*|youkuid=[\\d\\w]*/i', $Headers, $matches, PREG_SET_ORDER) != 0) {
        //			print_r($matches);
        if (count($matches) == 2) {
            echo "&" . $matches[0][0] . "&" . $matches[1][0];
        } else {
            echo "&" . $matches[0][0];
        }
    }
}
// php 获取
Example #8
0
function prepExport($headers, $cols, $data, $fdchoice, $custdel = "", $title, $template = false, $fid, $groups)
{
    // export of calculations added August 22 2006
    // come up with a filename and then return it
    // rest of logic in entriesdisplay.php will take the filename and create a file with the calculations in it once they are performed
    if ($fdchoice == "calcs") {
        $tempfold = microtime(true);
        $exfilename = _formulize_DE_XF . $tempfold . ".html";
        return XOOPS_URL . SPREADSHEET_EXPORT_FOLDER . "{$exfilename}";
    }
    global $xoopsDB;
    include_once XOOPS_ROOT_PATH . "/modules/formulize/include/extract.php";
    if ($fdchoice == "update") {
        // reset headers and cols to include all data -- when creating a blank template, this reset has already happened before prepexport is called
        $fdchoice = "comma";
        $template = "update";
        $cols1 = getAllColList($fid, "", $groups);
        // $cols1 will be a multidimensional array, one "entry" per column, and for each column the entry is an assoc array with ele_id, ele_colhead, ele_caption and ele_handle.
        unset($cols);
        $cols = array();
        foreach ($cols1[$fid] as $col) {
            $cols[] = $col['ele_handle'];
        }
        unset($headers);
        $headers = getHeaders($cols, true);
        // array of element handles, boolean for if the cols are handles (or ids, which is the default assumption)
    }
    if ($fdchoice == "comma") {
        $fd = ",";
        $fxt = ".csv";
    }
    if ($fdchoice == "tab") {
        $fd = "\t";
        $fxt = ".tabDelimited";
    }
    if ($fdchoice == "custom") {
        $fd = $custdel;
        if (!$fd) {
            $fd = "**";
        }
        $fxt = ".customDelimited";
    }
    $lineStarted = false;
    if ($template) {
        // add in other profile fields -- username, realname, e-mail, password, registration code
        if ($template == "blankprofile") {
            $csvfile = "\"" . _formulize_DE_IMPORT_USERNAME . "\"{$fd}\"" . _formulize_DE_IMPORT_FULLNAME . "\"{$fd}\"" . _formulize_DE_IMPORT_PASSWORD . "\"{$fd}\"" . _formulize_DE_IMPORT_EMAIL . "\"{$fd}\"" . _formulize_DE_IMPORT_REGCODE . "\"";
            $lineStarted = true;
        } else {
            if ($template == "update") {
                $csvfile = "\"" . _formulize_DE_IMPORT_IDREQCOL . "\"{$fd}\"" . _formulize_DE_CALC_CREATOR . "\"";
                $lineStarted = true;
            } else {
                $csvfile = "\"" . _formulize_DE_CALC_CREATOR . "\"";
                $lineStarted = true;
            }
        }
    } elseif ($_POST['metachoice'] == 1) {
        // only include metadata columns if the user requested them
        $csvfile = "\"" . _formulize_ENTRY_ID . "\"{$fd}\"" . _formulize_DE_CALC_CREATOR . "\"{$fd}\"" . _formulize_DE_CALC_CREATEDATE . "\"{$fd}\"" . _formulize_DE_CALC_MODIFIER . "\"{$fd}\"" . _formulize_DE_CALC_MODDATE . "\"";
        $lineStarted = true;
    } else {
        if (in_array("entry_id", $cols)) {
            $csvfile .= "\"" . _formulize_ENTRY_ID . "\"";
            $lineStarted = true;
        }
        if (in_array("uid", $cols) or in_array("creation_uid", $cols)) {
            $csvfile .= $lineStarted ? $fd : "";
            $csvfile .= "\"" . _formulize_DE_CALC_CREATOR . "\"";
            $lineStarted = true;
        }
        if (in_array("proxyid", $cols) or in_array("mod_uid", $cols)) {
            $csvfile .= $lineStarted ? $fd : "";
            $csvfile .= "\"" . _formulize_DE_CALC_MODIFIER . "\"";
            $lineStarted = true;
        }
        if (in_array("creation_date", $cols) or in_array("creation_datetime", $cols)) {
            $csvfile .= $lineStarted ? $fd : "";
            $csvfile .= "\"" . _formulize_DE_CALC_CREATEDATE . "\"";
            $lineStarted = true;
        }
        if (in_array("mod_date", $cols) or in_array("mod_datetime", $cols)) {
            $csvfile .= $lineStarted ? $fd : "";
            $csvfile .= "\"" . _formulize_DE_CALC_MODDATE . "\"";
            $lineStarted = true;
        }
    }
    foreach ($headers as $header) {
        // ignore the metadata columns if they are selected, since we already handle them better above. as long as the user requested that they be included
        if ($header == "" or $_POST['metachoice'] == 1 and ($header == _formulized_ENTRY_ID or $header == _formulize_DE_CALC_CREATOR or $header == _formulize_DE_CALC_MODIFIER or $header == _formulize_DE_CALC_CREATEDATE or $header == _formulize_DE_CALC_MODDATE)) {
            continue;
        }
        $header = str_replace("\"", "\"\"", $header);
        $header = "\"" . trans($header) . "\"";
        if ($lineStarted) {
            $csvfile .= $fd;
        }
        $csvfile .= $header;
        $lineStarted = true;
    }
    $csvfile .= "\r\n";
    $colcounter = 0;
    $i = 0;
    foreach ($data as $entry) {
        $formhandle = getFormHandlesFromEntry($entry);
        $ids = internalRecordIds($entry, $formhandle[0]);
        $id = $ids[0];
        $id_req[] = $id;
        $c_uid = display($entry, 'creation_uid');
        $c_name_q = q("SELECT name, uname FROM " . $xoopsDB->prefix("users") . " WHERE uid='{$c_uid}'");
        $c_name = $c_name_q[0]['name'];
        if (!$c_name) {
            $c_name = $c_name_q[0]['uname'];
        }
        $c_date = display($entry, 'creation_datetime');
        $m_uid = display($entry, 'mod_uid');
        if ($m_uid) {
            $m_name_q = q("SELECT name, uname FROM " . $xoopsDB->prefix("users") . " WHERE uid='{$m_uid}'");
            $m_name = $m_name_q[0]['name'];
            if (!$m_name) {
                $m_name = $m_name_q[0]['uname'];
            }
        } else {
            $m_name = $c_name;
        }
        $m_date = display($entry, 'mod_datetime');
        // write in metadata
        $lineStarted = false;
        // will be update only, since blank ones have no data
        if ($template) {
            $csvfile .= $id . $fd . "\"{$c_name}\"";
            $lineStarted = true;
        } elseif ($_POST['metachoice'] == 1) {
            $csvfile .= "\"{$id}\"" . $fd . "\"{$c_name}\"" . $fd . "\"{$c_date}\"" . $fd . "\"{$m_name}\"" . $fd . "\"{$m_date}\"";
            $lineStarted = true;
        }
        // write in data
        foreach ($cols as $col) {
            // ignore the metadata columns if they are selected, since we already handle them better above
            if (isMetaDataField($col) and $_POST['metachoice'] == 1) {
                continue;
            }
            if ($col == "creation_uid" or $col == "mod_uid" or $col == "uid" or $col == "proxyid") {
                $name_q = q("SELECT name, uname FROM " . $xoopsDB->prefix("users") . " WHERE uid=" . intval(display($entry, $col)));
                $data_to_write = $name_q[0]['name'];
                if (!$data_to_write) {
                    $data_to_write = $name_q[0]['uname'];
                }
            } else {
                $data_to_write = displayTogether($entry, $col, ", ");
                $data_to_write = str_replace("&quot;", "\"\"", $data_to_write);
                $data_to_write = "\"" . trans($data_to_write) . "\"";
                $data_to_write = str_replace("\r\n", "\n", $data_to_write);
            }
            if ($lineStarted) {
                $csvfile .= $fd;
            }
            $csvfile .= $data_to_write;
            $lineStarted = true;
        }
        $csvfile .= "\r\n";
        // end of a line
    }
    $tempfold = microtime(true);
    $exfilename = _formulize_DE_XF . $tempfold . $fxt;
    // open the output file for writing
    $wpath = XOOPS_ROOT_PATH . SPREADSHEET_EXPORT_FOLDER . "{$exfilename}";
    $csvfile = html_entity_decode($csvfile, ENT_QUOTES);
    $exportfile = fopen($wpath, "w");
    fwrite($exportfile, $csvfile);
    fclose($exportfile);
    // garbage collection. delete files older than 6 hours
    formulize_scandirAndClean(XOOPS_ROOT_PATH . SPREADSHEET_EXPORT_FOLDER, _formulize_DE_XF);
    // write id_reqs and tempfold to the DB if we're making an update template
    if ($template == "update") {
        $sql = "INSERT INTO " . $xoopsDB->prefix("formulize_valid_imports") . " (file, id_reqs) VALUES (\"{$tempfold}\", \"" . serialize($id_req) . "\")";
        if (!($res = $xoopsDB->queryF($sql))) {
            exit("Error: could not write import information to the database.  SQL: {$sql}<br>" . $xoopsDB->error());
        }
    }
    // need to add in logic to cull old files
    return XOOPS_URL . SPREADSHEET_EXPORT_FOLDER . "{$exfilename}";
}
Example #9
0
    $stmt->execute();
    $stmt->store_result();
    $stmt->bind_result($m);
    $stmt->fetch();
    return $m;
}
function getMail($to, $ext = 'to', $mysqli)
{
    if ($ext == 'to') {
        $ml = explode(":", $to[0]['mail_to']);
    } else {
        if ($ext == 'cc') {
            $ml = explode(":", $to[0]['mail_cc']);
        } else {
            if ($ext == 'bcc') {
                $ml = explode(":", $to[0]['mail_bcc']);
            }
        }
    }
    $mlarr = array();
    for ($i = 0; $i < count($ml); $i++) {
        $mlarr[] = getMailEach($ml[$i], $mysqli);
    }
    return $mlarr;
}
echo "TO: " . implode(", ", getMail(getHeaders(8, $db), 'to', $db));
echo "<br/>";
echo "CC: " . implode(", ", getMail(getHeaders(8, $db), 'cc', $db));
echo "<br/>";
echo "BCC: " . implode(", ", getMail(getHeaders(8, $db), 'bcc', $db));
Example #10
0
}
echo "{";
if ($_GET["action"] == "update") {
    connectDatabase("usagedata");
    getData();
    echo ", ";
    getMeta();
} else {
    if ($_GET["action"] == "headers") {
        connectDatabase("usagedata");
        getHeaders();
    } else {
        if ($_GET["action"] == "locations") {
            connectDatabase("usagedata");
            getLocations();
        } else {
            if ($_GET["action"] == "delete") {
                connectDatabase("usagedata");
                deleteRecord();
            } else {
                connectDatabase("usagedata");
                getHeaders();
                echo ", ";
                getData();
                echo ", ";
                getMeta();
            }
        }
    }
}
echo "}";
function drawEntries($fid, $cols, $searches = "", $frid = "", $scope, $standalone = "", $currentURL, $gperm_handler, $uid, $mid, $groups, $settings, $member_handler, $screen, $data, $wq, $regeneratePageNumbers, $hiddenQuickSearches, $cResults)
{
    // , $loadview="") { // -- loadview removed from this function sept 24 2005
    // determine if the query reached a limit in the number of entries to return
    $LOE_limit = 0;
    if (!is_array($data)) {
        $LOE_limit = is_numeric($data) ? $data : 0;
        $data = array();
    }
    global $xoopsDB;
    $useScrollBox = true;
    $useHeadings = true;
    $repeatHeaders = 5;
    $columnWidth = 0;
    $textWidth = 35;
    $useCheckboxes = 0;
    $useViewEntryLinks = 1;
    $useSearch = 1;
    $deColumns = array();
    $useSearchCalcMsgs = 1;
    $listTemplate = false;
    $inlineButtons = array();
    $hiddenColumns = array();
    $formulize_LOEPageSize = 10;
    if ($screen) {
        $useScrollBox = $screen->getVar('usescrollbox');
        $useHeadings = $screen->getVar('useheadings');
        $repeatHeaders = $screen->getVar('repeatheaders');
        $columnWidth = $screen->getVar('columnwidth');
        $textWidth = $screen->getVar('textwidth');
        if ($textWidth == 0) {
            $textWidth = 10000;
        }
        $useCheckboxes = $screen->getVar('usecheckboxes');
        $useViewEntryLinks = $screen->getVar('useviewentrylinks');
        $useSearch = $screen->getVar('usesearch');
        $hiddenColumns = $screen->getVar('hiddencolumns');
        $deColumns = $screen->getVar('decolumns');
        $deDisplay = $screen->getVar('dedisplay');
        $useSearchCalcMsgs = $screen->getVar('usesearchcalcmsgs');
        $listTemplate = $screen->getTemplate("listtemplate");
        foreach ($screen->getVar('customactions') as $caid => $thisCustomAction) {
            if ($thisCustomAction['appearinline'] == 1) {
                list($caCode) = processCustomButton($caid, $thisCustomAction);
                if ($caCode) {
                    $inlineButtons[$caid] = $thisCustomAction;
                }
            }
        }
        $formulize_LOEPageSize = $screen->getVar('entriesperpage');
    }
    $filename = "";
    // $settings['xport'] no longer set by a page load, except if called as part of the import process to create a template for updating
    if (!$settings['xport']) {
        $settings['xport'] = $settings['hlist'] ? "calcs" : "comma";
        $xportDivText1 = "<div id=exportlink style=\"display: none;\">";
        // export button turns this link on and off now
        $xportDivText2 = "</div>";
    } else {
        $xportDivText1 = "";
        $xportDivText2 = "";
    }
    if (@$_POST['advcalc_acid']) {
        if ($_POST['acid'] > 0) {
            $result = formulize_runAdvancedCalculation(intval($_POST['acid']));
            // result will be an array with two or three keys: 'text' and 'output', and possibly 'groupingMap'.  Text is for display on screen "raw" and Output is a variable that can be used by a dev.  The output variable will be an array if groupings are in effect.  The keys of the array will be the various grouping values in effect.  The groupingMap will be present if there's a set of groupings in effect.  It is an array that contains all the grouping choices, their text equivalents and their data values (which are the keys in the output array) -- groupingMap is still to be developed/added to the mix....will be necessary when we are integrating with Drupal or other API uses.
            print "<br/>" . $result['text'] . "<br/><br/>";
        }
    }
    // export of Data is moved out to a popup
    // Calculations still handled in the old way for now
    if ($settings['xport'] == "calcs") {
        $filename = prepExport($headers, $cols, $data, $settings['xport'], $settings['xport_cust'], $settings['title'], false, $fid, $groups);
        $linktext = $_POST['xport'] == "update" ? _formulize_DE_CLICKSAVE_TEMPLATE : _formulize_DE_CLICKSAVE;
        print "{$xportDivText1}<center><p><a href='{$filename}' target=\"_blank\">{$linktext}</a></p></center>";
        print "<br>{$xportDivText2}";
    }
    $scrollBoxWasSet = false;
    if ($useScrollBox and count($data) > 0) {
        print "<div class=scrollbox id=resbox>\n";
        $scrollBoxWasSet = true;
    }
    // perform calculations...
    // calc_cols is the columns requested (separated by / -- ele_id for each, also metadata is indicated with uid, proxyid, creation_date, mod_date)
    // calc_calcs is the calcs for each column, columns separated by / and calcs for a column separated by ,. possible calcs are sum, avg, min, max, count, per
    // calc_blanks is the blank setting for each calculation, setup the same way as the calcs, possible settings are all,  noblanks, onlyblanks
    // calc_grouping is the grouping option.  same format as calcs.  possible values are ele_ids or the uid, proxyid, creation_date and mod_date metadata terms
    // 1. extract data from four settings into arrays
    // 2. loop through the array and perform all the requested calculations
    if ($settings['calc_cols'] and !$settings['hcalc']) {
        //		print "<p><input type=button style=\"width: 140px;\" name=cancelcalcs1 value='" . _formulize_DE_CANCELCALCS . "' onclick=\"javascript:cancelCalcs();\"></input></p>\n";
        //		print "<div";
        //		if($totalcalcs>4) { print " class=scrollbox"; }
        //		print " id=calculations>
        $calc_cols = $settings['calc_cols'];
        $calc_calcs = $settings['calc_calcs'];
        $calc_blanks = $settings['calc_blanks'];
        $calc_grouping = $settings['calc_grouping'];
        print "<table class=outer>";
        if ($useHeadings) {
            $headers = getHeaders($cols, true);
            // second param indicates we're using element headers and not ids
            drawHeaders($headers, $cols, $useCheckboxes, $useViewEntryLinks, count($inlineButtons), $settings['lockedColumns']);
        }
        if ($useSearch) {
            drawSearches($searches, $cols, $useCheckboxes, $useViewEntryLinks, count($inlineButtons), false, $hiddenQuickSearches);
        }
        print "</table>";
        print "<table class=outer><tr><th colspan=2>" . _formulize_DE_CALCHEAD . "</th></tr>\n";
        if (!$settings['lockcontrols'] and ($useSearchCalcMsgs == 1 or $useSearchCalcMsgs == 3)) {
            // AND !$loadview) { // -- loadview removed from this function sept 24 2005
            print "<tr><td class=head colspan=2><input type=button style=\"width: 140px;\" name=mod_calculations value='" . _formulize_DE_MODCALCS . "' onclick=\"javascript:showPop('" . XOOPS_URL . "/modules/formulize/include/pickcalcs.php?fid={$fid}&frid={$frid}&calc_cols=" . urlencode($calc_cols) . "&calc_calcs=" . urlencode($calc_calcs) . "&calc_blanks=" . urlencode($calc_blanks) . "&calc_grouping=" . urlencode($calc_grouping) . "&cols=" . urlencode(implode(",", $cols)) . "');\"></input>&nbsp;&nbsp;" . "<input type=button style=\"width: 140px;\" name=cancelcalcs value='" . _formulize_DE_CANCELCALCS . "' onclick=\"javascript:cancelCalcs();\"></input>&nbsp;&nbsp" . "<input type=button style=\"width: 140px;\" name=showlist value='" . _formulize_DE_SHOWLIST . "' onclick=\"javascript:showList();\"></input></td></tr>";
        }
        $exportFilename = $settings['xport'] == "calcs" ? $filename : "";
        //formulize_benchmark("before printing results");
        // 0 is the masterresults, 1 is the blanksettings, 2 is grouping settings -- exportFilename is the name of the file that we need to create and into which we need to dump a copy of the calcs
        printResults($cResults[0], $cResults[1], $cResults[2], $cResults[3], $cResults[4], $exportFilename, $settings['title']);
        //formulize_benchmark("after printing results");
        print "</table>\n";
    }
    // MASTER HIDELIST CONDITIONAL...
    if (!$settings['hlist'] and !$listTemplate) {
        print "<div class=\"list-of-entries-container\"><table class=\"outer\">";
        $count_colspan = count($cols) + 1;
        if ($useViewEntryLinks or $useCheckboxes != 2) {
            $count_colspan_calcs = $count_colspan;
        } else {
            $count_colspan_calcs = $count_colspan - 1;
        }
        $count_colspan_calcs = $count_colspan_calcs + count($inlineButtons);
        // add to the column count for each inline custom button
        $count_colspan_calcs++;
        // add one more for the hidden floating column
        if (!$screen) {
            print "<tr><th colspan={$count_colspan_calcs}>" . _formulize_DE_DATAHEADING . "</th></tr>\n";
        }
        if ($settings['calc_cols'] and !$settings['lockcontrols'] and ($useSearchCalcMsgs == 1 or $useSearchCalcMsgs == 3)) {
            // AND !$loadview) { // -- loadview removed from this function sept 24 2005
            $calc_cols = $settings['calc_cols'];
            $calc_calcs = $settings['calc_calcs'];
            $calc_blanks = $settings['calc_blanks'];
            $calc_grouping = $settings['calc_grouping'];
            print "<tr><td class=head colspan={$count_colspan_calcs}><input type=button style=\"width: 140px;\" name=mod_calculations value='" . _formulize_DE_MODCALCS . "' onclick=\"javascript:showPop('" . XOOPS_URL . "/modules/formulize/include/pickcalcs.php?fid={$fid}&frid={$frid}&calc_cols={$calc_cols}&calc_calcs={$calc_calcs}&calc_blanks={$calc_blanks}&calc_grouping=" . urlencode($calc_grouping) . "&cols=" . urlencode(implode(",", $cols)) . "');\"></input>&nbsp;&nbsp;<input type=button style=\"width: 140px;\" name=cancelcalcs value='" . _formulize_DE_CANCELCALCS . "' onclick=\"javascript:cancelCalcs();\"></input>&nbsp;&nbsp;<input type=button style=\"width: 140px;\" name=hidelist value='" . _formulize_DE_HIDELIST . "' onclick=\"javascript:hideList();\"></input></td></tr>";
        }
        // draw advanced search notification
        if ($settings['as_0'] and ($useSearchCalcMsgs == 1 or $useSearchCalcMsgs == 2)) {
            $writable_q = writableQuery($wq);
            $minus1colspan = $count_colspan - 1 + count($inlineButtons);
            if (!$asearch_parse_error) {
                print "<tr>";
                if ($useViewEntryLinks or $useCheckboxes != 2) {
                    // only include this column if necessary
                    print "<td class=head></td>";
                }
                print "<td colspan={$minus1colspan} class=head>" . _formulize_DE_ADVSEARCH . ": {$writable_q}";
            } else {
                print "<tr>";
                if ($useViewEntryLinks or $useCheckboxes != 2) {
                    print "<td class=head></td>";
                }
                print "<td colspan={$minus1colspan} class=head><span style=\"font-weight: normal;\">" . _formulize_DE_ADVSEARCH_ERROR . "</span>";
            }
            if (!$settings['lockcontrols']) {
                // AND !$loadview) { // -- loadview removed from this function sept 24 2005
                print "<br><input type=button style=\"width: 140px;\" name=advsearch value='" . _formulize_DE_MOD_ADVSEARCH . "' onclick=\"javascript:showPop('" . XOOPS_URL . "/modules/formulize/include/advsearch.php?fid={$fid}&frid={$frid}";
                foreach ($settings as $k => $v) {
                    if (substr($k, 0, 3) == "as_") {
                        $v = str_replace("'", "&#39;", $v);
                        $v = stripslashes($v);
                        print "&{$k}=" . urlencode($v);
                    }
                }
                print "');\"></input>&nbsp;&nbsp;<input type=button style=\"width: 140px;\" name=cancelasearch value='" . _formulize_DE_CANCELASEARCH . "' onclick=\"javascript:killSearch();\"></input>";
            }
            print "</td></tr>\n";
        }
        if ($useHeadings) {
            $headers = getHeaders($cols, true);
            // second param indicates we're using element headers and not ids
            drawHeaders($headers, $cols, $useCheckboxes, $useViewEntryLinks, count($inlineButtons), $settings['lockedColumns']);
        }
        if ($useSearch) {
            drawSearches($searches, $cols, $useCheckboxes, $useViewEntryLinks, count($inlineButtons), false, $hiddenQuickSearches);
        }
        if (count($data) == 0) {
            // kill an empty dataset so there's no rows drawn
            unset($data);
        } else {
            // get form handles in use
            $mainFormHandle = key($data[key($data)]);
        }
        $headcounter = 0;
        $blankentries = 0;
        $GLOBALS['formulize_displayElement_LOE_Used'] = false;
        $formulize_LOEPageStart = (isset($_POST['formulize_LOEPageStart']) and !$regeneratePageNumbers) ? intval($_POST['formulize_LOEPageStart']) : 0;
        // adjust formulize_LOEPageSize if the actual count of entries is less than the page size
        $formulize_LOEPageSize = $GLOBALS['formulize_countMasterResultsForPageNumbers'] < $formulize_LOEPageSize ? $GLOBALS['formulize_countMasterResultsForPageNumbers'] : $formulize_LOEPageSize;
        $actualPageSize = $formulize_LOEPageSize ? $formulize_LOEPageStart + $formulize_LOEPageSize : $GLOBALS['formulize_countMasterResultsForPageNumbers'];
        if (isset($data)) {
            foreach ($data as $id => $entry) {
                formulize_benchmark("starting to draw one row of results");
                // check to make sure this isn't an unset entry (ie: one that was blanked by the extraction layer just prior to sending back results
                // Since the extraction layer is unsetting entries to blank them, this condition should never be met?
                // If this condition is ever met, it may very well screw up the paging of results!
                // NOTE: this condition is met on the last page of a paged set of results, unless the last page as exactly the same number of entries on it as the limit of entries per page
                if ($entry != "") {
                    if ($headcounter == $repeatHeaders and $repeatHeaders > 0) {
                        if ($useHeadings) {
                            drawHeaders($headers, $cols, $useCheckboxes, $useViewEntryLinks, count($inlineButtons));
                        }
                        $headcounter = 0;
                    }
                    $headcounter++;
                    print "<tr>\n";
                    if ($class == "even") {
                        $class = "odd";
                    } else {
                        $class = "even";
                    }
                    unset($linkids);
                    $linkids = internalRecordIds($entry, $mainFormHandle);
                    // draw in the margin column where the links and metadata goes
                    if ($useViewEntryLinks or $useCheckboxes != 2) {
                        print "<td class=\"head formulize-controls\">\n";
                    }
                    if (!$settings['lockcontrols']) {
                        //  AND !$loadview) { // -- loadview removed from this function sept 24 2005
                        // check to see if we should draw in the delete checkbox
                        // 2 is none, 1 is all
                        if ($useCheckboxes != 2 and ($useCheckboxes == 1 or formulizePermHandler::user_can_delete_entry($fid, $uid, $linkids[0]))) {
                            print "<input type=checkbox title='" . _formulize_DE_DELBOXDESC . "' class='formulize_selection_checkbox' name='delete_" . $linkids[0] . "' id='delete_" . $linkids[0] . "' value='delete_" . $linkids[0] . "'>";
                        }
                        if ($useViewEntryLinks) {
                            print "<a href='" . $currentURL;
                            if (strstr($currentURL, "?")) {
                                // if params are already part of the URL...
                                print "&";
                            } else {
                                print "?";
                            }
                            print "ve=" . $linkids[0] . "' onclick=\"javascript:goDetails('" . $linkids[0] . "');return false;\" " . " class=\"loe-edit-entry\" alt=\"" . _formulize_DE_VIEWDETAILS . "\" title=\"" . _formulize_DE_VIEWDETAILS . "\" >";
                            print "&nbsp;</a>";
                        }
                    }
                    // end of IF NO LOCKCONTROLS
                    if ($useViewEntryLinks or $useCheckboxes != 2) {
                        print "</td>\n";
                    }
                    $column_counter = 0;
                    if ($columnWidth) {
                        $columnWidthParam = "style=\"width: {$columnWidth}" . "px\"";
                    } else {
                        $columnWidthParam = "";
                    }
                    for ($i = 0; $i < count($cols); $i++) {
                        //formulize_benchmark("drawing one column");
                        $col = $cols[$i];
                        $colhandle = $settings['columnhandles'][$i];
                        $classToUse = $class . " column column" . $i;
                        $cellRowAddress = $id + 2;
                        if ($i == 0) {
                            print "<td {$columnWidthParam} class=\"{$class} floating-column\" id='floatingcelladdress_{$cellRowAddress}'>\n";
                        }
                        print "<td {$columnWidthParam} class=\"{$classToUse}\" id=\"celladdress_" . $cellRowAddress . "_" . $i . "\">\n";
                        if ($col == "creation_uid" or $col == "mod_uid") {
                            $userObject = $member_handler->getUser(display($entry, $col));
                            if ($userObject) {
                                $nameToDisplay = $userObject->getVar('name') ? $userObject->getVar('name') : $userObject->getVar('uname');
                            } else {
                                $nameToDisplay = _FORM_ANON_USER;
                            }
                            $value = "<a href=\"" . XOOPS_URL . "/userinfo.php?uid=" . display($entry, $col) . "\" target=_blank>" . $nameToDisplay . "</a>";
                        } else {
                            $value = display($entry, $col);
                        }
                        // set in the display function, corresponds to the entry id of the record in the form where the current value was retrieved from.  If there is more than one local entry id, because of a one to many framework, then this will be an array that corresponds to the order of the values returned by display.
                        $currentColumnLocalId = $GLOBALS['formulize_mostRecentLocalId'];
                        // if we're supposed to display this column as an element... (only show it if they have permission to update this entry)
                        if (in_array($colhandle, $deColumns) and formulizePermHandler::user_can_edit_entry($fid, $uid, $entry)) {
                            include_once XOOPS_ROOT_PATH . "/modules/formulize/include/elementdisplay.php";
                            if ($frid) {
                                // need to work out which form this column belongs to, and use that form's entry ID.  Need to loop through the entry to find all possible internal IDs, since a subform situation would lead to multiple values appearing in a single cell, so multiple displayElement calls would be made each with their own internal ID.
                                foreach ($entry as $entryFormHandle => $entryFormData) {
                                    foreach ($entryFormData as $internalID => $entryElements) {
                                        $deThisIntId = false;
                                        foreach ($entryElements as $entryHandle => $values) {
                                            if ($entryHandle == $col) {
                                                // we found the element that we're trying to display
                                                if ($deThisIntId) {
                                                    print "\n<br />\n";
                                                }
                                                // could be a subform so we'd display multiple values
                                                if ($deDisplay) {
                                                    print '<div id="deDiv_' . $colhandle . '_' . $internalID . '">';
                                                    print getHTMLForList($values, $colhandle, $internalID, $deDisplay, $textWidth, $currentColumnLocalId, $fid, $cellRowAddress, $i);
                                                    print "</div>";
                                                } else {
                                                    displayElement("", $colhandle, $internalID);
                                                }
                                                $deThisIntId = true;
                                            }
                                        }
                                    }
                                }
                            } else {
                                // display based on the mainform entry id
                                if ($deDisplay) {
                                    print '<div id="deDiv_' . $colhandle . '_' . $linkids[0] . '">';
                                    print getHTMLForList($value, $colhandle, $linkids[0], $deDisplay, $textWidth, $currentColumnLocalId, $fid, $cellRowAddress, $i);
                                    print "</div>";
                                } else {
                                    displayElement("", $colhandle, $linkids[0]);
                                    // works for mainform only!  To work on elements from a framework, we need to figure out the form the element is from, and the entry ID in that form, which is done above
                                }
                            }
                            $GLOBALS['formulize_displayElement_LOE_Used'] = true;
                        } elseif ($col != "creation_uid" and $col != "mod_uid" and $col != "entry_id") {
                            print getHTMLForList($value, $col, $linkids[0], 0, $textWidth, $currentColumnLocalId, $fid, $cellRowAddress, $i);
                        } else {
                            // no special formatting on the uid columns:
                            print $value;
                        }
                        print "</td>\n";
                        $column_counter++;
                    }
                    // handle inline custom buttons
                    foreach ($inlineButtons as $caid => $thisCustomAction) {
                        list($caCode) = processCustomButton($caid, $thisCustomAction, $linkids[0], $entry);
                        // only bother with the code, since we already processed any clicked button above
                        if ($caCode) {
                            print "<td {$columnWidthParam} class={$class}>\n";
                            print "<center>{$caCode}</center>\n";
                            print "</td>\n";
                        }
                    }
                    // handle hidden elements for passing back to custom buttons
                    foreach ($hiddenColumns as $thisHiddenCol) {
                        print "\n<input type=\"hidden\" name=\"hiddencolumn_" . $linkids[0] . "_{$thisHiddenCol}\" value=\"" . htmlspecialchars(display($entry, $thisHiddenCol)) . "\"></input>\n";
                    }
                    print "</tr>\n";
                } else {
                    // this is a blank entry
                    $blankentries++;
                }
                // end of not "" check
            }
            // end of foreach data as entry
        }
        // end of if there is any data to draw
        print "</table></div>";
    } elseif ($listTemplate and !$settings['hlist']) {
        // USING A CUSTOM LIST TEMPLATE SO DO EVERYTHING DIFFERENTLY
        // print str_replace("\n", "<br />", $listTemplate); // debug code
        $mainFormHandle = key($data[key($data)]);
        $formulize_LOEPageStart = (isset($_POST['formulize_LOEPageStart']) and !$regeneratePageNumbers) ? intval($_POST['formulize_LOEPageStart']) : 0;
        $actualPageSize = $formulize_LOEPageSize ? $formulize_LOEPageStart + $formulize_LOEPageSize : $GLOBALS['formulize_countMasterResultsForPageNumbers'];
        if (strstr($listTemplate, "displayElement")) {
            include_once XOOPS_ROOT_PATH . "/modules/formulize/include/elementdisplay.php";
        }
        if (isset($data)) {
            //for($entryCounter=$formulize_LOEPageStart;$entryCounter<$actualPageSize;$entryCounter++) {
            // setup the view name variables, with true only set for the last loaded view
            $viewNumber = 1;
            foreach ($settings['publishedviewnames'] as $id => $thisViewName) {
                $thisViewName = str_replace(" ", "_", $thisViewName);
                if ($id == $settings['lastloaded']) {
                    ${$thisViewName} = true;
                    ${'view' . $viewNumber} = true;
                } else {
                    ${$thisViewName} = false;
                    $view['view' . $viewNumber] = false;
                }
                $viewNumber++;
            }
            foreach ($data as $id => $entry) {
                //$entry = $data[$entryCounter];
                //$id=$entryCounter;
                // check to make sure this isn't an unset entry (ie: one that was blanked by the extraction layer just prior to sending back results
                // Since the extraction layer is unsetting entries to blank them, this condition should never be met?
                // If this condition is ever met, it may very well screw up the paging of results!
                // NOTE: this condition is met on the last page of a paged set of results, unless the last page as exactly the same number of entries on it as the limit of entries per page
                if ($entry != "") {
                    // Set up the variables for the link to the current entry, and the checkbox that can be used to select the current entry
                    $linkids = internalRecordIds($entry, $mainFormHandle);
                    $entry_id = $linkids[0];
                    // make a nice way of referring to this for in the eval'd code
                    $form_id = $fid;
                    // make a nice way of referring to this for in the eval'd code
                    if (!$settings['lockcontrols']) {
                        //  AND !$loadview) { // -- loadview removed from this function sept 24 2005
                        $viewEntryLinkCode = "<a href='" . $currentURL;
                        if (strstr($currentURL, "?")) {
                            // if params are already part of the URL...
                            $viewEntryLinkCode .= "&";
                        } else {
                            $viewEntryLinkCode .= "?";
                        }
                        $viewEntryLinkCode .= "ve=" . $entry_id . "' onclick=\"javascript:goDetails('" . $entry_id . "');return false;\">";
                        $GLOBALS['formulize_viewEntryId'] = $entry_id;
                        // put into global scope so the function 'viewEntryLink' can pick it up if necessary
                        $GLOBALS['formulize_viewEntryLinkCode'] = $viewEntryLinkCode;
                        // check to see if we should draw in the delete checkbox
                        // 2 is none, 1 is all
                        if ($useCheckboxes != 2 and ($useCheckboxes == 1 or formulizePermHandler::user_can_delete_entry($fid, $uid, $entry_id))) {
                            $selectionCheckbox = "<input type=checkbox title='" . _formulize_DE_DELBOXDESC . "' class='formulize_selection_checkbox' name='delete_" . $entry_id . "' id='delete_" . $entry_id . "' value='delete_" . $entry_id . "'>";
                        } else {
                            $selectionCheckbox = "";
                        }
                    }
                    // end of IF NO LOCKCONTROLS
                    $ids = internalRecordIds($entry, $mainFormHandle);
                    foreach ($inlineButtons as $caid => $thisCustomAction) {
                        list($caCode) = processCustomButton($caid, $thisCustomAction, $ids[0], $entry);
                        // only bother with the code, since we already processed any clicked button above
                        if ($caCode) {
                            ${$thisCustomAction['handle']} = $caCode;
                            // assign the button code that was returned
                        }
                    }
                    // handle hidden elements for passing back to custom buttons
                    foreach ($hiddenColumns as $thisHiddenCol) {
                        print "\n<input type=\"hidden\" name=\"hiddencolumn_" . $linkids[0] . "_{$thisHiddenCol}\" value=\"" . htmlspecialchars(display($entry, $thisHiddenCol)) . "\"></input>\n";
                    }
                    include XOOPS_ROOT_PATH . "/modules/formulize/templates/screens/default/" . $screen->getVar('sid') . "/listtemplate.php";
                }
            }
        }
    }
    // END OF MASTER HIDELIST CONDITIONAL
    if ((!isset($data) or count($data) == $blankentries) and !$LOE_limit) {
        // if no data was returned, or the dataset was empty...
        print "<p><b>" . _formulize_DE_NODATAFOUND . "</b></p>\n";
    } elseif ($LOE_limit) {
        print "<p>" . _formulize_DE_LOE_LIMIT_REACHED1 . " <b>" . $LOE_limit . "</b> " . _formulize_DE_LOE_LIMIT_REACHED2 . " <a href=\"\" onclick=\"javascript:forceQ();return false;\">" . _formulize_DE_LOE_LIMIT_REACHED3 . "</a></p>\n";
    }
    if ($scrollBoxWasSet) {
        print "</div>";
    }
    formulize_benchmark("We're done");
}
<?php

session_start();
function getHeaders()
{
    $headers = array();
    foreach ($_SERVER as $k => $v) {
        if (substr($k, 0, 5) == "HTTP_") {
            $k = str_replace('_', ' ', substr($k, 5));
            $k = str_replace(' ', '-', ucwords(strtolower($k)));
            $headers[$k] = $v;
        }
    }
    return $headers;
}
foreach (getHeaders() as $name => $value) {
    error_log("{$name}: {$value}");
}
class SecuredAction
{
    function doEcho($data)
    {
        //session_start();
        return $data;
    }
}
Example #13
0
/**
 * Send off a piece of mail.
 *
 * @param {String} $name: The contacting user's name.
 * @param {String} $email: The contacting user's email.
 * @param {String} $message: The contacting user's message.
 * @param {String} $captcha: The Google Captcha's client-sided value.
 * @param {String} $receiver: The word directly after "Contact" inside the .modal-header > h4.modal-title
 */
function sendContactMail($name, $email, $message, $captcha, $receiver)
{
    $name = trim($name);
    $email = trim($email);
    $message = trim($message);
    $captcha = trim($captcha);
    $catcher = "";
    if ($receiver == "Colin") {
        $catcher = "*****@*****.**";
    } else {
        if ($receiver == "Abigail") {
            $catcher = "*****@*****.**";
        } else {
            return array("type" => "danger", "text" => "Please do not alter the webpage.");
        }
    }
    // Validate server-side due to client-side modifications.
    if ($name === "") {
        return array("type" => "warning", "text" => "Please enter in a name.");
    }
    if ($email === "" || !filter_var($email, FILTER_VALIDATE_EMAIL)) {
        return array("type" => "warning", "text" => "Please enter in a valid email.");
    }
    if ($message === "") {
        return array("type" => "warning", "text" => "Please enter in a message.");
    }
    $response = json_decode(file_get_contents("https://www.google.com/recaptcha/api/siteverify?secret=" . CAPTCHA_SECRET_KEY . "&response=" . $captcha));
    if ($response->success != 1) {
        if ($response->{"error-codes"}[0] == "missing-input-response") {
            return array("type" => "warning", "text" => "The CAPTCHA response is missing.");
        } else {
            if ($response->{"error-codes"}[0] == "invalid-input-response") {
                return array("type" => "danger", "text" => "The CAPTCHA response is invalid or malformed.");
            } else {
                return array("type" => "warning", "text" => "Something went wrong while trying to validate the CAPTCHA. Please try again.");
            }
        }
    }
    if (mail($catcher, "Contact from Index Iuris", $message, getHeaders($email))) {
        return array("type" => "success", "text" => "Thank you " . $name . ", your message has been sent!");
    } else {
        return array("type" => "warning", "text" => "There was an error sending your message. Please try again.");
    }
}
Example #14
0
$HOST = $_SERVER["HTTP_HOST"];
$SCRIPTNAME = $_SERVER["SCRIPT_FILENAME"];
$ROOTDIR = rtrim(shell_exec("dirname {$SCRIPTNAME}"));
require "{$ROOTDIR}/etc/library.php";
////////////////////////////////////////////////////////////////////////
//ACTIVE PART
////////////////////////////////////////////////////////////////////////
if (isset($action)) {
    if (0) {
    }
    //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    //CERRAR SESSION
    //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    if ($action == "Cerrar") {
        $urlref = "{$SITEURL}/index.php";
        $content = getHeaders(false);
        $content .= <<<C
<div class="g-signin2" data-theme="dark" data-width="0" data-height="0">
</div>

<div style="display:table;width:100%;height:100%">
<div style="display:table-cell;vertical-align:middle;text-align:center">
  <a href="#" onclick="signOut();" style="font-size:1.5em">Presione aquí para desonectar también {$SINFIN} de su cuenta de google</a>
</div>
</div>

C;
        echo $content;
        session_unset();
        header("Refresh:3;url={$urlref}");
    } else {
Example #15
0
$SCRIPTNAME = $_SERVER["SCRIPT_FILENAME"];
$ROOTDIR = rtrim(shell_exec("dirname {$SCRIPTNAME}"));
require "etc/library.php";
////////////////////////////////////////////////////////////////////////
//ACTIONS
////////////////////////////////////////////////////////////////////////
if ($action == "test") {
    $ps = parseParams($params);
    print_r($ps);
    $html .= "Test";
} else {
    //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    //LOGIN
    //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    if ($action == "login") {
        $html = getHeaders(false);
        $ps = parseParams($params);
        $email = $ps["email"];
        $nombre = $ps["fullname"];
        //IF USER EXIST
        if ($results = mysqlCmd("select * from Usuarios where email='{$email}'")) {
            session_start();
            foreach (array_keys($results) as $key) {
                if (preg_match("/^\\d\$/", $key)) {
                    continue;
                }
                $_SESSION["{$key}"] = $results[$key];
            }
            $urlref = "{$SITEURL}?yes";
        } else {
            $html .= "<div id='msg'>El usuario no ha sido creado en nuestra base de datos...</div>";
Example #16
0
$to = $_SESSION['sess_user_id'];
$rsesult = getmail($to, $db);
foreach ($rsesult as $row) {
    $tosend = $row['email'];
    //echo $tosend;
}
$getname = getusername($_SESSION['sess_user_id'], $db);
foreach ($getname as $result) {
    $fname = $result['user_name'];
    $eid = $result['user_eid'];
    //echo $eid;
}
$getCurrentMonth = getCurrentMonth($yr, $_SESSION['sess_user_id'], $db);
$to_mail = implode(", ", MailList(getHeaders(1, $db), 'to', $db));
$to_cc = implode(", ", MailList(getHeaders(1, $db), 'cc', $db));
$to_bcc = implode(", ", MailList(getHeaders(1, $db), 'bcc', $db));
$body = '<html>
							<head><title></title>
							<style>
								td{text-align:center; border-bottom: 1px dotted #514F4F;}
								table{width:900px;}
								span{color:red;}
								th{border-top: 1px solid #514F4F;border-bottom: 1px solid #514F4F;background: #514F4F;color: #E1E1E1;}
							</style>
							</head>
								<body>';
$body .= 'User Name: ' . $fname . '<br>';
$body .= 'User Id: ' . $eid . '<br>';
$body .= '<table>
									<tr>
										<th>日付</th>
Example #17
0
        $id_reqs = false;
    }
    $validateOverride = $_POST['validatedata'] == 0 ? true : false;
    importCsv(array($_FILES['csv_name']['name'], $csv_name), $id_reqs, $regfid, $validateOverride);
    print "</td></tr>\n";
} else {
    print "<tr><td class=head><p>" . _formulize_DE_IMPORT_STEP1 . "</p></td><td class=even>";
    // provide a blank template, and a blank update template
    // store the id_reqs and the filename in the DB for later reference in the case of the update template
    // determine if this is the profile form and if so, send special flag to template creation
    $cols1 = getAllColList($fid, "", $groups);
    $cols = array();
    foreach ($cols1[$fid] as $col) {
        $cols[] = $col['ele_id'];
    }
    $headers = getHeaders($cols);
    $template = $regfid == $fid ? "blankprofile" : "blank";
    $blank_template = prepExport($headers, $cols, "", "comma", "", "", $template);
    print "<p><b>" . _formulize_DE_IMPORT_EITHEROR . "</b><p>";
    print "<ul><li>" . _formulize_DE_IMPORT_BLANK . "<br><a href={$blank_template} target=_blank>" . _formulize_DE_IMPORT_BLANK2 . "</a></li></ul>\n";
    print "<Center><p><b>" . _formulize_DE_IMPORT_OR . "</b></p></center>";
    print "<ul><li>" . _formulize_DE_IMPORT_DATATEMP . "<br><a href=\"\" onclick=\"javascript:window.opener.showPop('" . XOOPS_URL . "/modules/formulize/include/export.php?fid={$fid}&frid=&colids=&eq=" . intval($_GET['eq']) . "&type=update');return false;\">" . _formulize_DE_IMPORT_DATATEMP2 . "</a>";
    print "</li></ul></td></tr>\n";
    print "<tr><td class=head><p>" . _formulize_DE_IMPORT_STEP2 . "</p></td><td class=even>" . _formulize_DE_IMPORT_INSTRUCTIONS;
    if ($regfid == $fid) {
        print _formulize_DE_IMPORT_INSTNEWPROFILE;
    } else {
        print _formulize_DE_IMPORT_INSTNEW;
    }
    print _formulize_DE_IMPORT_INSTUPDATE . "</td></tr>\n";
    print "<tr><td class=head><p>" . _formulize_DE_IMPORT_STEP3 . "</p></td><td class=even><p>" . _formulize_DE_IMPORT_FILE . ": <form method=\"post\" ENCTYPE=\"multipart/form-data\"><input type=\"file\" name=\"csv_name\" size=\"40\" /><br><input type=\"checkbox\" name=\"validatedata\" value=\"1\" checked>&nbsp;" . _formulize_DE_IMPORT_VALIDATEDATA . "</p><p><input type=\"submit\" value=\"" . _formulize_DE_IMPORT_GO . "\"></form></p></td></tr>\n";
Example #18
0
function ewiki_page_wiki_email_page($id = 0, $data = 0, $action = 0)
{
    if (isRequestNotSet($_REQUEST["email_page"], $_REQUEST["email_address"])) {
        if ($action == "emailpage") {
            getUserInfo($from_email, $from_name);
            $defined = isUserInfoDefined($from_email, $from_name);
            $warning = checkEmailField($_REQUEST["email_address"], $_REQUEST["not_first_time"]);
            $html = htmlFormGenerate($defined, $id, $warning, $from_email, $from_name);
            return $html;
        } else {
            return "You shouldn't be here.";
        }
    } else {
        $emailAddress = $_REQUEST["email_address"];
        $emailText = $_REQUEST["email_text"];
        getUserInfo($from_email, $from_name);
        $headers = getHeaders($from_email, $from_name);
        $subject = getSubject($id);
        $body = buildEmail($id, $data, $emailText);
        mail($emailAddress, $subject, $body, $headers);
        $success_message = "<p><h4>Success!</h4></p><p>Page sent to <a href=mailto:{$emailAddress}>{$emailAddress}</a></p>";
        $success_message .= "<p>Click <a href=\"" . ewiki_script("view", $id) . "\">here</a> to return to the page you just sent.</p>";
        return ewiki_t($success_message);
    }
}
Example #19
0
     // Remove any nasty stuff
     $owner = $db->escape($owner);
     $user_account = $db->get_row("SELECT * FROM user WHERE rs_wh = \"{$owner}\" ");
     if ($user_account) {
         $go = true;
         $owner = $user_account->id;
     } else {
         // DB Lookup Failed.
         $status = "Auth";
         $msg = "Authentication Failed - " . $owner;
         json_respond($status, $msg);
     }
 }
 if ($go) {
     // passed ^above^ checks, time to write to DB.
     $headers = getHeaders();
     $headers = serialize($headers);
     $headers = $db->escape($headers);
     $post = serialize($post);
     $post = $db->escape($post);
     $saved = $db->query("INSERT INTO alarms (id, post, headers, owner) VALUES (NULL,\"{$post}\", \"{$headers}\", \"{$owner}\")");
     if ($saved) {
         $status = "OK";
         $msg = $db->insert_id . ": Alarm Saved.";
         json_respond($status, $msg);
     } else {
         $status = "Error";
         $msg = "Database Error, failed to save post.";
         json_respond($status, $msg);
     }
 } else {
 /**
  * @param $resp
  *
  * @return mixed
  */
 public static function getPollURL($resp)
 {
     $headers = getHeaders($resp);
     return $headers['Location'];
 }
Example #21
0
<html>
<?php 
////////////////////////////////////////////////////////////////////////
//LOAD LIBRARY
////////////////////////////////////////////////////////////////////////
$HOST = $_SERVER["HTTP_HOST"];
$SCRIPTNAME = $_SERVER["SCRIPT_FILENAME"];
$ROOTDIR = rtrim(shell_exec("dirname {$SCRIPTNAME}"));
require "{$ROOTDIR}/etc/library.php";
////////////////////////////////////////////////////////////////////////
//INITIALIZATION
////////////////////////////////////////////////////////////////////////
$content = "";
$content .= getHeaders();
$content .= getHead();
$content .= getMainMenu();
////////////////////////////////////////////////////////////////////////
//SUBMENU
////////////////////////////////////////////////////////////////////////
$content .= <<<M
<div class="moduletitle">
  Documentos
</div>
<div class="submenu">
  <a href="?">Inicio</a> 
  <span class="level5">| <a href="?mode=mode">Modo</a></span>
</div>
<div class="container">
M;
////////////////////////////////////////////////////////////////////////
//BODY
Example #22
0
function updateUser($uid, $mysqli)
{
    //TODO save an history of (different) ip and ua for each user
    $ip = getUserIP();
    $ua = sanitize($_SERVER['HTTP_USER_AGENT']);
    $hd = getHeaders();
    $d = date("Y-m-d H:i:s");
    if ($mysqli->query("UPDATE users SET ip='" . $ip . "', ua='" . $ua . "',lastupdate='" . $d . "',status=1,lastonline='" . $d . "',headers='" . $hd . "' WHERE id=" . $uid . ";") === FALSE) {
        logErr("Failed to update information of the user [" . $ip . "]");
    }
}