예제 #1
0
         } else {
             $rang_gen = $i + 1;
         }
         $note_prec = $tmp_tab[$i];
         $rang_prec = $rang_gen;
     }
     //$col[$nb_col+1][$ind]="ind=$ind, i=$i et rang_gen=$rang_gen";
     for ($m = 1; $m <= $nb_colonnes; $m++) {
         my_echo("\$tmp_col[{$m}][{$i}]=\$col[{$m}][{$ind}+{$corr}]=" . $col[$m][$ind + $corr] . "<br />");
         $tmp_col[$m][$i] = $col[$m][$ind + $corr];
         //$tmp_col_csv[$m][$ind]=$col_csv[$m][$ind];
     }
     $i++;
 }
 my_echo("</td></tr>");
 my_echo("</table>");
 // On réaffecte les valeurs dans le tableau initial à l'aide du tableau temporaire
 if (isset($_POST['sens_tri']) && $_POST['sens_tri'] == "inverse") {
     for ($m = 1; $m <= $nb_colonnes; $m++) {
         for ($i = 0; $i < $nb_lignes_tableau; $i++) {
             $col[$m][$i + $corr] = $tmp_col[$m][$nb_lignes_tableau - 1 - $i];
             //$col_csv[$m][$i]=$tmp_col_csv[$m][$nombre_eleves-1-$i];
         }
     }
 } else {
     for ($m = 1; $m <= $nb_colonnes; $m++) {
         //$col[$m]=$tmp_col[$m];
         //$col_csv[$m]=$tmp_col_csv[$m];
         // Pour ne pas perdre les lignes de moyennes de classe
         for ($i = 0; $i < $nb_lignes_tableau; $i++) {
             $col[$m][$i + $corr] = $tmp_col[$m][$i];
예제 #2
0
파일: benchmark.php 프로젝트: gariev/xref
$slices = array();
$pf = $parser->parse($code, $filename);
$project_database = new XRef_ProjectDatabase();
foreach ($xref->getPlugins("XRef_IProjectLintPlugin") as $id => $plugin) {
    $slices[$id] = $plugin->createFileSlice($pf);
}
$slices['_db'] = $project_database->createFileSlice($pf);
$pf->release();
$serialized = serialize($slices);
my_echo("XRef serialized size", strlen($serialized), "bytes");
$compressed = gzcompress($serialized);
my_echo("XRef compressed size", strlen($compressed), "bytes");
$f = function () use($serialized) {
    $slices = unserialize($serialized);
};
my_echo("XRef unserialize time", $b->timeIt($f), "sec");
function my_echo($prefix, $data, $suffix = null)
{
    printf('%-30s %s', $prefix . ':', $data);
    if ($suffix) {
        echo " ", $suffix;
    }
    echo "\n";
}
class Benchmark
{
    protected $timerResolution;
    protected $emptyCallTime;
    public function __construct()
    {
        // 1. find the resolution of the microtimer
예제 #3
0
/**

* Verifie et corrige le pseudo
* @Parametres

* @Return

*/

function verif_et_corrige_pseudo($uid,$nom,$prenom) {
	// Verification/correction de l'attribut choisi pour le pseudo
	global $attribut_pseudo;
	global $annuelle;
    global $simulation;

	// En minuscules pour la recherche:
	$attribut_pseudo_min=strtolower($attribut_pseudo);

	// Correction du nom/prenom fournis
	$nom=remplace_accents(traite_espaces($nom));
	$prenom=remplace_accents(traite_espaces($prenom));

	$nom=preg_replace("/[^a-z_-]/","",strtolower("$nom"));
	$prenom=preg_replace("/[^a-z_-]/","",strtolower("$prenom"));

	unset($attribut);
	$attribut=array("$attribut_pseudo_min");
	$tab=get_tab_attribut("people", "uid=$uid", $attribut);
	//my_echo("\$tab=get_tab_attribut(\"people\", \"uid=$uid\", \$attribut)<br />");
	//my_echo("count(\$tab)=".count($tab)."<br />");

	$tmp_pseudo=strtolower($prenom).strtoupper(substr($nom,0,1));
	if(count($tab)>0){
		// Si le pseudo existe déjà, on ne réinitialise le pseudo que lors d'un import annuel
		if($annuelle=="y") {
			//my_echo("\$tab[0]=".$tab[0]." et \$prenom=$prenom<br />");
			//$tmp_pseudo=strtolower($prenom).strtoupper(substr($nom,0,1));
			if("$tab[0]"!="$tmp_pseudo") {
				unset($attributs);
				$attributs=array();
				$attributs["$attribut_pseudo"]=$tmp_pseudo;
				my_echo("Correction de l'attribut '$attribut_pseudo': ");
                if($simulation!='y') {
                    if(modify_attribut ("uid=$uid", "people", $attributs, "replace")) {
                        my_echo("<font color='green'>SUCCES</font>");
                    }
                    else{
                        my_echo("<font color='red'>ECHEC</font>");
                        $nb_echecs++;
                    }
                }
                else {
                    my_echo("<font color='blue'>SIMULATION</font>");
                }
                my_echo("<br />\n");
			}
		}
	}
	else {
		// L'attribut pseudo n'existait pas:
		unset($attributs);
		$attributs=array();
		//$attributs["$tmp_pseudo"]=strtolower($prenom).strtoupper(substr($nom,0,1));
		$attributs["$attribut_pseudo"]=$tmp_pseudo;
		my_echo("Renseignement de l'attribut '$attribut_pseudo': ");
        if($simulation!='y') {
            if(modify_attribut("uid=$uid", "people", $attributs, "add")) {
                my_echo("<font color='green'>SUCCES</font>");
            }
            else{
                my_echo("<font color='red'>ECHEC</font>");
                $nb_echecs++;
            }
        }
        else {
            my_echo("<font color='blue'>SIMULATION</font>");
        }
		my_echo("<br />\n");
	}
}
function handle_products($product_link)
{
    global $base_url_host, $base_url_scheme, $total;
    if (!empty($product_link)) {
        // There are times when Thule will list discontinued products as part of their catalog - test for this...
        $found = stripos($product_link, "discontinued");
        if ($found === false) {
            $link_3 = $base_url_scheme . SCHEME_TO_HOST . $base_url_host . $product_link->href;
            $link_elements = parse_url($link_3);
            $link_path = explode("/", $link_elements['path']);
            $product_name = str_replace("-", " ", end($link_path));
            my_echo("Product Link: " . $link_3);
            my_echo("Product Name: " . $product_name);
            $html_content_3 = scraperwiki::scrape($link_3 . PARTS_APPEND);
            $html_3 = str_get_html($html_content_3);
            // Get the name.
            $par_name_raw = trim($html_3->find("div[@class='parts_page_column'] h2", 0));
            $par_name = !empty($par_name_raw) ? strip_tags($par_name_raw) : "";
            // Get the parts image.
            $a_link = $html_3->find("a[@id='phcontent_0_ctl00_lbBomImage']");
            $img_raw = !empty($a_link) ? $a_link[0]->find("img", 0)->src : "";
            // Loop over the table rows we have.
            foreach ($html_3->find("div[@id='phcontent_0_ctl00_pnlPartsList'] table tr[id]") as $data) {
                $tds = $data->find("td");
                $seq = trim($tds[0]->plaintext);
                $name = trim($tds[1]->find("h4", 0)->plaintext);
                $sku = trim($tds[1]->find("span.partno", 0)->plaintext);
                $price = trim($tds[2]->plaintext);
                $needed = trim($tds[3]->plaintext);
                $status = trim($tds[5]->plaintext);
                // If we don't have a sequence available, it most likely means we are dealing with an ad-hoc part.
                if (strlen($seq) > 0) {
                    // Ad-hoc parts have commas in their prices; we'll substitute them with 'periods.'
                    $price = str_replace(",", ".", $price);
                    // Add it to an array.
                    $record = array('id' => $total, 'sku' => $sku, 'name' => $name, 'price' => $price, 'parent_name' => $par_name, 'img' => $img_raw, 'sequence' => $seq, 'needed' => $needed, 'status' => $status);
                    // Add it to the table.
                    scraperwiki::save_sqlite(array('id'), array($record), "parts", 2);
                    // Increment the 'id' counter.
                    $total++;
                }
            }
        }
    }
}
예제 #5
0
function parseline($bm_row, $ID)
{
    debug("raw: {$bm_row}");
    // debugging love.
    if (get_magic_quotes_gpc() == 1) {
        // auto-escape is on...
        $bm_row = stripslashes($bm_row);
    }
    // so remove extra slashes.
    debug("final: {$bm_row}");
    // debugging love.
    $bm_row = trim($bm_row);
    // get rid of ooky whitespace.
    $cmd = substr($bm_row, 0, 1);
    // first char is what command to perform.
    $bm_row = substr($bm_row, 3);
    // strip token of COMMAND,COMMA,SLASH.
    $l = strpos($bm_row, "\"");
    // find the end of our bookmark path.
    $tpath = substr($bm_row, 0, $l);
    // and save the path itself into $tpath.
    $path = addslashes($tpath);
    // encode slashes and apostraphes for SQL.
    // add bookmark
    if ($cmd == "A") {
        $url = substr($bm_row, strlen($tpath) + 3);
        // get the URL from our row.
        $url = addslashes(trim($url, "\"\r\n"));
        // remove ookiness and junk.
        $surl = addslashes(substr($url, 7, 55) . substr($url, -200));
        // MySQL indexes can only be 255.
        // insert the bookmark.
        my_mysql_query("insert into syncit_bookmarks (url, surl) values ('{$url}', '{$surl}')");
        $res = my_mysql_query("select bookid from syncit_bookmarks where surl='{$surl}'");
        // and check the expiration date. deleted URLs should
        // be regularly purged from the database after a certain
        // amount of time, but if the current URL is set to be
        // deleted, but hasn't yet, we resurrect it.
        if ($data = mysql_fetch_assoc($res)) {
            $bid = $data['bookid'];
            // shorter.
            $res = my_mysql_query("insert into syncit_link (expiration, person_id, access, path, " . "book_id) values (NULL, '{$ID}', now(), '{$path}', '{$bid}')");
            // bookmark exists already, but expired. Unexpire!
            if (!$res) {
                my_mysql_query("update syncit_link set expiration = NULL, book_id = '{$bid}' " . "where person_id = '{$ID}' and path = '{$path}'");
            }
        }
    } else {
        if ($cmd == "D") {
            my_mysql_query("update syncit_link set expiration = now() where path = '{$path}' and person_id = '{$ID}'");
        } else {
            if ($cmd == "M") {
                $res = my_mysql_query("insert into syncit_link (expiration, person_id, access, " . "path) values (NULL, '{$ID}', now(), '{$path}')");
                if (!$res) {
                    // resurrect a deleted directory.
                    my_mysql_query("update syncit_link set expiration = NULL, book_id = NULL " . "where person_id = '{$ID}' and path = '{$path}'");
                }
            } else {
                if ($cmd == "R") {
                    my_mysql_query("update syncit_link set expiration = now() where path = '{$path}' and person_id = '{$ID}'");
                } else {
                    my_echo("*E");
                    my_echo("Invalid Bookmark Command: {$cmd} ");
                    debug("Invalid Bookmark Command: [{$cmd}].");
                    return true;
                }
            }
        }
    }
    return false;
}
예제 #6
0
function my_remove_tokens($f, $tokens)
{
    global $lf;
    foreach ($tokens as $k => $v) {
        $tokens[$k] = trim($v);
    }
    $file = file($f);
    $removing = false;
    $something = false;
    $file2 = array();
    foreach ($file as $l => $str) {
        if (substr($str, 0, 9) === 'window.l_') {
            $removing = false;
            $token = $str;
            $ep = strpos($str, '=');
            if ($ep !== false) {
                $token = substr($str, 0, $ep);
            }
            $token = str_replace("\t", '', trim($token));
            if (in_array($token, $tokens)) {
                $removing = true;
                $something = true;
                my_echo("Token {$token} will removed from {$f}. Токен {$token} будет удалён из {$f}.{$lf}");
            }
        }
        if (!$removing) {
            $file2[] = $str;
        }
    }
    if ($something) {
        my_echo("File {$f} will be rewritten. Файл {$f} будет перезаписан.{$lf}");
        file_put_contents($f, join('', $file2));
    }
}
예제 #7
0
		unset($tabssmtp);
		$tabssmtp=lireSSMTP();
		// Contrôler les champs affectés...
		if (isset($tabssmtp["root"])) {
		$adressedestination=$tabssmtp["root"];
		$sujet="[$domain] Rapport de ";
		if($simulation=="y") {$sujet.="simulation de ";}
		$sujet.="création de comptes";
		$message="Import du $debut_import\n";
		$message.="$chaine\n";
		$message.="\n";
		$message.="Vous pouvez consulter le rapport détaillé à l'adresse $echo_http_file\n";
		$entete="From: ".$tabssmtp["root"];
		mail("$adressedestination", "$sujet", "$message", "$entete") or my_echo("<p style='color:red;'><b>ERREUR</b> lors de l'envoi du rapport par mail.</p>\n");
		} else  my_echo("<p style='color:red;'><b>MAIL:</b> La configuration mail ne permet pas d'expédier le rapport.<br />Consultez/renseignez le menu Informations système/Actions sur le serveur/Configurer l'expédition des mails.</p>\n");
		} elseif ( $servertype=="LCS") {
		$adressedestination="admin@$domain";
		$sujet="[$domain] Rapport de ";
		if($simulation=="y") {$sujet.="simulation de ";}
		$sujet.="création de comptes";
		$message="Import du $debut_import\n";
		$message.="$chaine\n";
		$message.="\n";
		$message.="Vous pouvez consulter le rapport détaillé à l'adresse $echo_http_file\n";
		$entete="From: root@$domain";
		mail("$adressedestination", "$sujet", "$message", "$entete") or my_echo("<p style='color:red;'><b>ERREUR</b> lors de l'envoi du rapport par mail.</p>\n");
	}
	my_echo("</body>\n</html>\n");

?>
예제 #8
0
				if(!mkdir($dossiercsv)){$temoin_creation_fichiers="non";}
			}

			//my_echo("disk_total_space($dossiercsv)=".disk_total_space($dossiercsv)."<br />");


			// Date et heure...
			$aujourdhui = getdate();
			$annee_aujourdhui = $aujourdhui['year'];
			$mois_aujourdhui = sprintf("%02d",$aujourdhui['mon']);
			$jour_aujourdhui = sprintf("%02d",$aujourdhui['mday']);
			$heure_aujourdhui = sprintf("%02d",$aujourdhui['hours']);
			$minute_aujourdhui = sprintf("%02d",$aujourdhui['minutes']);
			$seconde_aujourdhui = sprintf("%02d",$aujourdhui['seconds']);

			my_echo("<p>Import du $jour_aujourdhui/$mois_aujourdhui/$annee_aujourdhui &#224; $heure_aujourdhui:$minute_aujourdhui:$seconde_aujourdhui<br />\n(<i>l'op&#233;ration d&#233;marre 2min apr&#232;s; vous pouvez alors commencer &#224; jouer avec la touche F5 pour suivre le traitement</i>)</p>\n");


			// Importation annuelle
			if ( $_POST['annuelle'] == 'y' ) $annuelle ='y'; else $annuelle ='n';

			// Mode simulation
			if ( $_POST['simulation'] == 'y' ) $simulation ='y'; else $simulation ='n';

			// Prefixe LP/LEGT,...
			$prefix=isset($_POST['prefix']) ? $purifier->purify($_POST['prefix']) : "";
			
			#$prefix=strtoupper(ereg_replace("[^A-Za-z0-9_]", "", strtr(remplace_accents($prefix)," ","_")));
            $prefix=strtoupper(ereg_replace("[^A-Za-z0-9]", "", remplace_accents($prefix)));
			if(strlen(ereg_replace("_","",$prefix))==0) $prefix="";
			if (strlen($prefix)>0) $prefix=$prefix."_";