コード例 #1
0
ファイル: debuglib.php プロジェクト: dehvCurtis/phplist
function dbg($variable = "", $description = 'Value', $table_started = 0)
{
    # WARNING recursive
    if (!$table_started) {
        echo "<ul type='circle' style='border:1px solid #a0a0a0;padding-bottom:4px;padding-right:4px'>\n<li>{" . getenv("REQUEST_URI") . "} ";
    }
    echo "<i>{$description}</i>: ";
    if (is_array($variable) || is_object($variable)) {
        if (is_array($variable)) {
            echo "(array)[" . count($variable) . "]";
        } else {
            echo "<B>(object)</B>[" . count($variable) . "]";
        }
        echo "<ul type='circle' style='border:1px solid #a0a0a0;padding-bottom:4px;padding-right:4px'>\n";
        foreach ($variable as $key => $value) {
            echo "<li>\"{$key}\" => ";
            dbg($value, '', TRUE);
            echo "</li>\n";
        }
        echo "</ul>\n";
    } else {
        echo "(" . gettype($variable) . ") '{$variable}'\n";
    }
    if (!$table_started) {
        echo "</li></ul>\n";
    }
}
コード例 #2
0
ファイル: quarantine_maint.php プロジェクト: thctlo/1.2.0
 function quarantine_clean()
 {
     $oldest = date('U', strtotime('-' . QUARANTINE_DAYS_TO_KEEP . " days"));
     $quarantine = get_conf_var('QuarantineDir');
     $d = dir($quarantine) or die($php_errormsg);
     while (false !== ($f = $d->read())) {
         // Only interested in quarantine directories (yyyymmdd)
         if (preg_match('/^\\d{8}$/', $f)) {
             $unixtime = quarantine_date_to_unixtime($f);
             if ($unixtime < $oldest) {
                 // Needs to be deleted
                 $array = quarantine_list_dir($f);
                 dbg("Processing directory {$f}: found " . count($array) . " records to delete");
                 foreach ($array as $id) {
                     // Update the quarantine flag
                     $sql = "UPDATE maillog SET timestamp=timestamp, quarantined = NULL WHERE id='{$id}'";
                     dbquery($sql);
                 }
                 dbg("Deleting: " . escapeshellarg($quarantine . '/' . $f));
                 exec('rm -rf ' . escapeshellarg($quarantine . '/' . $f), $output, $return);
                 if ($return > 0) {
                     echo "Error: {$output}\n";
                 }
             }
         }
     }
     $d->close();
 }
コード例 #3
0
ファイル: upload.php プロジェクト: browserplus/borg
function result($status, $value)
{
    $json = json_encode(array("status" => $status, "value" => $value));
    dbg($json);
    echo $json;
    exit;
}
コード例 #4
0
 private function initSqlInjectionFilter()
 {
     if (function_exists('sqlInjectionFilter') && $this->isNeedFilterSql) {
         dbg('sqlInjectionFilter');
         sqlInjectionFilter();
     }
 }
コード例 #5
0
ファイル: rfunctions.php プロジェクト: rigidus/cobutilniki
function getFileContent($m)
{
    global $xmlrpcerruser;
    global $xmlrpcString;
    $file_name = $m->getParam(0);
    $file_path = $m->getParam(1);
    $file_name = $file_name->scalarval();
    $file_path = $file_path->scalarval();
    $sql = "SELECT * FROM `" . DB_PREFIX . DB_TBL_FILES . "` WHERE \n\t\t`name` = '" . mysql_escape_string($file_name) . "' AND \n\t\t`path` = '" . mysql_escape_string($file_path) . "'";
    $sql = mysql_query($sql);
    if (false == $sql) {
        dbg();
        my_die();
    }
    $aList = array();
    while ($row = mysql_fetch_assoc($sql)) {
        $aList[] = $row;
    }
    if (empty($aList)) {
        return new xmlrpcresp(0, $xmlrpcerruser, 'file not exist');
    }
    $aList = current($aList);
    if (!defined($aList['path'])) {
        return new xmlrpcresp(0, $xmlrpcerruser, 'file path not correct (remote error)');
    }
    $response = saferead(constant($aList['path']) . '/' . $aList['name']);
    // Возвращаем
    $response = base64_encode($response);
    return new xmlrpcresp(new xmlrpcval($response), $xmlrpcString);
}
コード例 #6
0
ファイル: actionhandler.php プロジェクト: estamina/imagery
 public function cycle()
 {
     $this->dirServer->setPageSize(500);
     $this->dirServer->setPageNo(0);
     dbg("CYCLE");
     $_SESSION['show'] = true;
 }
コード例 #7
0
 public function runtimeError()
 {
     $solutionId = I('get.sid', 0, 'intval');
     $type = SourceModel::RUNTIMEERROR;
     $error = SourceModel::instance()->getErrorBySolutionId($solutionId, $type);
     dbg($error);
 }
コード例 #8
0
ファイル: display.php プロジェクト: estamina/imagery
 function viewport()
 {
     $relativeCategoriesPath = '../' . appdataDir . '/' . categoriesDir . '/' . $_SESSION['category'] . '/';
     $urlbase = 'http://' . $_SERVER['SERVER_NAME'] . $_SERVER['PHP_SELF'];
     $categDirs = $this->catsource->getList();
     $key = array_search(all, $categDirs);
     if ($key !== false) {
         dbg("reducing array:");
         dbgmp($categDirs);
         unset($categDirs[$key]);
         dbgmp($categDirs);
         //	array_splice($categDirs, $key,1);//not needed?
         dbgmp($categDirs);
     }
     $files = $this->source->getList();
     dbgmp($files);
     include "ui/header.php";
     if (isset($_SESSION['show'])) {
         if ($_SESSION['show']) {
             include "ui/slideshow.php";
             $_SESSION['show'] = false;
         } else {
             include "ui/thumbnails.php";
         }
     } else {
         include "ui/thumbnails.php";
     }
 }
コード例 #9
0
function daemon_body()
{
    # The main loop
    dbg("start main loop");
    while (sleep(1) == 0) {
        info("I'm working hard!");
    }
}
コード例 #10
0
ファイル: session.php プロジェクト: rigidus/cobutilniki
function s_clean($max)
{
    dbg(__FUNCTION__);
    exit;
    global $Db;
    $old = time() - $max;
    $sql = "DELETE FROM " . DB_PREFIX . DB_TBL_SESSIONS . " WHERE `access` < '{$old}'";
    return $Db->query($sql);
}
コード例 #11
0
ファイル: main.php プロジェクト: robhell/friendica-addons
/**
 * @param App $a
 */
function dav_init(&$a)
{
    /*
     * Recommended settings:
     * ALTER TABLE `photo` ADD INDEX ( `contact-id` )
     */
    dav_include_files();
    if (false) {
        dbg(true);
        error_reporting(E_ALL);
        ini_set("display_errors", 1);
    }
    wdcal_create_std_calendars();
    if ($a->argc >= 2 && $a->argv[1] == "wdcal") {
        if ($a->argc >= 3 && $a->argv[2] == "feed") {
            wdcal_print_feed($a->get_baseurl() . "/dav/wdcal/");
            killme();
        } elseif ($a->argc >= 3 && strlen($a->argv[2]) > 0) {
            wdcal_addRequiredHeadersEdit();
        } else {
            wdcal_addRequiredHeaders();
        }
        return;
    }
    if ($a->argc >= 2 && $a->argv[1] == "settings") {
        return;
    }
    $authBackend = new Sabre_DAV_Auth_Backend_Friendica();
    $principalBackend = new Sabre_DAVACL_PrincipalBackend_Friendica($authBackend);
    $caldavBackend_std = new Sabre_CalDAV_Backend_Std();
    $caldavBackend_community = new Sabre_CalDAV_Backend_Friendica();
    $carddavBackend_std = new Sabre_CardDAV_Backend_Std();
    $carddavBackend_community = new Sabre_CardDAV_Backend_FriendicaCommunity();
    if (isset($_SERVER["PHP_AUTH_USER"])) {
        $tree = new Sabre_DAV_SimpleCollection('root', array(new Sabre_DAV_SimpleCollection('principals', array(new Sabre_CalDAV_Principal_Collection($principalBackend, "principals/users"))), new Sabre_CalDAV_AnimexxCalendarRootNode($principalBackend, array($caldavBackend_std, $caldavBackend_community)), new Sabre_CardDAV_AddressBookRootFriendica($principalBackend, array($carddavBackend_std, $carddavBackend_community))));
    } else {
        $tree = new Sabre_DAV_SimpleCollection('root', array());
    }
    // The object tree needs in turn to be passed to the server class
    $server = new Sabre_DAV_Server($tree);
    $url = parse_url($a->get_baseurl());
    $server->setBaseUri(CALDAV_URL_PREFIX);
    $authPlugin = new Sabre_DAV_Auth_Plugin($authBackend, 'SabreDAV');
    $server->addPlugin($authPlugin);
    $aclPlugin = new Sabre_DAVACL_Plugin_Friendica();
    $aclPlugin->defaultUsernamePath = "principals/users";
    $server->addPlugin($aclPlugin);
    $caldavPlugin = new Sabre_CalDAV_Plugin();
    $server->addPlugin($caldavPlugin);
    $carddavPlugin = new Sabre_CardDAV_Plugin();
    $server->addPlugin($carddavPlugin);
    $browser = new Sabre_DAV_Browser_Plugin();
    $server->addPlugin($browser);
    $server->exec();
    killme();
}
コード例 #12
0
ファイル: configure.php プロジェクト: jnwatts/credentials
function show_audit($log)
{
    $info = date('c', $log->_when);
    $info .= ' ' . $log->_who;
    $info .= ': ' . $log->_what;
    if ($log->_extra != "") {
        $info .= ' context:' . $log->_extra;
    }
    dbg($info);
}
コード例 #13
0
 /**
  * @param string $id
  * @return string|null
  */
 public function load($id)
 {
     $cacheFile = $this->getCacheFileName($id);
     if (file_exists($cacheFile) && Carbon::createFromTimestamp(filemtime($cacheFile))->diffInSeconds(Carbon::now()) < $this->cacheTtlSeconds) {
         dbg('CACHE LOAD: ' . $cacheFile . ', cache ttl ' . $this->cacheTtlSeconds . ' (' . $id . ')');
         return file_get_contents($cacheFile);
     }
     dbg('CACHE NOT FOUND: ' . $cacheFile . ', cache ttl ' . $this->cacheTtlSeconds . ' (' . $id . ')');
     return null;
 }
コード例 #14
0
ファイル: components.php プロジェクト: rigidus/cobutilniki
function ExecDispatcher($sExec, $aParams)
{
    //dbg($aParams, $sExec);
    $component_id = 0;
    if (isset($aParams['component_id'])) {
        $component_id = $aParams['component_id'];
    }
    //dbg($component_id,'$component_id');
    unset($aParams['component_id']);
    switch ($sExec) {
        case 'getAllTablesAndAliases':
            return cComponents::getAllTablesAndAliases();
            break;
        case 'getTables_Component':
            return cComponents::getTables_Component($component_id);
            break;
        case 'getModules_Component':
            return cComponents::getModules_Component($component_id);
            break;
        case 'getTpls_Component':
            return cComponents::getTpls_Component($component_id);
            break;
        case 'getPages_Component':
            return cp1251_to_utf(cComponents::getPages_Component($component_id));
            break;
        case 'delPage_Component':
            return cComponents::delLink_Component($component_id, $aParams, DB_TBL_COMPONENTS2PAGES, 'page_id');
            break;
        case 'delTable_Component':
            return cComponents::delLink_Component($component_id, $aParams, DB_TBL_COMPONENTS2TABLES, 'table_id');
            break;
        case 'delTpl_Component':
            return cComponents::delLink_Component($component_id, $aParams, DB_TBL_COMPONENTS2TPLS, 'tpl_id');
            break;
        case 'delModule_Component':
            return cComponents::delLink_Component($component_id, $aParams, DB_TBL_COMPONENTS2MODULES, 'module_id');
            break;
        case 'setPages_Component':
            return cComponents::setLink_Component($component_id, $aParams, DB_TBL_COMPONENTS2PAGES, 'page_id');
            break;
        case 'setTables_Component':
            return cComponents::setLink_Component($component_id, $aParams, DB_TBL_COMPONENTS2TABLES, 'table_id');
            break;
        case 'setTpls_Component':
            return cComponents::setLink_Component($component_id, $aParams, DB_TBL_COMPONENTS2TPLS, 'tpl_id');
            break;
        case 'setModules_Component':
            return cComponents::setLink_Component($component_id, $aParams, DB_TBL_COMPONENTS2MODULES, 'module_id');
            break;
        default:
            dbg($sParams, 'Execution Dispatcher Fault: ' . $sExec);
            return '';
            break;
    }
}
コード例 #15
0
ファイル: db.php プロジェクト: piter65/spilldec
function logit($msg)
{
    global $db;
    $msg = preg_replace("/'/", "\\'", $msg);
    dbg("logging '{$msg}'");
    $sql = "insert into log (stamp, msg) values (now(), '{$msg}')";
    $rs = $db->Execute($sql);
    if (!$rs) {
        p_sqlfail($db, $sql);
    }
}
コード例 #16
0
ファイル: Scraper.php プロジェクト: martinlindhe/php-tvnu
 private function getRequest($url)
 {
     $ch = curl_init();
     curl_setopt($ch, CURLOPT_URL, $url);
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
     curl_setopt($ch, CURLOPT_USERAGENT, $this->userAgent);
     $output = curl_exec($ch);
     $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
     dbg('GET ' . $url . ' ' . $httpCode);
     curl_close($ch);
     return $output;
 }
コード例 #17
0
ファイル: imagen_model.php プロジェクト: jbetan/publicidad
 public function updateImagen($id, $titulo, $desc, $rest, $ubic, $info = '', $fecha = '')
 {
     $this->db->trans_start();
     $data = array('id' => $id, 'titulo' => $titulo, 'descripcion' => $desc, 'restripcion' => $rest, 'ubicacion' => $ubic, 'infoadicional' => $info);
     print_r($data);
     $this->db->where('id', $id);
     $this->db->update('galeria', $data);
     $this->db->trans_complete();
     dbg('model');
     return true;
     //Falta las fechas del calendario
 }
コード例 #18
0
ファイル: home_model.php プロジェクト: jbetan/publicidad
 public function getPromocionToday()
 {
     $fecha_actual = date("Y-m-d");
     dbg($fecha_actual);
     $query = $this->db->select('gal.ruta, gal.titulo, gal.descripcion, gal.restripcion, ')->from('galeria AS gal')->join('calendario AS cal', 'gal.id = cal.idGaleria', 'INNER')->where('cal.fecha', $fecha_actual)->get();
     if ($query->num_rows > 0) {
         foreach ($query->result() as $fila) {
             $data[] = $fila;
         }
         return $data;
     } else {
         return false;
     }
 }
コード例 #19
0
ファイル: transcat.php プロジェクト: NonameTV/nonametv
function sql_deleteTransCat($myc, $s)
{
    global $debug;
    $tblname = 'trans_cat';
    $q = "DELETE FROM " . $tblname . " WHERE `type`='" . $s['type'] . "' AND `original`='" . $s['original'] . "'";
    if ($debug) {
        dbg("DELETE", $q);
    }
    if (!mysql_query($q, $myc)) {
        print "<h4>Can't delete category type " . $s['type'] . " and original " . $s['original'] . "</h4>\n";
        print mysql_error($myc) . "\n";
        return false;
    }
    print "<h4>MySQL: Category type " . $s['type'] . " and original " . $s['original'] . " deleted</h4>\n";
    return true;
}
コード例 #20
0
function nor_account_by_id($account_id)
{
    global $YBdebug;
    $conn = nor_db_connect();
    $res = nor_db_q("select * from accounts where id = {$account_id}", $conn);
    $row = nor_db_fetch_array($res, NOR_DB_ASSOC);
    if (!$row) {
        if ($u = posix_getpwuid($account_id)) {
            $row = array();
            $row["id"] = $u["uid"];
            $row["username"] = $u["name"];
            $row["full_name"] = $u["gecos"];
            dbg("nor_account_by_id: id={$account_id} LOCAL " . $row["username"]);
        }
    }
    return $row;
}
コード例 #21
0
ファイル: debug.php プロジェクト: rotoballer/emily
function wysija_queries()
{
    if (is_admin() && (defined('WYSIJA_ITF') && WYSIJA_ITF) || isset($_GET['dbg'])) {
        global $wpdb, $wysija_queries;
        echo '<div class="wysija-footer"><h2>WYSIJA QUERIES</h2>';
        echo '<pre>';
        dbg($wysija_queries, 0);
        echo '</pre>';
        /*echo "<h2>WYSIJA QUEUE</h2>";
          $modelQ=&WYSIJA::get('queue','model');
          $wysija_queue=$modelQ->getReady();
          echo "<pre>";
          print_r($wysija_queue);
          echo "</pre>";*/
        echo '</div>';
    }
}
コード例 #22
0
ファイル: debug.php プロジェクト: crazyyy/octagram
function wysija_queries()
{
    if (is_admin() && (defined('WYSIJA_ITF') && WYSIJA_ITF) || isset($_GET['dbg'])) {
        global $wpdb, $wysija_queries, $wysija_queries_errors;
        echo '<div class="wysija-footer"><div class="expandquer"><h2>WYSIJA QUERIES</h2>';
        echo '<pre>';
        dbg($wysija_queries, 0);
        echo '</pre></div>';
        if ($wysija_queries_errors) {
            echo '<div class="expandquer"><h2 class="errors">WYSIJA QUERIES ERRORS</h2>';
            echo '<pre>';
            dbg($wysija_queries_errors, 0);
            echo '</pre></div>';
        }
        echo '</div>';
    }
}
コード例 #23
0
ファイル: main.php プロジェクト: ZerGabriel/friendica-addons
/**
 * @param App $a
 */
function dav_init(&$a)
{
    /*
     * Recommended settings:
     * ALTER TABLE `photo` ADD INDEX ( `contact-id` )
     */
    ini_set("display_errors", 1);
    error_reporting(E_ALL);
    dav_include_files();
    if (false) {
        dbg(true);
        error_reporting(E_ALL);
        ini_set("display_errors", 1);
    }
    wdcal_create_std_calendars();
    wdcal_create_std_addressbooks();
    wdcal_addRequiredHeaders();
    if ($a->argc >= 2 && $a->argv[1] == "wdcal") {
        if ($a->argc >= 3 && $a->argv[2] == "feed") {
            wdcal_print_feed($a->get_baseurl() . "/dav/wdcal/");
            killme();
        }
        return;
    }
    if ($a->argc >= 2 && $a->argv[1] == "getExceptionDates") {
        echo wdcal_getEditPage_exception_selector();
        killme();
    }
    if ($a->argc >= 2 && $a->argv[1] == "settings") {
        return;
    }
    if (isset($_REQUEST["test"])) {
        renderAllCalDavEntries();
    }
    $server = dav_create_server();
    $browser = new Sabre_DAV_Browser_Plugin();
    $server->addPlugin($browser);
    $server->exec();
    killme();
}
コード例 #24
0
ファイル: cache.php プロジェクト: piter65/spilldec
function cache($url, $rawOpts)
{
    $opts = array();
    foreach ($rawOpts as $key => $val) {
        $opts[] = sprintf('%s=%s', urlencode($key), urlencode($val));
    }
    $uri = $url . '?' . implode('&', $opts);
    $ch = curl_init($uri);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    $r = curl_exec($ch);
    if ($r === false) {
        dbg("ERROR: cache server unavailable");
        return null;
    }
    //dbg("u= $uri");
    //dbg("r= $r");
    $o = json2obj($r);
    if ($o->error) {
        dbg("ERROR: {$o->error}");
        return null;
    }
    return $o->value;
}
コード例 #25
0
ファイル: auth.php プロジェクト: piter65/spilldec
function authenticate($pass, $user)
{
    global $auth_list, $salt, $authkey, $username;
    dbg("salt is {$salt} ");
    dbg("auth {$user}/{$pass} ... ");
    $user = strtolower(trim($user));
    $pass = strtolower(trim($pass));
    foreach ($auth_list as $u => $p) {
        $u = strtolower(trim($u));
        $p = strtolower(trim($p));
        dbg("testing {$user}={$u} and {$pass}={$p} or " . sha1($pass) . "={$p}");
        if ($user == $u && ($pass == $p || sha1($pass) == $p)) {
            // login ok
            $authkey = sha1($u . $p . $salt);
            setcookie("sid", $authkey, time() + 15 * 60);
            $username = $user;
            setcookie("username", $username, time() + 30 * 24 * 60 * 60);
            dbg("login ok ... key={$authkey} ");
            return $authkey;
        }
    }
    return null;
}
コード例 #26
0
ファイル: config.php プロジェクト: christocmp/bingopaws
 function log()
 {
     $option_log = get_option('wysija_log');
     foreach ($option_log as $key => $data) {
         echo '<h3>' . $key . '</h3>';
         dbg($data, 0);
     }
 }
コード例 #27
0
ファイル: config.php プロジェクト: rotoballer/emily
 function log()
 {
     dbg(get_option('wysija_log'), 0);
 }
コード例 #28
0
ファイル: utils.php プロジェクト: ncareol/nidas
function dbg2($msg, $debug_level)
{
    if ($debug_level >= 2) {
        dbg($msg);
    }
}
コード例 #29
0
ファイル: userlib.php プロジェクト: radicaldesigns/amp
function saveUserData($username,$fields) {
	# saves data in session, not in database
  dbg("Saving user $username");
	if (!is_array($_SESSION["userdata"])) {
  	dbg("Nothing to save");
    return;
  }
  if (!$username) {
  	$username = '******';
  }
	$res = "";
  $required_fields = explode(",",$_POST["required"]);
  $required_formats = explode(",",$_POST["required_formats"]);
  $description_fields = explode(",",$_POST["required_description"]);

  reset($fields);
  dbg("Checking fields");
  while (list($fname,$fval) = each ($fields)) {
 # 	dbg($fname);
  	$key = $fname;
    $val = $_POST[$fname];
		if (!ereg("required",$key) &&
    	$fields[$key]["type"] != "separator" &&
    	$fields[$key]["type"] != "emailcheck" &&
    	$fields[$key]["type"] != "passwordcheck"
      ) {
	#  	dbg($fname ." of type ".$fields[$key]["type"]);
       if (!is_array($_SESSION["userdata"][$key]))
       	 $_SESSION["userdata"][$key] = array();
       $_SESSION["userdata"][$key]["name"] = $fields[$key]["name"];
       $_SESSION["userdata"][$key]["type"] = $fields[$key]["type"];
       if ($fields[$key]["type"] == "creditcardno") {
       	 # dont overwrite known CC with ***
         if (!preg_match("#^\*+#",$val)) {
		     	 $_SESSION["userdata"][$key]["value"] = ltrim($val);
         }
       } else {
	     	 $_SESSION["userdata"][$key]["value"] = ltrim($val);
       }
       if ($fields[$key]["type"] == "select") {
	     	 $_SESSION["userdata"][$key]["displayvalue"] = $fields[$key]["values"][$val];
       } elseif ($fields[$key]["type"] == "checkboxgroup") {
	     	 $_SESSION["userdata"][$key]["value"] = join(",",$val);
       } elseif ($fields[$key]["type"] == "creditcardno") {
       		# erase any non digits from the CC numbers
					$_SESSION["userdata"][$key]["value"] = preg_replace("/\D/","",$_SESSION["userdata"][$key]["value"]);
					$_SESSION["userdata"][$key]["displayvalue"] = obscureCreditCard($_SESSION["userdata"][$key]["value"]);
       } elseif ($fields[$key]["name"] == "Card Number") {
					$_SESSION["userdata"][$key]["value"] = preg_replace("/\D/","",$_SESSION["userdata"][$key]["value"]);
					$_SESSION["userdata"][$key]["displayvalue"] = obscureCreditCard($_SESSION["userdata"][$key]["value"]);
/*					$_SESSION["userdata"][$key]["displayvalue"] = substr($_SESSION["userdata"][$key]["displayvalue"],0,4);
       		for ($i=0;$i<strlen($_SESSION["userdata"][$key]["value"]-4);$i++) {
		     	  $_SESSION["userdata"][$key]["displayvalue"] .= '*';
         	}
*/
		   } else {
	     	 $_SESSION["userdata"][$key]["displayvalue"] = $val;
		   }
       
/*       # remember other aspects of the fields
       foreach ($fields as $key => $val) {
         foreach ($val as $field_attr => $value) {
	       	 if (!isset($_SESSION["userdata"][$key][$field_attr]) && !preg_match("/^\d+$/",$key)
           	&& !preg_match("/^\d+$/",$field_attr)
           ) {
						 $_SESSION["userdata"][$key][$field_attr] = $value;
           }
          }
       }
*/
       # save it to the DB as well
    } else {
#  	  	dbg("Not checking ".$fname ." of type ".$fields[$key]["type"]);
		}
  }
  
  # fix UK postcodes to correct format
  if ($_SESSION["userdata"][$GLOBALS["config"]["country_attribute"]]["displayvalue"] == "United Kingdom") {
    $postcode = $_SESSION["userdata"][$GLOBALS["config"]["postcode_attribute"]]["value"];
    $postcode = strtoupper(str_replace(" ","",$postcode));
    if (preg_match("/(.*)(\d\w\w)$/",$postcode,$regs)) {
      $_SESSION["userdata"][$GLOBALS["config"]["postcode_attribute"]]["value"] = trim($regs[1])." ".$regs[2];
      $_SESSION["userdata"][$GLOBALS["config"]["postcode_attribute"]]["displayvalue"] = trim($regs[1])." ".$regs[2];
    }
  }

  while (list($index,$field) = each ($required_fields)) {
 		$type = $fields[$field]["type"];
    if ($field && !$_SESSION["userdata"][$field]["value"]) {
      $res = "Information missing: ".$description_fields[$index];
      break;
    } else if ($required_formats[$index] && !preg_match(stripslashes($required_formats[$index]),$_SESSION["userdata"][$field]["value"])) {
      $res = "Sorry, you entered an invalid ".$description_fields[$index].": ".$_SESSION["userdata"][$field]["value"];
      break;
    } else if ($field == "email" && !validateEmail($_SESSION["userdata"][$field]["value"])) {
      $res = "Sorry, you entered an invalid ".$description_fields[$index].": ".$_SESSION["userdata"][$field]["value"];
      break;
    } else if ($field == "cardtype" && $_SESSION["userdata"][$field]["value"] == "WSWITCH" && !preg_match("/\d/",$_SESSION["userdata"]["attribute82"]["value"])) {
      $res = "Sorry, a Switch Card requires a valid issue number. If you have a new Switch card without an issue number, please use 0 as the issue number.";
      break;
    } else if ($field == "cardtype" && $_SESSION["userdata"][$field]["value"] != "WSWITCH" && $_SESSION["userdata"]["attribute82"]["value"]) {
      $res = "Sorry, an issue number is not valid when not using a Switch Card";
      break;
    } else if (($type == "creditcardno" || $field == "cardnumber") && !checkCCrange($_SESSION["userdata"][$field]["value"])) {
    	list($cid,$cname) = ccCompany($_SESSION["userdata"][$field]["value"]);
      if (!$cname)
      	$cname = '(Unknown Credit card)';
      $res = "Sorry, we currently don't accept $cname cards";
      break;
    } else if (($type == "creditcardno" || $field == "cardnumber") && !validateCC($_SESSION["userdata"][$field]["value"])) {
      $res = "Sorry, you entered an invalid ".$description_fields[$index];#.": ".$_SESSION["userdata"][$field]["value"];
      break;
    } else if (($type == "creditcardexpiry" ||$field == "cardexpiry") && !validateCCExpiry($_SESSION["userdata"][$field]["value"])) {
      $res = "Sorry, you entered an invalid ".$description_fields[$index].": ".$_SESSION["userdata"][$field]["value"];
      break;
    }
  }
	if ($_SESSION["userdata"][$GLOBALS["config"]["country_attribute"]]["displayvalue"] == "United Kingdom") {
    $postcode = $_SESSION["userdata"][$GLOBALS["config"]["postcode_attribute"]]["displayvalue"];
    if (!preg_match("/(.*)(\d\w\w)$/",$postcode,$regs)) {
      $res = "That does not seem to be a valid UK postcode";
    } elseif (!preg_match("/^[\s\w\d]+$/",$postcode,$regs)) {
      $res = "That does not seem to be a valid UK postcode";
    }
  }
  if (is_array($GLOBALS["config"]["bocs_dpa"])) {
    if (!is_array($_SESSION["DPA"]))
      $_SESSION["DPA"] = array();
  	foreach ($GLOBALS["config"]["bocs_dpa"] as $dpaatt => $val) {
    	if ($_SESSION["userdata"][$dpaatt]["displayvalue"]) {
      	$_SESSION["DPA"][$val] = "Y";
     	} else {
      	$_SESSION["DPA"][$val] = "N";
      }
   	}
  }
  return $res;
}
コード例 #30
0
ファイル: dbg.php プロジェクト: piter65/spilldec
    global $dbg;
    if ($dbg) {
        print "{$msg}\n";
    }
}
function dbg($msg)
{
    global $dbg;
    if ($dbg) {
        if (is_array($msg) || is_object($msg)) {
            print "<pre class='dbg'>";
            print_r($msg);
            print "</pre>\n";
        } else {
            print "<span class='dbg'>{$msg}</span><br>\n";
        }
    }
}
$dbg = isset($_COOKIE["dbg"]) && $_COOKIE["dbg"] == "true" ? true : false;
if (isset($_GET["dbg"])) {
    if ($_GET["dbg"] == "on") {
        dbg_sc("dbg", "true");
        $dbg = true;
        dbg("Debug mode enabled");
    } else {
        if ($_GET["dbg"] == "off") {
            dbg_sc("dbg", "");
            $dbg = false;
        }
    }
}