Авторизуйтесь по паролю
Или через соцсеть
pavel31 22.03.2014 Общие вопросы, Общие вопросы по PHP 2521
dj-avtosh - 2014-09-1523 марта 2014 10:48 - #25450
pavel31 - 2014-09-1523 марта 2014 11:58 - #25454
dj-avtosh - 2014-09-1523 марта 2014 12:02 - #25455
pavel31 - 2014-09-1523 марта 2014 12:28 - #25457
case "stats" : include ENGINE_DIR . '/modules/stats.php';break;
case "music" : include ENGINE_DIR . '/modules/music/music.php';break;
dj-avtosh - 2014-09-1523 марта 2014 12:40 - #25461
pavel31 - 2014-09-1523 марта 2014 12:45 - #25464
dj-avtosh - 2014-09-1523 марта 2014 13:02 - #25466
<?php$file = file_get_contents ( 'engine.php' );$newModule = <<<NEWMOD case "music" : include ENGINE_DIR . '/modules/music/music.php'; break;NEWMOD;preg_match ( '#case.*?break;#is', $file, $out );! empty ( $out[0] ) && $file = str_replace ( $out[0], $out[0] . $newModule, $file );print_r($file);
pavel31 - 2014-09-1523 марта 2014 13:13 - #25470
dj-avtosh - 2014-09-1523 марта 2014 13:16 - #25474
pavel31 - 2014-09-1523 марта 2014 15:00 - #25480
<?php@ini_set ('display_errors', false);@ini_set ('html_errors', false);define ('DATALIFEENGINE', true);define ('ROOT_DIR', dirname (__FILE__));define ('ENGINE_DIR', ROOT_DIR . '/engine');include ROOT_DIR . 'engine/data/config.php';$filename = $config['http_home_url'] . 'engine/engine.php';$newmodule = <<<MUSIC case "music" : include ENGINE_DIR . '/modules/music/music.php'; break;MUSIC;preg_match ( '#case.*?break;#is', $filename, $out );!empty ( $out[0] ) && $filename = str_replace ( $out[0], $out[0] . $newModule, $filename );$engine_file = fopen($filename, 'r+');fwrite($engine_file, $newmodule);fclose($engine_file);?>
dj-avtosh - 2014-09-1523 марта 2014 15:29 - #25481
dj-avtosh - 2014-09-1523 марта 2014 15:32 - #25482
D0Gmatist - 2014-09-1523 марта 2014 15:52 - #25484
file_put_contents ( "file.tmp", $name_radio, LOCK_EX );
file_put_contents ( "путь к файлу с названием и расширением", "контент будущего файла", LOCK_EX );
$buffer = @file_get_contents( "путь к файлу с названием и расширением" ); // получаем контент файла
if ( $buffer !== false ) { // если файл есть $filedate = @filemtime( "путь к файлу с названием и расширением" ); // получение даты создания файла $filedate = time()-$file_date; // вычисление промежутка меду датой создания и реальным времинем if ( $filedate > ( 60 * 60 * 24 ) ) { // 60 секунд * 60 минут * 24 часа = сутки $buffer = false; // убиваем переменную @unlink( "путь к файлу с названием и расширением" ); // удаляем файл }}if ($buffer == false) { file_put_contents ( "путь к файлу с названием и расширением", "контент будущего файла", LOCK_EX ); $buffer = @file_get_contents( "путь к файлу с названием и расширением" );} esle { $buffer = @file_get_contents( "путь к файлу с названием и расширением" );}
dj-avtosh - 2014-09-1523 марта 2014 15:53 - #25485
D0Gmatist - 2014-09-1523 марта 2014 15:58 - #25486
dj-avtosh - 2014-09-1523 марта 2014 16:03 - #25487
D0Gmatist - 2014-09-1523 марта 2014 16:35 - #25488
arrayToFile($textarrayX , $namearray, "адрес, имя и расширение для создаваемого файла");
/* функции сохранения массива */function arrayToFile($array, $arrayName, $filename = false, $file = false) { $level = 1; if($file == 0) { $level = 0; $file = fopen($filename, "w"); if(!$file) { return false; } fwrite($file, "<" . "?\n\n"); fwrite($file, "$" . $arrayName); fwrite($file, " = "); } $cnt = count($array); $i = 0; fwrite($file, "array(\n"); foreach($array as $key => $value) { if($i++ != 0) { fwrite($file, ",\n"); } if(is_array($array[$key])) { fwrite($file, "'$key' => "); arraytofile($array[$key], 0, $file); } else { $value = addcslashes($value, "'"."\\\\"); fwrite($file, str_repeat(' ', ($level + 1) * 2) . "'$key' => '$value'"); } } fwrite($file, "\n)"); if($level == 0) { fwrite($file, ";\n\n?".">"); fclose($file); return true; } chmod( $file, 0666 );}
kricha - 2014-09-1523 марта 2014 16:54 - #25489
foreach($array as $key => $value) { if($i++ != 0) { fwrite($file, ",\n"); } if(is_array($array[$key])) { fwrite($file, "'$key' => "); arraytofile($array[$key], 0, $file); } else { $value = addcslashes($value, "'"."\\\\"); fwrite($file, str_repeat(' ', ($level + 1) * 2) . "'$key' => '$value'"); } }
D0Gmatist - 2014-09-1523 марта 2014 16:57 - #25491
kricha - 2014-09-1523 марта 2014 17:03 - #25493
D0Gmatist - 2014-09-1523 марта 2014 17:08 - #25494
dj-avtosh - 2014-09-1523 марта 2014 17:59 - #25495
D0Gmatist - 2014-09-1523 марта 2014 18:01 - #25496
kricha - 2014-09-1523 марта 2014 18:26 - #25497
dj-avtosh - 2014-09-1523 марта 2014 18:52 - #25500
pavel31 - 2014-09-1523 марта 2014 19:00 - #25502
$engine_file = fopen($filename, 'r+');fwrite($engine_file, $newmodule);fclose($engine_file);
dj-avtosh - 2014-09-1523 марта 2014 19:03 - #25503
dj-avtosh - 2014-09-1523 марта 2014 19:05 - #25505
// Получим содержимое файла$fileContent = file_get_contents ( 'engine.php' );$newModule = <<<NEWMOD case "music" : include ENGINE_DIR . '/modules/music/music.php'; break;NEWMOD;preg_match ( '#case.*?break;#is', $file, $out );// Сделаем замену в содержимом! empty ( $out[0] ) && $fileContent = str_replace ( $out[0], $out[0] . $newModule, $fileContent );// Мы получили уже измененный файл, запишем его$engine_file = fopen($filename, 'r+');fwrite($engine_file, $fileContent);fclose($engine_file);
pavel31 - 2014-09-1523 марта 2014 20:44 - #25514
dj-avtosh - 2014-09-1524 марта 2014 01:41 - #25529
pavel31 - 2014-09-1524 марта 2014 21:50 - #25574
$fileContent = ROOT_DIR . '/engine/engine.php';
$fileContent = file_get_contents(ROOT_DIR . '/engine/engine.php');
pavel31 - 2014-09-1524 марта 2014 22:19 - #25578
<style> .sociallinks { display: none; position: fixed; z-index: 999; left: 0; top: 0; width: 100%; height: 100%; overflow: auto; background-color: rgba(0,0,0,0.4); } .sociallinks-content { background-color: #fefefe; margin: auto; padding: 20px; border: 1px solid #888; width: 80%; max-width: 500px; border-radius: 10px; position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); } .close { color: #aaa; position: absolute; top: 10px; right: 10px; font-size: 28px; font-weight: bold; } .close:hover, .close:focus { color: black; text-decoration: none; cursor: pointer; } .social-container { display: flex; align-items: center; } .social-container > div { margin-left: 10px; } h2, p { margin: 5px 0; } .social { padding-top: 20px; } .social img { margin: 10px; } .sharebtn { padding-top: 20px; width: 100%; } .sharebtn_area { border: 1px solid black; height: 40px; } .sharebtn input[type="text"] { width: 70%; border: none; height: 95%; } .sharebtn button { width: 25%; height: 95%; border: none; background-color: #fff; } </style> <button id="opensociallinksBtn">Поделиться</button> <div id="mysociallinks" class="sociallinks"> <div class="sociallinks-content"> <span class="close">×</span> <div class="social-container"> <img src="{image-1}" alt="Icon" width="30" height="30"> <div> <h2>{title}</h2> <p>Поделиться</p> </div> </div> <div class="social"> <a href="https://api.whatsapp.com/send/?text={full-link}"><img src="whatsapp.png" alt="WhatsApp" width="30" height="30"></a> <a href="https://www.facebook.com/sharer/sharer.php?u={full-link}"><img src="facebook.png" alt="Facebook" width="30" height="30"></a> <a href="https://twitter.com/intent/post?url={full-link}"><img src="twitter.png" alt="Twitter" width="30" height="30"></a> <a href="https://www.instagram.com/share?url={full-link}"><img src="instagram.png" alt="Instagram" width="30" height="30"></a> </div> <div class="sharebtn"> <div class="sharebtn_area"> <input type="text" id="inputText" value="{full-link}" readonly="true"> <button id="copyBtn">Поделиться <img src="share.png" width="10px" alt="Share Icon"></button> </div> </div> </div> </div> <script> var sociallinks = document.getElementById("mysociallinks"); var opensociallinksBtn = document.getElementById("opensociallinksBtn"); var closeBtn = document.getElementsByClassName("close")[0]; var copyBtn = document.getElementById("copyBtn"); var inputText = document.getElementById("inputText"); opensociallinksBtn.onclick = function() { sociallinks.style.display = "block"; } closeBtn.onclick = function() { sociallinks.style.display = "none"; } window.onclick = function(event) { if (event.target == sociallinks) { sociallinks.style.display = "none"; } } copyBtn.onclick = function() { inputText.select(); document.execCommand("copy"); } </script>