Вы не зашли.
tipsun   Off  (19)
Moderator
2013.01.30 18:06
Вот выдал мой мозг загагулину, не уверен что верно.
Код:
span style="color: #0000BB"><?phpfunction dread($parent, $childId = 0, $parentId = 0) { $query = null; if (false != ($resource = opendir($parent))) { while (false != ($name = readdir($resource))) { if ('.' != $name && '..' != $name) { $child = $parent . DIRECTORY_SEPARATOR . $name; $childId += 1; $query .= (is_file($child) ? '' : '>>>') . 'VALUES(`id`=\'' . $childId . '\', `parent_id`=\''.$parentId.'\', `type`=\''.(is_file($child) ? 1 : 0).'\', `name`=\''.$name.'\', `path`=\''.$child.'\'), ' . PHP_EOL; if (is_dir($child)) { $result = dread($child, $childId, $childId); $query .= $result[0]; $childId = $result[1]; } } } closedir($resource); } return array($query, $childId);}
VALUES(`id`='1', `parent_id`='0', `type`='1', `name`='0028.jpg', `path`='files\0028.jpg'),
VALUES(`id`='2', `parent_id`='0', `type`='1', `name`='0029.jpg', `path`='files\0029.jpg'),
VALUES(`id`='3', `parent_id`='0', `type`='1', `name`='0030.jpg', `path`='files\0030.jpg'),
VALUES(`id`='4', `parent_id`='0', `type`='1', `name`='0031.jpg', `path`='files\0031.jpg'),
VALUES(`id`='5', `parent_id`='0', `type`='1', `name`='0032.jpg', `path`='files\0032.jpg'),
>>>VALUES(`id`='6', `parent_id`='0', `type`='0', `name`='filesIsubdir1', `path`='files\filesIsubdir1'),
VALUES(`id`='7', `parent_id`='6', `type`='1', `name`='0002.jpg', `path`='files\filesIsubdir1\0002.jpg'),
VALUES(`id`='8', `parent_id`='6', `type`='1', `name`='0003.jpg', `path`='files\filesIsubdir1\0003.jpg'),
VALUES(`id`='9', `parent_id`='6', `type`='1', `name`='0004.jpg', `path`='files\filesIsubdir1\0004.jpg'),
VALUES(`id`='10', `parent_id`='6', `type`='1', `name`='0005.jpg', `path`='files\filesIsubdir1\0005.jpg'),
VALUES(`id`='11', `parent_id`='6', `type`='1', `name`='0006.jpg', `path`='files\filesIsubdir1\0006.jpg'),
>>>VALUES(`id`='12', `parent_id`='6', `type`='0', `name`='subdirIsubdir1', `path`='files\filesIsubdir1\subdirIsubdir1'),
VALUES(`id`='13', `parent_id`='12', `type`='1', `name`='0008.jpg', `path`='files\filesIsubdir1\subdirIsubdir1\0008.jpg'),
VALUES(`id`='14', `parent_id`='12', `type`='1', `name`='0009.jpg', `path`='files\filesIsubdir1\subdirIsubdir1\0009.jpg'),
VALUES(`id`='15', `parent_id`='12', `type`='1', `name`='0010.jpg', `path`='files\filesIsubdir1\subdirIsubdir1\0010.jpg'),
VALUES(`id`='16', `parent_id`='12', `type`='1', `name`='0011.jpg', `path`='files\filesIsubdir1\subdirIsubdir1\0011.jpg'),
VALUES(`id`='17', `parent_id`='12', `type`='1', `name`='0012.jpg', `path`='files\filesIsubdir1\subdirIsubdir1\0012.jpg'),
VALUES(`id`='18', `parent_id`='12', `type`='1', `name`='Thumbs.db', `path`='files\filesIsubdir1\subdirIsubdir1\Thumbs.db'),
>>>VALUES(`id`='19', `parent_id`='6', `type`='0', `name`='subdirIsubdir2', `path`='files\filesIsubdir1\subdirIsubdir2'),
VALUES(`id`='20', `parent_id`='19', `type`='1', `name`='0013.jpg', `path`='files\filesIsubdir1\subdirIsubdir2\0013.jpg'),
VALUES(`id`='21', `parent_id`='19', `type`='1', `name`='0014.jpg', `path`='files\filesIsubdir1\subdirIsubdir2\0014.jpg'),
VALUES(`id`='22', `parent_id`='19', `type`='1', `name`='0015.jpg', `path`='files\filesIsubdir1\subdirIsubdir2\0015.jpg'),
VALUES(`id`='23', `parent_id`='19', `type`='1', `name`='0016.jpg', `path`='files\filesIsubdir1\subdirIsubdir2\0016.jpg'),
VALUES(`id`='24', `parent_id`='19', `type`='1', `name`='0017.jpg', `path`='files\filesIsubdir1\subdirIsubdir2\0017.jpg'),
>>>VALUES(`id`='25', `parent_id`='19', `type`='0', `name`='1', `path`='files\filesIsubdir1\subdirIsubdir2\1'),
VALUES(`id`='26', `parent_id`='25', `type`='1', `name`='0018.jpg', `path`='files\filesIsubdir1\subdirIsubdir2\1\0018.jpg'),
VALUES(`id`='27', `parent_id`='25', `type`='1', `name`='0019.jpg', `path`='files\filesIsubdir1\subdirIsubdir2\1\0019.jpg'),
VALUES(`id`='28', `parent_id`='25', `type`='1', `name`='0020.jpg', `path`='files\filesIsubdir1\subdirIsubdir2\1\0020.jpg'),
VALUES(`id`='29', `parent_id`='25', `type`='1', `name`='0021.jpg', `path`='files\filesIsubdir1\subdirIsubdir2\1\0021.jpg'),
VALUES(`id`='30', `parent_id`='25', `type`='1', `name`='0022.jpg', `path`='files\filesIsubdir1\subdirIsubdir2\1\0022.jpg'),
>>>VALUES(`id`='31', `parent_id`='25', `type`='0', `name`='b', `path`='files\filesIsubdir1\subdirIsubdir2\1\b'),
VALUES(`id`='32', `parent_id`='31', `type`='1', `name`='0023.jpg', `path`='files\filesIsubdir1\subdirIsubdir2\1\b\0023.jpg'),
VALUES(`id`='33', `parent_id`='31', `type`='1', `name`='0024.jpg', `path`='files\filesIsubdir1\subdirIsubdir2\1\b\0024.jpg'),
VALUES(`id`='34', `parent_id`='31', `type`='1', `name`='0025.jpg', `path`='files\filesIsubdir1\subdirIsubdir2\1\b\0025.jpg'),
VALUES(`id`='35', `parent_id`='31', `type`='1', `name`='0026.jpg', `path`='files\filesIsubdir1\subdirIsubdir2\1\b\0026.jpg'),
VALUES(`id`='36', `parent_id`='31', `type`='1', `name`='0027.jpg', `path`='files\filesIsubdir1\subdirIsubdir2\1\b\0027.jpg'),
VALUES(`id`='37', `parent_id`='31', `type`='1', `name`='Thumbs.db', `path`='files\filesIsubdir1\subdirIsubdir2\1\b\Thumbs.db'),
VALUES(`id`='38', `parent_id`='25', `type`='1', `name`='Thumbs.db', `path`='files\filesIsubdir1\subdirIsubdir2\1\Thumbs.db'),
VALUES(`id`='39', `parent_id`='19', `type`='1', `name`='Thumbs.db', `path`='files\filesIsubdir1\subdirIsubdir2\Thumbs.db'),
VALUES(`id`='40', `parent_id`='6', `type`='1', `name`='Thumbs.db', `path`='files\filesIsubdir1\Thumbs.db'),
>>>VALUES(`id`='41', `parent_id`='0', `type`='0', `name`='filesIsubdir2', `path`='files\filesIsubdir2'),
VALUES(`id`='42', `parent_id`='41', `type`='1', `name`='0033.jpg', `path`='files\filesIsubdir2\0033.jpg'),
VALUES(`id`='43', `parent_id`='41', `type`='1', `name`='0034.jpg', `path`='files\filesIsubdir2\0034.jpg'),
VALUES(`id`='44', `parent_id`='41', `type`='1', `name`='0037.jpg', `path`='files\filesIsubdir2\0037.jpg'),
VALUES(`id`='45', `parent_id`='41', `type`='1', `name`='0038.jpg', `path`='files\filesIsubdir2\0038.jpg'),
VALUES(`id`='46', `parent_id`='41', `type`='1', `name`='0039.jpg', `path`='files\filesIsubdir2\0039.jpg'),
VALUES(`id`='47', `parent_id`='41', `type`='1', `name`='0040.jpg', `path`='files\filesIsubdir2\0040.jpg'),
VALUES(`id`='48', `parent_id`='41', `type`='1', `name`='0041.jpg', `path`='files\filesIsubdir2\0041.jpg'),
VALUES(`id`='49', `parent_id`='41', `type`='1', `name`='0042.jpg', `path`='files\filesIsubdir2\0042.jpg'),
VALUES(`id`='50', `parent_id`='41', `type`='1', `name`='0043.jpg', `path`='files\filesIsubdir2\0043.jpg'),
VALUES(`id`='51', `parent_id`='41', `type`='1', `name`='0044.jpg', `path`='files\filesIsubdir2\0044.jpg'),
VALUES(`id`='52', `parent_id`='41', `type`='1', `name`='0045.jpg', `path`='files\filesIsubdir2\0045.jpg'),
VALUES(`id`='53', `parent_id`='41', `type`='1', `name`='0046.jpg', `path`='files\filesIsubdir2\0046.jpg'),
VALUES(`id`='54', `parent_id`='41', `type`='1', `name`='0048-Makhachkala.jpg', `path`='files\filesIsubdir2\0048-Makhachkala.jpg'),
VALUES(`id`='55', `parent_id`='41', `type`='1', `name`='Thumbs.db', `path`='files\filesIsubdir2\Thumbs.db'),
VALUES(`id`='56', `parent_id`='41', `type`='1', `name`='x002.jpg', `path`='files\filesIsubdir2\x002.jpg'),
VALUES(`id`='57', `parent_id`='41', `type`='1', `name`='x003.jpg', `path`='files\filesIsubdir2\x003.jpg'),
VALUES(`id`='58', `parent_id`='41', `type`='1', `name`='x004.jpg', `path`='files\filesIsubdir2\x004.jpg'),
VALUES(`id`='59', `parent_id`='41', `type`='1', `name`='x005.jpg', `path`='files\filesIsubdir2\x005.jpg'),
VALUES(`id`='60', `parent_id`='41', `type`='1', `name`='x006.jpg', `path`='files\filesIsubdir2\x006.jpg'),
VALUES(`id`='61', `parent_id`='41', `type`='1', `name`='x007.jpg', `path`='files\filesIsubdir2\x007.jpg'),
VALUES(`id`='62', `parent_id`='41', `type`='1', `name`='x008.jpg', `path`='files\filesIsubdir2\x008.jpg'),
VALUES(`id`='63', `parent_id`='41', `type`='1', `name`='x009.jpg', `path`='files\filesIsubdir2\x009.jpg'),
VALUES(`id`='64', `parent_id`='41', `type`='1', `name`='x010.jpg', `path`='files\filesIsubdir2\x010.jpg'),
VALUES(`id`='65', `parent_id`='41', `type`='1', `name`='x011.jpg', `path`='files\filesIsubdir2\x011.jpg'),
VALUES(`id`='66', `parent_id`='41', `type`='1', `name`='x012.jpg', `path`='files\filesIsubdir2\x012.jpg'),
VALUES(`id`='67', `parent_id`='41', `type`='1', `name`='x013.jpg', `path`='files\filesIsubdir2\x013.jpg'),
VALUES(`id`='68', `parent_id`='41', `type`='1', `name`='x014.jpg', `path`='files\filesIsubdir2\x014.jpg'),
VALUES(`id`='69', `parent_id`='41', `type`='1', `name`='x015.jpg', `path`='files\filesIsubdir2\x015.jpg'),
VALUES(`id`='70', `parent_id`='41', `type`='1', `name`='x016.jpg', `path`='files\filesIsubdir2\x016.jpg'),
VALUES(`id`='71', `parent_id`='41', `type`='1', `name`='x017.jpg', `path`='files\filesIsubdir2\x017.jpg'),
VALUES(`id`='72', `parent_id`='41', `type`='1', `name`='x018.jpg', `path`='files\filesIsubdir2\x018.jpg'),
VALUES(`id`='73', `parent_id`='41', `type`='1', `name`='x019.jpg', `path`='files\filesIsubdir2\x019.jpg'),
VALUES(`id`='74', `parent_id`='41', `type`='1', `name`='x020.jpg', `path`='files\filesIsubdir2\x020.jpg'),
VALUES(`id`='75', `parent_id`='41', `type`='1', `name`='x021.jpg', `path`='files\filesIsubdir2\x021.jpg'),
VALUES(`id`='76', `parent_id`='41', `type`='1', `name`='x022.jpg', `path`='files\filesIsubdir2\x022.jpg'),
VALUES(`id`='77', `parent_id`='41', `type`='1', `name`='x023.jpg', `path`='files\filesIsubdir2\x023.jpg'),
VALUES(`id`='78', `parent_id`='41', `type`='1', `name`='x024.jpg', `path`='files\filesIsubdir2\x024.jpg'),
VALUES(`id`='79', `parent_id`='41', `type`='1', `name`='x025.jpg', `path`='files\filesIsubdir2\x025.jpg'),
VALUES(`id`='80', `parent_id`='41', `type`='1', `name`='x026.jpg', `path`='files\filesIsubdir2\x026.jpg'),
VALUES(`id`='81', `parent_id`='41', `type`='1', `name`='x027.jpg', `path`='files\filesIsubdir2\x027.jpg'),
VALUES(`id`='82', `parent_id`='41', `type`='1', `name`='x028.jpg', `path`='files\filesIsubdir2\x028.jpg'),
VALUES(`id`='83', `parent_id`='41', `type`='1', `name`='x029.jpg', `path`='files\filesIsubdir2\x029.jpg'),
VALUES(`id`='84', `parent_id`='41', `type`='1', `name`='x030.jpg', `path`='files\filesIsubdir2\x030.jpg'),
VALUES(`id`='85', `parent_id`='41', `type`='1', `name`='x031.jpg', `path`='files\filesIsubdir2\x031.jpg'),
VALUES(`id`='86', `parent_id`='41', `type`='1', `name`='x032.jpg', `path`='files\filesIsubdir2\x032.jpg'),
VALUES(`id`='87', `parent_id`='41', `type`='1', `name`='x033.jpg', `path`='files\filesIsubdir2\x033.jpg'),
VALUES(`id`='88', `parent_id`='41', `type`='1', `name`='x034.jpg', `path`='files\filesIsubdir2\x034.jpg'),
VALUES(`id`='89', `parent_id`='41', `type`='1', `name`='x035.jpg', `path`='files\filesIsubdir2\x035.jpg'),
VALUES(`id`='90', `parent_id`='41', `type`='1', `name`='x036.jpg', `path`='files\filesIsubdir2\x036.jpg'),
VALUES(`id`='91', `parent_id`='41', `type`='1', `name`='x037.jpg', `path`='files\filesIsubdir2\x037.jpg'),
VALUES(`id`='92', `parent_id`='41', `type`='1', `name`='x038.jpg', `path`='files\filesIsubdir2\x038.jpg'),
VALUES(`id`='93', `parent_id`='41', `type`='1', `name`='x039.jpg', `path`='files\filesIsubdir2\x039.jpg'),
VALUES(`id`='94', `parent_id`='41', `type`='1', `name`='x040.jpg', `path`='files\filesIsubdir2\x040.jpg'),
VALUES(`id`='95', `parent_id`='41', `type`='1', `name`='x041.jpg', `path`='files\filesIsubdir2\x041.jpg'),
VALUES(`id`='96', `parent_id`='41', `type`='1', `name`='x042.jpg', `path`='files\filesIsubdir2\x042.jpg'),
VALUES(`id`='97', `parent_id`='41', `type`='1', `name`='x043.jpg', `path`='files\filesIsubdir2\x043.jpg'),
VALUES(`id`='98', `parent_id`='41', `type`='1', `name`='x044.jpg', `path`='files\filesIsubdir2\x044.jpg'),
VALUES(`id`='99', `parent_id`='41', `type`='1', `name`='x045.jpg', `path`='files\filesIsubdir2\x045.jpg'),
VALUES(`id`='100', `parent_id`='41', `type`='1', `name`='x046.jpg', `path`='files\filesIsubdir2\x046.jpg'),
VALUES(`id`='101', `parent_id`='41', `type`='1', `name`='x047.jpg', `path`='files\filesIsubdir2\x047.jpg'),
VALUES(`id`='102', `parent_id`='41', `type`='1', `name`='x048.jpg', `path`='files\filesIsubdir2\x048.jpg'),
VALUES(`id`='103', `parent_id`='41', `type`='1', `name`='x049.jpg', `path`='files\filesIsubdir2\x049.jpg'),
VALUES(`id`='104', `parent_id`='41', `type`='1', `name`='x050.jpg', `path`='files\filesIsubdir2\x050.jpg'),
VALUES(`id`='105', `parent_id`='41', `type`='1', `name`='x051.jpg', `path`='files\filesIsubdir2\x051.jpg'),
VALUES(`id`='106', `parent_id`='41', `type`='1', `name`='x052.jpg', `path`='files\filesIsubdir2\x052.jpg'),
VALUES(`id`='107', `parent_id`='0', `type`='1', `name`='Thumbs.db', `path`='files\Thumbs.db'),

Добавлено спустя   9 минут  58 секунд:
Правда существующие записи придется удалять. А так больше мыслей нет, пока что.
Главная
WEB
PunBB Mod v0.6.2
0.011 s